[cfe-commits] r77535 - in /cfe/trunk: include/clang/Index/ASTLocation.h include/clang/Index/Handlers.h lib/Index/Handlers.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Wed Jul 29 16:40:02 PDT 2009


Author: akirtzidis
Date: Wed Jul 29 18:40:02 2009
New Revision: 77535

URL: http://llvm.org/viewvc/llvm-project?rev=77535&view=rev
Log:
Introduce TULocation and TULocationHandler classes.

TULocation is like ASTLocation but also contains the TranslationUnit* that
the ASTLocation originated from.

Modified:
    cfe/trunk/include/clang/Index/ASTLocation.h
    cfe/trunk/include/clang/Index/Handlers.h
    cfe/trunk/lib/Index/Handlers.cpp

Modified: cfe/trunk/include/clang/Index/ASTLocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/ASTLocation.h?rev=77535&r1=77534&r2=77535&view=diff

==============================================================================
--- cfe/trunk/include/clang/Index/ASTLocation.h (original)
+++ cfe/trunk/include/clang/Index/ASTLocation.h Wed Jul 29 18:40:02 2009
@@ -26,6 +26,7 @@
   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 @@
   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

Modified: cfe/trunk/include/clang/Index/Handlers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/Handlers.h?rev=77535&r1=77534&r2=77535&view=diff

==============================================================================
--- cfe/trunk/include/clang/Index/Handlers.h (original)
+++ cfe/trunk/include/clang/Index/Handlers.h Wed Jul 29 18:40:02 2009
@@ -21,6 +21,7 @@
 namespace idx {
   class Entity;
   class TranslationUnit;
+  class TULocation;
 
 /// \brief Abstract interface for receiving Entities.
 class EntityHandler {
@@ -40,6 +41,15 @@
   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

Modified: cfe/trunk/lib/Index/Handlers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/Handlers.cpp?rev=77535&r1=77534&r2=77535&view=diff

==============================================================================
--- cfe/trunk/lib/Index/Handlers.cpp (original)
+++ cfe/trunk/lib/Index/Handlers.cpp Wed Jul 29 18:40:02 2009
@@ -19,3 +19,4 @@
 // Out-of-line to give the virtual tables a home.
 EntityHandler::~EntityHandler() { }
 TranslationUnitHandler::~TranslationUnitHandler() { }
+TULocationHandler::~TULocationHandler() { }





More information about the cfe-commits mailing list