[CFG] Try to narrow down MSVC compiler crash via binary search.
authorArtem Dergachev <artem.dergachev@gmail.com>
Fri, 23 Feb 2018 23:38:41 +0000 (23:38 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Fri, 23 Feb 2018 23:38:41 +0000 (23:38 +0000)
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

index 7431c19..3dec2b2 100644 (file)
@@ -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<CXXConstructExpr>(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<ExprWithCleanups>(Child)) {
     findConstructionContexts(ContextSoFar, Cleanups->getSubExpr());
   } else if (auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Child)) {