| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_MACROUSAGECHECK_H |
| 10 |
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_MACROUSAGECHECK_H |
| 11 |
|
| 12 |
#include "../ClangTidyCheck.h" |
| 13 |
#include "clang/Lex/MacroInfo.h" |
| 14 |
#include <string> |
| 15 |
|
| 16 |
namespace clang { |
| 17 |
class MacroDirective; |
| 18 |
namespace tidy::cppcoreguidelines { |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
class MacroUsageCheck : public ClangTidyCheck { |
| 26 |
public: |
| 27 |
MacroUsageCheck(StringRef Name, ClangTidyContext *Context) |
| 28 |
: ClangTidyCheck(Name, Context), |
| 29 |
AllowedRegexp(Options.get("AllowedRegexp", "^DEBUG_*")), |
| 30 |
CheckCapsOnly(Options.get("CheckCapsOnly", false)), |
| 31 |
IgnoreCommandLineMacros(Options.get("IgnoreCommandLineMacros", true)) {} |
| 32 |
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { |
| 33 |
return LangOpts.CPlusPlus11; |
| 34 |
} |
| 35 |
void storeOptions(ClangTidyOptions::OptionMap &Opts) override; |
| 36 |
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, |
| 37 |
Preprocessor *ModuleExpanderPP) override; |
| 38 |
void warnMacro(const MacroDirective *MD, StringRef MacroName); |
| 39 |
void warnNaming(const MacroDirective *MD, StringRef MacroName); |
| 40 |
|
| 41 |
private: |
| 42 |
|
| 43 |
std::string AllowedRegexp; |
| 44 |
|
| 45 |
bool CheckCapsOnly; |
| 46 |
|
| 47 |
bool IgnoreCommandLineMacros; |
| 48 |
}; |
| 49 |
|
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
#endif |