[Libreoffice-commits] core.git: compilerplugins/clang

Stephan Bergmann sbergman at redhat.com
Thu May 18 12:26:32 UTC 2017


 compilerplugins/clang/comparisonwithconstant.cxx |   10 ++++++++++
 1 file changed, 10 insertions(+)

New commits:
commit a7551b34adf847777de976fdaa3a3432448eea3b
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu May 18 14:25:38 2017 +0200

    Rewrite in macro arguments
    
    Change-Id: I6ae619edac26fe06d1f86f139b7cf71ce31146d4

diff --git a/compilerplugins/clang/comparisonwithconstant.cxx b/compilerplugins/clang/comparisonwithconstant.cxx
index b55a73e05c17..1c7daf5c3c4f 100644
--- a/compilerplugins/clang/comparisonwithconstant.cxx
+++ b/compilerplugins/clang/comparisonwithconstant.cxx
@@ -150,6 +150,11 @@ std::string ComparisonWithConstant::getExprAsString(SourceRange range)
 }
 
 SourceRange ComparisonWithConstant::ignoreMacroExpansions(SourceRange range) {
+    while (compiler.getSourceManager().isMacroArgExpansion(range.getBegin())) {
+        range.setBegin(
+            compiler.getSourceManager().getImmediateMacroCallerLoc(
+                range.getBegin()));
+    }
     if (range.getBegin().isMacroID()) {
         SourceLocation loc;
         if (Lexer::isAtStartOfMacroExpansion(
@@ -159,6 +164,11 @@ SourceRange ComparisonWithConstant::ignoreMacroExpansions(SourceRange range) {
             range.setBegin(loc);
         }
     }
+    while (compiler.getSourceManager().isMacroArgExpansion(range.getEnd())) {
+        range.setEnd(
+            compiler.getSourceManager().getImmediateMacroCallerLoc(
+                range.getEnd()));
+    }
     if (range.getEnd().isMacroID()) {
         SourceLocation loc;
         if (Lexer::isAtEndOfMacroExpansion(


More information about the Libreoffice-commits mailing list