diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-06-14 01:20:12 +0000 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-06-14 01:20:12 +0000 |
commit | 239452ca3e55be720917758b0dff12664e731325 (patch) | |
tree | e91100490b75c7f65dee681a84cbc8dfeecf0727 /clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | |
parent | 20eb9baa6d530bf421360b3d8afb87a09c0753e3 (diff) | |
download | bcm5719-llvm-239452ca3e55be720917758b0dff12664e731325.tar.gz bcm5719-llvm-239452ca3e55be720917758b0dff12664e731325.zip |
[analyzer] NFC: Merge code for finding and tracking construction target.
When analyzing C++ code, a common operation in the analyzer is to discover
target region for object construction by looking at CFG metadata ("construction
contexts"), and then track the region path-sensitively until object construction
is resolved, where the amount of information, again, depends on construction
context.
Scan construction context only once for both purposes.
Differential Revision: https://reviews.llvm.org/D47304
llvm-svn: 334678
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ExprEngine.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 32a969b2cb7..3fed9c088b8 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -417,81 +417,6 @@ bool ExprEngine::areAllObjectsFullyConstructed(ProgramStateRef State, return true; } -ProgramStateRef ExprEngine::markStatementsCorrespondingToConstructedObject( - ProgramStateRef State, const ConstructionContext *CC, - const LocationContext *LC, SVal V) { - if (CC) { - // If the temporary is being returned from the function, it will be - // destroyed or lifetime-extended in the caller stack frame. - if (isa<ReturnedValueConstructionContext>(CC)) { - const StackFrameContext *SFC = LC->getCurrentStackFrame(); - assert(SFC); - LC = SFC->getParent(); - if (!LC) { - // We are on the top frame. We won't ever need any info - // for this temporary, so don't set anything. - return State; - } - const CFGElement &CallElem = - (*SFC->getCallSiteBlock())[SFC->getIndex()]; - auto RTCElem = CallElem.getAs<CFGCXXRecordTypedCall>(); - if (!RTCElem) { - // We have a parent stack frame, but no construction context for the - // return value. Give up until we provide the construction context - // at the call site. - return State; - } - // We use the ReturnedValueConstructionContext as an indication that we - // need to look for the actual construction context on the parent stack - // frame. This purpose has been fulfilled, so now we replace CC with the - // actual construction context. - CC = RTCElem->getConstructionContext(); - if (!isa<TemporaryObjectConstructionContext>(CC)) { - // TODO: We are not returning an object into a temporary. There must - // be copy elision happening at the call site. We still need to - // explicitly support the situation when the return value is put - // into another return statement, i.e. - // ReturnedValueConstructionContexts are chained through multiple - // stack frames before finally settling in a temporary. - // We don't seem to need to explicitly support construction into - // a variable after a return. - return State; - } - // Proceed to deal with the temporary we've found on the parent - // stack frame. - } - // In case of temporary object construction, extract data necessary for - // destruction and lifetime extension. - if (const auto *TCC = dyn_cast<TemporaryObjectConstructionContext>(CC)) { - if (AMgr.getAnalyzerOptions().includeTemporaryDtorsInCFG()) { - const CXXBindTemporaryExpr *BTE = - TCC->getCXXBindTemporaryExpr(); - const MaterializeTemporaryExpr *MTE = - TCC->getMaterializedTemporaryExpr(); - if (!BTE) { - // FIXME: Lifetime extension for temporaries without destructors - // is not implemented yet. - MTE = nullptr; - } - if (MTE && 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; - } - - if (BTE) - State = addObjectUnderConstruction(State, BTE, LC, V); - - if (MTE) - State = addObjectUnderConstruction(State, MTE, LC, V); - } - } - } - - return State; -} - //===----------------------------------------------------------------------===// // Top-level transfer function logic (Dispatcher). |