From: Artem Dergachev Date: Tue, 15 Nov 2016 22:22:57 +0000 (+0000) Subject: [analyzer] NumberObjectConversion: Workaround for a linker error with modules. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97fb9e6d43c5f066380ed685330220552ce58558;p=clang [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@287045 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp b/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp index e0e892def0..40e379cb2e 100644 --- a/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp @@ -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(