Summary:
This diff tries to achieve the followings: if we have the following C++ codes:
```
bool foo(int x, int y) {
return &x == &y;
}
```
We want the C++ frontend to emit Sil as if the input is written as
```
bool foo(int x, int y) {
if (&x == &y) return 1; else return 0;
}
```
This matches the behavior of our Java frontend.
The reason why we prefer an explicit branch is that it will force the backend to eagerly produce two different specs for `foo`. Without the explicit branch, for the above example the backend would produce one spec with `return = (&x == &y)` as the post condition, which is not ideal because (1) we don't want local variables to escape to the function summary, and (2) with the knowledge that no two local variables may alias each other, the backend could actually determines that `&x == &y` is always false, emitting a more precise postcondition `return = 0`. This is not possible if we do not eagerly resolve the comparison expression.
Reviewed By: akotulski
Differential Revision: D5260745
fbshipit-source-id: 6bbbf99
master
Jia Chen8 years agocommitted byFacebook Github Bot
codetoanalyze/objc/errors/npe/UpdateDict.m, add_nil_in_dict, 10, NULL_DEREFERENCE, [start of procedure add_nil_in_dict(),Skipped call: function or method not found]
codetoanalyze/objc/errors/npe/UpdateDict.m, add_nil_to_array, 4, NULL_DEREFERENCE, [start of procedure add_nil_to_array()]
codetoanalyze/objc/errors/npe/UpdateDict.m, insert_nil_in_array, 4, NULL_DEREFERENCE, [start of procedure insert_nil_in_array()]
codetoanalyze/objc/errors/npe/UpdateDict.m, nullable_NSDictionary_objectForKey, 4, NULL_DEREFERENCE, [start of procedure nullable_NSDictionary_objectForKey(),Condition is true,Condition is true]
codetoanalyze/objc/errors/npe/UpdateDict.m, nullable_NSDictionary_objectForKeyedSubscript, 5, NULL_DEREFERENCE, [start of procedure nullable_NSDictionary_objectForKeyedSubscript(),Condition is true,Condition is true]
codetoanalyze/objc/errors/npe/UpdateDict.m, nullable_NSMapTable_objectForKey, 4, NULL_DEREFERENCE, [start of procedure nullable_NSMapTable_objectForKey(),Condition is true,Condition is true]
codetoanalyze/objc/errors/npe/UpdateDict.m, nullable_NSDictionary_objectForKey, 4, NULL_DEREFERENCE, [start of procedure nullable_NSDictionary_objectForKey(),Condition is true,Condition is true,Condition is true]
codetoanalyze/objc/errors/npe/UpdateDict.m, nullable_NSDictionary_objectForKeyedSubscript, 5, NULL_DEREFERENCE, [start of procedure nullable_NSDictionary_objectForKeyedSubscript(),Condition is true,Condition is true,Condition is true]
codetoanalyze/objc/errors/npe/UpdateDict.m, nullable_NSMapTable_objectForKey, 4, NULL_DEREFERENCE, [start of procedure nullable_NSMapTable_objectForKey(),Condition is true,Condition is true,Condition is true]
codetoanalyze/objc/errors/npe/UpdateDict.m, update_array_with_null, 5, NULL_DEREFERENCE, [start of procedure update_array_with_null()]
codetoanalyze/objc/errors/npe/UpdateDict.m, update_dict_with_key_null, 10, NULL_DEREFERENCE, [start of procedure update_dict_with_key_null(),Skipped call: function or method not found]
codetoanalyze/objc/errors/npe/WeakCapturedVarsNPE.m, __objc_anonymous_block_WeakCapturedA_strongSelfNoCheck______2, 2, NULL_DEREFERENCE, [start of procedure block]