diff options
Diffstat (limited to 'src/MacroUtils.h')
-rw-r--r-- | src/MacroUtils.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/MacroUtils.h b/src/MacroUtils.h index d531e674..985a6cea 100644 --- a/src/MacroUtils.h +++ b/src/MacroUtils.h @@ -31,7 +31,6 @@ #include <clang/Lex/PreprocessorOptions.h> #include <clang/Basic/SourceLocation.h> -#include <string> #include <vector> namespace clang { @@ -39,14 +38,14 @@ class CompilerInstance; class SourceLocation; } -namespace MacroUtils +namespace clazy { /** * Returns true is macroName was defined via compiler invocation argument. * Like $ gcc -Dfoo main.cpp */ -inline bool isPredefined(const clang::PreprocessorOptions &ppOpts, const std::string ¯oName) +inline bool isPredefined(const clang::PreprocessorOptions &ppOpts, const llvm::StringRef ¯oName) { const auto ¯os = ppOpts.Macros; @@ -61,10 +60,10 @@ inline bool isPredefined(const clang::PreprocessorOptions &ppOpts, const std::st /** * Returns true if the source location loc is inside a macro named macroName. */ -inline bool isInMacro(const clang::ASTContext *context, clang::SourceLocation loc, const std::string ¯oName) +inline bool isInMacro(const clang::ASTContext *context, clang::SourceLocation loc, const llvm::StringRef ¯oName) { if (loc.isValid() && loc.isMacroID()) { - auto macro = clang::Lexer::getImmediateMacroName(loc, context->getSourceManager(), context->getLangOpts()); + StringRef macro = clang::Lexer::getImmediateMacroName(loc, context->getSourceManager(), context->getLangOpts()); return macro == macroName; } @@ -74,9 +73,9 @@ inline bool isInMacro(const clang::ASTContext *context, clang::SourceLocation lo /** * Returns true if the source location loc is inside any of the specified macros. */ -inline bool isInAnyMacro(const clang::ASTContext *context, clang::SourceLocation loc, const std::vector<std::string> ¯oNames) +inline bool isInAnyMacro(const clang::ASTContext *context, clang::SourceLocation loc, const std::vector<llvm::StringRef> ¯oNames) { - return clazy_std::any_of(macroNames, [context, loc](const std::string ¯oName) { + return clazy::any_of(macroNames, [context, loc](const llvm::StringRef ¯oName) { return isInMacro(context, loc, macroName); }); } |