[cfe-dev] [PATCH] PCH Support for C++ decls

Andrew Sutton andrew.n.sutton at gmail.com
Tue Mar 2 08:26:20 PST 2010


All,

Since I noticed Doug commit PCH support for NamespaceDecl's the other day
(week?), I thought I'd send an update to my last PCH patch. I've been
sitting on this work for quite some time while I've been busy with other
things.

The attached implements serialization for
- namespaces, using directives, namespace aliases, using (and shadow)
declarations
- classes
- methods, constructors, destructors, conversion functions
- and linkage specifications
There's some support for serializing friend declarations, but only if it's
not a friend type. Fixing that should be relatively easy. There is also some
work on serializing templates and dependent types, but it's asserted out for
now. I integrated Doug's implementation of VisitNamespaceDecl (I wasn't
serializing the AnonymousNamespace) into this patch.

The patch adds a large number of getters and setters to AST declarations
since the PCH code has to construct them piecemeal. I've had to expose some
new functionality for creating CXXRecord::DefinitionData objects (see
createDefinition() and shareDefinition() in the attached patch). I think
it's kind of nice. I also renamed one or two existing methods to make them
have similar names as other functions--I forget which methods, though. These
changes have been propagated to Sema.

I had to add new Create() functions for CXXMethod and its derivations since
the normal Create() function asserts when you try to create these objects
without names. As per a previous suggestion, these take an "EmptyShell"
type, which is added as a public empty class in Decl (should it be private?)

WRT to the PCH reader/writer classes, I added some new functions for reading
and writing base class specifiers and nested name specifiers. I also added a
ReadSourceLocation and ReadSourceRange methods to the PCHReader to make
their reading consistent with other operations (and easier in some cases).

I modified PCH/namespaces test to include some of the other namespace and
using decls and linkage specs. There should be a new classes test in the
patch with (let's just say... "not exhaustive") tests for serializing
classes.

Please let me know if there is anything that I can do to help get this patch
applied.

Andrew Sutton
andrew.n.sutton at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100302/abee3566/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pch.patch
Type: application/octet-stream
Size: 66100 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100302/abee3566/attachment.obj>


More information about the cfe-dev mailing list