From 78ad5ecd988270f3308fe98cc128ddf832c0c00b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Sat, 28 Mar 2015 19:16:29 +0100 Subject: Clean up isMacroBodyExpansion Change-Id: I745b320dd5f44d54371d8a0b961c49793e3e0ad6 --- compilerplugins/clang/compat.hxx | 11 ----------- compilerplugins/clang/literaltoboolconversion.cxx | 2 +- compilerplugins/clang/salbool.cxx | 13 +------------ compilerplugins/clang/staticmethods.cxx | 2 +- 4 files changed, 3 insertions(+), 25 deletions(-) (limited to 'compilerplugins') diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index 64e0b04659b9..08787e8c77fd 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -221,17 +221,6 @@ inline bool isMacroBodyExpansion(clang::CompilerInstance& compiler, clang::Sourc #endif } - -} - -inline bool isMacroBodyExpansion(clang::CompilerInstance& compiler, clang::SourceLocation location) -{ -#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3 - return compiler.getSourceManager().isMacroBodyExpansion(location); -#else - return location.isMacroID() - && !compiler.getSourceManager().isMacroArgExpansion(location); -#endif } #endif diff --git a/compilerplugins/clang/literaltoboolconversion.cxx b/compilerplugins/clang/literaltoboolconversion.cxx index 00ecdd8045c1..c6d63813ebc5 100644 --- a/compilerplugins/clang/literaltoboolconversion.cxx +++ b/compilerplugins/clang/literaltoboolconversion.cxx @@ -62,7 +62,7 @@ bool LiteralToBoolConversion::VisitImplicitCastExpr( while (compiler.getSourceManager().isMacroArgExpansion(loc)) { loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc); } - if (isMacroBodyExpansion(compiler, loc)) { + if (compat::isMacroBodyExpansion(compiler, loc)) { StringRef name { Lexer::getImmediateMacroName( loc, compiler.getSourceManager(), compiler.getLangOpts()) }; if (name == "sal_False" || name == "sal_True") { diff --git a/compilerplugins/clang/salbool.cxx b/compilerplugins/clang/salbool.cxx index f5ee945db673..933f80fc7839 100644 --- a/compilerplugins/clang/salbool.cxx +++ b/compilerplugins/clang/salbool.cxx @@ -153,8 +153,6 @@ public: private: bool isInSpecialMainFile(SourceLocation spellingLocation) const; - bool isMacroBodyExpansion(SourceLocation location) const; - bool rewrite(SourceLocation location); std::set varDecls_; @@ -274,7 +272,7 @@ bool SalBool::VisitCStyleCastExpr(CStyleCastExpr * expr) { while (compiler.getSourceManager().isMacroArgExpansion(loc)) { loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc); } - if (isMacroBodyExpansion(loc)) { + if (compat::isMacroBodyExpansion(compiler, loc)) { StringRef name { Lexer::getImmediateMacroName( loc, compiler.getSourceManager(), compiler.getLangOpts()) }; if (name == "sal_False" || name == "sal_True") { @@ -580,15 +578,6 @@ bool SalBool::isInSpecialMainFile(SourceLocation spellingLocation) const { == SRCDIR "/cppu/qa/test_any.cxx"); } -bool SalBool::isMacroBodyExpansion(SourceLocation location) const { -#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3 - return compiler.getSourceManager().isMacroBodyExpansion(location); -#else - return location.isMacroID() - && !compiler.getSourceManager().isMacroArgExpansion(location); -#endif -} - bool SalBool::rewrite(SourceLocation location) { if (rewriter != nullptr) { //TODO: "::sal_Bool" -> "bool", not "::bool" diff --git a/compilerplugins/clang/staticmethods.cxx b/compilerplugins/clang/staticmethods.cxx index b5b2a9d79d80..b3f1b587cd29 100644 --- a/compilerplugins/clang/staticmethods.cxx +++ b/compilerplugins/clang/staticmethods.cxx @@ -84,7 +84,7 @@ bool StaticMethods::TraverseCXXMethodDecl(const CXXMethodDecl * pCXXMethodDecl) // leave these alone for now, it is possible to fix them, but I don't understand how SourceLocation canonicalLoc = pCXXMethodDecl->getCanonicalDecl()->getLocStart(); - if (isMacroBodyExpansion(compiler, canonicalLoc) ) { + if (compat::isMacroBodyExpansion(compiler, canonicalLoc) ) { StringRef name { Lexer::getImmediateMacroName( canonicalLoc, compiler.getSourceManager(), compiler.getLangOpts()) }; if (name == "DECL_LINK") { -- cgit