Author: Richard Smith Date: 2020-04-15T00:07:12-07:00 New Revision: b09ee8882010ff2a7d55e30c46c19533d0ab562d
URL: https://github.com/llvm/llvm-project/commit/b09ee8882010ff2a7d55e30c46c19533d0ab562d DIFF: https://github.com/llvm/llvm-project/commit/b09ee8882010ff2a7d55e30c46c19533d0ab562d.diff LOG: Generalize our two different kinds of declaration argument for attributes to support any kind of declaration. In preparation for adding a third kind. Added: Modified: clang/include/clang/Basic/Attr.td clang/utils/TableGen/ClangAttrEmitter.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index c586f9b9466a..e22e9063b305 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -174,12 +174,10 @@ class IdentifierArgument<string name, bit opt = 0> : Argument<name, opt>; class IntArgument<string name, bit opt = 0> : Argument<name, opt>; class StringArgument<string name, bit opt = 0> : Argument<name, opt>; class ExprArgument<string name, bit opt = 0> : Argument<name, opt>; -class FunctionArgument<string name, bit opt = 0, bit fake = 0> : Argument<name, - opt, - fake>; -class NamedArgument<string name, bit opt = 0, bit fake = 0> : Argument<name, - opt, - fake>; +class DeclArgument<DeclNode kind, string name, bit opt = 0, bit fake = 0> + : Argument<name, opt, fake> { + DeclNode Kind = kind; +} // An argument of a OMPDeclareVariantAttr that represents the `match` // clause of the declare variant by keeping the information (incl. nesting) in @@ -956,7 +954,7 @@ def OSConsumesThis : InheritableAttr { def Cleanup : InheritableAttr { let Spellings = [GCC<"cleanup">]; - let Args = [FunctionArgument<"FunctionDecl">]; + let Args = [DeclArgument<Function, "FunctionDecl">]; let Subjects = SubjectList<[LocalVar]>; let Documentation = [Undocumented]; } @@ -2382,7 +2380,7 @@ def DiagnoseIf : InheritableAttr { ["error", "warning"], ["DT_Error", "DT_Warning"]>, BoolArgument<"ArgDependent", 0, /*fake*/ 1>, - NamedArgument<"Parent", 0, /*fake*/ 1>]; + DeclArgument<Named, "Parent", 0, /*fake*/ 1>]; let InheritEvenIfAlreadyPresent = 1; let LateParsed = 1; let AdditionalMembers = [{ diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index 486799eb81ba..ca3bebd54c7c 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -339,7 +339,7 @@ namespace { } void writeDump(raw_ostream &OS) const override { - if (type == "FunctionDecl *" || type == "NamedDecl *") { + if (StringRef(type).endswith("Decl *")) { OS << " OS << \" \";\n"; OS << " dumpBareDeclRef(SA->get" << getUpperName() << "());\n"; } else if (type == "IdentifierInfo *") { @@ -1290,10 +1290,9 @@ createArgument(const Record &Arg, StringRef Attr, Ptr = std::make_unique<EnumArgument>(Arg, Attr); else if (ArgName == "ExprArgument") Ptr = std::make_unique<ExprArgument>(Arg, Attr); - else if (ArgName == "FunctionArgument") - Ptr = std::make_unique<SimpleArgument>(Arg, Attr, "FunctionDecl *"); - else if (ArgName == "NamedArgument") - Ptr = std::make_unique<SimpleArgument>(Arg, Attr, "NamedDecl *"); + else if (ArgName == "DeclArgument") + Ptr = std::make_unique<SimpleArgument>( + Arg, Attr, (Arg.getValueAsDef("Kind")->getName() + "Decl *").str()); else if (ArgName == "IdentifierArgument") Ptr = std::make_unique<SimpleArgument>(Arg, Attr, "IdentifierInfo *"); else if (ArgName == "DefaultBoolArgument") _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits