[cfe-commits] patch: make UsingDirective derive from Decl, not NamedDecl

Nick Lewycky nicholas at mxc.ca
Mon Oct 8 03:05:22 PDT 2012

Richard Smith wrote:
> On Fri, Oct 5, 2012 at 2:21 AM, Nick Lewycky <nicholas at mxc.ca
> <mailto:nicholas at mxc.ca>> wrote:
>     This patch changes UsingDirectives to be derived from Decl instead
>     of NamedDecl, and consequently removes the CXXUsingDirective
>     DeclarationName.
>     The way using directives are stored with this patch is to have a
>     single pointer on each UsingDirectiveDecl that points to the
>     previous declaration, and a pointer on TranslationUnit and Namespace
>     DeclContexts that point to the last one in that chain. We don't need
>     such pointers on other DeclContexts because they either can't hold
>     using-directives or the lookup will be handled by Scope.
>     Please review!
> This looks good to me. Have you tested the patch with chained PCH (or
> modules)?

No, and in doing so I found all sorts of problems. This updated patch 
teaches PCH to actually serialize these things. Namespaces need to 
serialize LastUsingDirective, and I'm doing something a little 
inefficient with the translation-unit wide ones, marking them all 
"external", which is technically inefficient in the PCH format but not 

I also found a case where we would put a UsingDirectiveDecl inside a 
LinkageSpecDecl instead of the NamespaceDecl or TranslationUnitDecl and 
changed the code for that too. This means we build a different AST, but 
I think there's no difference in behaviour. (Otherwise, we would need to 
add a LastUsingDirective field to LinkageSpecDecls as well, and I don't 
think we need that.)

Please review!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: usingdirective-noname-2.patch
Type: text/x-patch
Size: 42095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121008/cb24cce8/attachment.bin>

More information about the cfe-commits mailing list