[cfe-commits] r47030 - in /cfe/trunk/Analysis: RValues.cpp RValues.h ValueState.cpp
Ted Kremenek
kremenek at apple.com
Tue Feb 12 13:37:56 PST 2008
Author: kremenek
Date: Tue Feb 12 15:37:56 2008
New Revision: 47030
URL: http://llvm.org/viewvc/llvm-project?rev=47030&view=rev
Log:
Added transfer function/value track logic for taking the address of a label.
Modified:
cfe/trunk/Analysis/RValues.cpp
cfe/trunk/Analysis/RValues.h
cfe/trunk/Analysis/ValueState.cpp
Modified: cfe/trunk/Analysis/RValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/RValues.cpp?rev=47030&r1=47029&r2=47030&view=diff
==============================================================================
--- cfe/trunk/Analysis/RValues.cpp (original)
+++ cfe/trunk/Analysis/RValues.cpp Tue Feb 12 15:37:56 2008
@@ -491,14 +491,22 @@
return nonlval::SymbolVal(SymMgr.getSymbol(D));
}
-void RValue::print() const {
- print(*llvm::cerr.stream());
+//===----------------------------------------------------------------------===//
+// Utility methods for constructing LValues.
+//===----------------------------------------------------------------------===//
+
+LValue LValue::GetValue(AddrLabelExpr* E) {
+ return lval::GotoLabel(E->getLabel());
}
//===----------------------------------------------------------------------===//
// Pretty-Printing.
//===----------------------------------------------------------------------===//
+void RValue::print() const {
+ print(*llvm::cerr.stream());
+}
+
void RValue::print(std::ostream& Out) const {
switch (getBaseKind()) {
case UnknownKind:
@@ -577,6 +585,11 @@
case lval::SymbolValKind:
Out << '$' << cast<lval::SymbolVal>(this)->getSymbol();
break;
+
+ case lval::GotoLabelKind:
+ Out << "&&"
+ << cast<lval::GotoLabel>(this)->getLabel()->getID()->getName();
+ break;
case lval::DeclValKind:
Out << '&'
Modified: cfe/trunk/Analysis/RValues.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/RValues.h?rev=47030&r1=47029&r2=47030&view=diff
==============================================================================
--- cfe/trunk/Analysis/RValues.h (original)
+++ cfe/trunk/Analysis/RValues.h Tue Feb 12 15:37:56 2008
@@ -364,6 +364,8 @@
RValue EvalCast(ValueManager& ValMgr, Expr* CastExpr) const;
+ static LValue GetValue(AddrLabelExpr* E);
+
// Implement isa<T> support.
static inline bool classof(const RValue* V) {
return V->getBaseKind() != NonLValueKind;
@@ -445,6 +447,7 @@
namespace lval {
enum Kind { SymbolValKind,
+ GotoLabelKind,
DeclValKind,
ConcreteIntKind,
NumKind };
@@ -460,9 +463,31 @@
static inline bool classof(const RValue* V) {
return isa<LValue>(V) && V->getSubKind() == SymbolValKind;
- }
+ }
+
+ static inline bool classof(const LValue* V) {
+ return V->getSubKind() == SymbolValKind;
+ }
};
+ class GotoLabel : public LValue {
+ public:
+ GotoLabel(LabelStmt* Label) : LValue(GotoLabelKind, Label) {}
+
+ LabelStmt* getLabel() const {
+ return static_cast<LabelStmt*>(getRawPtr());
+ }
+
+ static inline bool classof(const RValue* V) {
+ return isa<LValue>(V) && V->getSubKind() == GotoLabelKind;
+ }
+
+ static inline bool classof(const LValue* V) {
+ return V->getSubKind() == GotoLabelKind;
+ }
+ };
+
+
class DeclVal : public LValue {
public:
DeclVal(const ValueDecl* vd) : LValue(DeclValKind,vd) {}
@@ -483,6 +508,10 @@
static inline bool classof(const RValue* V) {
return isa<LValue>(V) && V->getSubKind() == DeclValKind;
}
+
+ static inline bool classof(const LValue* V) {
+ return V->getSubKind() == DeclValKind;
+ }
};
class ConcreteInt : public LValue {
@@ -510,8 +539,7 @@
};
} // end clang::lval namespace
-
-
+
} // end clang namespace
#endif
Modified: cfe/trunk/Analysis/ValueState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/ValueState.cpp?rev=47030&r1=47029&r2=47030&view=diff
==============================================================================
--- cfe/trunk/Analysis/ValueState.cpp (original)
+++ cfe/trunk/Analysis/ValueState.cpp Tue Feb 12 15:37:56 2008
@@ -168,6 +168,9 @@
RValue ValueStateManager::GetValue(ValueState St, Expr* E, bool* hasVal) {
for (;;) {
switch (E->getStmtClass()) {
+
+ case Stmt::AddrLabelExprClass:
+ return LValue::GetValue(cast<AddrLabelExpr>(E));
// ParenExprs are no-ops.
More information about the cfe-commits
mailing list