diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-29 23:40:02 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-29 23:40:02 +0000 |
commit | 40c0e73be6b2508c33f802368080f6b369dc67bc (patch) | |
tree | bedc693962b266ce573cc1d9afcfea9617fd4a17 /include/clang | |
parent | 52f1d4793588af6c5c09ab096818ff942bae3af6 (diff) |
Introduce TULocation and TULocationHandler classes.
TULocation is like ASTLocation but also contains the TranslationUnit* that
the ASTLocation originated from.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77535 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Index/ASTLocation.h | 15 | ||||
-rw-r--r-- | include/clang/Index/Handlers.h | 10 |
2 files changed, 25 insertions, 0 deletions
diff --git a/include/clang/Index/ASTLocation.h b/include/clang/Index/ASTLocation.h index 3fd99289f5..954792d0f9 100644 --- a/include/clang/Index/ASTLocation.h +++ b/include/clang/Index/ASTLocation.h @@ -26,6 +26,7 @@ namespace clang { class SourceRange; namespace idx { + class TranslationUnit; /// \brief Represents a Decl or a Stmt and its immediate Decl parent. It's /// immutable. @@ -84,6 +85,20 @@ public: void print(llvm::raw_ostream &OS) const; }; +/// \brief Like ASTLocation but also contains the TranslationUnit that the +/// ASTLocation originated from. +class TULocation : public ASTLocation { + TranslationUnit *TU; + +public: + TULocation(TranslationUnit *tu, ASTLocation astLoc) + : ASTLocation(astLoc), TU(tu) { + assert(tu && "Passed null translation unit"); + } + + TranslationUnit *getTU() const { return TU; } +}; + } // namespace idx } // namespace clang diff --git a/include/clang/Index/Handlers.h b/include/clang/Index/Handlers.h index 4a7b855831..2fe83c7f8b 100644 --- a/include/clang/Index/Handlers.h +++ b/include/clang/Index/Handlers.h @@ -21,6 +21,7 @@ namespace clang { namespace idx { class Entity; class TranslationUnit; + class TULocation; /// \brief Abstract interface for receiving Entities. class EntityHandler { @@ -40,6 +41,15 @@ public: virtual void Handle(TranslationUnit *TU) = 0; }; +/// \brief Abstract interface for receiving TULocations. +class TULocationHandler { +public: + typedef TULocation receiving_type; + + virtual ~TULocationHandler(); + virtual void Handle(TULocation TULoc) = 0; +}; + /// \brief Helper for the Handler classes. Stores the objects into a vector. /// example: /// @code |