r325978 - [CFG] Try to narrow down MSVC compiler crash via binary search.

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 23 15:38:42 PST 2018


Author: dergachev
Date: Fri Feb 23 15:38:41 2018
New Revision: 325978

URL: http://llvm.org/viewvc/llvm-project?rev=325978&view=rev
Log:
[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.

Modified:
    cfe/trunk/lib/Analysis/CFG.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=325978&r1=325977&r2=325978&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Fri Feb 23 15:38:41 2018
@@ -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(c
   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::findConstructionContext
   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)) {




More information about the cfe-commits mailing list