aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2010-01-21 02:21:40 +0000
committerMike Stump <mrs@apple.com>2010-01-21 02:21:40 +0000
commitb978a441c7d8bf59e7fede938e1f3b672573b443 (patch)
treea5f2b95afdb0460ea4677fd4004889146ededc68
parent481683955a28dc5e373d4c380c4737bf3ad51f1c (diff)
Add infrastructure to add base initializers and member initializers to
the CFG. WIP. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94062 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Stmt.h1
-rw-r--r--include/clang/Analysis/CFG.h4
-rw-r--r--lib/Analysis/AnalysisContext.cpp2
-rw-r--r--lib/Analysis/CFG.cpp16
4 files changed, 17 insertions, 6 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index d058f838a0..1cfa5934cb 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -24,6 +24,7 @@
#include "llvm/ADT/SmallVector.h"
#include "clang/AST/ASTContext.h"
#include <string>
+#include <iterator>
using llvm::dyn_cast_or_null;
namespace llvm {
diff --git a/include/clang/Analysis/CFG.h b/include/clang/Analysis/CFG.h
index d85330b7d6..fcfa6b7c95 100644
--- a/include/clang/Analysis/CFG.h
+++ b/include/clang/Analysis/CFG.h
@@ -27,6 +27,7 @@ namespace llvm {
class raw_ostream;
}
namespace clang {
+ class Decl;
class Stmt;
class Expr;
class CFG;
@@ -285,7 +286,8 @@ public:
/// buildCFG - Builds a CFG from an AST. The responsibility to free the
/// constructed CFG belongs to the caller.
- static CFG* buildCFG(Stmt* AST, ASTContext *C, bool AddScopes = false);
+ static CFG* buildCFG(const Decl *D, Stmt* AST, ASTContext *C,
+ bool AddScopes = false);
/// createBlock - Create a new block in the CFG. The CFG owns the block;
/// the caller should not directly free it.
diff --git a/lib/Analysis/AnalysisContext.cpp b/lib/Analysis/AnalysisContext.cpp
index 2093b5e23e..1d5b4a18e9 100644
--- a/lib/Analysis/AnalysisContext.cpp
+++ b/lib/Analysis/AnalysisContext.cpp
@@ -55,7 +55,7 @@ const ImplicitParamDecl *AnalysisContext::getSelfDecl() const {
CFG *AnalysisContext::getCFG() {
if (!cfg)
- cfg = CFG::buildCFG(getBody(), &D->getASTContext());
+ cfg = CFG::buildCFG(D, getBody(), &D->getASTContext());
return cfg;
}
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index 97bf675180..57053b1658 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -14,6 +14,7 @@
#include "clang/Analysis/Support/SaveAndRestore.h"
#include "clang/Analysis/CFG.h"
+#include "clang/AST/DeclCXX.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/PrettyPrinter.h"
#include "llvm/Support/GraphWriter.h"
@@ -93,7 +94,7 @@ public:
TryTerminatedBlock(NULL) {}
// buildCFG - Used by external clients to construct the CFG.
- CFG* buildCFG(Stmt *Statement, ASTContext *C, bool AddScopes);
+ CFG* buildCFG(const Decl *D, Stmt *Statement, ASTContext *C, bool AddScopes);
private:
// Visitors to walk an AST and construct the CFG.
@@ -229,7 +230,8 @@ static VariableArrayType* FindVA(Type* t) {
/// body (compound statement). The ownership of the returned CFG is
/// transferred to the caller. If CFG construction fails, this method returns
/// NULL.
-CFG* CFGBuilder::buildCFG(Stmt* Statement, ASTContext* C, bool AddScopes) {
+CFG* CFGBuilder::buildCFG(const Decl *D, Stmt* Statement, ASTContext* C,
+ bool AddScopes) {
Context = C;
assert(cfg.get());
if (!Statement)
@@ -247,6 +249,11 @@ CFG* CFGBuilder::buildCFG(Stmt* Statement, ASTContext* C, bool AddScopes) {
// Visit the statements and create the CFG.
CFGBlock* B = addStmt(Statement);
+
+ if (const CXXConstructorDecl *CD = dyn_cast_or_null<CXXConstructorDecl>(D)) {
+ // FIXME: Add code for base initializers and member initializers.
+ (void)CD;
+ }
if (!B)
B = Succ;
@@ -1706,9 +1713,10 @@ CFGBlock* CFG::createBlock() {
/// buildCFG - Constructs a CFG from an AST. Ownership of the returned
/// CFG is returned to the caller.
-CFG* CFG::buildCFG(Stmt* Statement, ASTContext *C, bool AddScopes) {
+CFG* CFG::buildCFG(const Decl *D, Stmt* Statement, ASTContext *C,
+ bool AddScopes) {
CFGBuilder Builder;
- return Builder.buildCFG(Statement, C, AddScopes);
+ return Builder.buildCFG(D, Statement, C, AddScopes);
}
//===----------------------------------------------------------------------===//