From c1b07bdde9e8a7737a7d5ae0ddf163cb3c263746 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. llvm-svn: 325978 --- clang/lib/Analysis/CFG.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 7431c19..3dec2b2 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/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.7.4