[cfe-commits] r46378 - /cfe/trunk/Analysis/GRConstants.cpp
Ted Kremenek
kremenek at apple.com
Fri Jan 25 15:43:12 PST 2008
Author: kremenek
Date: Fri Jan 25 17:43:12 2008
New Revision: 46378
URL: http://llvm.org/viewvc/llvm-project?rev=46378&view=rev
Log:
Further refactoring of transfer functions by having APSIntSetOp take
a template-template parameter.
Modified:
cfe/trunk/Analysis/GRConstants.cpp
Modified: cfe/trunk/Analysis/GRConstants.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRConstants.cpp?rev=46378&r1=46377&r2=46378&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRConstants.cpp (original)
+++ cfe/trunk/Analysis/GRConstants.cpp Fri Jan 25 17:43:12 2008
@@ -50,23 +50,26 @@
class VISIBILITY_HIDDEN ValueKey {
uintptr_t Raw;
+
+ void operator=(const ValueKey& RHS); // Do not implement.
public:
enum Kind { IsSubExpr=0x0, IsBlkExpr=0x1, IsDecl=0x2, Flags=0x3 };
inline void* getPtr() const { return reinterpret_cast<void*>(Raw & ~Flags); }
inline Kind getKind() const { return (Kind) (Raw & Flags); }
ValueKey(const ValueDecl* VD)
- : Raw(reinterpret_cast<uintptr_t>(VD) | IsDecl) {}
+ : Raw(reinterpret_cast<uintptr_t>(VD) | IsDecl) { assert(VD); }
ValueKey(Stmt* S, bool isBlkExpr = false)
- : Raw(reinterpret_cast<uintptr_t>(S) | isBlkExpr ? IsBlkExpr : IsSubExpr) {}
+ : Raw(reinterpret_cast<uintptr_t>(S) | (isBlkExpr ? IsBlkExpr : IsSubExpr)){
+ assert(S);
+ }
bool isSubExpr() const { return getKind() == IsSubExpr; }
bool isDecl() const { return getKind() == IsDecl; }
inline void Profile(llvm::FoldingSetNodeID& ID) const {
ID.AddPointer(getPtr());
- ID.AddInteger((unsigned) getKind());
}
inline bool operator==(const ValueKey& X) const {
@@ -146,16 +149,17 @@
};
} // end anonymous namespace
-template <typename OpTy>
+template <template <typename T> class OpTy>
static inline APSIntSetTy APSIntSetOp(ValueManager& ValMgr,
- APSIntSetTy S1, APSIntSetTy S2,
- OpTy Op) {
+ APSIntSetTy S1, APSIntSetTy S2) {
APSIntSetTy M = ValMgr.GetEmptyAPSIntSet();
+ OpTy<APSInt> Op;
+
for (APSIntSetTy::iterator I1=S1.begin(), E1=S2.end(); I1!=E1; ++I1)
for (APSIntSetTy::iterator I2=S2.begin(), E2=S2.end(); I2!=E2; ++I2)
- M = ValMgr.AddToSet(M, Op(*I1,*I2));
+ M = ValMgr.AddToSet(M, Op(*I1, *I2));
return M;
}
@@ -277,26 +281,22 @@
RValEqualityORSet
EvalAdd(ValueManager& ValMgr, const RValEqualityORSet& V) const {
- return APSIntSetOp(ValMgr, GetValues(), V.GetValues(),
- std::plus<APSInt>());
+ return APSIntSetOp<std::plus>(ValMgr, GetValues(), V.GetValues());
}
RValEqualityORSet
EvalSub(ValueManager& ValMgr, const RValEqualityORSet& V) const {
- return APSIntSetOp(ValMgr, GetValues(), V.GetValues(),
- std::minus<APSInt>());
+ return APSIntSetOp<std::minus>(ValMgr, GetValues(), V.GetValues());
}
RValEqualityORSet
EvalMul(ValueManager& ValMgr, const RValEqualityORSet& V) const {
- return APSIntSetOp(ValMgr, GetValues(), V.GetValues(),
- std::multiplies<APSInt>());
+ return APSIntSetOp<std::multiplies>(ValMgr, GetValues(), V.GetValues());
}
RValEqualityORSet
EvalDiv(ValueManager& ValMgr, const RValEqualityORSet& V) const {
- return APSIntSetOp(ValMgr, GetValues(), V.GetValues(),
- std::divides<APSInt>());
+ return APSIntSetOp<std::divides>(ValMgr, GetValues(), V.GetValues());
}
RValEqualityORSet
@@ -775,6 +775,7 @@
GRConstants::StateTy GRConstants::SetValue(StateTy St, Stmt* S,
const ExprValue& V) {
+ assert (S);
if (!StateCleaned) {
St = RemoveDeadBindings(CurrentStmt, St);
More information about the cfe-commits
mailing list