Skip to content
Snippets Groups Projects
  • Jordan Rose's avatar
    e2b1246a
    [analyzer] Consolidate constant evaluation logic in SValBuilder. · e2b1246a
    Jordan Rose authored
    Previously, this was scattered across Environment (literal expressions),
    ExprEngine (default arguments), and RegionStore (global constants). The
    former special-cased several kinds of simple constant expressions, while
    the latter two deferred to the AST's constant evaluator.
    
    Now, these are all unified as SValBuilder::getConstantVal(). To keep
    Environment fast, the special cases for simple constant expressions have
    been left in, but the main benefits are that (a) unusual constants like
    ObjCStringLiterals now work as default arguments and global constant
    initializers, and (b) we're not duplicating code between ExprEngine and
    RegionStore.
    
    This actually caught a bug in our test suite, which is awesome: we stop
    tracking allocated memory if it's passed as an argument along with some
    kind of callback, but not if the callback is 0. We were testing this in
    a case where the callback parameter had a default value, but that value
    was 0. After this change, the analyzer now (correctly) flags that as a
    leak!
    
    <rdar://problem/13773117>
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180894 91177308-0d34-0410-b5e6-96231b3b80d8
    e2b1246a
    History
    [analyzer] Consolidate constant evaluation logic in SValBuilder.
    Jordan Rose authored
    Previously, this was scattered across Environment (literal expressions),
    ExprEngine (default arguments), and RegionStore (global constants). The
    former special-cased several kinds of simple constant expressions, while
    the latter two deferred to the AST's constant evaluator.
    
    Now, these are all unified as SValBuilder::getConstantVal(). To keep
    Environment fast, the special cases for simple constant expressions have
    been left in, but the main benefits are that (a) unusual constants like
    ObjCStringLiterals now work as default arguments and global constant
    initializers, and (b) we're not duplicating code between ExprEngine and
    RegionStore.
    
    This actually caught a bug in our test suite, which is awesome: we stop
    tracking allocated memory if it's passed as an argument along with some
    kind of callback, but not if the callback is 0. We were testing this in
    a case where the callback parameter had a default value, but that value
    was 0. After this change, the analyzer now (correctly) flags that as a
    leak!
    
    <rdar://problem/13773117>
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180894 91177308-0d34-0410-b5e6-96231b3b80d8
Code owners
Assign users and groups as approvers for specific file changes. Learn more.