Add ParsedAttrInfo::handleDeclAttribute
This makes it possible for plugin attributes to actually do something, and also
removes a lot of boilerplate for simple attributes in SemaDeclAttr.cpp.
Differential Revision: https://reviews.llvm.org/D31342
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 601f186..f640c9e 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3661,6 +3661,20 @@
OS << "}\n\n";
}
+static void GenerateHandleDeclAttribute(const Record &Attr, raw_ostream &OS) {
+ // Only generate if Attr can be handled simply.
+ if (!Attr.getValueAsBit("SimpleHandler"))
+ return;
+
+ // Generate a function which just converts from ParsedAttr to the Attr type.
+ OS << "virtual AttrHandling handleDeclAttribute(Sema &S, Decl *D,";
+ OS << "const ParsedAttr &Attr) const {\n";
+ OS << " D->addAttr(::new (S.Context) " << Attr.getName();
+ OS << "Attr(S.Context, Attr));\n";
+ OS << " return AttributeApplied;\n";
+ OS << "}\n\n";
+}
+
static bool IsKnownToGCC(const Record &Attr) {
// Look at the spellings for this subject; if there are any spellings which
// claim to be known to GCC, the attribute is known to GCC.
@@ -3742,6 +3756,7 @@
GenerateTargetRequirements(Attr, Dupes, OS);
GenerateSpellingIndexToSemanticSpelling(Attr, OS);
PragmaAttributeSupport.generateStrictConformsTo(*I->second, OS);
+ GenerateHandleDeclAttribute(Attr, OS);
OS << "static const ParsedAttrInfo" << I->first << " Instance;\n";
OS << "};\n";
OS << "const ParsedAttrInfo" << I->first << " ParsedAttrInfo" << I->first