summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/PCHWriter.cpp
diff options
context:
space:
mode:
authorAlexis Hunt <alercah@gmail.com>2010-08-18 23:23:40 +0000
committerAlexis Hunt <alercah@gmail.com>2010-08-18 23:23:40 +0000
commitdcfba7b35b15ec4457ff7b7521507d944069d8f1 (patch)
tree8ecf93dbdcc5af83013af5dcf755174562a903c0 /clang/lib/Serialization/PCHWriter.cpp
parent1d2b159882deb73df00c63f07d43deec54ce9274 (diff)
downloadbcm5719-llvm-dcfba7b35b15ec4457ff7b7521507d944069d8f1.tar.gz
bcm5719-llvm-dcfba7b35b15ec4457ff7b7521507d944069d8f1.zip
Generate Attr subclasses with TableGen.
Now all classes derived from Attr are generated from TableGen. Additionally, Attr* is no longer its own linked list; SmallVectors or Attr* are used. The accompanying LLVM commit contains the updates to TableGen necessary for this. Some other notes about newly-generated attribute classes: - The constructor arguments are a SourceLocation and a Context&, followed by the attributes arguments in the order that they were defined in Attr.td - Every argument in Attr.td has an appropriate accessor named getFoo, and there are sometimes a few extra ones (such as to get the length of a variadic argument). Additionally, specific_attr_iterator has been introduced, which will iterate over an AttrVec, but only over attributes of a certain type. It can be accessed through either Decl::specific_attr_begin/end or the global functions of the same name. llvm-svn: 111455
Diffstat (limited to 'clang/lib/Serialization/PCHWriter.cpp')
-rw-r--r--clang/lib/Serialization/PCHWriter.cpp170
1 files changed, 7 insertions, 163 deletions
diff --git a/clang/lib/Serialization/PCHWriter.cpp b/clang/lib/Serialization/PCHWriter.cpp
index 2cb2758e9a8..f78a8ba23bd 100644
--- a/clang/lib/Serialization/PCHWriter.cpp
+++ b/clang/lib/Serialization/PCHWriter.cpp
@@ -1949,172 +1949,16 @@ void PCHWriter::WriteIdentifierTable(Preprocessor &PP) {
//===----------------------------------------------------------------------===//
/// \brief Write a record containing the given attributes.
-void PCHWriter::WriteAttributeRecord(const Attr *Attr) {
+void PCHWriter::WriteAttributeRecord(const AttrVec &Attrs) {
RecordData Record;
- for (; Attr; Attr = Attr->getNext()) {
- Record.push_back(Attr->getKind()); // FIXME: stable encoding, target attrs
- Record.push_back(Attr->isInherited());
- switch (Attr->getKind()) {
- default:
- assert(0 && "Does not support PCH writing for this attribute yet!");
- break;
- case attr::Alias:
- AddString(cast<AliasAttr>(Attr)->getAliasee(), Record);
- break;
-
- case attr::AlignMac68k:
- break;
-
- case attr::Aligned:
- Record.push_back(cast<AlignedAttr>(Attr)->getAlignment());
- break;
-
- case attr::AlwaysInline:
- break;
-
- case attr::AnalyzerNoReturn:
- break;
-
- case attr::Annotate:
- AddString(cast<AnnotateAttr>(Attr)->getAnnotation(), Record);
- break;
-
- case attr::AsmLabel:
- AddString(cast<AsmLabelAttr>(Attr)->getLabel(), Record);
- break;
-
- case attr::BaseCheck:
- break;
-
- case attr::Blocks:
- Record.push_back(cast<BlocksAttr>(Attr)->getType()); // FIXME: stable
- break;
-
- case attr::CDecl:
- break;
-
- case attr::Cleanup:
- AddDeclRef(cast<CleanupAttr>(Attr)->getFunctionDecl(), Record);
- break;
-
- case attr::Const:
- break;
-
- case attr::Constructor:
- Record.push_back(cast<ConstructorAttr>(Attr)->getPriority());
- break;
-
- case attr::DLLExport:
- case attr::DLLImport:
- case attr::Deprecated:
- break;
-
- case attr::Destructor:
- Record.push_back(cast<DestructorAttr>(Attr)->getPriority());
- break;
-
- case attr::FastCall:
- case attr::Final:
- break;
-
- case attr::Format: {
- const FormatAttr *Format = cast<FormatAttr>(Attr);
- AddString(Format->getType(), Record);
- Record.push_back(Format->getFormatIdx());
- Record.push_back(Format->getFirstArg());
- break;
- }
-
- case attr::FormatArg: {
- const FormatArgAttr *Format = cast<FormatArgAttr>(Attr);
- Record.push_back(Format->getFormatIdx());
- break;
- }
-
- case attr::Sentinel : {
- const SentinelAttr *Sentinel = cast<SentinelAttr>(Attr);
- Record.push_back(Sentinel->getSentinel());
- Record.push_back(Sentinel->getNullPos());
- break;
- }
-
- case attr::GNUInline:
- case attr::Hiding:
- case attr::IBAction:
- case attr::IBOutlet:
- case attr::Malloc:
- case attr::NoDebug:
- case attr::NoInline:
- case attr::NoReturn:
- case attr::NoThrow:
- break;
-
- case attr::IBOutletCollection: {
- const IBOutletCollectionAttr *ICA = cast<IBOutletCollectionAttr>(Attr);
- AddTypeRef(ICA->getType(), Record);
- break;
- }
-
- case attr::NonNull: {
- const NonNullAttr *NonNull = cast<NonNullAttr>(Attr);
- Record.push_back(NonNull->size());
- Record.insert(Record.end(), NonNull->begin(), NonNull->end());
- break;
- }
-
- case attr::CFReturnsNotRetained:
- case attr::CFReturnsRetained:
- case attr::NSReturnsNotRetained:
- case attr::NSReturnsRetained:
- case attr::ObjCException:
- case attr::ObjCNSObject:
- case attr::Overloadable:
- case attr::Override:
- break;
+ for (AttrVec::const_iterator i = Attrs.begin(), e = Attrs.end(); i != e; ++i){
+ const Attr * A = *i;
+ Record.push_back(A->getKind()); // FIXME: stable encoding, target attrs
+ AddSourceLocation(A->getLocation(), Record);
+ Record.push_back(A->isInherited());
- case attr::MaxFieldAlignment:
- Record.push_back(cast<MaxFieldAlignmentAttr>(Attr)->getAlignment());
- break;
-
- case attr::Packed:
- break;
-
- case attr::Pure:
- break;
-
- case attr::Regparm:
- Record.push_back(cast<RegparmAttr>(Attr)->getNumParams());
- break;
-
- case attr::ReqdWorkGroupSize:
- Record.push_back(cast<ReqdWorkGroupSizeAttr>(Attr)->getXDim());
- Record.push_back(cast<ReqdWorkGroupSizeAttr>(Attr)->getYDim());
- Record.push_back(cast<ReqdWorkGroupSizeAttr>(Attr)->getZDim());
- break;
+#include "clang/Serialization/AttrPCHWrite.inc"
- case attr::Section:
- AddString(cast<SectionAttr>(Attr)->getName(), Record);
- break;
-
- case attr::StdCall:
- case attr::TransparentUnion:
- case attr::Unavailable:
- case attr::Unused:
- case attr::Used:
- break;
-
- case attr::Visibility:
- // FIXME: stable encoding
- Record.push_back(cast<VisibilityAttr>(Attr)->getVisibility());
- Record.push_back(cast<VisibilityAttr>(Attr)->isFromPragma());
- break;
-
- case attr::WarnUnusedResult:
- case attr::Weak:
- case attr::WeakRef:
- case attr::WeakImport:
- break;
- }
}
Stream.EmitRecord(pch::DECL_ATTR, Record);
OpenPOWER on IntegriCloud