diff options
-rw-r--r-- | include/clang/AST/Attr.h | 178 | ||||
-rw-r--r-- | include/clang/AST/Makefile | 14 | ||||
-rw-r--r-- | include/clang/Basic/Attr.td | 357 | ||||
-rw-r--r-- | include/clang/Basic/AttrKinds.h | 31 | ||||
-rw-r--r-- | include/clang/Basic/DeclNodes.td | 4 | ||||
-rw-r--r-- | include/clang/Basic/Makefile | 7 | ||||
-rw-r--r-- | include/clang/Basic/StmtNodes.td | 4 | ||||
-rw-r--r-- | lib/AST/AttrImpl.cpp | 4 | ||||
-rw-r--r-- | lib/Frontend/PCHReaderDecl.cpp | 30 | ||||
-rw-r--r-- | lib/Frontend/PCHWriter.cpp | 114 | ||||
-rw-r--r-- | tools/libclang/CXCursor.cpp | 6 |
11 files changed, 543 insertions, 206 deletions
diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index 3240e50b07..531c74c700 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -16,6 +16,7 @@ #include "llvm/Support/Casting.h" #include "llvm/ADT/StringRef.h" +#include "clang/Basic/AttrKinds.h" #include <cassert> #include <cstring> #include <algorithm> @@ -41,75 +42,9 @@ namespace clang { /// Attr - This represents one attribute. class Attr { -public: - enum Kind { - Alias, - Aligned, - AlignMac68k, - AlwaysInline, - AnalyzerNoReturn, // Clang-specific. - Annotate, - AsmLabel, // Represent GCC asm label extension. - BaseCheck, - Blocks, - CDecl, - Cleanup, - Const, - Constructor, - Deprecated, - Destructor, - FastCall, - Final, - Format, - FormatArg, - GNUInline, - Hiding, - IBOutletKind, // Clang-specific. Use "Kind" suffix to not conflict w/ macro. - IBOutletCollectionKind, // Clang-specific. - IBActionKind, // Clang-specific. Use "Kind" suffix to not conflict w/ macro. - Malloc, - MaxFieldAlignment, - NoDebug, - NoInline, - NonNull, - NoReturn, - NoThrow, - ObjCException, - ObjCNSObject, - Override, - CFReturnsRetained, // Clang/Checker-specific. - CFReturnsNotRetained, // Clang/Checker-specific. - NSReturnsRetained, // Clang/Checker-specific. - NSReturnsNotRetained, // Clang/Checker-specific. - Overloadable, // Clang-specific - Packed, - Pure, - Regparm, - ReqdWorkGroupSize, // OpenCL-specific - Section, - Sentinel, - StdCall, - ThisCall, - TransparentUnion, - Unavailable, - Unused, - Used, - Visibility, - WarnUnusedResult, - Weak, - WeakImport, - WeakRef, - - FIRST_TARGET_ATTRIBUTE, - DLLExport, - DLLImport, - MSP430Interrupt, - X86ForceAlignArgPointer - }; - private: Attr *Next; - Kind AttrKind; + attr::Kind AttrKind; bool Inherited : 1; protected: @@ -122,7 +57,7 @@ protected: } protected: - Attr(Kind AK) : Next(0), AttrKind(AK), Inherited(false) {} + Attr(attr::Kind AK) : Next(0), AttrKind(AK), Inherited(false) {} virtual ~Attr() { assert(Next == 0 && "Destroy didn't work"); } @@ -133,7 +68,7 @@ public: /// declarations. virtual bool isMerged() const { return true; } - Kind getKind() const { return AttrKind; } + attr::Kind getKind() const { return AttrKind; } Attr *getNext() { return Next; } const Attr *getNext() const { return Next; } @@ -163,13 +98,15 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *) { return true; } }; + +#include "clang/AST/Attrs.inc" class AttrWithString : public Attr { private: const char *Str; unsigned StrLen; protected: - AttrWithString(Attr::Kind AK, ASTContext &C, llvm::StringRef s); + AttrWithString(attr::Kind AK, ASTContext &C, llvm::StringRef s); llvm::StringRef getString() const { return llvm::StringRef(Str, StrLen); } void ReplaceString(ASTContext &C, llvm::StringRef newS); public: @@ -179,9 +116,9 @@ public: #define DEF_SIMPLE_ATTR(ATTR) \ class ATTR##Attr : public Attr { \ public: \ - ATTR##Attr() : Attr(ATTR) {} \ + ATTR##Attr() : Attr(attr::ATTR) {} \ virtual Attr *clone(ASTContext &C) const; \ - static bool classof(const Attr *A) { return A->getKind() == ATTR; } \ + static bool classof(const Attr *A) { return A->getKind() == attr::ATTR; } \ static bool classof(const ATTR##Attr *A) { return true; } \ } @@ -194,7 +131,7 @@ class MaxFieldAlignmentAttr : public Attr { public: MaxFieldAlignmentAttr(unsigned alignment) - : Attr(MaxFieldAlignment), Alignment(alignment) {} + : Attr(attr::MaxFieldAlignment), Alignment(alignment) {} /// getAlignment - The specified alignment in bits. unsigned getAlignment() const { return Alignment; } @@ -203,7 +140,7 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == MaxFieldAlignment; + return A->getKind() == attr::MaxFieldAlignment; } static bool classof(const MaxFieldAlignmentAttr *A) { return true; } }; @@ -214,7 +151,7 @@ class AlignedAttr : public Attr { unsigned Alignment; public: AlignedAttr(unsigned alignment) - : Attr(Aligned), Alignment(alignment) {} + : Attr(attr::Aligned), Alignment(alignment) {} /// getAlignment - The specified alignment in bits. unsigned getAlignment() const { return Alignment; } @@ -232,7 +169,7 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == Aligned; + return A->getKind() == attr::Aligned; } static bool classof(const AlignedAttr *A) { return true; } }; @@ -240,7 +177,7 @@ public: class AnnotateAttr : public AttrWithString { public: AnnotateAttr(ASTContext &C, llvm::StringRef ann) - : AttrWithString(Annotate, C, ann) {} + : AttrWithString(attr::Annotate, C, ann) {} llvm::StringRef getAnnotation() const { return getString(); } @@ -248,7 +185,7 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == Annotate; + return A->getKind() == attr::Annotate; } static bool classof(const AnnotateAttr *A) { return true; } }; @@ -256,7 +193,7 @@ public: class AsmLabelAttr : public AttrWithString { public: AsmLabelAttr(ASTContext &C, llvm::StringRef L) - : AttrWithString(AsmLabel, C, L) {} + : AttrWithString(attr::AsmLabel, C, L) {} llvm::StringRef getLabel() const { return getString(); } @@ -264,7 +201,7 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == AsmLabel; + return A->getKind() == attr::AsmLabel; } static bool classof(const AsmLabelAttr *A) { return true; } }; @@ -274,54 +211,56 @@ DEF_SIMPLE_ATTR(AlwaysInline); class AliasAttr : public AttrWithString { public: AliasAttr(ASTContext &C, llvm::StringRef aliasee) - : AttrWithString(Alias, C, aliasee) {} + : AttrWithString(attr::Alias, C, aliasee) {} llvm::StringRef getAliasee() const { return getString(); } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Alias; } + static bool classof(const Attr *A) { return A->getKind() == attr::Alias; } static bool classof(const AliasAttr *A) { return true; } }; class ConstructorAttr : public Attr { int priority; public: - ConstructorAttr(int p) : Attr(Constructor), priority(p) {} + ConstructorAttr(int p) : Attr(attr::Constructor), priority(p) {} int getPriority() const { return priority; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Constructor; } + static bool classof(const Attr *A) + { return A->getKind() == attr::Constructor; } static bool classof(const ConstructorAttr *A) { return true; } }; class DestructorAttr : public Attr { int priority; public: - DestructorAttr(int p) : Attr(Destructor), priority(p) {} + DestructorAttr(int p) : Attr(attr::Destructor), priority(p) {} int getPriority() const { return priority; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Destructor; } + static bool classof(const Attr *A) + { return A->getKind() == attr::Destructor; } static bool classof(const DestructorAttr *A) { return true; } }; class IBOutletAttr : public Attr { public: - IBOutletAttr() : Attr(IBOutletKind) {} + IBOutletAttr() : Attr(attr::IBOutlet) {} virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == IBOutletKind; + return A->getKind() == attr::IBOutlet; } static bool classof(const IBOutletAttr *A) { return true; } }; @@ -330,7 +269,7 @@ class IBOutletCollectionAttr : public Attr { const ObjCInterfaceDecl *D; public: IBOutletCollectionAttr(const ObjCInterfaceDecl *d = 0) - : Attr(IBOutletCollectionKind), D(d) {} + : Attr(attr::IBOutletCollection), D(d) {} const ObjCInterfaceDecl *getClass() const { return D; } @@ -338,27 +277,26 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == IBOutletCollectionKind; + return A->getKind() == attr::IBOutletCollection; } static bool classof(const IBOutletCollectionAttr *A) { return true; } }; class IBActionAttr : public Attr { public: - IBActionAttr() : Attr(IBActionKind) {} + IBActionAttr() : Attr(attr::IBAction) {} virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == IBActionKind; + return A->getKind() == attr::IBAction; } static bool classof(const IBActionAttr *A) { return true; } }; DEF_SIMPLE_ATTR(AnalyzerNoReturn); DEF_SIMPLE_ATTR(Deprecated); -DEF_SIMPLE_ATTR(Final); DEF_SIMPLE_ATTR(GNUInline); DEF_SIMPLE_ATTR(Malloc); DEF_SIMPLE_ATTR(NoReturn); @@ -366,7 +304,7 @@ DEF_SIMPLE_ATTR(NoReturn); class SectionAttr : public AttrWithString { public: SectionAttr(ASTContext &C, llvm::StringRef N) - : AttrWithString(Section, C, N) {} + : AttrWithString(attr::Section, C, N) {} llvm::StringRef getName() const { return getString(); } @@ -374,7 +312,7 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == Section; + return A->getKind() == attr::Section; } static bool classof(const SectionAttr *A) { return true; } }; @@ -408,7 +346,7 @@ public: virtual Attr *clone(ASTContext &C) const; - static bool classof(const Attr *A) { return A->getKind() == NonNull; } + static bool classof(const Attr *A) { return A->getKind() == attr::NonNull; } static bool classof(const NonNullAttr *A) { return true; } }; @@ -416,7 +354,7 @@ class FormatAttr : public AttrWithString { int formatIdx, firstArg; public: FormatAttr(ASTContext &C, llvm::StringRef type, int idx, int first) - : AttrWithString(Format, C, type), formatIdx(idx), firstArg(first) {} + : AttrWithString(attr::Format, C, type), formatIdx(idx), firstArg(first) {} llvm::StringRef getType() const { return getString(); } void setType(ASTContext &C, llvm::StringRef type); @@ -426,27 +364,27 @@ public: virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Format; } + static bool classof(const Attr *A) { return A->getKind() == attr::Format; } static bool classof(const FormatAttr *A) { return true; } }; class FormatArgAttr : public Attr { int formatIdx; public: - FormatArgAttr(int idx) : Attr(FormatArg), formatIdx(idx) {} + FormatArgAttr(int idx) : Attr(attr::FormatArg), formatIdx(idx) {} int getFormatIdx() const { return formatIdx; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == FormatArg; } + static bool classof(const Attr *A) { return A->getKind() == attr::FormatArg; } static bool classof(const FormatArgAttr *A) { return true; } }; class SentinelAttr : public Attr { int sentinel, NullPos; public: - SentinelAttr(int sentinel_val, int nullPos) : Attr(Sentinel), + SentinelAttr(int sentinel_val, int nullPos) : Attr(attr::Sentinel), sentinel(sentinel_val), NullPos(nullPos) {} int getSentinel() const { return sentinel; } int getNullPos() const { return NullPos; } @@ -454,7 +392,7 @@ public: virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Sentinel; } + static bool classof(const Attr *A) { return A->getKind() == attr::Sentinel; } static bool classof(const SentinelAttr *A) { return true; } }; @@ -469,7 +407,7 @@ public: private: VisibilityTypes VisibilityType; public: - VisibilityAttr(VisibilityTypes v) : Attr(Visibility), + VisibilityAttr(VisibilityTypes v) : Attr(attr::Visibility), VisibilityType(v) {} VisibilityTypes getVisibility() const { return VisibilityType; } @@ -477,7 +415,8 @@ public: virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Visibility; } + static bool classof(const Attr *A) + { return A->getKind() == attr::Visibility; } static bool classof(const VisibilityAttr *A) { return true; } }; @@ -491,13 +430,14 @@ DEF_SIMPLE_ATTR(ObjCException); class OverloadableAttr : public Attr { public: - OverloadableAttr() : Attr(Overloadable) { } + OverloadableAttr() : Attr(attr::Overloadable) { } virtual bool isMerged() const { return false; } virtual Attr *clone(ASTContext &C) const; - static bool classof(const Attr *A) { return A->getKind() == Overloadable; } + static bool classof(const Attr *A) + { return A->getKind() == attr::Overloadable; } static bool classof(const OverloadableAttr *) { return true; } }; @@ -509,14 +449,14 @@ public: private: BlocksAttrTypes BlocksAttrType; public: - BlocksAttr(BlocksAttrTypes t) : Attr(Blocks), BlocksAttrType(t) {} + BlocksAttr(BlocksAttrTypes t) : Attr(attr::Blocks), BlocksAttrType(t) {} BlocksAttrTypes getType() const { return BlocksAttrType; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Blocks; } + static bool classof(const Attr *A) { return A->getKind() == attr::Blocks; } static bool classof(const BlocksAttr *A) { return true; } }; @@ -526,14 +466,14 @@ class CleanupAttr : public Attr { FunctionDecl *FD; public: - CleanupAttr(FunctionDecl *fd) : Attr(Cleanup), FD(fd) {} + CleanupAttr(FunctionDecl *fd) : Attr(attr::Cleanup), FD(fd) {} const FunctionDecl *getFunctionDecl() const { return FD; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Cleanup; } + static bool classof(const Attr *A) { return A->getKind() == attr::Cleanup; } static bool classof(const CleanupAttr *A) { return true; } }; @@ -545,14 +485,14 @@ class RegparmAttr : public Attr { unsigned NumParams; public: - RegparmAttr(unsigned np) : Attr(Regparm), NumParams(np) {} + RegparmAttr(unsigned np) : Attr(attr::Regparm), NumParams(np) {} unsigned getNumParams() const { return NumParams; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Regparm; } + static bool classof(const Attr *A) { return A->getKind() == attr::Regparm; } static bool classof(const RegparmAttr *A) { return true; } }; @@ -560,7 +500,7 @@ class ReqdWorkGroupSizeAttr : public Attr { unsigned X, Y, Z; public: ReqdWorkGroupSizeAttr(unsigned X, unsigned Y, unsigned Z) - : Attr(ReqdWorkGroupSize), X(X), Y(Y), Z(Z) {} + : Attr(attr::ReqdWorkGroupSize), X(X), Y(Y), Z(Z) {} unsigned getXDim() const { return X; } unsigned getYDim() const { return Y; } @@ -570,7 +510,7 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { - return A->getKind() == ReqdWorkGroupSize; + return A->getKind() == attr::ReqdWorkGroupSize; } static bool classof(const ReqdWorkGroupSizeAttr *A) { return true; } }; @@ -581,11 +521,6 @@ DEF_SIMPLE_ATTR(CFReturnsRetained); DEF_SIMPLE_ATTR(NSReturnsNotRetained); DEF_SIMPLE_ATTR(NSReturnsRetained); -// C++0x member checking attributes. -DEF_SIMPLE_ATTR(BaseCheck); -DEF_SIMPLE_ATTR(Hiding); -DEF_SIMPLE_ATTR(Override); - // Target-specific attributes DEF_SIMPLE_ATTR(DLLImport); DEF_SIMPLE_ATTR(DLLExport); @@ -594,14 +529,15 @@ class MSP430InterruptAttr : public Attr { unsigned Number; public: - MSP430InterruptAttr(unsigned n) : Attr(MSP430Interrupt), Number(n) {} + MSP430InterruptAttr(unsigned n) : Attr(attr::MSP430Interrupt), Number(n) {} unsigned getNumber() const { return Number; } virtual Attr *clone(ASTContext &C) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == MSP430Interrupt; } + static bool classof(const Attr *A) + { return A->getKind() == attr::MSP430Interrupt; } static bool classof(const MSP430InterruptAttr *A) { return true; } }; diff --git a/include/clang/AST/Makefile b/include/clang/AST/Makefile index 6e3dd89bf8..00a1e1bf79 100644 --- a/include/clang/AST/Makefile +++ b/include/clang/AST/Makefile @@ -1,17 +1,23 @@ CLANG_LEVEL := ../../.. -BUILT_SOURCES = StmtNodes.inc DeclNodes.inc TD_SRC_DIR = $(PROJ_SRC_DIR)/../Basic +BUILT_SOURCES = Attrs.inc StmtNodes.inc DeclNodes.inc TABLEGEN_INC_FILES_COMMON = 1 include $(CLANG_LEVEL)/Makefile -INPUT_TDS = $(TD_SRC_DIR)/StmtNodes.td $(TD_SRC_DIR)/DeclNodes.td +$(ObjDir)/Attrs.inc.tmp : $(TD_SRC_DIR)/Attr.td $(TBLGEN) \ + $(ObjDir)/.dir + $(Echo) "Building Clang attribute classes with tblgen" + $(Verb) $(TableGen) -gen-clang-attr-classes -o $(call SYSPATH, $@) \ + -I $(PROJ_SRC_DIR)/../../ $< -$(ObjDir)/StmtNodes.inc.tmp : $(TD_SRC_DIR)/StmtNodes.td $(TBLGEN) $(ObjDir)/.dir +$(ObjDir)/StmtNodes.inc.tmp : $(TD_SRC_DIR)/StmtNodes.td $(TBLGEN) \ + $(ObjDir)/.dir $(Echo) "Building Clang statement node tables with tblgen" $(Verb) $(TableGen) -gen-clang-stmt-nodes -o $(call SYSPATH, $@) $< -$(ObjDir)/DeclNodes.inc.tmp : $(TD_SRC_DIR)/DeclNodes.td $(TBLGEN) $(ObjDir)/.dir +$(ObjDir)/DeclNodes.inc.tmp : $(TD_SRC_DIR)/DeclNodes.td $(TBLGEN) \ + $(ObjDir)/.dir $(Echo) "Building Clang declaration node tables with tblgen" $(Verb) $(TableGen) -gen-clang-decl-nodes -o $(call SYSPATH, $@) $< diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td new file mode 100644 index 0000000000..417faf3a27 --- /dev/null +++ b/include/clang/Basic/Attr.td @@ -0,0 +1,357 @@ +//////////////////////////////////////////////////////////////////////////////// +// Note: This file is a work in progress. Please update it only if you believe +// there is an obvious error; otherwise please check with Sean Hunt. He can +// be reached at rideau3@gmail.com. +//////////////////////////////////////////////////////////////////////////////// + +class AttrSubject; + +include "clang/Basic/DeclNodes.td" +include "clang/Basic/StmtNodes.td" + +// A subset-subject is an AttrSubject constrained to operate only on some subset +// of that subject. +// +// The description is used in output messages to specify what the subject +// represents. FIXME: Deal with translation issues. +// +// The code fragment is a boolean expression that will confirm that the subject +// meets the requirements; the subject will have the name S, and will have the +// type specified by the base. It should be a simple boolean expression. + +class SubsetSubject<AttrSubject base, string description, code check> + : AttrSubject { + AttrSubject Base = base; + string Description = description; + code CheckCode = check; +} + +def NormalVar : SubsetSubject<Var, "non-register, non-parameter variable", + [{S->getStorageClass() != VarDecl::Register && + S->getKind() != Decl::ImplicitParam + S->getKind() != Decl::ParmVar + S->getKind() != Decl::NonTypeTemplateParm}]>; +def CXXVirtualMethod : SubsetSubject<CXXRecord, "virtual member function", + [{S->isVirtual()}]>; +def NonBitField : SubsetSubject<Field, "non-bit field", + [{!S->isBitField()}]>; + +class Argument<string name> { + string Name = name; +} + +class IdentifierArgument<string name> : Argument<name>; +class IntArgument<string name> : Argument<name>; +class StringArgument<string name> : Argument<name>; +class ExprArgument<string name> : Argument<name>; +class FunctionArgument<string name> : Argument<name>; +class ObjCInterfaceArgument<string name> : Argument<name>; +class UnsignedIntArgument<string name> : Argument<name>; +class UnsignedIntOrTypeArgument<string name> : Argument<name>; + +class DefaultIntArgument<string name, int default> : IntArgument<name> { + int Default = default; +} + +class VariadicArgument<Argument arg> : Argument<arg.Name> { + Argument VariadicArg = arg; +} + +class Attr { + list<string> Spellings; + list<AttrSubject> Subjects; + list<Argument> Args = []; + list<string> Namespaces = []; + list<string> Aliases = []; + bit DoNotEmit = 1; +} + +// +// Attributes begin here +// + +def Alias : Attr { + let Spellings = ["alias"]; + let Args = [StringArgument<"AliasName">]; +} + +def Aligned : Attr { + let Spellings = ["align", "aligned"]; + let Subjects = [NonBitField, NormalVar, Tag]; + let Args = [UnsignedIntOrTypeArgument<"Alignment">]; + let Namespaces = ["", "std"]; +} + +def AlignMac68k : Attr { + let Spellings = []; +} + +def AlwaysInline : Attr { + let Spellings = ["always_inline"]; +} + +def AnalyzerNoReturn : Attr { + let Spellings = ["analyzer_noreturn"]; +} + +def Annotate : Attr { + let Spellings = ["annotate"]; + let Args = [StringArgument<"Annotation">]; +} + +def AsmLabel : Attr { + let Spellings = []; + let Args = [StringArgument<"Label">]; +} + +def BaseCheck : Attr { + let Spellings = ["base_check"]; + let Subjects = [CXXRecord]; + let Namespaces = ["", "std"]; + let DoNotEmit = 0; +} + +def Blocks : Attr { + let Spellings = ["blocks"]; + let Args = [IdentifierArgument<"Type">]; +} + +def CarriesDependency : Attr { + let Spellings = ["carries_dependency"]; + let Subjects = [ParmVar, Function]; + let Namespaces = ["", "std"]; + let DoNotEmit = 0; +} + +def CDecl : Attr { + let Spellings = ["cdecl", "__cdecl"]; +} + +def CFReturnsRetained : Attr { + let Spellings = ["cf_returns_retained"]; +} + +def CFReturnsNotRetained : Attr { + let Spellings = ["cf_returns_not_retained"]; +} + +def Cleanup : Attr { + let Spellings = ["cleanup"]; + let Args = [FunctionArgument<"FunctionDecl">]; +} + +def Const : Attr { + let Spellings = ["const"]; +} + +def Constructor : Attr { + let Spellings = ["constructor"]; + let Args = [IntArgument<"Priority">]; +} + +def Deprecated : Attr { + let Spellings = ["deprecated"]; +} + +def Destructor : Attr { + let Spellings = ["destructor"]; + let Args = [IntArgument<"Priority">]; +} + +def DLLExport : Attr { + let Spellings = ["dllexport"]; +} + +def DLLImport : Attr { + let Spellings = ["dllimport"]; +} + +def FastCall : Attr { + let Spellings = ["fastcall", "__fastcall"]; +} + +def Final : Attr { + let Spellings = ["final"]; + let Subjects = [CXXRecord, CXXVirtualMethod]; + let Namespaces = ["", "std"]; + let DoNotEmit = 0; +} + +def Format : Attr { + let Spellings = ["format"]; + let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">, + IntArgument<"FirstArg">]; +} + +def FormatArg : Attr { + let Spellings = ["format_arg"]; + let Args = [IntArgument<"FormatIdx">]; +} + +def GNUInline : Attr { + let Spellings = ["gnu_inline"]; +} + +def Hiding : Attr { + let Spellings = ["hiding"]; + let Subjects = [Field, CXXMethod]; + let Namespaces = ["", "std"]; + let DoNotEmit = 0; +} + +def IBAction : Attr { + let Spellings = ["ibaction"]; +} + +def IBOutlet : Attr { + let Spellings = ["iboutlet"]; +} + +def IBOutletCollection : Attr { + let Spellings = ["iboutletcollection"]; + let Args = [ObjCInterfaceArgument<"Class">]; +} + +def Malloc : Attr { + let Spellings = ["malloc"]; +} + +def MaxFieldAlignment : Attr { + let Spellings = []; + let Args = [UnsignedIntArgument<"Alignment">]; +} + +def MSP430Interrupt : Attr { + let Spellings = []; + let Args = [UnsignedIntArgument<"Number">]; +} + +def NoDebug : Attr { + let Spellings = ["nodebug"]; +} + +def NoInline : Attr { + let Spellings = ["noinline"]; +} + +def NonNull : Attr { + let Spellings = ["nonnull"]; + let Args = [VariadicArgument<UnsignedIntArgument<"Args">>]; +} + +def NoReturn : Attr { + let Spellings = ["noreturn"]; + // FIXME: Does GCC allow this on the function instead? + let Subjects = [Function]; + let Namespaces = ["", "std"]; +} + +def NoThrow : Attr { + let Spellings = ["nothrow"]; +} + +def NSReturnsRetained : Attr { + let Spellings = ["ns_returns_retained"]; +} + +def NSReturnsNotRetained : Attr { + let Spellings = ["ns_returns_not_retained"]; +} + +def ObjCException : Attr { + let Spellings = ["objc_exception"]; +} + +def ObjCNSObject : Attr { + let Spellings = ["NSOjbect"]; +} + +def Override : Attr { + let Spellings = ["override"]; + let Subjects = [CXXVirtualMethod]; + let Namespaces = ["", "std"]; + let DoNotEmit = 0; +} + +def Overloadable : Attr { + let Spellings = ["overloadable"]; +} + +def Packed : Attr { + let Spellings = ["packed"]; +} + +def Pure : Attr { + let Spellings = ["pure"]; +} + +def Regparm : Attr { + let Spellings = ["regparm"]; + let Args = [UnsignedIntArgument<"NumParams">]; +} + +def ReqdWorkGroupSize : Attr { + let Spellings = ["reqd_work_group_size"]; + let Args = [UnsignedIntArgument<"XDim">, UnsignedIntArgument<"YDim">, + UnsignedIntArgument<"ZDim">]; +} + +def Section : Attr { + let Spellings = ["section"]; + let Args = [StringArgument<"Name">]; +} + +def Sentinel : Attr { + let Spellings = ["sentinel"]; + let Args = [DefaultIntArgument<"NulPos", 0>, + DefaultIntArgument<"Sentinel", 0>]; +} + +def StdCall : Attr { + let Spellings = ["stdcall", "__stdcall"]; +} + +def ThisCall : Attr { + let Spellings = ["thiscall", "__thiscall"]; +} + +def TransparentUnion : Attr { + let Spellings = ["transparent_union"]; +} + +def Unavailable : Attr { + let Spellings = ["unavailable"]; +} + +def Unused : Attr { + let Spellings = ["unused"]; +} + +def Used : Attr { + let Spellings = ["used"]; +} + +def Visibility : Attr { + let Spellings = ["visibility"]; + let Args = [StringArgument<"Visibility">]; +} + +def WarnUnusedResult : Attr { + let Spellings = ["warn_unused_result"]; +} + +def Weak : Attr { + let Spellings = ["weak"]; +} + +def WeakImport : Attr { + let Spellings = ["weak_import"]; +} + +def WeakRef : Attr { + let Spellings = ["weakref"]; +} + +def X86ForceAlignArgPointer : Attr { + let Spellings = []; +} diff --git a/include/clang/Basic/AttrKinds.h b/include/clang/Basic/AttrKinds.h new file mode 100644 index 0000000000..822573b734 --- /dev/null +++ b/include/clang/Basic/AttrKinds.h @@ -0,0 +1,31 @@ +//===----- Attr.h - Enum values for C Attribute Kinds ----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the attr::Kind enum +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_ATTRKINDS_H +#define LLVM_CLANG_ATTRKINDS_H + +namespace clang { + +namespace attr { + +// Kind - This is a list of all the recognized kinds of attributes. +enum Kind { +#define ATTR(X) X, +#include "clang/Basic/AttrList.inc" + NUM_ATTRS +}; + +} // end namespace attr +} // end namespace clang + +#endif diff --git a/include/clang/Basic/DeclNodes.td b/include/clang/Basic/DeclNodes.td index a25f3ee10b..203fb451e3 100644 --- a/include/clang/Basic/DeclNodes.td +++ b/include/clang/Basic/DeclNodes.td @@ -1,4 +1,6 @@ -class Decl<bit abstract = 0> { +class AttrSubject; + +class Decl<bit abstract = 0> : AttrSubject { bit Abstract = abstract; } diff --git a/include/clang/Basic/Makefile b/include/clang/Basic/Makefile index 1553a79914..a1445ced32 100644 --- a/include/clang/Basic/Makefile +++ b/include/clang/Basic/Makefile @@ -3,7 +3,7 @@ BUILT_SOURCES = DiagnosticAnalysisKinds.inc DiagnosticASTKinds.inc \ DiagnosticCommonKinds.inc DiagnosticDriverKinds.inc \ DiagnosticFrontendKinds.inc DiagnosticLexKinds.inc \ DiagnosticParseKinds.inc DiagnosticSemaKinds.inc \ - DiagnosticGroups.inc + DiagnosticGroups.inc AttrList.inc TABLEGEN_INC_FILES_COMMON = 1 @@ -19,4 +19,7 @@ $(ObjDir)/DiagnosticGroups.inc.tmp : Diagnostic.td DiagnosticGroups.td $(INPUT_T $(Echo) "Building Clang diagnostic groups with tblgen" $(Verb) $(TableGen) -gen-clang-diag-groups -o $(call SYSPATH, $@) $< - +$(ObjDir)/AttrList.inc.tmp : Attr.td $(TBLGEN) $(ObjDir)/.dir + $(Echo) "Building Clang attribute list with tblgen" + $(Verb) $(TableGen) -gen-clang-attr-list -o $(call SYSPATH, $@) \ + -I $(PROJ_SRC_DIR)/../.. $< diff --git a/include/clang/Basic/StmtNodes.td b/include/clang/Basic/StmtNodes.td index 60c94a609b..940e30884a 100644 --- a/include/clang/Basic/StmtNodes.td +++ b/include/clang/Basic/StmtNodes.td @@ -1,4 +1,6 @@ -class Stmt<bit abstract = 0> { +class AttrSubject; + +class Stmt<bit abstract = 0> : AttrSubject { bit Abstract = abstract; } diff --git a/lib/AST/AttrImpl.cpp b/lib/AST/AttrImpl.cpp index 0fab22cace..1927a222e8 100644 --- a/lib/AST/AttrImpl.cpp +++ b/lib/AST/AttrImpl.cpp @@ -24,7 +24,7 @@ void Attr::Destroy(ASTContext &C) { C.Deallocate((void*)this); } -AttrWithString::AttrWithString(Attr::Kind AK, ASTContext &C, llvm::StringRef s) +AttrWithString::AttrWithString(attr::Kind AK, ASTContext &C, llvm::StringRef s) : Attr(AK) { assert(!s.empty()); StrLen = s.size(); @@ -51,7 +51,7 @@ void FormatAttr::setType(ASTContext &C, llvm::StringRef type) { } NonNullAttr::NonNullAttr(ASTContext &C, unsigned* arg_nums, unsigned size) - : Attr(NonNull), ArgNums(0), Size(0) { + : Attr(attr::NonNull), ArgNums(0), Size(0) { if (size == 0) return; assert(arg_nums); diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp index cece1b659c..78ae5f01b7 100644 --- a/lib/Frontend/PCHReaderDecl.cpp +++ b/lib/Frontend/PCHReaderDecl.cpp @@ -679,24 +679,24 @@ Attr *PCHReader::ReadAttributes() { (void)RecCode; #define SIMPLE_ATTR(Name) \ - case Attr::Name: \ + case attr::Name: \ New = ::new (*Context) Name##Attr(); \ break #define STRING_ATTR(Name) \ - case Attr::Name: \ + case attr::Name: \ New = ::new (*Context) Name##Attr(*Context, ReadString(Record, Idx)); \ break #define UNSIGNED_ATTR(Name) \ - case Attr::Name: \ + case attr::Name: \ New = ::new (*Context) Name##Attr(Record[Idx++]); \ break |