From 9d3a7d8b2badf05a52188e2874a1e53c1416e279 Mon Sep 17 00:00:00 2001 From: Artem Dergachev Date: Fri, 30 Mar 2018 19:21:18 +0000 Subject: [CFG] [analyzer] Avoid modeling C++17 constructors that aren't fully supported. Not enough work has been done so far to ensure correctness of construction contexts in the CFG when C++17 copy elision is in effect, so for now we should drop construction contexts in the CFG and in the analyzer when they seem different from what we support anyway. This includes initializations with conditional operators and return values across multiple stack frames. Differential Revision: https://reviews.llvm.org/D44854 llvm-svn: 328893 --- clang/lib/Analysis/CFG.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'clang/lib/Analysis') diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 77770c56f31..0f0556135c2 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -1302,6 +1302,15 @@ void CFGBuilder::findConstructionContexts( } case Stmt::ConditionalOperatorClass: { auto *CO = cast(Child); + if (!dyn_cast_or_null(Layer->getTriggerStmt())) { + // If the object returned by the conditional operator is not going to be a + // temporary object that needs to be immediately materialized, then + // it must be C++17 with its mandatory copy elision. Do not yet promise + // to support this case. + assert(!CO->getType()->getAsCXXRecordDecl() || CO->isGLValue() || + Context->getLangOpts().CPlusPlus17); + break; + } findConstructionContexts(Layer, CO->getLHS()); findConstructionContexts(Layer, CO->getRHS()); break; -- cgit v1.2.3