From 09dd8b45bd39da1931aa9078912370e80fb5e653 Mon Sep 17 00:00:00 2001 From: Artem Dergachev Date: Fri, 23 Feb 2018 23:38:41 +0000 Subject: [PATCH] [CFG] Try to narrow down MSVC compiler crash via binary search. Split the presumably offending function in two to see which part of it causes the crash to occur. The crash was introduced in r325966. r325969 did not help. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325978 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/CFG.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index 7431c19cce..3dec2b21db 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -650,6 +650,10 @@ private: return Block; } + // Remember to apply \p CC when constructing the CFG element for \p CE. + void consumeConstructionContext(const ConstructionContext *CC, + CXXConstructExpr *CE); + // Scan the child statement \p Child to find the constructor that might // have been directly triggered by the current node, \p Trigger. If such // constructor has been found, set current construction context to point @@ -1149,6 +1153,18 @@ static const VariableArrayType *FindVA(const Type *t) { return nullptr; } +void CFGBuilder::consumeConstructionContext(const ConstructionContext *CC, CXXConstructExpr *CE) { + if (const ConstructionContext *PreviousContext = + ConstructionContextMap.lookup(CE)) { + // We might have visited this child when we were finding construction + // contexts within its parents. + assert(PreviousContext->isStrictlyMoreSpecificThan(CC) && + "Already within a different construction context!"); + } else { + ConstructionContextMap[CE] = CC; + } +} + void CFGBuilder::findConstructionContexts( const ConstructionContext *ContextSoFar, Stmt *Child) { if (!BuildOpts.AddRichCXXConstructors) @@ -1156,17 +1172,7 @@ void CFGBuilder::findConstructionContexts( if (!Child) return; if (auto *CE = dyn_cast(Child)) { - if (const ConstructionContext *PreviousContext = - ConstructionContextMap.lookup(CE)) { - // We might have visited this child when we were finding construction - // contexts within its parents. - assert(PreviousContext->isStrictlyMoreSpecificThan(ContextSoFar) && - "Already within a different construction context!"); - } else { - auto Pair = - ConstructionContextMap.insert(std::make_pair(CE, ContextSoFar)); - assert(Pair.second && "Already within a construction context!"); - } + consumeConstructionContext(ContextSoFar, CE); } else if (auto *Cleanups = dyn_cast(Child)) { findConstructionContexts(ContextSoFar, Cleanups->getSubExpr()); } else if (auto *BTE = dyn_cast(Child)) { -- 2.40.0