forked from OSchip/llvm-project
Introduce the notion of an attribute that has no direct representation
as an AST node, and fold a number of such attributes into Attr.td. llvm-svn: 155995
This commit is contained in:
parent
ba2e8aeda5
commit
b2daf8416e
|
@ -95,6 +95,8 @@ class Attr {
|
|||
bit LateParsed = 0;
|
||||
// Set to true for attributes which must be instantiated within templates
|
||||
bit TemplateDependent = 0;
|
||||
// Set to true for attributes that have a corresponding AST node.
|
||||
bit ASTNode = 1;
|
||||
// Set to true for attributes which have handler in Sema.
|
||||
bit SemaHandler = 1;
|
||||
// Any additional text that should be included verbatim in the class.
|
||||
|
@ -112,6 +114,12 @@ class InheritableParamAttr : InheritableAttr;
|
|||
// Attributes begin here
|
||||
//
|
||||
|
||||
def AddressSpace : Attr {
|
||||
let Spellings = ["address_space"];
|
||||
let Args = [IntArgument<"AddressSpace">];
|
||||
let ASTNode = 0;
|
||||
}
|
||||
|
||||
def Alias : InheritableAttr {
|
||||
let Spellings = ["alias"];
|
||||
let Args = [StringArgument<"Aliasee">];
|
||||
|
@ -162,6 +170,11 @@ def Availability : InheritableAttr {
|
|||
} }];
|
||||
}
|
||||
|
||||
def BaseCheck : Attr {
|
||||
let Spellings = ["base_check"];
|
||||
let ASTNode = 0;
|
||||
}
|
||||
|
||||
def Blocks : InheritableAttr {
|
||||
let Spellings = ["blocks"];
|
||||
let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
|
||||
|
@ -194,6 +207,11 @@ def CFUnknownTransfer : InheritableAttr {
|
|||
let Subjects = [Function];
|
||||
}
|
||||
|
||||
def CFReturnsAutoreleased : Attr {
|
||||
let Spellings = ["cf_returns_autoreleased"];
|
||||
let ASTNode = 0;
|
||||
}
|
||||
|
||||
def CFReturnsRetained : InheritableAttr {
|
||||
let Spellings = ["cf_returns_retained"];
|
||||
let Subjects = [ObjCMethod, Function];
|
||||
|
@ -256,6 +274,12 @@ def OpenCLKernel : Attr {
|
|||
let Spellings = ["opencl_kernel_function"];
|
||||
}
|
||||
|
||||
def OpenCLImageAccess : Attr {
|
||||
let Spellings = ["opencl_image_access"];
|
||||
let Args = [IntArgument<"Access">];
|
||||
let ASTNode = 0;
|
||||
}
|
||||
|
||||
def Deprecated : InheritableAttr {
|
||||
let Spellings = ["deprecated"];
|
||||
let Args = [StringArgument<"Message">];
|
||||
|
@ -274,6 +298,12 @@ def DLLImport : InheritableAttr {
|
|||
let Spellings = ["dllimport"];
|
||||
}
|
||||
|
||||
def ExtVectorType : Attr {
|
||||
let Spellings = ["ext_vector_type"];
|
||||
let Args = [ExprArgument<"NumElements">];
|
||||
let ASTNode = 0;
|
||||
}
|
||||
|
||||
def FastCall : InheritableAttr {
|
||||
let Spellings = ["fastcall", "__fastcall"];
|
||||
}
|
||||
|
@ -345,10 +375,28 @@ def MBlazeSaveVolatiles : InheritableAttr {
|
|||
let SemaHandler = 0;
|
||||
}
|
||||
|
||||
def Mode : Attr {
|
||||
let Spellings = ["mode"];
|
||||
let Args = [IdentifierArgument<"Mode">];
|
||||
let ASTNode = 0;
|
||||
}
|
||||
|
||||
def Naked : InheritableAttr {
|
||||
let Spellings = ["naked"];
|
||||
}
|
||||
|
||||
def NeonPolyVectorType : Attr {
|
||||
let Spellings = ["neon_polyvector_type"];
|
||||
let Args = [IntArgument<"NumElements">];
|
||||
let ASTNode = 0;
|
||||
}
|
||||
|
||||
def NeonVectorType : Attr {
|
||||
let Spellings = ["neon_vector_type"];
|
||||
let Args = [IntArgument<"NumElements">];
|
||||
let ASTNode = 0;
|
||||
}
|
||||
|
||||
def ReturnsTwice : InheritableAttr {
|
||||
let Spellings = ["returns_twice"];
|
||||
}
|
||||
|
@ -542,6 +590,18 @@ def ArcWeakrefUnavailable : InheritableAttr {
|
|||
let Subjects = [ObjCInterface];
|
||||
}
|
||||
|
||||
def ObjCGC : Attr {
|
||||
let Spellings = ["objc_gc"];
|
||||
let Args = [IdentifierArgument<"Kind">];
|
||||
let ASTNode = 0;
|
||||
}
|
||||
|
||||
def ObjCOwnership : Attr {
|
||||
let Spellings = ["objc_ownership"];
|
||||
let Args = [IdentifierArgument<"Kind">];
|
||||
let ASTNode = 0;
|
||||
}
|
||||
|
||||
def ObjCRequiresPropertyDefs : InheritableAttr {
|
||||
let Spellings = ["objc_requires_property_definitions"];
|
||||
let Subjects = [ObjCInterface];
|
||||
|
@ -561,6 +621,12 @@ def Uuid : InheritableAttr {
|
|||
let Subjects = [CXXRecord];
|
||||
}
|
||||
|
||||
def VectorSize : Attr {
|
||||
let Spellings = ["vector_size"];
|
||||
let Args = [ExprArgument<"NumBytes">];
|
||||
let ASTNode = 0;
|
||||
}
|
||||
|
||||
def Visibility : InheritableAttr {
|
||||
let Spellings = ["visibility"];
|
||||
let Args = [EnumArgument<"Visibility", "VisibilityType",
|
||||
|
|
|
@ -162,17 +162,6 @@ public:
|
|||
enum Kind {
|
||||
#define PARSED_ATTR(NAME) AT_##NAME,
|
||||
#include "clang/Sema/AttrParsedAttrList.inc"
|
||||
PARSED_ATTR(address_space)
|
||||
PARSED_ATTR(base_check)
|
||||
PARSED_ATTR(cf_returns_autoreleased)
|
||||
PARSED_ATTR(ext_vector_type)
|
||||
PARSED_ATTR(mode)
|
||||
PARSED_ATTR(neon_polyvector_type)
|
||||
PARSED_ATTR(neon_vector_type)
|
||||
PARSED_ATTR(objc_gc)
|
||||
PARSED_ATTR(objc_ownership)
|
||||
PARSED_ATTR(opencl_image_access)
|
||||
PARSED_ATTR(vector_size)
|
||||
#undef PARSED_ATTR
|
||||
IgnoredAttribute,
|
||||
UnknownAttribute
|
||||
|
|
|
@ -107,18 +107,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
|
|||
|
||||
return llvm::StringSwitch<AttributeList::Kind>(AttrName)
|
||||
#include "clang/Sema/AttrParsedAttrKinds.inc"
|
||||
.Case("address_space", AT_address_space)
|
||||
.Case("base_check", AT_base_check)
|
||||
.Case("bounded", IgnoredAttribute) // OpenBSD
|
||||
.Case("cf_returns_autoreleased", AT_cf_returns_autoreleased)
|
||||
.Case("mode", AT_mode)
|
||||
.Case("vec_type_hint", IgnoredAttribute)
|
||||
.Case("ext_vector_type", AT_ext_vector_type)
|
||||
.Case("neon_vector_type", AT_neon_vector_type)
|
||||
.Case("neon_polyvector_type", AT_neon_polyvector_type)
|
||||
.Case("opencl_image_access", AT_opencl_image_access)
|
||||
.Case("objc_gc", AT_objc_gc)
|
||||
.Case("objc_ownership", AT_objc_ownership)
|
||||
.Case("vector_size", AT_vector_size)
|
||||
.Default(UnknownAttribute);
|
||||
}
|
||||
|
|
|
@ -670,6 +670,10 @@ void ClangAttrClassEmitter::run(raw_ostream &OS) {
|
|||
for (std::vector<Record*>::iterator i = Attrs.begin(), e = Attrs.end();
|
||||
i != e; ++i) {
|
||||
Record &R = **i;
|
||||
|
||||
if (!R.getValueAsBit("ASTNode"))
|
||||
continue;
|
||||
|
||||
const std::string &SuperName = R.getSuperClasses().back()->getName();
|
||||
|
||||
OS << "class " << R.getName() << "Attr : public " << SuperName << " {\n";
|
||||
|
@ -754,6 +758,10 @@ void ClangAttrImplEmitter::run(raw_ostream &OS) {
|
|||
|
||||
for (; i != e; ++i) {
|
||||
Record &R = **i;
|
||||
|
||||
if (!R.getValueAsBit("ASTNode"))
|
||||
continue;
|
||||
|
||||
std::vector<Record*> ArgRecords = R.getValueAsListOfDefs("Args");
|
||||
std::vector<StringRef> Spellings = getValueAsListOfStrings(R, "Spellings");
|
||||
std::vector<Argument*> Args;
|
||||
|
@ -798,8 +806,12 @@ static void EmitAttrList(raw_ostream &OS, StringRef Class,
|
|||
|
||||
if (i != e) {
|
||||
// Move the end iterator back to emit the last attribute.
|
||||
for(--e; i != e; ++i)
|
||||
for(--e; i != e; ++i) {
|
||||
if (!(*i)->getValueAsBit("ASTNode"))
|
||||
continue;
|
||||
|
||||
OS << Class << "(" << (*i)->getName() << ")\n";
|
||||
}
|
||||
|
||||
OS << "LAST_" << Class << "(" << (*i)->getName() << ")\n\n";
|
||||
}
|
||||
|
@ -835,6 +847,9 @@ void ClangAttrListEmitter::run(raw_ostream &OS) {
|
|||
NonInhAttrs, InhAttrs, InhParamAttrs;
|
||||
for (std::vector<Record*>::iterator i = Attrs.begin(), e = Attrs.end();
|
||||
i != e; ++i) {
|
||||
if (!(*i)->getValueAsBit("ASTNode"))
|
||||
continue;
|
||||
|
||||
if ((*i)->isSubClassOf(InhParamClass))
|
||||
InhParamAttrs.push_back(*i);
|
||||
else if ((*i)->isSubClassOf(InhClass))
|
||||
|
@ -870,6 +885,9 @@ void ClangAttrPCHReadEmitter::run(raw_ostream &OS) {
|
|||
OS << " break;\n";
|
||||
for (; i != e; ++i) {
|
||||
Record &R = **i;
|
||||
if (!R.getValueAsBit("ASTNode"))
|
||||
continue;
|
||||
|
||||
OS << " case attr::" << R.getName() << ": {\n";
|
||||
if (R.isSubClassOf(InhClass))
|
||||
OS << " bool isInherited = Record[Idx++];\n";
|
||||
|
@ -905,6 +923,8 @@ void ClangAttrPCHWriteEmitter::run(raw_ostream &OS) {
|
|||
OS << " break;\n";
|
||||
for (; i != e; ++i) {
|
||||
Record &R = **i;
|
||||
if (!R.getValueAsBit("ASTNode"))
|
||||
continue;
|
||||
OS << " case attr::" << R.getName() << ": {\n";
|
||||
Args = R.getValueAsListOfDefs("Args");
|
||||
if (R.isSubClassOf(InhClass) || !Args.empty())
|
||||
|
@ -979,6 +999,8 @@ void ClangAttrTemplateInstantiateEmitter::run(raw_ostream &OS) {
|
|||
for (std::vector<Record*>::iterator I = Attrs.begin(), E = Attrs.end();
|
||||
I != E; ++I) {
|
||||
Record &R = **I;
|
||||
if (!R.getValueAsBit("ASTNode"))
|
||||
continue;
|
||||
|
||||
OS << " case attr::" << R.getName() << ": {\n";
|
||||
OS << " const " << R.getName() << "Attr *A = cast<"
|
||||
|
|
Loading…
Reference in New Issue