r287045 - [analyzer] NumberObjectConversion: Workaround for a linker error with modules.

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 15 14:22:57 PST 2016


Author: dergachev
Date: Tue Nov 15 16:22:57 2016
New Revision: 287045

URL: http://llvm.org/viewvc/llvm-project?rev=287045&view=rev
Log:
[analyzer] NumberObjectConversion: Workaround for a linker error with modules.

A combination of C++ modules, variadic functions with more than one argument,
and const globals in headers (all three being necessary) causes some releases
of clang to misplace the matcher objects, which causes the linker to fail.

No functional change - the extra allOf() matcher is no-op here.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp?rev=287045&r1=287044&r2=287045&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp Tue Nov 15 16:22:57 2016
@@ -265,9 +265,9 @@ void NumberObjectConversionChecker::chec
       expr(ignoringParenImpCasts(expr(hasType(SuspiciousScalarTypeM))));
 
   auto ConversionThroughAssignmentM =
-      binaryOperator(hasOperatorName("="),
-                     hasLHS(SuspiciousScalarExprM),
-                     hasRHS(SuspiciousNumberObjectExprM));
+      binaryOperator(allOf(hasOperatorName("="),
+                           hasLHS(SuspiciousScalarExprM),
+                           hasRHS(SuspiciousNumberObjectExprM)));
 
   auto ConversionThroughBranchingM =
       ifStmt(hasCondition(SuspiciousNumberObjectExprM))
@@ -282,40 +282,40 @@ void NumberObjectConversionChecker::chec
   // in case it was intended to compare a pointer to 0 with a relatively-ok
   // construct "x == 0" or "x != 0".
   auto ConversionThroughEquivalenceM =
-      binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")),
-                     hasEitherOperand(SuspiciousNumberObjectExprM),
-                     hasEitherOperand(SuspiciousScalarExprM
-                                      .bind("check_if_null")))
+      binaryOperator(allOf(anyOf(hasOperatorName("=="), hasOperatorName("!=")),
+                           hasEitherOperand(SuspiciousNumberObjectExprM),
+                           hasEitherOperand(SuspiciousScalarExprM
+                                            .bind("check_if_null"))))
       .bind("comparison");
 
   auto ConversionThroughComparisonM =
-      binaryOperator(anyOf(hasOperatorName(">="), hasOperatorName(">"),
-                           hasOperatorName("<="), hasOperatorName("<")),
-                     hasEitherOperand(SuspiciousNumberObjectExprM),
-                     hasEitherOperand(SuspiciousScalarExprM))
+      binaryOperator(allOf(anyOf(hasOperatorName(">="), hasOperatorName(">"),
+                                 hasOperatorName("<="), hasOperatorName("<")),
+                           hasEitherOperand(SuspiciousNumberObjectExprM),
+                           hasEitherOperand(SuspiciousScalarExprM)))
       .bind("comparison");
 
   auto ConversionThroughConditionalOperatorM =
-      conditionalOperator(
+      conditionalOperator(allOf(
           hasCondition(SuspiciousNumberObjectExprM),
           unless(hasTrueExpression(
               hasDescendant(AnotherSuspiciousNumberObjectExprM))),
           unless(hasFalseExpression(
-              hasDescendant(AnotherSuspiciousNumberObjectExprM))))
+              hasDescendant(AnotherSuspiciousNumberObjectExprM)))))
       .bind("pedantic");
 
   auto ConversionThroughExclamationMarkM =
-      unaryOperator(hasOperatorName("!"),
-                    has(expr(SuspiciousNumberObjectExprM)))
+      unaryOperator(allOf(hasOperatorName("!"),
+                          has(expr(SuspiciousNumberObjectExprM))))
       .bind("pedantic");
 
   auto ConversionThroughExplicitBooleanCastM =
-      explicitCastExpr(hasType(SuspiciousScalarBooleanTypeM),
-                       has(expr(SuspiciousNumberObjectExprM)));
+      explicitCastExpr(allOf(hasType(SuspiciousScalarBooleanTypeM),
+                             has(expr(SuspiciousNumberObjectExprM))));
 
   auto ConversionThroughExplicitNumberCastM =
-      explicitCastExpr(hasType(SuspiciousScalarNumberTypeM),
-                       has(expr(SuspiciousNumberObjectExprM)));
+      explicitCastExpr(allOf(hasType(SuspiciousScalarNumberTypeM),
+                             has(expr(SuspiciousNumberObjectExprM))));
 
   auto ConversionThroughInitializerM =
       declStmt(hasSingleDecl(




More information about the cfe-commits mailing list