]> granicus.if.org Git - clang/commitdiff
Accept Handler objects in parameters as references.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 29 Jul 2009 23:38:45 +0000 (23:38 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 29 Jul 2009 23:38:45 +0000 (23:38 +0000)
Reinforces that they shouldn't be null and it's a bit more natural when
they are passed as stack objects.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77526 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Index/IndexProvider.h
include/clang/Index/Indexer.h
include/clang/Index/Program.h
lib/Index/Indexer.cpp
lib/Index/Program.cpp

index bf776eee4fdf6d914c6a5823ab0396a6c893f583..f69945eb2b4e1c10516b4efdae30a86f5ae2b6be 100644 (file)
@@ -25,7 +25,7 @@ class IndexProvider {
 public:
   virtual ~IndexProvider();
   virtual void GetTranslationUnitsFor(Entity Ent,
-                                      TranslationUnitHandler *Handler) = 0;
+                                      TranslationUnitHandler &Handler) = 0;
 };
 
 } // namespace idx
index a7c29581a02b41c7e9a8234d0d44315c26ca25c3..88a2acea8ec5f0679ad9ce5f7b6baac686b3a66b 100644 (file)
@@ -38,7 +38,7 @@ public:
   void IndexAST(TranslationUnit *TU);
 
   virtual void GetTranslationUnitsFor(Entity Ent,
-                                      TranslationUnitHandler *Handler);
+                                      TranslationUnitHandler &Handler);
 
   typedef TUSetTy::iterator translation_unit_iterator;
 
index 1a08118ca57c54891316c7342720cee3464690d0..2605bb685a7592b2c461c8eeb209609d8112c3d7 100644 (file)
@@ -34,7 +34,7 @@ public:
   ~Program();
 
   /// \brief Traverses the AST and passes all the entities to the Handler.
-  void FindEntities(ASTContext &Ctx, EntityHandler *Handler);
+  void FindEntities(ASTContext &Ctx, EntityHandler &Handler);
 };
 
 } // namespace idx
index 03fa80f5717db49f9f665c64f0b55a3040505df6..9a49496d74af43bbb5a198d2f149df78dd084e5e 100644 (file)
@@ -39,11 +39,11 @@ public:
 
 void Indexer::IndexAST(TranslationUnit *TU) {
   EntityIndexer Idx(TU, Map);
-  Prog.FindEntities(TU->getASTContext(), &Idx);
+  Prog.FindEntities(TU->getASTContext(), Idx);
 }
 
 void Indexer::GetTranslationUnitsFor(Entity Ent,
-                                     TranslationUnitHandler *Handler) {
+                                     TranslationUnitHandler &Handler) {
   assert(Ent.isValid() && "Expected valid Entity");
   assert(!Ent.isInternalToTU() &&
          "Expected an Entity visible outside of its translation unit");
@@ -54,7 +54,7 @@ void Indexer::GetTranslationUnitsFor(Entity Ent,
   
   TUSetTy &Set = I->second;
   for (TUSetTy::iterator I = Set.begin(), E = Set.end(); I != E; ++I)
-    Handler->Handle(*I);
+    Handler.Handle(*I);
 }
 
 static Indexer::TUSetTy EmptySet;
index a6bb96c09f3b3aa0030ebb5c75788cd0fc5c924d..4efad2c5e92b6fbb70de49933c1c36b7db915317 100644 (file)
@@ -30,20 +30,21 @@ Program::~Program() {
   delete static_cast<ProgramImpl *>(Impl);
 }
 
-static void FindEntitiesInDC(DeclContext *DC, Program &Prog, EntityHandler *Handler) {
+static void FindEntitiesInDC(DeclContext *DC, Program &Prog,
+                             EntityHandler &Handler) {
   for (DeclContext::decl_iterator
          I = DC->decls_begin(), E = DC->decls_end(); I != E; ++I) {
     if (I->getLocation().isInvalid())
       continue;
     Entity Ent = Entity::get(*I, Prog);
     if (Ent.isValid())
-      Handler->Handle(Ent);
+      Handler.Handle(Ent);
     if (DeclContext *SubDC = dyn_cast<DeclContext>(*I))
       FindEntitiesInDC(SubDC, Prog, Handler);
   }
 }
 
 /// \brief Traverses the AST and passes all the entities to the Handler.
-void Program::FindEntities(ASTContext &Ctx, EntityHandler *Handler) {
+void Program::FindEntities(ASTContext &Ctx, EntityHandler &Handler) {
   FindEntitiesInDC(Ctx.getTranslationUnitDecl(), *this, Handler);
 }