make CallGraph more flexible by letting it accept ASTContext instead of ASTUnit.

Patch by Simone Pellegrini.

llvm-svn: 85386
This commit is contained in:
Zhongxing Xu 2009-10-28 12:23:03 +00:00
parent f50fd57543
commit cb131542f1
3 changed files with 4 additions and 7 deletions

View File

@ -17,7 +17,6 @@
#include "clang/Index/ASTLocation.h"
#include "clang/Index/Entity.h"
#include "clang/Index/Program.h"
#include "clang/Frontend/ASTUnit.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/STLExtras.h"
@ -87,7 +86,7 @@ public:
CallGraphNode *getExternalCallingNode() { return ExternalCallingNode; }
void addTU(ASTUnit &AST);
void addTU(ASTContext &AST);
idx::Program &getProgram() { return Prog; }

View File

@ -68,10 +68,8 @@ CallGraph::~CallGraph() {
}
}
void CallGraph::addTU(ASTUnit &AST) {
ASTContext &Ctx = AST.getASTContext();
void CallGraph::addTU(ASTContext& Ctx) {
DeclContext *DC = Ctx.getTranslationUnitDecl();
for (DeclContext::decl_iterator I = DC->decls_begin(), E = DC->decls_end();
I != E; ++I) {

View File

@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Analysis/CallGraph.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Frontend/TextDiagnosticBuffer.h"
@ -56,7 +56,7 @@ int main(int argc, char **argv) {
CG.reset(new CallGraph());
for (unsigned i = 0, e = ASTUnits.size(); i != e; ++i)
CG->addTU(*ASTUnits[i]);
CG->addTU(ASTUnits[i]->getASTContext());
CG->ViewCallGraph();
}