[analyzer] When creating a temporary object, properly copy the value into it.
Adjustments should be considered properly; we should copy the unadjusted object over the whole temporary base region. If the unadjusted object is no longer available in the Environment, invalidate the temporary base region, and then copy the adjusted object into the adjusted sub-region of the temporary region. This fixes a regression introduced by r288263, that caused various false positives, due to copying only adjusted object into the adjusted region; the rest of the base region therefore remained undefined. Before r288263, the adjusted value was copied over the unadjusted region, which is incorrect, but accidentally worked better due to how region store disregards compound value bindings to non-base regions. An additional test machinery is introduced to make sure that despite making two binds, we only notify checkers once for both of them, without exposing the partially copied objects. This fix is a hack over a hack. The proper fix would be to model C++ temporaries in the CFG, and after that dealing with adjustments would no longer be necessary, and the values we need would no longer disappear from the Environment. rdar://problem/30658168 Differential Revision: https://reviews.llvm.org/D30534 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@298924 91177308-0d34-0410-b5e6-96231b3b80d8
Showing
- include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 7 additions, 7 deletionsinclude/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
- lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp 40 additions, 9 deletionslib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
- lib/StaticAnalyzer/Core/ExprEngine.cpp 50 additions, 14 deletionslib/StaticAnalyzer/Core/ExprEngine.cpp
- test/Analysis/temporaries-callback-order.cpp 36 additions, 0 deletionstest/Analysis/temporaries-callback-order.cpp
- test/Analysis/temporaries.cpp 27 additions, 0 deletionstest/Analysis/temporaries.cpp
Loading
Please register or sign in to comment