Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp =================================================================== --- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp +++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp @@ -437,7 +437,10 @@ // overflow bounds. static bool shouldRearrange(ProgramStateRef State, BinaryOperator::Opcode Op, SymbolRef Sym, llvm::APSInt Int, QualType Ty) { + BasicValueFactory &BV = State->getStateManager().getBasicVals(); + return Sym->getType() == Ty && + APSIntType(Int) == BV.getAPSIntType(Sym->getType()) && (!BinaryOperator::isComparisonOp(Op) || (isWithinConstantOverflowBounds(Sym, State) && isWithinConstantOverflowBounds(Int))); Index: test/Analysis/svalbuilder-rearrange-comparisons.c =================================================================== --- test/Analysis/svalbuilder-rearrange-comparisons.c +++ test/Analysis/svalbuilder-rearrange-comparisons.c @@ -929,3 +929,8 @@ clang_analyzer_eval(n - 126 == m + 3); // expected-warning{{UNKNOWN}} } } + +int mixed_integer_types(int x, int y) { + short a = x - 1U; + return a - y; +}