From f7cf15ca3c9bee7c0348f549e7a8f0af32b5fa54 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Tue, 21 Jul 2009 00:07:06 +0000 Subject: Change the semantics for Entity. Entity can now refer to declarations that are not visible outside the translation unit. It is a wrapper of a pointer union, it's either a Decl* for declarations that don't "cross" translation units, or an EntityImpl* which is associated with the specific "visible" Decl. Included is a test case for handling fields across translation units. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76515 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Index/Program.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/Index/Program.cpp') diff --git a/lib/Index/Program.cpp b/lib/Index/Program.cpp index 807d18c699..73759dc95c 100644 --- a/lib/Index/Program.cpp +++ b/lib/Index/Program.cpp @@ -25,6 +25,8 @@ using namespace idx; EntityHandler::~EntityHandler() { } TranslationUnit::~TranslationUnit() { } +void EntityHandler::HandleEntity(Entity Ent) { } + Program::Program() : Impl(new ProgramImpl()) { } Program::~Program() { @@ -34,8 +36,10 @@ Program::~Program() { static void FindEntitiesInDC(DeclContext *DC, Program &Prog, EntityHandler *Handler) { for (DeclContext::decl_iterator I = DC->decls_begin(), E = DC->decls_end(); I != E; ++I) { - Entity *Ent = Entity::get(*I, Prog); - if (Ent) + if (I->getLocation().isInvalid()) + continue; + Entity Ent = Entity::get(*I, Prog); + if (Ent.isValid()) Handler->HandleEntity(Ent); if (DeclContext *SubDC = dyn_cast(*I)) FindEntitiesInDC(SubDC, Prog, Handler); -- cgit v1.2.3-18-g5258