diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-06-28 00:18:52 +0000 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-06-28 00:18:52 +0000 |
commit | d18639bd13e354f224ca49038cb6519dac222cd7 (patch) | |
tree | 722663fd2bcef67b5da1915b6ea03d4b7c21f35b /clang/lib/Analysis | |
parent | 98f5475f4402b23efecc8c88f8105d1d25e27c66 (diff) | |
download | bcm5719-llvm-d18639bd13e354f224ca49038cb6519dac222cd7.tar.gz bcm5719-llvm-d18639bd13e354f224ca49038cb6519dac222cd7.zip |
[CFG] [analyzer] Simplify lifetime-extended temporary construction contexts.
When a temporary object is materialized and through that obtain lifetime that
is longer than the duration of the full-expression, it does not require a
temporary object destructor; it will be destroyed in a different manner.
Therefore it's not necessary to include CXXBindTemporaryExpr into the
construction context for such temporary in the CFG only to make clients
throw it away.
Differential Revision: https://reviews.llvm.org/D47667
llvm-svn: 335798
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r-- | clang/lib/Analysis/ConstructionContext.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Analysis/ConstructionContext.cpp b/clang/lib/Analysis/ConstructionContext.cpp index de003753367..ed1e6324321 100644 --- a/clang/lib/Analysis/ConstructionContext.cpp +++ b/clang/lib/Analysis/ConstructionContext.cpp @@ -76,6 +76,13 @@ const ConstructionContext *ConstructionContext::createFromLayers( // both destruction and materialization info attached to it in the AST. if ((MTE = dyn_cast<MaterializeTemporaryExpr>( ParentLayer->getTriggerStmt()))) { + if (MTE->getStorageDuration() != SD_FullExpression) { + // If the temporary is lifetime-extended, don't save the BTE, + // because we don't need a temporary destructor, but an automatic + // destructor. + BTE = nullptr; + } + // Handle pre-C++17 copy and move elision. const CXXConstructExpr *ElidedCE = nullptr; const ConstructionContext *ElidedCC = nullptr; |