]> granicus.if.org Git - clang/commit
[analyzer] Reduce parallel code paths in SimpleSValBuilder::evalBinOpNN, and handle...
authorJordy Rose <jediknil@belkadan.com>
Sun, 6 May 2012 23:40:02 +0000 (23:40 +0000)
committerJordy Rose <jediknil@belkadan.com>
Sun, 6 May 2012 23:40:02 +0000 (23:40 +0000)
commitc838fd2ab889ffbb82c90da0cd634ef75b614b2c
treeca1d359888f8fb74d728575eee4ce7cf7695df5c
parent3b294360febd89e3383143af086efe2014571afa
[analyzer] Reduce parallel code paths in SimpleSValBuilder::evalBinOpNN, and handle mixed-type operations more generally.

The logical change is that the integers in SymIntExprs may not have the same type as the symbols they are paired with. This was already the case with taint-propagation expressions created by SValBuilder::makeSymExprValNN, but I think those integers may never have been used. SimpleSValBuilder should be able to handle mixed-integer-type SymIntExprs fine now, though, and the constraint managers were already being defensive (though not entirely correct). All existing tests pass.

The logic in evalBinOpNN has been simplified so that conversion is done as late as possible. As a result, most of the switch cases have been reduced to do the minimal amount of work, delegating to another case when they can by substituting ConcreteInts and (as before) reversing the left and right arguments when useful.

Comparisons require special handling in two places (building SymIntExprs and evaluating constant-constant operations) because we don't /know/ the best type for comparing the two values. I've approximated the rules in Sema [C99 6.3.1.8]  but it'd be nice to refactor Sema's actual algorithm into ASTContext.

This is also groundwork for handling mixed-type constraints better than we do now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156270 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
test/Analysis/constant-folding.c