diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-06-28 00:04:54 +0000 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-06-28 00:04:54 +0000 |
commit | ff267df0de9664fa9af06987d455ae5f02425c3f (patch) | |
tree | d7ca32950960fee9964aa476bbe3d622323074b9 /clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp | |
parent | 5bf1ead3771667bc51d7b6b2ddc29cb860b4fe21 (diff) | |
download | bcm5719-llvm-ff267df0de9664fa9af06987d455ae5f02425c3f.tar.gz bcm5719-llvm-ff267df0de9664fa9af06987d455ae5f02425c3f.zip |
[CFG] [analyzer] Add construction contexts that explain pre-C++17 copy elision.
Before C++17 copy elision was optional, even if the elidable copy/move
constructor had arbitrary side effects. The elidable constructor is present
in the AST, but marked as elidable.
In these cases CFG now contains additional information that allows its clients
to figure out if a temporary object is only being constructed so that to pass
it to an elidable constructor. If so, it includes a reference to the elidable
constructor's construction context, so that the client could elide the
elidable constructor and construct the object directly at its final destination.
Differential Revision: https://reviews.llvm.org/D47616
llvm-svn: 335795
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp index f85bfc6e492..497e1fa5560 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp @@ -209,7 +209,11 @@ std::pair<ProgramStateRef, SVal> ExprEngine::prepareForObjectConstruction( } llvm_unreachable("Unhandled return value construction context!"); } - case ConstructionContext::TemporaryObjectKind: { + case ConstructionContext::ElidedTemporaryObjectKind: + assert(AMgr.getAnalyzerOptions().shouldElideConstructors()); + // FALL-THROUGH + case ConstructionContext::SimpleTemporaryObjectKind: { + // TODO: Copy elision implementation goes here. const auto *TCC = cast<TemporaryObjectConstructionContext>(CC); const CXXBindTemporaryExpr *BTE = TCC->getCXXBindTemporaryExpr(); const MaterializeTemporaryExpr *MTE = TCC->getMaterializedTemporaryExpr(); |