summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-12-05 02:56:39 +0000
committerTed Kremenek <kremenek@apple.com>2008-12-05 02:56:39 +0000
commitbd4551cced6ac25e2b5a5c4126921462bf12b4fc (patch)
tree08e00a9f2fb1a3b8f489d57e7ec500de00964897
parentc9e7622a523ac706d09db5f3b18e45a41a35e7f3 (diff)
downloadbcm5719-llvm-bd4551cced6ac25e2b5a5c4126921462bf12b4fc.tar.gz
bcm5719-llvm-bd4551cced6ac25e2b5a5c4126921462bf12b4fc.zip
Change the implementation of symbol_iterator to not use a union and rely on any details of SymbolRef's implementation.
llvm-svn: 60579
-rw-r--r--clang/include/clang/Analysis/PathSensitive/SVals.h22
-rw-r--r--clang/include/clang/Analysis/PathSensitive/SymbolManager.h3
2 files changed, 14 insertions, 11 deletions
diff --git a/clang/include/clang/Analysis/PathSensitive/SVals.h b/clang/include/clang/Analysis/PathSensitive/SVals.h
index 45435b0dae9..70824eb561d 100644
--- a/clang/include/clang/Analysis/PathSensitive/SVals.h
+++ b/clang/include/clang/Analysis/PathSensitive/SVals.h
@@ -101,37 +101,37 @@ public:
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;
diff --git a/clang/include/clang/Analysis/PathSensitive/SymbolManager.h b/clang/include/clang/Analysis/PathSensitive/SymbolManager.h
index 887e3d9f9cd..1adc7c6eafc 100644
--- a/clang/include/clang/Analysis/PathSensitive/SymbolManager.h
+++ b/clang/include/clang/Analysis/PathSensitive/SymbolManager.h
@@ -40,6 +40,9 @@ public:
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;
OpenPOWER on IntegriCloud