[cfe-commits] r60579 - in /cfe/trunk/include/clang/Analysis/PathSensitive: SVals.h SymbolManager.h

Ted Kremenek kremenek at apple.com
Thu Dec 4 18:56:39 PST 2008


Author: kremenek
Date: Thu Dec  4 20:56:39 2008
New Revision: 60579

URL: http://llvm.org/viewvc/llvm-project?rev=60579&view=rev
Log:
Change the implementation of symbol_iterator to not use a union and rely on any details of SymbolRef's implementation.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h
    cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h?rev=60579&r1=60578&r2=60579&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h Thu Dec  4 20:56:39 2008
@@ -101,37 +101,37 @@
   void printStdErr() const;
   
   class symbol_iterator {
-    const enum { One, Many } HowMany;
-    union { uintptr_t sym; const SymbolRef* sptr; };
+    SymbolRef SingleRef;
+    const SymbolRef* sptr;
   public:
     
     bool operator==(const symbol_iterator& X) {
-      return X.sym == sym;
+      return SingleRef == X.SingleRef && sptr == X.sptr;
     }
     
     bool operator!=(const symbol_iterator& X) {
-      return X.sym != sym;
+      return SingleRef != X.SingleRef || sptr != X.sptr;
     }
     
     symbol_iterator& operator++() {
-      if (HowMany == Many)
+      if (sptr)
         ++sptr;
       else
-        sym = ~0x0;
+        SingleRef = SymbolRef();
       
       return *this;
     }
     
     SymbolRef operator*() const {
-      if (HowMany)
+      if (sptr)
         return *sptr;
       
-      return SymbolRef(sym);
+      return SingleRef;
     }
     
-    symbol_iterator(SymbolRef x) : HowMany(One), sym(x.getNumber()) {}
-    symbol_iterator() : HowMany(One), sym(~0x0) {}
-    symbol_iterator(const SymbolRef* x) : HowMany(Many), sptr(x) {}
+    symbol_iterator(SymbolRef x) : SingleRef(x), sptr(0) {}
+    symbol_iterator() : sptr(0) {}
+    symbol_iterator(const SymbolRef* x) : sptr(x) {}
   };
   
   symbol_iterator symbol_begin() const;

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h?rev=60579&r1=60578&r2=60579&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h Thu Dec  4 20:56:39 2008
@@ -40,6 +40,9 @@
   bool isInitialized() const { return Data != (unsigned) (~0U - 2); }
   operator unsigned() const { return getNumber(); }
   unsigned getNumber() const { assert (isInitialized()); return Data; }
+  
+  bool operator==(const SymbolRef& X) const { return Data == X.Data; }
+  bool operator!=(const SymbolRef& X) const { return Data != X.Data; }
     
   void print(llvm::raw_ostream& os) const;
   





More information about the cfe-commits mailing list