diff options
author | Sergio Martins <smartins@kde.org> | 2018-01-09 20:54:28 +0000 |
---|---|---|
committer | Sergio Martins <smartins@kde.org> | 2018-01-09 20:54:28 +0000 |
commit | 860f5820f43cf69b6a18822bf3c8cd4ef228d232 (patch) | |
tree | 4b162a71ed204e3e83ea1cefa7357395e4d90ab1 /src/MacroUtils.h | |
parent | b0d4b97fd3a8d71496f2805744c2b6a46124ff7d (diff) |
llvm::StringRef++
Diffstat (limited to 'src/MacroUtils.h')
-rw-r--r-- | src/MacroUtils.h | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/MacroUtils.h b/src/MacroUtils.h index 9b45bc99..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 { @@ -46,7 +45,7 @@ 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::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); }); } |