aboutsummaryrefslogtreecommitdiffstats
path: root/src/MacroUtils.h
diff options
context:
space:
mode:
authorSergio Martins <smartins@kde.org>2018-01-09 20:54:28 +0000
committerSergio Martins <smartins@kde.org>2018-01-09 20:54:28 +0000
commit860f5820f43cf69b6a18822bf3c8cd4ef228d232 (patch)
tree4b162a71ed204e3e83ea1cefa7357395e4d90ab1 /src/MacroUtils.h
parentb0d4b97fd3a8d71496f2805744c2b6a46124ff7d (diff)
llvm::StringRef++
Diffstat (limited to 'src/MacroUtils.h')
-rw-r--r--src/MacroUtils.h11
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 &macroName)
+inline bool isPredefined(const clang::PreprocessorOptions &ppOpts, const llvm::StringRef &macroName)
{
const auto &macros = 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 &macroName)
+inline bool isInMacro(const clang::ASTContext *context, clang::SourceLocation loc, const llvm::StringRef &macroName)
{
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> &macroNames)
+inline bool isInAnyMacro(const clang::ASTContext *context, clang::SourceLocation loc, const std::vector<llvm::StringRef> &macroNames)
{
- return clazy::any_of(macroNames, [context, loc](const std::string &macroName) {
+ return clazy::any_of(macroNames, [context, loc](const llvm::StringRef &macroName) {
return isInMacro(context, loc, macroName);
});
}