19
19
#include " clang/AST/Expr.h"
20
20
#include " clang/AST/Type.h"
21
21
#include " clang/Basic/AttrKinds.h"
22
+ #include " clang/Basic/AttributeCommonInfo.h"
22
23
#include " clang/Basic/LLVM.h"
23
24
#include " clang/Basic/OpenMPKinds.h"
24
25
#include " clang/Basic/Sanitizers.h"
32
33
33
34
namespace clang {
34
35
class ASTContext ;
36
+ class AttributeCommonInfo ;
35
37
class IdentifierInfo ;
36
38
class ObjCInterfaceDecl ;
37
39
class Expr ;
@@ -40,84 +42,79 @@ namespace clang {
40
42
class TypeSourceInfo ;
41
43
42
44
// / Attr - This represents one attribute.
43
- class Attr {
44
- private:
45
- SourceRange Range;
46
- unsigned AttrKind : 16 ;
47
-
48
- protected:
49
- // / An index into the spelling list of an
50
- // / attribute defined in Attr.td file.
51
- unsigned SpellingListIndex : 4 ;
52
- unsigned Inherited : 1 ;
53
- unsigned IsPackExpansion : 1 ;
54
- unsigned Implicit : 1 ;
55
- // FIXME: These are properties of the attribute kind, not state for this
56
- // instance of the attribute.
57
- unsigned IsLateParsed : 1 ;
58
- unsigned InheritEvenIfAlreadyPresent : 1 ;
59
-
60
- void *operator new (size_t bytes) noexcept {
61
- llvm_unreachable (" Attrs cannot be allocated with regular 'new'." );
62
- }
63
- void operator delete (void *data) noexcept {
64
- llvm_unreachable (" Attrs cannot be released with regular 'delete'." );
65
- }
66
-
67
- public:
68
- // Forward so that the regular new and delete do not hide global ones.
69
- void *operator new (size_t Bytes, ASTContext &C,
70
- size_t Alignment = 8 ) noexcept {
71
- return ::operator new (Bytes, C, Alignment);
72
- }
73
- void operator delete (void *Ptr, ASTContext &C, size_t Alignment) noexcept {
74
- return ::operator delete (Ptr, C, Alignment);
75
- }
45
+ class Attr : public AttributeCommonInfo {
46
+ private:
47
+ unsigned AttrKind : 16 ;
48
+
49
+ protected:
50
+ // / An index into the spelling list of an
51
+ // / attribute defined in Attr.td file.
52
+ unsigned Inherited : 1 ;
53
+ unsigned IsPackExpansion : 1 ;
54
+ unsigned Implicit : 1 ;
55
+ // FIXME: These are properties of the attribute kind, not state for this
56
+ // instance of the attribute.
57
+ unsigned IsLateParsed : 1 ;
58
+ unsigned InheritEvenIfAlreadyPresent : 1 ;
59
+
60
+ void *operator new (size_t bytes) noexcept {
61
+ llvm_unreachable (" Attrs cannot be allocated with regular 'new'." );
62
+ }
63
+ void operator delete (void *data) noexcept {
64
+ llvm_unreachable (" Attrs cannot be released with regular 'delete'." );
65
+ }
76
66
77
- protected:
78
- Attr (attr::Kind AK, SourceRange R, unsigned SpellingListIndex,
79
- bool IsLateParsed)
80
- : Range(R), AttrKind(AK), SpellingListIndex(SpellingListIndex),
81
- Inherited (false ), IsPackExpansion(false ), Implicit(false ),
82
- IsLateParsed(IsLateParsed), InheritEvenIfAlreadyPresent(false ) {}
67
+ public:
68
+ // Forward so that the regular new and delete do not hide global ones.
69
+ void *operator new (size_t Bytes, ASTContext &C,
70
+ size_t Alignment = 8 ) noexcept {
71
+ return ::operator new (Bytes, C, Alignment);
72
+ }
73
+ void operator delete (void *Ptr, ASTContext &C, size_t Alignment) noexcept {
74
+ return ::operator delete (Ptr, C, Alignment);
75
+ }
83
76
84
- public:
77
+ protected:
78
+ Attr (ASTContext &Context, const AttributeCommonInfo &CommonInfo,
79
+ attr::Kind AK, bool IsLateParsed)
80
+ : AttributeCommonInfo(CommonInfo), AttrKind(AK), Inherited(false ),
81
+ IsPackExpansion (false ), Implicit(false ), IsLateParsed(IsLateParsed),
82
+ InheritEvenIfAlreadyPresent(false ) {}
85
83
86
- attr::Kind getKind () const {
87
- return static_cast <attr::Kind>(AttrKind);
88
- }
84
+ public:
85
+ attr::Kind getKind () const { return static_cast <attr::Kind>(AttrKind); }
89
86
90
- unsigned getSpellingListIndex () const { return SpellingListIndex; }
91
- const char *getSpelling () const ;
87
+ unsigned getSpellingListIndex () const {
88
+ return getAttributeSpellingListIndex ();
89
+ }
90
+ const char *getSpelling () const ;
92
91
93
- SourceLocation getLocation () const { return Range.getBegin (); }
94
- SourceRange getRange () const { return Range; }
95
- void setRange (SourceRange R) { Range = R; }
92
+ SourceLocation getLocation () const { return getRange ().getBegin (); }
96
93
97
- bool isInherited () const { return Inherited; }
94
+ bool isInherited () const { return Inherited; }
98
95
99
- // / Returns true if the attribute has been implicitly created instead
100
- // / of explicitly written by the user.
101
- bool isImplicit () const { return Implicit; }
102
- void setImplicit (bool I) { Implicit = I; }
96
+ // / Returns true if the attribute has been implicitly created instead
97
+ // / of explicitly written by the user.
98
+ bool isImplicit () const { return Implicit; }
99
+ void setImplicit (bool I) { Implicit = I; }
103
100
104
- void setPackExpansion (bool PE) { IsPackExpansion = PE; }
105
- bool isPackExpansion () const { return IsPackExpansion; }
101
+ void setPackExpansion (bool PE) { IsPackExpansion = PE; }
102
+ bool isPackExpansion () const { return IsPackExpansion; }
106
103
107
- // Clone this attribute.
108
- Attr *clone (ASTContext &C) const ;
104
+ // Clone this attribute.
105
+ Attr *clone (ASTContext &C) const ;
109
106
110
- bool isLateParsed () const { return IsLateParsed; }
107
+ bool isLateParsed () const { return IsLateParsed; }
111
108
112
- // Pretty print this attribute.
113
- void printPretty (raw_ostream &OS, const PrintingPolicy &Policy) const ;
114
- };
109
+ // Pretty print this attribute.
110
+ void printPretty (raw_ostream &OS, const PrintingPolicy &Policy) const ;
111
+ };
115
112
116
113
class TypeAttr : public Attr {
117
114
protected:
118
- TypeAttr (attr::Kind AK, SourceRange R, unsigned SpellingListIndex ,
119
- bool IsLateParsed)
120
- : Attr(AK, R, SpellingListIndex , IsLateParsed) {}
115
+ TypeAttr (ASTContext &Context, const AttributeCommonInfo &CommonInfo ,
116
+ attr::Kind AK, bool IsLateParsed)
117
+ : Attr(Context, CommonInfo, AK , IsLateParsed) {}
121
118
122
119
public:
123
120
static bool classof (const Attr *A) {
@@ -128,9 +125,9 @@ class TypeAttr : public Attr {
128
125
129
126
class StmtAttr : public Attr {
130
127
protected:
131
- StmtAttr (attr::Kind AK, SourceRange R, unsigned SpellingListIndex ,
132
- bool IsLateParsed)
133
- : Attr(AK, R, SpellingListIndex , IsLateParsed) {}
128
+ StmtAttr (ASTContext &Context, const AttributeCommonInfo &CommonInfo ,
129
+ attr::Kind AK, bool IsLateParsed)
130
+ : Attr(Context, CommonInfo, AK , IsLateParsed) {}
134
131
135
132
public:
136
133
static bool classof (const Attr *A) {
@@ -141,9 +138,10 @@ class StmtAttr : public Attr {
141
138
142
139
class InheritableAttr : public Attr {
143
140
protected:
144
- InheritableAttr (attr::Kind AK, SourceRange R, unsigned SpellingListIndex,
145
- bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
146
- : Attr(AK, R, SpellingListIndex, IsLateParsed) {
141
+ InheritableAttr (ASTContext &Context, const AttributeCommonInfo &CommonInfo,
142
+ attr::Kind AK, bool IsLateParsed,
143
+ bool InheritEvenIfAlreadyPresent)
144
+ : Attr(Context, CommonInfo, AK, IsLateParsed) {
147
145
this ->InheritEvenIfAlreadyPresent = InheritEvenIfAlreadyPresent;
148
146
}
149
147
@@ -165,9 +163,10 @@ class InheritableAttr : public Attr {
165
163
166
164
class InheritableParamAttr : public InheritableAttr {
167
165
protected:
168
- InheritableParamAttr (attr::Kind AK, SourceRange R, unsigned SpellingListIndex,
166
+ InheritableParamAttr (ASTContext &Context,
167
+ const AttributeCommonInfo &CommonInfo, attr::Kind AK,
169
168
bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
170
- : InheritableAttr(AK, R, SpellingListIndex , IsLateParsed,
169
+ : InheritableAttr(Context, CommonInfo, AK , IsLateParsed,
171
170
InheritEvenIfAlreadyPresent) {}
172
171
173
172
public:
@@ -182,11 +181,11 @@ class InheritableParamAttr : public InheritableAttr {
182
181
// / for the parameter.
183
182
class ParameterABIAttr : public InheritableParamAttr {
184
183
protected:
185
- ParameterABIAttr (attr::Kind AK, SourceRange R ,
186
- unsigned SpellingListIndex , bool IsLateParsed,
184
+ ParameterABIAttr (ASTContext &Context, const AttributeCommonInfo &CommonInfo ,
185
+ attr::Kind AK , bool IsLateParsed,
187
186
bool InheritEvenIfAlreadyPresent)
188
- : InheritableParamAttr(AK, R, SpellingListIndex , IsLateParsed,
189
- InheritEvenIfAlreadyPresent) {}
187
+ : InheritableParamAttr(Context, CommonInfo, AK , IsLateParsed,
188
+ InheritEvenIfAlreadyPresent) {}
190
189
191
190
public:
192
191
ParameterABI getABI () const {
0 commit comments