summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-03-28 19:16:29 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-03-28 19:16:47 +0100
commit78ad5ecd988270f3308fe98cc128ddf832c0c00b (patch)
tree94074dc6e4bca25f1823f07f0651d21d0885eebd /compilerplugins
parentc1434d6826aec313854072c9614a2d281762f5e1 (diff)
Clean up isMacroBodyExpansion
Change-Id: I745b320dd5f44d54371d8a0b961c49793e3e0ad6
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/compat.hxx11
-rw-r--r--compilerplugins/clang/literaltoboolconversion.cxx2
-rw-r--r--compilerplugins/clang/salbool.cxx13
-rw-r--r--compilerplugins/clang/staticmethods.cxx2
4 files changed, 3 insertions, 25 deletions
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<VarDecl const *> 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") {