[cfe-commits] r94062 - in /cfe/trunk: include/clang/AST/Stmt.h include/clang/Analysis/CFG.h lib/Analysis/AnalysisContext.cpp lib/Analysis/CFG.cpp

Mike Stump mrs at apple.com
Wed Jan 20 18:21:41 PST 2010


Author: mrs
Date: Wed Jan 20 20:21:40 2010
New Revision: 94062

URL: http://llvm.org/viewvc/llvm-project?rev=94062&view=rev
Log:
Add infrastructure to add base initializers and member initializers to
the CFG.  WIP.

Modified:
    cfe/trunk/include/clang/AST/Stmt.h
    cfe/trunk/include/clang/Analysis/CFG.h
    cfe/trunk/lib/Analysis/AnalysisContext.cpp
    cfe/trunk/lib/Analysis/CFG.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=94062&r1=94061&r2=94062&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Wed Jan 20 20:21:40 2010
@@ -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 {

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=94062&r1=94061&r2=94062&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Wed Jan 20 20:21:40 2010
@@ -27,6 +27,7 @@
   class raw_ostream;
 }
 namespace clang {
+  class Decl;
   class Stmt;
   class Expr;
   class CFG;
@@ -285,7 +286,8 @@
 
   /// 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.

Modified: cfe/trunk/lib/Analysis/AnalysisContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisContext.cpp?rev=94062&r1=94061&r2=94062&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/AnalysisContext.cpp (original)
+++ cfe/trunk/lib/Analysis/AnalysisContext.cpp Wed Jan 20 20:21:40 2010
@@ -55,7 +55,7 @@
 
 CFG *AnalysisContext::getCFG() {
   if (!cfg)
-    cfg = CFG::buildCFG(getBody(), &D->getASTContext());
+    cfg = CFG::buildCFG(D, getBody(), &D->getASTContext());
   return cfg;
 }
 

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=94062&r1=94061&r2=94062&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Wed Jan 20 20:21:40 2010
@@ -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 @@
                           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 @@
 ///  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 @@
 
   // 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 @@
 
 /// 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);
 }
 
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list