Index: lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp +++ lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp @@ -270,8 +270,10 @@ hasRHS(SuspiciousNumberObjectExprM))); auto ConversionThroughBranchingM = - ifStmt(hasCondition(SuspiciousNumberObjectExprM)) - .bind("pedantic"); + ifStmt(allOf( + hasCondition(SuspiciousNumberObjectExprM), + unless(hasConditionVariableStatement(declStmt()) + ))).bind("pedantic"); auto ConversionThroughCallM = callExpr(hasAnyArgument(allOf(hasType(SuspiciousScalarTypeM), Index: test/Analysis/number-object-conversion.mm =================================================================== --- test/Analysis/number-object-conversion.mm +++ test/Analysis/number-object-conversion.mm @@ -0,0 +1,13 @@ +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -fblocks -fobjc-arc -w -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true %s -verify + +#include "Inputs/system-header-simulator-objc.h" + +NSNumber* generateNumber(); + +// expected-no-diagnostics +int test_initialization_in_ifstmt() { // Don't warn on initialization in guard. + if (NSNumber* number = generateNumber()) { // no-warning + return 0; + } + return 1; +}