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
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index d058f83..1cfa593 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 d85330b..fcfa6b7 100644
--- a/include/clang/Analysis/CFG.h
+++ b/include/clang/Analysis/CFG.h
@@ -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.
diff --git a/lib/Analysis/AnalysisContext.cpp b/lib/Analysis/AnalysisContext.cpp
index 2093b5e..1d5b4a1 100644
--- a/lib/Analysis/AnalysisContext.cpp
+++ b/lib/Analysis/AnalysisContext.cpp
@@ -55,7 +55,7 @@
 
 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 97bf675..57053b1 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 @@
                           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);
 }
 
 //===----------------------------------------------------------------------===//