Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp =================================================================== --- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp +++ lib/StaticAnalyzer/Core/AnalyzerOptions.cpp @@ -390,7 +390,7 @@ unsigned AnalyzerOptions::getMaxSymbolComplexity() { if (!MaxSymbolComplexity.hasValue()) - MaxSymbolComplexity = getOptionAsInteger("max-symbol-complexity", 10000); + MaxSymbolComplexity = getOptionAsInteger("max-symbol-complexity", 25); return MaxSymbolComplexity.getValue(); } Index: lib/StaticAnalyzer/Core/RangedConstraintManager.cpp =================================================================== --- lib/StaticAnalyzer/Core/RangedConstraintManager.cpp +++ lib/StaticAnalyzer/Core/RangedConstraintManager.cpp @@ -52,17 +52,18 @@ assert(BinaryOperator::isComparisonOp(Op)); // For now, we only support comparing pointers. - assert(Loc::isLocType(SSE->getLHS()->getType())); - assert(Loc::isLocType(SSE->getRHS()->getType())); - QualType DiffTy = SymMgr.getContext().getPointerDiffType(); - SymbolRef Subtraction = - SymMgr.getSymSymExpr(SSE->getRHS(), BO_Sub, SSE->getLHS(), DiffTy); - - const llvm::APSInt &Zero = getBasicVals().getValue(0, DiffTy); - Op = BinaryOperator::reverseComparisonOp(Op); - if (!Assumption) - Op = BinaryOperator::negateComparisonOp(Op); - return assumeSymRel(State, Subtraction, Op, Zero); + if (Loc::isLocType(SSE->getLHS()->getType()) && + Loc::isLocType(SSE->getRHS()->getType())) { + QualType DiffTy = SymMgr.getContext().getPointerDiffType(); + SymbolRef Subtraction = + SymMgr.getSymSymExpr(SSE->getRHS(), BO_Sub, SSE->getLHS(), DiffTy); + + const llvm::APSInt &Zero = getBasicVals().getValue(0, DiffTy); + Op = BinaryOperator::reverseComparisonOp(Op); + if (!Assumption) + Op = BinaryOperator::negateComparisonOp(Op); + return assumeSymRel(State, Subtraction, Op, Zero); + } } // If we get here, there's nothing else we can do but treat the symbol as Index: lib/StaticAnalyzer/Core/SValBuilder.cpp =================================================================== --- lib/StaticAnalyzer/Core/SValBuilder.cpp +++ lib/StaticAnalyzer/Core/SValBuilder.cpp @@ -379,11 +379,9 @@ BinaryOperator::Opcode Op, NonLoc LHS, NonLoc RHS, QualType ResultTy) { - if (!State->isTainted(RHS) && !State->isTainted(LHS)) - return UnknownVal(); - const SymExpr *symLHS = LHS.getAsSymExpr(); const SymExpr *symRHS = RHS.getAsSymExpr(); + // TODO: When the Max Complexity is reached, we should conjure a symbol // instead of generating an Unknown value and propagate the taint info to it. const unsigned MaxComp = StateMgr.getOwningEngine() Index: test/Analysis/PR37855.c =================================================================== --- test/Analysis/PR37855.c +++ test/Analysis/PR37855.c @@ -20,5 +20,5 @@ nodep = n; } if (nodep) // expected-warning {{Branch condition evaluates to a garbage value}} - n[1].node->s; // expected-warning {{Dereference of undefined pointer value}} + n[1].node->s; } Index: test/Analysis/bitwise-ops.c =================================================================== --- test/Analysis/bitwise-ops.c +++ test/Analysis/bitwise-ops.c @@ -9,8 +9,8 @@ CHECK(x & 1); // expected-warning{{TRUE}} // False positives due to SValBuilder giving up on certain kinds of exprs. - CHECK(1 - x); // expected-warning{{UNKNOWN}} - CHECK(x & y); // expected-warning{{UNKNOWN}} + CHECK(1 - x); // expected-warning{{TRUE}} + CHECK(x & y); // expected-warning{{TRUE}} } int testConstantShifts_PR18073(int which) { Index: test/Analysis/std-c-library-functions.c =================================================================== --- test/Analysis/std-c-library-functions.c +++ test/Analysis/std-c-library-functions.c @@ -57,8 +57,7 @@ size_t y = fread(buf, sizeof(int), 10, fp); clang_analyzer_eval(y <= 10); // expected-warning{{TRUE}} size_t z = fwrite(buf, sizeof(int), y, fp); - // FIXME: should be TRUE once symbol-symbol constraint support is improved. - clang_analyzer_eval(z <= y); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(z <= y); // expected-warning{{TRUE}} } ssize_t getline(char **, size_t *, FILE *); Index: test/Analysis/svalbuilder-rearrange-comparisons.c =================================================================== --- test/Analysis/svalbuilder-rearrange-comparisons.c +++ test/Analysis/svalbuilder-rearrange-comparisons.c @@ -560,7 +560,7 @@ clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}} clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} clang_analyzer_dump(x == y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{((conj_$2{int}) + 1U) == (conj_$2{int})}} } void compare_same_symbol_minus_left_int_equal_unsigned() { @@ -569,7 +569,7 @@ clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}} clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} clang_analyzer_dump(x == y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{((conj_$2{int}) - 1U) == (conj_$2{int})}} } void compare_same_symbol_plus_right_int_equal_unsigned() { @@ -577,7 +577,7 @@ clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) + 1}} clang_analyzer_dump(x == y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{(conj_$2{int}) == ((conj_$2{int}) + 1U)}} } void compare_same_symbol_minus_right_int_equal_unsigned() { @@ -585,7 +585,7 @@ clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) - 1}} clang_analyzer_dump(x == y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{(conj_$2{int}) == ((conj_$2{int}) - 1U)}} } void compare_same_symbol_plus_left_plus_right_int_equal_unsigned() { @@ -603,7 +603,7 @@ clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}} clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) - 1}} clang_analyzer_dump(x == y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{((conj_$2{int}) + 1U) == ((conj_$2{int}) - 1U)}} } void compare_same_symbol_minus_left_plus_right_int_equal_unsigned() { @@ -612,7 +612,7 @@ clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}} clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) + 1}} clang_analyzer_dump(x == y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{((conj_$2{int}) - 1U) == ((conj_$2{int}) + 1U)}} } void compare_same_symbol_minus_left_minus_right_int_equal_unsigned() { @@ -710,7 +710,7 @@ clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}} clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} clang_analyzer_dump(x <= y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{((conj_$2{int}) + 1U) <= (conj_$2{int})}} } void compare_same_symbol_minus_left_int_less_or_equal_unsigned() { @@ -719,7 +719,7 @@ clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}} clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} clang_analyzer_dump(x <= y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{((conj_$2{int}) - 1U) <= (conj_$2{int})}} } void compare_same_symbol_plus_right_int_less_or_equal_unsigned() { @@ -727,7 +727,7 @@ clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) + 1}} clang_analyzer_dump(x <= y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{(conj_$2{int}) <= ((conj_$2{int}) + 1U)}} } void compare_same_symbol_minus_right_int_less_or_equal_unsigned() { @@ -735,7 +735,7 @@ clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) - 1}} clang_analyzer_dump(x <= y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{(conj_$2{int}) <= ((conj_$2{int}) - 1U)}} } void compare_same_symbol_plus_left_plus_right_int_less_or_equal_unsigned() { @@ -753,7 +753,7 @@ clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}} clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) - 1}} clang_analyzer_dump(x <= y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{((conj_$2{int}) + 1U) <= ((conj_$2{int}) - 1U)}} } void compare_same_symbol_minus_left_plus_right_int_less_or_equal_unsigned() { @@ -762,7 +762,7 @@ clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}} clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) + 1}} clang_analyzer_dump(x <= y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{((conj_$2{int}) - 1U) <= ((conj_$2{int}) + 1U)}} } void compare_same_symbol_minus_left_minus_right_int_less_or_equal_unsigned() { @@ -860,7 +860,7 @@ clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}} clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} clang_analyzer_dump(x < y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{((conj_$2{int}) + 1U) < (conj_$2{int})}} } void compare_same_symbol_minus_left_int_less_unsigned() { @@ -869,7 +869,7 @@ clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}} clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}} clang_analyzer_dump(x < y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{((conj_$2{int}) - 1U) < (conj_$2{int})}} } void compare_same_symbol_plus_right_int_less_unsigned() { @@ -877,7 +877,7 @@ clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) + 1}} clang_analyzer_dump(x < y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{(conj_$2{int}) < ((conj_$2{int}) + 1U)}} } void compare_same_symbol_minus_right_int_less_unsigned() { @@ -885,7 +885,7 @@ clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}} clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) - 1}} clang_analyzer_dump(x < y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{(conj_$2{int}) < ((conj_$2{int}) - 1U)}} } void compare_same_symbol_plus_left_plus_right_int_less_unsigned() { @@ -903,7 +903,7 @@ clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}} clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) - 1}} clang_analyzer_dump(x < y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{((conj_$2{int}) + 1U) < ((conj_$2{int}) - 1U)}} } void compare_same_symbol_minus_left_plus_right_int_less_unsigned() { @@ -912,7 +912,7 @@ clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}} clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) + 1}} clang_analyzer_dump(x < y); - // expected-warning@-1{{Unknown}} // FIXME: Can this be simplified? + // expected-warning@-1{{((conj_$2{int}) - 1U) < ((conj_$2{int}) + 1U)}} } void compare_same_symbol_minus_left_minus_right_int_less_unsigned() {