[cfe-commits] r42145 - in /cfe/trunk: Analysis/UninitializedValues.cpp include/clang/Analysis/UninitializedValues.h
Ted Kremenek
kremenek at apple.com
Wed Sep 19 11:00:03 PDT 2007
Author: kremenek
Date: Wed Sep 19 13:00:03 2007
New Revision: 42145
URL: http://llvm.org/viewvc/llvm-project?rev=42145&view=rev
Log:
More refactoring: decl and expr regisitration now uses CFGRecStmtDeclVisitor.
Modified:
cfe/trunk/Analysis/UninitializedValues.cpp
cfe/trunk/include/clang/Analysis/UninitializedValues.h
Modified: cfe/trunk/Analysis/UninitializedValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/UninitializedValues.cpp?rev=42145&r1=42144&r2=42145&view=diff
==============================================================================
--- cfe/trunk/Analysis/UninitializedValues.cpp (original)
+++ cfe/trunk/Analysis/UninitializedValues.cpp Wed Sep 19 13:00:03 2007
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Analysis/UninitializedValues.h"
-#include "clang/Analysis/CFGStmtVisitor.h"
+#include "clang/Analysis/CFGRecStmtDeclVisitor.h"
#include "clang/Analysis/LocalCheckers.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/AST/ASTContext.h"
@@ -28,39 +28,24 @@
namespace {
-class RegisterDeclsAndExprs : public CFGStmtVisitor<RegisterDeclsAndExprs> {
+class RegisterDeclsExprs : public CFGRecStmtDeclVisitor<RegisterDeclsExprs> {
UninitializedValues::AnalysisDataTy& AD;
public:
- RegisterDeclsAndExprs(UninitializedValues::AnalysisDataTy& ad) : AD(ad) {}
+ RegisterDeclsExprs(UninitializedValues::AnalysisDataTy& ad) : AD(ad) {}
void VisitBlockVarDecl(BlockVarDecl* VD) {
- if (AD.VMap.find(VD) == AD.VMap.end())
- AD.VMap[VD] = AD.NumDecls++;
- }
-
- void VisitDeclChain(ScopedDecl* D) {
- for (; D != NULL; D = D->getNextDeclarator())
- if (BlockVarDecl* VD = dyn_cast<BlockVarDecl>(D))
- VisitBlockVarDecl(VD);
+ if (!AD.isTracked(VD)) AD[VD] = AD.NumDecls++;
}
- void BlockStmt_VisitExpr(Expr* E) {
- if (AD.EMap.find(E) == AD.EMap.end())
- AD.EMap[E] = AD.NumBlockExprs++;
-
- Visit(E);
+ void BlockStmt_VisitExpr(Expr* E) {
+ if (!AD.isTracked(E)) AD[E] = AD.NumBlockExprs++;
}
-
- void VisitDeclRefExpr(DeclRefExpr* DR) { VisitDeclChain(DR->getDecl()); }
- void VisitDeclStmt(DeclStmt* S) { VisitDeclChain(S->getDecl()); }
- void VisitStmt(Stmt* S) { VisitChildren(S); }
- void operator()(Stmt* S) { BlockStmt_Visit(S); }
};
} // end anonymous namespace
void UninitializedValues::InitializeValues(const CFG& cfg) {
- RegisterDeclsAndExprs R(this->getAnalysisData());
+ RegisterDeclsExprs R(this->getAnalysisData());
cfg.VisitBlockStmts(R);
}
Modified: cfe/trunk/include/clang/Analysis/UninitializedValues.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/UninitializedValues.h?rev=42145&r1=42144&r2=42145&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/UninitializedValues.h (original)
+++ cfe/trunk/include/clang/Analysis/UninitializedValues.h Wed Sep 19 13:00:03 2007
@@ -54,6 +54,9 @@
bool isTracked(const Expr* E) {
return EMap.find(E) != EMap.end();
}
+
+ unsigned& operator[](const BlockVarDecl *VD) { return VMap[VD]; }
+ unsigned& operator[](const Expr* E) { return EMap[E]; }
};
//===--------------------------------------------------------------------===//
More information about the cfe-commits
mailing list