diff options
-rw-r--r-- | include/clang/AST/ASTLocation.h (renamed from include/clang/AST/ASTNode.h) | 18 | ||||
-rw-r--r-- | include/clang/AST/DeclReferenceMap.h | 34 | ||||
-rw-r--r-- | include/clang/Frontend/Utils.h | 4 | ||||
-rw-r--r-- | lib/AST/ASTLocation.cpp (renamed from lib/AST/ASTNode.cpp) | 12 | ||||
-rw-r--r-- | lib/AST/CMakeLists.txt | 2 | ||||
-rw-r--r-- | lib/AST/DeclReferenceMap.cpp | 16 | ||||
-rw-r--r-- | lib/Frontend/ResolveLocation.cpp | 8 | ||||
-rw-r--r-- | tools/index-test/index-test.cpp | 22 |
8 files changed, 58 insertions, 58 deletions
diff --git a/include/clang/AST/ASTNode.h b/include/clang/AST/ASTLocation.h index 852e946380..f6ace25ca7 100644 --- a/include/clang/AST/ASTNode.h +++ b/include/clang/AST/ASTLocation.h @@ -1,4 +1,4 @@ -//===--- ASTNode.h - A <Decl, Stmt> pair ------------------------*- C++ -*-===// +//===--- ASTLocation.h - A <Decl, Stmt> pair --------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// // -// ASTNode is Decl or a Stmt and its immediate Decl parent. +// ASTLocation is Decl or a Stmt and its immediate Decl parent. // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_AST_ASTNODE_H -#define LLVM_CLANG_AST_ASTNODE_H +#ifndef LLVM_CLANG_AST_ASTLOCATION_H +#define LLVM_CLANG_AST_ASTLOCATION_H #include <cassert> @@ -26,14 +26,14 @@ namespace clang { /// \brief Represents a Decl or a Stmt and its immediate Decl parent. It's /// immutable. -class ASTNode { +class ASTLocation { Decl *D; Stmt *Stm; public: - ASTNode() : D(0), Stm(0) {} + ASTLocation() : D(0), Stm(0) {} - explicit ASTNode(const Decl *d, const Stmt *stm = 0) + explicit ASTLocation(const Decl *d, const Stmt *stm = 0) : D(const_cast<Decl*>(d)), Stm(const_cast<Stmt*>(stm)) { assert((Stm == 0 || isImmediateParent(D, Stm)) && "The Decl is not the immediate parent of the Stmt."); @@ -51,10 +51,10 @@ public: /// \brief Checks that D is the immediate Decl parent of Node. static bool isImmediateParent(Decl *D, Stmt *Node); - friend bool operator==(const ASTNode &L, const ASTNode &R) { + friend bool operator==(const ASTLocation &L, const ASTLocation &R) { return L.D == R.D && L.Stm == R.Stm; } - friend bool operator!=(const ASTNode &L, const ASTNode &R) { + friend bool operator!=(const ASTLocation &L, const ASTLocation &R) { return !(L == R); } diff --git a/include/clang/AST/DeclReferenceMap.h b/include/clang/AST/DeclReferenceMap.h index b2068fb275..9dd5d47fef 100644 --- a/include/clang/AST/DeclReferenceMap.h +++ b/include/clang/AST/DeclReferenceMap.h @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// DeclReferenceMap creates a mapping from Decls to the ASTNodes that +// DeclReferenceMap creates a mapping from Decls to the ASTLocations that // reference them. // //===----------------------------------------------------------------------===// @@ -15,14 +15,14 @@ #ifndef LLVM_CLANG_AST_DECLREFERENCEMAP_H #define LLVM_CLANG_AST_DECLREFERENCEMAP_H -#include "clang/AST/ASTNode.h" +#include "clang/AST/ASTLocation.h" #include <map> namespace clang { class ASTContext; class NamedDecl; -/// \brief Maps NamedDecls with the ASTNodes that reference them. +/// \brief Maps NamedDecls with the ASTLocations that reference them. /// /// References are mapped and retrieved using the primary decls /// (see Decl::getPrimaryDecl()). @@ -30,47 +30,47 @@ class DeclReferenceMap { public: explicit DeclReferenceMap(ASTContext &Ctx); - typedef std::multimap<NamedDecl*, ASTNode> MapTy; + typedef std::multimap<NamedDecl*, ASTLocation> MapTy; - class astnode_iterator { + class astlocation_iterator { MapTy::iterator I; - astnode_iterator(MapTy::iterator i) : I(i) { } + astlocation_iterator(MapTy::iterator i) : I(i) { } friend class DeclReferenceMap; public: - typedef ASTNode value_type; - typedef ASTNode& reference; - typedef ASTNode* pointer; + typedef ASTLocation value_type; + typedef ASTLocation& reference; + typedef ASTLocation* pointer; typedef MapTy::iterator::iterator_category iterator_category; typedef MapTy::iterator::difference_type difference_type; - astnode_iterator() { } + astlocation_iterator() { } reference operator*() const { return I->second; } pointer operator->() const { return &I->second; } - astnode_iterator& operator++() { + astlocation_iterator& operator++() { ++I; return *this; } - astnode_iterator operator++(int) { - astnode_iterator tmp(*this); + astlocation_iterator operator++(int) { + astlocation_iterator tmp(*this); ++(*this); return tmp; } - friend bool operator==(astnode_iterator L, astnode_iterator R) { + friend bool operator==(astlocation_iterator L, astlocation_iterator R) { return L.I == R.I; } - friend bool operator!=(astnode_iterator L, astnode_iterator R) { + friend bool operator!=(astlocation_iterator L, astlocation_iterator R) { return L.I != R.I; } }; - astnode_iterator refs_begin(NamedDecl *D) const; - astnode_iterator refs_end(NamedDecl *D) const; + astlocation_iterator refs_begin(NamedDecl *D) const; + astlocation_iterator refs_end(NamedDecl *D) const; bool refs_empty(NamedDecl *D) const; private: diff --git a/include/clang/Frontend/Utils.h b/include/clang/Frontend/Utils.h index 7e7efbce57..3153e400ef 100644 --- a/include/clang/Frontend/Utils.h +++ b/include/clang/Frontend/Utils.h @@ -36,7 +36,7 @@ class Decl; class Stmt; class ASTContext; class SourceLocation; -class ASTNode; +class ASTLocation; /// ProcessWarningOptions - Initialize the diagnostic client and process the /// warning options specified on the command line. @@ -103,7 +103,7 @@ void CacheTokens(Preprocessor& PP, llvm::raw_fd_ostream* OS); /// Pointing at '100' will return a <VarDecl 'foo', IntegerLiteral '100'> pair. /// Pointing at '++foo' will return a <FunctionDecl 'f', UnaryOperator> pair. /// -ASTNode ResolveLocationInAST(ASTContext &Ctx, SourceLocation Loc); +ASTLocation ResolveLocationInAST(ASTContext &Ctx, SourceLocation Loc); } // end namespace clang diff --git a/lib/AST/ASTNode.cpp b/lib/AST/ASTLocation.cpp index ff5ecc10de..e72acf0793 100644 --- a/lib/AST/ASTNode.cpp +++ b/lib/AST/ASTLocation.cpp @@ -1,4 +1,4 @@ -//===--- ASTNode.h - A <Decl, Stmt> pair ------------------------*- C++ -*-===// +//===--- ASTLocation.h - A <Decl, Stmt> pair --------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,11 +7,11 @@ // //===----------------------------------------------------------------------===// // -// ASTNode is Decl or a Stmt and its immediate Decl parent. +// ASTLocation is Decl or a Stmt and its immediate Decl parent. // //===----------------------------------------------------------------------===// -#include "clang/AST/ASTNode.h" +#include "clang/AST/ASTLocation.h" #include "clang/AST/Decl.h" #include "clang/AST/Stmt.h" #include "clang/AST/Expr.h" @@ -60,13 +60,13 @@ static Decl *FindImmediateParent(Decl *D, Stmt *Node) { return 0; } -bool ASTNode::isImmediateParent(Decl *D, Stmt *Node) { +bool ASTLocation::isImmediateParent(Decl *D, Stmt *Node) { assert(D && Node && "Passed null Decl or null Stmt"); return D == FindImmediateParent(D, Node); } -void ASTNode::print(llvm::raw_ostream &OS) { - assert(isValid() && "ASTNode is not valid"); +void ASTLocation::print(llvm::raw_ostream &OS) { + assert(isValid() && "ASTLocation is not valid"); OS << "[Decl: " << getDecl()->getDeclKindName() << " "; if (NamedDecl *ND = dyn_cast<NamedDecl>(getDecl())) diff --git a/lib/AST/CMakeLists.txt b/lib/AST/CMakeLists.txt index 899bc8f78e..f844cf1529 100644 --- a/lib/AST/CMakeLists.txt +++ b/lib/AST/CMakeLists.txt @@ -4,7 +4,7 @@ add_clang_library(clangAST APValue.cpp ASTConsumer.cpp ASTContext.cpp - ASTNode.cpp + ASTLocation.cpp CFG.cpp DeclarationName.cpp DeclBase.cpp diff --git a/lib/AST/DeclReferenceMap.cpp b/lib/AST/DeclReferenceMap.cpp index 3e0114a0cb..41f53fdd52 100644 --- a/lib/AST/DeclReferenceMap.cpp +++ b/lib/AST/DeclReferenceMap.cpp @@ -7,15 +7,15 @@ // //===----------------------------------------------------------------------===// // -// DeclReferenceMap creates a mapping from Decls to the ASTNodes that -// references them. +// DeclReferenceMap creates a mapping from Decls to the ASTLocations that +// reference them. // //===----------------------------------------------------------------------===// #include "clang/AST/DeclReferenceMap.h" #include "clang/AST/Decl.h" #include "clang/AST/Stmt.h" -#include "clang/AST/ASTNode.h" +#include "clang/AST/ASTLocation.h" #include "clang/AST/DeclVisitor.h" #include "clang/AST/StmtVisitor.h" #include "llvm/Support/Compiler.h" @@ -65,7 +65,7 @@ void StmtMapper::VisitDeclStmt(DeclStmt *Node) { void StmtMapper::VisitDeclRefExpr(DeclRefExpr *Node) { NamedDecl *PrimD = cast<NamedDecl>(Node->getDecl()->getPrimaryDecl()); - Map.insert(std::make_pair(PrimD, ASTNode(Parent, Node))); + Map.insert(std::make_pair(PrimD, ASTLocation(Parent, Node))); } void StmtMapper::VisitStmt(Stmt *Node) { @@ -113,16 +113,16 @@ DeclReferenceMap::DeclReferenceMap(ASTContext &Ctx) { DeclMapper(Map).Visit(Ctx.getTranslationUnitDecl()); } -DeclReferenceMap::astnode_iterator +DeclReferenceMap::astlocation_iterator DeclReferenceMap::refs_begin(NamedDecl *D) const { NamedDecl *Prim = cast<NamedDecl>(D->getPrimaryDecl()); - return astnode_iterator(Map.lower_bound(Prim)); + return astlocation_iterator(Map.lower_bound(Prim)); } -DeclReferenceMap::astnode_iterator +DeclReferenceMap::astlocation_iterator DeclReferenceMap::refs_end(NamedDecl *D) const { NamedDecl *Prim = cast<NamedDecl>(D->getPrimaryDecl()); - return astnode_iterator(Map.upper_bound(Prim)); + return astlocation_iterator(Map.upper_bound(Prim)); } bool DeclReferenceMap::refs_empty(NamedDecl *D) const { diff --git a/lib/Frontend/ResolveLocation.cpp b/lib/Frontend/ResolveLocation.cpp index 5b8eed0c0e..c2d32bbc90 100644 --- a/lib/Frontend/ResolveLocation.cpp +++ b/lib/Frontend/ResolveLocation.cpp @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// #include "clang/Frontend/Utils.h" -#include "clang/AST/ASTNode.h" +#include "clang/AST/ASTLocation.h" #include "clang/AST/DeclVisitor.h" #include "clang/AST/StmtVisitor.h" #include "clang/Lex/Lexer.h" @@ -321,11 +321,11 @@ void LocResolverBase::print(Stmt *Node) { /// \brief Returns the AST node that a source location points to. /// -ASTNode clang::ResolveLocationInAST(ASTContext &Ctx, SourceLocation Loc) { +ASTLocation clang::ResolveLocationInAST(ASTContext &Ctx, SourceLocation Loc) { if (Loc.isInvalid()) - return ASTNode(); + return ASTLocation(); DeclLocResolver DLR(Ctx, Loc); DLR.Visit(Ctx.getTranslationUnitDecl()); - return ASTNode(DLR.getDecl(), DLR.getStmt()); + return ASTLocation(DLR.getDecl(), DLR.getStmt()); } diff --git a/tools/index-test/index-test.cpp b/tools/index-test/index-test.cpp index 5043e3e62b..f44cd53b77 100644 --- a/tools/index-test/index-test.cpp +++ b/tools/index-test/index-test.cpp @@ -22,13 +22,13 @@ // specified, prints some info about it. // // -print-refs -// Print ASTNodes that reference the -point-at node +// Print ASTLocations that reference the -point-at node // // -print-defs -// Print ASTNodes that define the -point-at node +// Print ASTLocations that define the -point-at node // // -print-decls -// Print ASTNodes that declare the -point-at node +// Print ASTLocations that declare the -point-at node // //===----------------------------------------------------------------------===// @@ -41,7 +41,7 @@ #include "clang/Frontend/CommandLineSourceLoc.h" #include "clang/AST/Decl.h" #include "clang/AST/Expr.h" -#include "clang/AST/ASTNode.h" +#include "clang/AST/ASTLocation.h" #include "clang/AST/DeclReferenceMap.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" @@ -107,7 +107,7 @@ static void ProcessDecl(Decl *D) { return; DeclReferenceMap RefMap(ND->getASTContext()); - for (DeclReferenceMap::astnode_iterator + for (DeclReferenceMap::astlocation_iterator I = RefMap.refs_begin(ND), E = RefMap.refs_end(ND); I != E; ++I) I->print(OS); break; @@ -126,29 +126,29 @@ static void ProcessDecl(Decl *D) { } if (DefD) - ASTNode(DefD).print(OS); + ASTLocation(DefD).print(OS); break; } case PrintDecls : if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { while (FD) { - ASTNode(FD).print(OS); + ASTLocation(FD).print(OS); FD = FD->getPreviousDeclaration(); } } else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { while (VD) { - ASTNode(VD).print(OS); + ASTLocation(VD).print(OS); VD = VD->getPreviousDeclaration(); } } else - ASTNode(D).print(OS); + ASTLocation(D).print(OS); break; } } -static void ProcessNode(ASTNode Node, IndexProvider &IdxProvider) { +static void ProcessNode(ASTLocation Node, IndexProvider &IdxProvider) { assert(Node.isValid()); Decl *D = 0; @@ -214,7 +214,7 @@ int main(int argc, char **argv) { IdxProvider.IndexAST(TU); } - ASTNode Node; + ASTLocation Node; const std::string &FirstFile = TUnits[0]->Filename; ASTUnit *FirstAST = TUnits[0]->AST.get(); |