xref: /llvm-project/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidDoWhileCheck.h (revision 4718da506091a37ca4863d979bc541e359b79b10)
11ae33bf4SCarlos Galvez //===--- AvoidDoWhileCheck.h - clang-tidy -----------------------*- C++ -*-===//
21ae33bf4SCarlos Galvez //
31ae33bf4SCarlos Galvez // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
41ae33bf4SCarlos Galvez // See https://llvm.org/LICENSE.txt for license information.
51ae33bf4SCarlos Galvez // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
61ae33bf4SCarlos Galvez //
71ae33bf4SCarlos Galvez //===----------------------------------------------------------------------===//
81ae33bf4SCarlos Galvez 
91ae33bf4SCarlos Galvez #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDDOWHILECHECK_H
101ae33bf4SCarlos Galvez #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDDOWHILECHECK_H
111ae33bf4SCarlos Galvez 
121ae33bf4SCarlos Galvez #include "../ClangTidyCheck.h"
131ae33bf4SCarlos Galvez 
14*4718da50SCarlos Galvez namespace clang::tidy::cppcoreguidelines {
151ae33bf4SCarlos Galvez 
161ae33bf4SCarlos Galvez /// do-while loops are less readable than plan while loops, and can lead to
171ae33bf4SCarlos Galvez /// subtle bugs.
181ae33bf4SCarlos Galvez ///
191ae33bf4SCarlos Galvez /// For the user-facing documentation see:
201ae33bf4SCarlos Galvez /// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-do-while.html
211ae33bf4SCarlos Galvez class AvoidDoWhileCheck : public ClangTidyCheck {
221ae33bf4SCarlos Galvez public:
231ae33bf4SCarlos Galvez   AvoidDoWhileCheck(StringRef Name, ClangTidyContext *Context);
isLanguageVersionSupported(const LangOptions & LangOpts)241ae33bf4SCarlos Galvez   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
251ae33bf4SCarlos Galvez     return LangOpts.CPlusPlus;
261ae33bf4SCarlos Galvez   }
271ae33bf4SCarlos Galvez   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
281ae33bf4SCarlos Galvez   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
291ae33bf4SCarlos Galvez   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
301ae33bf4SCarlos Galvez 
311ae33bf4SCarlos Galvez private:
321ae33bf4SCarlos Galvez   bool IgnoreMacros;
331ae33bf4SCarlos Galvez };
341ae33bf4SCarlos Galvez 
35*4718da50SCarlos Galvez } // namespace clang::tidy::cppcoreguidelines
361ae33bf4SCarlos Galvez 
371ae33bf4SCarlos Galvez #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDDOWHILECHECK_H
38