]> granicus.if.org Git - clang/commitdiff
Handle the case where EmitBlock might be called multiple times for the same block...
authorAnders Carlsson <andersca@mac.com>
Tue, 10 Feb 2009 22:50:24 +0000 (22:50 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 10 Feb 2009 22:50:24 +0000 (22:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64252 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGStmt.cpp
test/CodeGen/vla.c

index 85ea8c5e31c85bf695f5c029f2f177c22c8e729b..d23547fb36afa36b28b275e96eea7ecb1089fff6 100644 (file)
@@ -182,8 +182,14 @@ void CodeGenFunction::EmitBlock(llvm::BasicBlock *BB, bool IsFinished) {
 
   // If necessary, associate the block with the cleanup stack size.
   if (!CleanupEntries.empty()) {
-    BlockScopes[BB] = CleanupEntries.size() - 1;
-    CleanupEntries.back().Blocks.push_back(BB);
+    // Check if the basic block has already been inserted.
+    BlockScopeMap::iterator I = BlockScopes.find(BB);
+    if (I != BlockScopes.end()) {
+      assert(I->second == CleanupEntries.size() - 1);
+    } else {
+      BlockScopes[BB] = CleanupEntries.size() - 1;
+      CleanupEntries.back().Blocks.push_back(BB);
+    }
   }
   
   CurFn->getBasicBlockList().push_back(BB);
index 2197ee10cf843c021d1c531776c4be8fe90826ed..beb928b0668ce103be5537fa88775a24a6ef16be 100644 (file)
@@ -18,3 +18,14 @@ int f0(int x) {
   int vla[x];
   return vla[x-1];
 }
+
+void
+f(int count)
+{
+ int a[count];
+
+  do {  } while (0);
+
+  if (a[0] != 3) {
+  }
+}