[PATCH] D43104: [analyzer] Find correct region for simple temporary destructor calls and inline them if possible.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 14 17:13:36 PST 2018


NoQ updated this revision to Diff 134341.
NoQ added a comment.

All right, so the assertion that we actually destroy all temporaries in our `InitializedTemporaries` map is still violated quite often -  every time we do any sort of lifetime extension, we're actually calling the destructor on a different object, because `createTemporaryRegionIfNeeded()` has moved the object to a different place. I made a large brain dump on this matter in http://lists.llvm.org/pipermail/cfe-dev/2018-February/056898.html . For now it means that the assertion is still not going in. I added it in a commented-out form. In fact, @klimek has tried that long before me, and failed in a similar manner. If only i added the assertion in the right place (not in `processCallExit`, but in `processEndOfFunction`, which is also called for the top frame), i would have seen it earlier :) So i've reinvented quite a bit of a wheel here.

- Move the assertion to the right place and disable it, explaining that lifetime extension is broken.
- Move the similar operator-new assertion to the right place as well, while we're at it.
- Add a flag to disable inlining of temporary destructors, which is different from having them at all. It's on by default but does nothing until `cfg-temporary-dtors` are also enabled.
- Add a test for that flag. This flag cannot be tested in `analyzer-config.cpp` because it is never read unless `cfg-temporary-dtors` takes a non-default value, so `ConfigDumper` doesn't see it.


https://reviews.llvm.org/D43104

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  test/Analysis/analyzer-config.cpp
  test/Analysis/temp-obj-dtors-option.cpp
  test/Analysis/temporaries.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43104.134341.patch
Type: text/x-patch
Size: 25353 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180215/5130a8c0/attachment-0001.bin>


More information about the cfe-commits mailing list