diff options
| author | Anna Zaks <ganna@apple.com> | 2012-03-02 22:54:36 +0000 |
|---|---|---|
| committer | Anna Zaks <ganna@apple.com> | 2012-03-02 22:54:36 +0000 |
| commit | fc5dfe9f7cafebfc0b8cdee36082a6ef5eb24488 (patch) | |
| tree | 70d0dea7a4565fa5b4129cca8ce175d4018a4df4 /clang | |
| parent | 611306eae6c901916443b528b4fe789fd1574a90 (diff) | |
| download | bcm5719-llvm-fc5dfe9f7cafebfc0b8cdee36082a6ef5eb24488.tar.gz bcm5719-llvm-fc5dfe9f7cafebfc0b8cdee36082a6ef5eb24488.zip | |
[analyzer] Rename clang::CallGraph into clang::idx::CallGraph + rename
the corresponding files to avoid confusion.
This is a preparation to adding an AST-based call graph to Analysis. The
existing call graph works with indexer entries. We might be able to
refactor it to use the AST based graph in the future.
(Minimal testing here as the only example that uses the API has been
completely broken, does not compile.)
llvm-svn: 151950
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/examples/wpa/clang-wpa.cpp | 6 | ||||
| -rw-r--r-- | clang/include/clang/Index/GlobalCallGraph.h (renamed from clang/include/clang/Index/CallGraph.h) | 33 | ||||
| -rw-r--r-- | clang/lib/Index/GlobalCallGraph.cpp (renamed from clang/lib/Index/CallGraph.cpp) | 10 |
3 files changed, 27 insertions, 22 deletions
diff --git a/clang/examples/wpa/clang-wpa.cpp b/clang/examples/wpa/clang-wpa.cpp index b1119e14b79..8e29090fe78 100644 --- a/clang/examples/wpa/clang-wpa.cpp +++ b/clang/examples/wpa/clang-wpa.cpp @@ -22,7 +22,7 @@ #include "clang/StaticAnalyzer/Checkers/LocalCheckers.h" #include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/CompilerInstance.h" -#include "clang/Index/CallGraph.h" +#include "clang/Index/GlobalCallGraph.h" #include "clang/Index/Indexer.h" #include "clang/Index/TranslationUnit.h" #include "clang/Index/DeclReferenceMap.h" @@ -104,8 +104,8 @@ int main(int argc, char **argv) { } if (ViewCallGraph) { - OwningPtr<CallGraph> CG; - CG.reset(new CallGraph(Prog)); + OwningPtr<clang::idx::CallGraph> CG; + CG.reset(new clang::idx::CallGraph(Prog)); for (unsigned i = 0, e = ASTUnits.size(); i != e; ++i) CG->addTU(ASTUnits[i]->getASTContext()); diff --git a/clang/include/clang/Index/CallGraph.h b/clang/include/clang/Index/GlobalCallGraph.h index 38baf0f7537..7ba1cceac18 100644 --- a/clang/include/clang/Index/CallGraph.h +++ b/clang/include/clang/Index/GlobalCallGraph.h @@ -1,4 +1,4 @@ -//== CallGraph.cpp - Call graph building ------------------------*- C++ -*--==// +//== GlobalCallGraph.h - Call graph building --------------------*- C++ -*--==// // // The LLVM Compiler Infrastructure // @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_ANALYSIS_CALLGRAPH -#define LLVM_CLANG_ANALYSIS_CALLGRAPH +#ifndef LLVM_CLANG_INDEX_CALLGRAPH +#define LLVM_CLANG_INDEX_CALLGRAPH #include "clang/Index/ASTLocation.h" #include "clang/Index/Entity.h" @@ -23,15 +23,18 @@ #include <vector> #include <map> +using namespace clang; + namespace clang { +namespace idx { class CallGraphNode { - idx::Entity F; - typedef std::pair<idx::ASTLocation, CallGraphNode*> CallRecord; + Entity F; + typedef std::pair<ASTLocation, CallGraphNode*> CallRecord; std::vector<CallRecord> CalledFunctions; public: - CallGraphNode(idx::Entity f) : F(f) {} + CallGraphNode(Entity f) : F(f) {} typedef std::vector<CallRecord>::iterator iterator; typedef std::vector<CallRecord>::const_iterator const_iterator; @@ -41,7 +44,7 @@ public: const_iterator begin() const { return CalledFunctions.begin(); } const_iterator end() const { return CalledFunctions.end(); } - void addCallee(idx::ASTLocation L, CallGraphNode *Node) { + void addCallee(ASTLocation L, CallGraphNode *Node) { CalledFunctions.push_back(std::make_pair(L, Node)); } @@ -54,9 +57,9 @@ public: class CallGraph { /// Program manages all Entities. - idx::Program &Prog; + Program &Prog; - typedef std::map<idx::Entity, CallGraphNode *> FunctionMapTy; + typedef std::map<Entity, CallGraphNode *> FunctionMapTy; /// FunctionMap owns all CallGraphNodes. FunctionMapTy FunctionMap; @@ -71,7 +74,7 @@ class CallGraph { CallGraphNode *ExternalCallingNode; public: - CallGraph(idx::Program &P); + CallGraph(Program &P); ~CallGraph(); typedef FunctionMapTy::iterator iterator; @@ -88,7 +91,7 @@ public: void addTU(ASTContext &AST); - idx::Program &getProgram() { return Prog; } + Program &getProgram() { return Prog; } CallGraphNode *getOrInsertFunction(idx::Entity F); @@ -100,13 +103,13 @@ public: void ViewCallGraph() const; }; -} // end clang namespace +}} // end clang idx namespace namespace llvm { -template <> struct GraphTraits<clang::CallGraph> { - typedef clang::CallGraph GraphType; - typedef clang::CallGraphNode NodeType; +template <> struct GraphTraits<clang::idx::CallGraph> { + typedef clang::idx::CallGraph GraphType; + typedef clang::idx::CallGraphNode NodeType; typedef std::pair<clang::idx::ASTLocation, NodeType*> CGNPairTy; typedef std::pointer_to_unary_function<CGNPairTy, NodeType*> CGNDerefFun; diff --git a/clang/lib/Index/CallGraph.cpp b/clang/lib/Index/GlobalCallGraph.cpp index 741e78107f8..a21b52ae602 100644 --- a/clang/lib/Index/CallGraph.cpp +++ b/clang/lib/Index/GlobalCallGraph.cpp @@ -1,4 +1,4 @@ -//== CallGraph.cpp - Call graph building ------------------------*- C++ -*--==// +//== GlobalCallGraph.cpp - Call graph building ------------------*- C++ -*--==// // // The LLVM Compiler Infrastructure // @@ -11,15 +11,17 @@ // //===----------------------------------------------------------------------===// -#include "clang/Index/CallGraph.h" +#include "clang/Index/GlobalCallGraph.h" #include "clang/AST/ASTContext.h" #include "clang/AST/StmtVisitor.h" #include "llvm/Support/GraphWriter.h" -using namespace clang; -using namespace idx; +using namespace clang::idx; +using clang::FunctionDecl; +using clang::DeclContext; +using clang::ASTContext; namespace { class CGBuilder : public StmtVisitor<CGBuilder> { |

