[PATCH] PCH support for CXXRecordDecl

All,

Here’s the 2nd part of the previous PCH patch for (some) C++ declarations. This patch only really adds support for CXXRecordDecl, CXXBaseClassSpecifier, and (partial support) CXXBaseOrMemberInitializer. Just a couple of notes:

  1. This re-enables a previously disabled check in the namespace tests (which passes nicely)

  2. I renamed an existing method CXXRecordDecl::setUserDeclaredDestructor to setHasUserDeclaredDestructor to be consistent with other setHasTrivial… methods. The only place this was called is SemaDecl.cpp.

  3. I modified all of the member function documentation of most of the accessor/mutators I looked at to use \brief instead of “FunctionName - …”. Current comment formatting is inconsistent, so I chose this style. It seems less redundant.

  4. CXXBaseOrMemberSpecializer seems like it might need some attention. It looks like it acquired some functionality for C99 designated initializers, which I had to look up :slight_smile: That feature makes the class decidedly not CXX specific. Also, I think that there may be some redundancy in the storing of source locations between the BaseInitializer component and the MemberInitializer component. Basically, the class is starting to seem a little “unclean”. One solution might be to refactor the class as a union of 3 others: CXXBaseInitializer, CXXMemberInitializer, and DesignatedInitializer.

As it stands, I haven’t implemented PCH support for the DesignatedInitializer component of the class.

Also, this patch does /not/ (yet) add full support for methods, ctors, dtors, or conversion operators. I’ll try to send that upstream next after this is reviewed and eventually committed. Let me know if I need to add or remove anything prior to committing.

Thanks,

Andrew Sutton
andrew.n.sutton@gmail.com

pch-classes.patch (25.6 KB)

Here’s the 2nd part of the previous PCH patch for (some) C++ declarations. This patch only really adds support for CXXRecordDecl, CXXBaseClassSpecifier, and (partial support) CXXBaseOrMemberInitializer. Just a couple of notes:

  1. This re-enables a previously disabled check in the namespace tests (which passes nicely)

  2. I renamed an existing method CXXRecordDecl::setUserDeclaredDestructor to setHasUserDeclaredDestructor to be consistent with other setHasTrivial… methods. The only place this was called is SemaDecl.cpp.

  3. I modified all of the member function documentation of most of the accessor/mutators I looked at to use \brief instead of “FunctionName - …”. Current comment formatting is inconsistent, so I chose this style. It seems less redundant.

  4. CXXBaseOrMemberSpecializer seems like it might need some attention.

As it stands, I haven’t implemented PCH support for the DesignatedInitializer component of the class.

Attached is the part 3 of the PCH patch for CXXDecls. This subsumes the previous patch since there wasn’t any response on it. This now includes support for CXXMethodDecl, CXXConstructorDecl, CXXDestructorDecl, and CXXConversionDecl.

Conversions are added to their declaring class when loaded rather than being part of the class serialization being loaded, which should address Doug’s previous comment about being lazily loaded. The test case actually checks C++0x explicit conversions as well.

The patch also fixes a (seemingly) unreported PCH bug in the serialization of CXXConstructExpr. The number of arguments in the constructor call was being written but not read. This fixes a problem encountered with the original (large) patch.

Andrew Sutton
andrew.n.sutton@gmail.com

pch-classes2.patch (31.2 KB)