Accept Handler objects in parameters as references.

Reinforces that they shouldn't be null and it's a bit more natural when
they are passed as stack objects.

llvm-svn: 77526
This commit is contained in:
Argyrios Kyrtzidis 2009-07-29 23:38:45 +00:00
parent 9ddd99ade7
commit 14df96c730
5 changed files with 10 additions and 9 deletions

View File

@ -25,7 +25,7 @@ class IndexProvider {
public:
virtual ~IndexProvider();
virtual void GetTranslationUnitsFor(Entity Ent,
TranslationUnitHandler *Handler) = 0;
TranslationUnitHandler &Handler) = 0;
};
} // namespace idx

View 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;

View 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

View 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;

View 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);
}