]> granicus.if.org Git - clang/commitdiff
Introduce TULocation and TULocationHandler classes.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 29 Jul 2009 23:40:02 +0000 (23:40 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 29 Jul 2009 23:40:02 +0000 (23:40 +0000)
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

include/clang/Index/ASTLocation.h
include/clang/Index/Handlers.h
lib/Index/Handlers.cpp

index 3fd99289f5af510a39b06fc1f6bee75a54990ed6..954792d0f9ee9db68f0af0a39b510b3f89621347 100644 (file)
@@ -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
index 4a7b85583186809b5a614a7f85a885c88324a95b..2fe83c7f8b7799b2cb25bf0a8a7ef2ab682cd4ae 100644 (file)
@@ -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
index c94314b2953bb9ba16ebb3cb0f32a4f2881bb88e..1e9a27d297c3268d5664371fba23fe29be96379f 100644 (file)
@@ -19,3 +19,4 @@ using namespace idx;
 // Out-of-line to give the virtual tables a home.
 EntityHandler::~EntityHandler() { }
 TranslationUnitHandler::~TranslationUnitHandler() { }
+TULocationHandler::~TULocationHandler() { }