aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-04-15 22:42:06 +0000
committerSteve Naroff <snaroff@apple.com>2008-04-15 22:42:06 +0000
commit248a753f6b670692523c99afaeb8fe98f7ae3ca7 (patch)
treef51ae4f62f1bdefaf28f672616ec7eaf4ff67f9a /lib/Analysis
parent4b0f81323b518429203051bbcd4864bbf4b000a9 (diff)
Remove FileVarDecl and BlockVarDecl. They are replaced by VarDecl::isBlockVarDecl() and VarDecl::isFileVarDecl().
This is a fairly mechanical/large change. As a result, I avoided making any changes/simplifications that weren't directly related. I did break two Analysis tests. I also have a couple FIXME's in UninitializedValues.cpp. Ted, can you take a look? If the bug isn't obvious, I am happy to dig in and fix it (since I broke it). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49748 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/GRExprEngine.cpp2
-rw-r--r--lib/Analysis/UninitializedValues.cpp35
2 files changed, 22 insertions, 15 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index 3211da2918..e2cc530330 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -738,7 +738,7 @@ void GRExprEngine::VisitDeclStmt(DeclStmt* DS, GRExprEngine::NodeTy* Pred,
// In this context, Static => Local variable.
assert (!VD->getStorageClass() == VarDecl::Static ||
- !isa<FileVarDecl>(VD));
+ !VD->isFileVarDecl());
// If there is no initializer, set the value of the
// variable to "Undefined".
diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp
index 2116e505d5..9958166c67 100644
--- a/lib/Analysis/UninitializedValues.cpp
+++ b/lib/Analysis/UninitializedValues.cpp
@@ -36,7 +36,7 @@ class VISIBILITY_HIDDEN RegisterDecls
public:
RegisterDecls(UninitializedValues::AnalysisDataTy& ad) : AD(ad) {}
- void VisitBlockVarDecl(BlockVarDecl* VD) { AD.Register(VD); }
+ void VisitBlockVarDecl(VarDecl* VD) { AD.Register(VD); }
CFG& getCFG() { return AD.getCFG(); }
};
@@ -80,14 +80,16 @@ public:
void VisitTerminator(Stmt* T) { }
- BlockVarDecl* FindBlockVarDecl(Stmt* S);
+ VarDecl* FindBlockVarDecl(Stmt* S);
};
static const bool Initialized = true;
static const bool Uninitialized = false;
bool TransferFuncs::VisitDeclRefExpr(DeclRefExpr* DR) {
- if (BlockVarDecl* VD = dyn_cast<BlockVarDecl>(DR->getDecl())) {
+ // FIXME: Ted, can this be simplified?
+ VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl());
+ if (VD && VD->isBlockVarDecl()) {
if (AD.Observer) AD.Observer->ObserveDeclRefExpr(V,AD,DR,VD);
// Pseudo-hack to prevent cascade of warnings. If an accessed variable
@@ -101,13 +103,15 @@ bool TransferFuncs::VisitDeclRefExpr(DeclRefExpr* DR) {
else return Initialized;
}
-BlockVarDecl* TransferFuncs::FindBlockVarDecl(Stmt *S) {
+VarDecl* TransferFuncs::FindBlockVarDecl(Stmt *S) {
for (;;)
if (ParenExpr* P = dyn_cast<ParenExpr>(S)) {
S = P->getSubExpr(); continue;
}
else if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(S)) {
- if (BlockVarDecl* VD = dyn_cast<BlockVarDecl>(DR->getDecl()))
+ // FIXME: Ted, can this be simplified?
+ VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl());
+ if (VD->isBlockVarDecl())
return VD;
else
return NULL;
@@ -116,7 +120,9 @@ BlockVarDecl* TransferFuncs::FindBlockVarDecl(Stmt *S) {
}
bool TransferFuncs::VisitBinaryOperator(BinaryOperator* B) {
- if (BlockVarDecl* VD = FindBlockVarDecl(B->getLHS()))
+ // FIXME: Ted, can this be simplified?
+ VarDecl* VD = FindBlockVarDecl(B->getLHS());
+ if (VD && VD->isBlockVarDecl())
if (B->isAssignmentOp()) {
if (B->getOpcode() == BinaryOperator::Assign)
return V(VD,AD) = Visit(B->getRHS());
@@ -128,8 +134,9 @@ bool TransferFuncs::VisitBinaryOperator(BinaryOperator* B) {
}
bool TransferFuncs::VisitDeclStmt(DeclStmt* S) {
- for (ScopedDecl* D = S->getDecl(); D != NULL; D = D->getNextDeclarator())
- if (BlockVarDecl* VD = dyn_cast<BlockVarDecl>(D)) {
+ for (ScopedDecl* D = S->getDecl(); D != NULL; D = D->getNextDeclarator()) {
+ VarDecl *VD = dyn_cast<VarDecl>(D);
+ if (VD && VD->isBlockVarDecl()) {
if (Stmt* I = VD->getInit())
V(VD,AD) = AD.FullUninitTaint ? V(cast<Expr>(I),AD) : Initialized;
else {
@@ -149,10 +156,10 @@ bool TransferFuncs::VisitDeclStmt(DeclStmt* S) {
V(VD,AD) = Uninitialized;
}
}
-
+ }
return Uninitialized; // Value is never consumed.
}
-
+
bool TransferFuncs::VisitCallExpr(CallExpr* C) {
VisitChildren(C);
return Initialized;
@@ -161,9 +168,9 @@ bool TransferFuncs::VisitCallExpr(CallExpr* C) {
bool TransferFuncs::VisitUnaryOperator(UnaryOperator* U) {
switch (U->getOpcode()) {
case UnaryOperator::AddrOf:
- if (BlockVarDecl* VD = FindBlockVarDecl(U->getSubExpr()))
+ VarDecl* VD = FindBlockVarDecl(U->getSubExpr());
+ if (VD && VD->isBlockVarDecl())
return V(VD,AD) = Initialized;
-
break;
case UnaryOperator::SizeOf:
@@ -240,7 +247,7 @@ class VISIBILITY_HIDDEN UninitializedValuesChecker
ASTContext &Ctx;
Diagnostic &Diags;
- llvm::SmallPtrSet<BlockVarDecl*,10> AlreadyWarned;
+ llvm::SmallPtrSet<VarDecl*,10> AlreadyWarned;
public:
UninitializedValuesChecker(ASTContext &ctx, Diagnostic &diags)
@@ -248,7 +255,7 @@ public:
virtual void ObserveDeclRefExpr(UninitializedValues::ValTy& V,
UninitializedValues::AnalysisDataTy& AD,
- DeclRefExpr* DR, BlockVarDecl* VD) {
+ DeclRefExpr* DR, VarDecl* VD) {
assert ( AD.isTracked(VD) && "Unknown VarDecl.");