[cfe-commits] r76857 - /cfe/trunk/lib/Sema/SemaDecl.cpp

Daniel Dunbar daniel at zuster.org
Wed Jul 22 22:01:57 PDT 2009


Author: ddunbar
Date: Thu Jul 23 00:01:54 2009
New Revision: 76857

URL: http://llvm.org/viewvc/llvm-project?rev=76857&view=rev
Log:
Use llvm::BitVector instead of managing memory by hand.
 - As it happens, this also fixes a use-of-uninitialized memory that was causing
   non-deterministic test failures.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=76857&r1=76856&r2=76857&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jul 23 00:01:54 2009
@@ -28,6 +28,7 @@
 // FIXME: layering (ideally, Sema shouldn't be dependent on Lex API's)
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/HeaderSearch.h" 
+#include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/STLExtras.h"
 #include <algorithm>
@@ -1023,18 +1024,18 @@
   // The CFG leaves in dead things, run a simple mark and sweep on it
   // to weed out the trivially dead things.
   std::queue<CFGBlock*> workq;
-  llvm::OwningArrayPtr<char> live(new char[cfg->getNumBlockIDs()]);
+  llvm::BitVector live(cfg->getNumBlockIDs());
   // Prep work queue
   workq.push(&cfg->getEntry());
   // Solve
   while (!workq.empty()) {
     CFGBlock *item = workq.front();
     workq.pop();
-    live[item->getBlockID()] = 1;
+    live.set(item->getBlockID());
     CFGBlock::succ_iterator i;
     for (i=item->succ_begin(); i != item->succ_end(); ++i) {
       if ((*i) && ! live[(*i)->getBlockID()]) {
-        live[(*i)->getBlockID()] = 1;
+        live.set((*i)->getBlockID());
         workq.push(*i);
       }
     }





More information about the cfe-commits mailing list