[cfe-commits] r119135 - in /cfe/trunk: include/clang/Analysis/CFG.h include/clang/Checker/PathSensitive/GRCoreEngine.h include/clang/Checker/PathSensitive/GRExprEngine.h include/clang/Checker/PathSensitive/GRSubEngine.h lib/Checker/GRCoreEngine.cpp lib/Checker/GRExprEngine.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Mon Nov 15 00:48:43 PST 2010
Author: zhongxingxu
Date: Mon Nov 15 02:48:43 2010
New Revision: 119135
URL: http://llvm.org/viewvc/llvm-project?rev=119135&view=rev
Log:
Add skeleton for handling other kinds of CFGElements.
Modified:
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h
cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
cfe/trunk/include/clang/Checker/PathSensitive/GRSubEngine.h
cfe/trunk/lib/Checker/GRCoreEngine.cpp
cfe/trunk/lib/Checker/GRExprEngine.cpp
Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=119135&r1=119134&r2=119135&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Mon Nov 15 02:48:43 2010
@@ -49,7 +49,7 @@
Statement,
StatementAsLValue,
Initializer,
- Dtor,
+ ImplicitDtor,
// dtor kind
AutomaticObjectDtor,
BaseDtor,
@@ -74,7 +74,7 @@
Kind getKind() const { return static_cast<Kind>(Data1.getInt()); }
Kind getDtorKind() const {
- assert(getKind() == Dtor);
+ assert(getKind() == ImplicitDtor);
return static_cast<Kind>(Data2.getInt() + DTOR_BEGIN);
}
@@ -132,13 +132,13 @@
class CFGImplicitDtor : public CFGElement {
protected:
CFGImplicitDtor(unsigned K, void* P, void* S)
- : CFGElement(P, Dtor, S, K - DTOR_BEGIN) {}
+ : CFGElement(P, ImplicitDtor, S, K - DTOR_BEGIN) {}
public:
CFGImplicitDtor() {}
static bool classof(const CFGElement *E) {
- return E->getKind() == Dtor;
+ return E->getKind() == ImplicitDtor;
}
};
@@ -161,7 +161,8 @@
}
static bool classof(const CFGElement *E) {
- return E->getKind() == Dtor && E->getDtorKind() == AutomaticObjectDtor;
+ return E->getKind() == ImplicitDtor &&
+ E->getDtorKind() == AutomaticObjectDtor;
}
};
@@ -178,7 +179,7 @@
}
static bool classof(const CFGElement *E) {
- return E->getKind() == Dtor && E->getDtorKind() == BaseDtor;
+ return E->getKind() == ImplicitDtor && E->getDtorKind() == BaseDtor;
}
};
@@ -195,7 +196,7 @@
}
static bool classof(const CFGElement *E) {
- return E->getKind() == Dtor && E->getDtorKind() == MemberDtor;
+ return E->getKind() == ImplicitDtor && E->getDtorKind() == MemberDtor;
}
};
@@ -212,7 +213,7 @@
}
static bool classof(const CFGElement *E) {
- return E->getKind() == Dtor && E->getDtorKind() == TemporaryDtor;
+ return E->getKind() == ImplicitDtor && E->getDtorKind() == TemporaryDtor;
}
};
Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h?rev=119135&r1=119134&r2=119135&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h Mon Nov 15 02:48:43 2010
@@ -90,8 +90,8 @@
SubEngine.ProcessEndPath(Builder);
}
- void ProcessStmt(const CFGElement E, GRStmtNodeBuilder& Builder) {
- SubEngine.ProcessStmt(E, Builder);
+ void ProcessElement(const CFGElement E, GRStmtNodeBuilder& Builder) {
+ SubEngine.ProcessElement(E, Builder);
}
bool ProcessBlockEntrance(const CFGBlock* Blk, const ExplodedNode *Pred,
Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h?rev=119135&r1=119134&r2=119135&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h Mon Nov 15 02:48:43 2010
@@ -175,9 +175,15 @@
return static_cast<CHECKER*>(lookupChecker(CHECKER::getTag()));
}
- /// ProcessStmt - Called by GRCoreEngine. Used to generate new successor
- /// nodes by processing the 'effects' of a block-level statement.
- void ProcessStmt(const CFGElement E, GRStmtNodeBuilder& builder);
+ /// ProcessElement - Called by GRCoreEngine. Used to generate new successor
+ /// nodes by processing the 'effects' of a CFG element.
+ void ProcessElement(const CFGElement E, GRStmtNodeBuilder& builder);
+
+ void ProcessStmt(const CFGStmt S, GRStmtNodeBuilder &builder);
+
+ void ProcessInitializer(const CFGInitializer I, GRStmtNodeBuilder &builder);
+
+ void ProcessImplicitDtor(const CFGImplicitDtor D, GRStmtNodeBuilder &builder);
/// ProcessBlockEntrance - Called by GRCoreEngine when start processing
/// a CFGBlock. This method returns true if the analysis should continue
Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRSubEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRSubEngine.h?rev=119135&r1=119134&r2=119135&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRSubEngine.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRSubEngine.h Mon Nov 15 02:48:43 2010
@@ -47,7 +47,7 @@
/// Called by GRCoreEngine. Used to generate new successor
/// nodes by processing the 'effects' of a block-level statement.
- virtual void ProcessStmt(const CFGElement E, GRStmtNodeBuilder& builder) = 0;
+ virtual void ProcessElement(const CFGElement E, GRStmtNodeBuilder& builder)=0;
/// Called by GRCoreEngine when start processing
/// a CFGBlock. This method returns true if the analysis should continue
Modified: cfe/trunk/lib/Checker/GRCoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRCoreEngine.cpp?rev=119135&r1=119134&r2=119135&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRCoreEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRCoreEngine.cpp Mon Nov 15 02:48:43 2010
@@ -309,7 +309,7 @@
if (CFGElement E = L.getFirstElement()) {
GRStmtNodeBuilder Builder(L.getBlock(), 0, Pred, this,
SubEngine.getStateManager());
- ProcessStmt(E, Builder);
+ ProcessElement(E, Builder);
}
else
HandleBlockExit(L.getBlock(), Pred);
@@ -423,7 +423,7 @@
else {
GRStmtNodeBuilder Builder(B, StmtIdx, Pred, this,
SubEngine.getStateManager());
- ProcessStmt((*B)[StmtIdx], Builder);
+ ProcessElement((*B)[StmtIdx], Builder);
}
}
Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=119135&r1=119134&r2=119135&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Mon Nov 15 02:48:43 2010
@@ -552,8 +552,27 @@
}
}
-void GRExprEngine::ProcessStmt(const CFGElement CE,GRStmtNodeBuilder& builder) {
- CurrentStmt = CE.getAs<CFGStmt>();
+void GRExprEngine::ProcessElement(const CFGElement E,
+ GRStmtNodeBuilder& builder) {
+ switch (E.getKind()) {
+ case CFGElement::Statement:
+ case CFGElement::StatementAsLValue:
+ ProcessStmt(E.getAs<CFGStmt>(), builder);
+ break;
+ case CFGElement::Initializer:
+ ProcessInitializer(E.getAs<CFGInitializer>(), builder);
+ break;
+ case CFGElement::ImplicitDtor:
+ ProcessImplicitDtor(E.getAs<CFGImplicitDtor>(), builder);
+ break;
+ default:
+ // Suppress compiler warning.
+ llvm_unreachable("Unexpected CFGElement kind.");
+ }
+}
+
+void GRExprEngine::ProcessStmt(const CFGStmt S, GRStmtNodeBuilder& builder) {
+ CurrentStmt = S.getStmt();
PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
CurrentStmt->getLocStart(),
"Error evaluating statement");
@@ -636,7 +655,7 @@
Builder->SetCleanedState(*I == EntryNode ? CleanedState : GetState(*I));
// Visit the statement.
- if (CE.getAs<CFGStmt>().asLValue())
+ if (S.asLValue())
VisitLValue(cast<Expr>(CurrentStmt), *I, Dst);
else
Visit(CurrentStmt, *I, Dst);
@@ -660,6 +679,14 @@
Builder = NULL;
}
+void GRExprEngine::ProcessInitializer(const CFGInitializer I,
+ GRStmtNodeBuilder &builder) {
+}
+
+void GRExprEngine::ProcessImplicitDtor(const CFGImplicitDtor D,
+ GRStmtNodeBuilder &builder) {
+}
+
void GRExprEngine::Visit(const Stmt* S, ExplodedNode* Pred,
ExplodedNodeSet& Dst) {
PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
More information about the cfe-commits
mailing list