]> granicus.if.org Git - clang/commitdiff
[analyzer] NumberObjectConversion: Workaround for a linker error with modules.
authorArtem Dergachev <artem.dergachev@gmail.com>
Tue, 15 Nov 2016 22:22:57 +0000 (22:22 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Tue, 15 Nov 2016 22:22:57 +0000 (22:22 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@287045 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp

index e0e892def0a49a3e1acaa93b77889843ab7c83fa..40e379cb2efc608b092251f23d1b698eb56488d2 100644 (file)
@@ -265,9 +265,9 @@ void NumberObjectConversionChecker::checkASTCodeBody(const Decl *D,
       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::checkASTCodeBody(const Decl *D,
   // 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(