On Sep 8, 2011, at 11:44 PM, Argyrios Kyrtzidis wrote:

> Author: akirtzidis
> Date: Fri Sep  9 01:44:17 2011
> New Revision: 139358
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=139358&view=rev
> Log:
> [PCH] When loading the decls linked to an identifier, also make them visible
> in the translation unit.
> 
> Modified:
>    cfe/trunk/lib/Serialization/ASTReader.cpp
> 
> Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=139358&r1=139357&r2=139358&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Sep  9 01:44:17 2011
> @@ -4841,8 +4841,16 @@
>     return;
>   }
> 
> +  ASTContext &Ctx = *getContext();
>   for (unsigned I = 0, N = DeclIDs.size(); I != N; ++I) {
>     NamedDecl *D = cast<NamedDecl>(GetDecl(DeclIDs[I]));
> +
> +    // In C++, translation unit's visible decls map gets emitted in the AST
> +    // file, but not on C; make the decl visible so it can be looked up.
> +    if (!Ctx.getLangOptions().CPlusPlus)
> +      SetExternalVisibleDeclsForName(Ctx.getTranslationUnitDecl(),
> +                                     DeclarationName(II), D);
> +
>   

This is a bit unfortunate. Creating the lookup table in the translation unit 
forces the AST to continually maintain that lookup table (e.g., adding entries 
to it every time a visible declaration is added to the translation unit), which 
is a cost we'd like to avoid in C. I presume that you only made this change to 
support the new lookup used in  r139359? I have an alternative suggestion for 
that...

        - Doug
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to