File: | tools/clang/lib/Sema/SemaStmtAttr.cpp |
Warning: | line 7448, column 9 Called C++ object pointer is null |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | //===--- SemaStmtAttr.cpp - Statement Attribute Handling ------------------===// | |||
2 | // | |||
3 | // The LLVM Compiler Infrastructure | |||
4 | // | |||
5 | // This file is distributed under the University of Illinois Open Source | |||
6 | // License. See LICENSE.TXT for details. | |||
7 | // | |||
8 | //===----------------------------------------------------------------------===// | |||
9 | // | |||
10 | // This file implements stmt-related attribute processing. | |||
11 | // | |||
12 | //===----------------------------------------------------------------------===// | |||
13 | ||||
14 | #include "clang/Sema/SemaInternal.h" | |||
15 | #include "clang/AST/ASTContext.h" | |||
16 | #include "clang/Basic/SourceManager.h" | |||
17 | #include "clang/Sema/DelayedDiagnostic.h" | |||
18 | #include "clang/Sema/Lookup.h" | |||
19 | #include "clang/Sema/LoopHint.h" | |||
20 | #include "clang/Sema/ScopeInfo.h" | |||
21 | #include "llvm/ADT/StringExtras.h" | |||
22 | ||||
23 | using namespace clang; | |||
24 | using namespace sema; | |||
25 | ||||
26 | static Attr *handleFallThroughAttr(Sema &S, Stmt *St, const AttributeList &A, | |||
27 | SourceRange Range) { | |||
28 | FallThroughAttr Attr(A.getRange(), S.Context, | |||
29 | A.getAttributeSpellingListIndex()); | |||
30 | if (!isa<NullStmt>(St)) { | |||
31 | S.Diag(A.getRange().getBegin(), diag::err_fallthrough_attr_wrong_target) | |||
32 | << Attr.getSpelling() << St->getLocStart(); | |||
33 | if (isa<SwitchCase>(St)) { | |||
34 | SourceLocation L = S.getLocForEndOfToken(Range.getEnd()); | |||
35 | S.Diag(L, diag::note_fallthrough_insert_semi_fixit) | |||
36 | << FixItHint::CreateInsertion(L, ";"); | |||
37 | } | |||
38 | return nullptr; | |||
39 | } | |||
40 | auto *FnScope = S.getCurFunction(); | |||
41 | if (FnScope->SwitchStack.empty()) { | |||
42 | S.Diag(A.getRange().getBegin(), diag::err_fallthrough_attr_outside_switch); | |||
43 | return nullptr; | |||
44 | } | |||
45 | ||||
46 | // If this is spelled as the standard C++17 attribute, but not in C++17, warn | |||
47 | // about using it as an extension. | |||
48 | if (!S.getLangOpts().CPlusPlus17 && A.isCXX11Attribute() && | |||
49 | !A.getScopeName()) | |||
50 | S.Diag(A.getLoc(), diag::ext_cxx17_attr) << A.getName(); | |||
51 | ||||
52 | FnScope->setHasFallthroughStmt(); | |||
53 | return ::new (S.Context) auto(Attr); | |||
54 | } | |||
55 | ||||
56 | static Attr *handleSuppressAttr(Sema &S, Stmt *St, const AttributeList &A, | |||
57 | SourceRange Range) { | |||
58 | if (A.getNumArgs() < 1) { | |||
59 | S.Diag(A.getLoc(), diag::err_attribute_too_few_arguments) | |||
60 | << A.getName() << 1; | |||
61 | return nullptr; | |||
62 | } | |||
63 | ||||
64 | std::vector<StringRef> DiagnosticIdentifiers; | |||
65 | for (unsigned I = 0, E = A.getNumArgs(); I != E; ++I) { | |||
66 | StringRef RuleName; | |||
67 | ||||
68 | if (!S.checkStringLiteralArgumentAttr(A, I, RuleName, nullptr)) | |||
69 | return nullptr; | |||
70 | ||||
71 | // FIXME: Warn if the rule name is unknown. This is tricky because only | |||
72 | // clang-tidy knows about available rules. | |||
73 | DiagnosticIdentifiers.push_back(RuleName); | |||
74 | } | |||
75 | ||||
76 | return ::new (S.Context) SuppressAttr( | |||
77 | A.getRange(), S.Context, DiagnosticIdentifiers.data(), | |||
78 | DiagnosticIdentifiers.size(), A.getAttributeSpellingListIndex()); | |||
79 | } | |||
80 | ||||
81 | static Attr *handleLoopHintAttr(Sema &S, Stmt *St, const AttributeList &A, | |||
82 | SourceRange) { | |||
83 | IdentifierLoc *PragmaNameLoc = A.getArgAsIdent(0); | |||
84 | IdentifierLoc *OptionLoc = A.getArgAsIdent(1); | |||
85 | IdentifierLoc *StateLoc = A.getArgAsIdent(2); | |||
86 | Expr *ValueExpr = A.getArgAsExpr(3); | |||
87 | ||||
88 | bool PragmaUnroll = PragmaNameLoc->Ident->getName() == "unroll"; | |||
89 | bool PragmaNoUnroll = PragmaNameLoc->Ident->getName() == "nounroll"; | |||
90 | if (St->getStmtClass() != Stmt::DoStmtClass && | |||
91 | St->getStmtClass() != Stmt::ForStmtClass && | |||
92 | St->getStmtClass() != Stmt::CXXForRangeStmtClass && | |||
93 | St->getStmtClass() != Stmt::WhileStmtClass) { | |||
94 | const char *Pragma = | |||
95 | llvm::StringSwitch<const char *>(PragmaNameLoc->Ident->getName()) | |||
96 | .Case("unroll", "#pragma unroll") | |||
97 | .Case("nounroll", "#pragma nounroll") | |||
98 | .Default("#pragma clang loop"); | |||
99 | S.Diag(St->getLocStart(), diag::err_pragma_loop_precedes_nonloop) << Pragma; | |||
100 | return nullptr; | |||
101 | } | |||
102 | ||||
103 | LoopHintAttr::Spelling Spelling = | |||
104 | LoopHintAttr::Spelling(A.getAttributeSpellingListIndex()); | |||
105 | LoopHintAttr::OptionType Option; | |||
106 | LoopHintAttr::LoopHintState State; | |||
107 | if (PragmaNoUnroll) { | |||
108 | // #pragma nounroll | |||
109 | Option = LoopHintAttr::Unroll; | |||
110 | State = LoopHintAttr::Disable; | |||
111 | } else if (PragmaUnroll) { | |||
112 | if (ValueExpr) { | |||
113 | // #pragma unroll N | |||
114 | Option = LoopHintAttr::UnrollCount; | |||
115 | State = LoopHintAttr::Numeric; | |||
116 | } else { | |||
117 | // #pragma unroll | |||
118 | Option = LoopHintAttr::Unroll; | |||
119 | State = LoopHintAttr::Enable; | |||
120 | } | |||
121 | } else { | |||
122 | // #pragma clang loop ... | |||
123 | assert(OptionLoc && OptionLoc->Ident &&(static_cast <bool> (OptionLoc && OptionLoc-> Ident && "Attribute must have valid option info.") ? void (0) : __assert_fail ("OptionLoc && OptionLoc->Ident && \"Attribute must have valid option info.\"" , "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/Sema/SemaStmtAttr.cpp" , 124, __extension__ __PRETTY_FUNCTION__)) | |||
124 | "Attribute must have valid option info.")(static_cast <bool> (OptionLoc && OptionLoc-> Ident && "Attribute must have valid option info.") ? void (0) : __assert_fail ("OptionLoc && OptionLoc->Ident && \"Attribute must have valid option info.\"" , "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/Sema/SemaStmtAttr.cpp" , 124, __extension__ __PRETTY_FUNCTION__)); | |||
125 | Option = llvm::StringSwitch<LoopHintAttr::OptionType>( | |||
126 | OptionLoc->Ident->getName()) | |||
127 | .Case("vectorize", LoopHintAttr::Vectorize) | |||
128 | .Case("vectorize_width", LoopHintAttr::VectorizeWidth) | |||
129 | .Case("interleave", LoopHintAttr::Interleave) | |||
130 | .Case("interleave_count", LoopHintAttr::InterleaveCount) | |||
131 | .Case("unroll", LoopHintAttr::Unroll) | |||
132 | .Case("unroll_count", LoopHintAttr::UnrollCount) | |||
133 | .Case("distribute", LoopHintAttr::Distribute) | |||
134 | .Default(LoopHintAttr::Vectorize); | |||
135 | if (Option == LoopHintAttr::VectorizeWidth || | |||
136 | Option == LoopHintAttr::InterleaveCount || | |||
137 | Option == LoopHintAttr::UnrollCount) { | |||
138 | assert(ValueExpr && "Attribute must have a valid value expression.")(static_cast <bool> (ValueExpr && "Attribute must have a valid value expression." ) ? void (0) : __assert_fail ("ValueExpr && \"Attribute must have a valid value expression.\"" , "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/Sema/SemaStmtAttr.cpp" , 138, __extension__ __PRETTY_FUNCTION__)); | |||
139 | if (S.CheckLoopHintExpr(ValueExpr, St->getLocStart())) | |||
140 | return nullptr; | |||
141 | State = LoopHintAttr::Numeric; | |||
142 | } else if (Option == LoopHintAttr::Vectorize || | |||
143 | Option == LoopHintAttr::Interleave || | |||
144 | Option == LoopHintAttr::Unroll || | |||
145 | Option == LoopHintAttr::Distribute) { | |||
146 | assert(StateLoc && StateLoc->Ident && "Loop hint must have an argument")(static_cast <bool> (StateLoc && StateLoc->Ident && "Loop hint must have an argument") ? void (0) : __assert_fail ("StateLoc && StateLoc->Ident && \"Loop hint must have an argument\"" , "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/Sema/SemaStmtAttr.cpp" , 146, __extension__ __PRETTY_FUNCTION__)); | |||
147 | if (StateLoc->Ident->isStr("disable")) | |||
148 | State = LoopHintAttr::Disable; | |||
149 | else if (StateLoc->Ident->isStr("assume_safety")) | |||
150 | State = LoopHintAttr::AssumeSafety; | |||
151 | else if (StateLoc->Ident->isStr("full")) | |||
152 | State = LoopHintAttr::Full; | |||
153 | else if (StateLoc->Ident->isStr("enable")) | |||
154 | State = LoopHintAttr::Enable; | |||
155 | else | |||
156 | llvm_unreachable("bad loop hint argument")::llvm::llvm_unreachable_internal("bad loop hint argument", "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/Sema/SemaStmtAttr.cpp" , 156); | |||
157 | } else | |||
158 | llvm_unreachable("bad loop hint")::llvm::llvm_unreachable_internal("bad loop hint", "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/Sema/SemaStmtAttr.cpp" , 158); | |||
159 | } | |||
160 | ||||
161 | return LoopHintAttr::CreateImplicit(S.Context, Spelling, Option, State, | |||
162 | ValueExpr, A.getRange()); | |||
163 | } | |||
164 | ||||
165 | static void | |||
166 | CheckForIncompatibleAttributes(Sema &S, | |||
167 | const SmallVectorImpl<const Attr *> &Attrs) { | |||
168 | // There are 4 categories of loop hints attributes: vectorize, interleave, | |||
169 | // unroll and distribute. Except for distribute they come in two variants: a | |||
170 | // state form and a numeric form. The state form selectively | |||
171 | // defaults/enables/disables the transformation for the loop (for unroll, | |||
172 | // default indicates full unrolling rather than enabling the transformation). | |||
173 | // The numeric form form provides an integer hint (for example, unroll count) | |||
174 | // to the transformer. The following array accumulates the hints encountered | |||
175 | // while iterating through the attributes to check for compatibility. | |||
176 | struct { | |||
177 | const LoopHintAttr *StateAttr; | |||
178 | const LoopHintAttr *NumericAttr; | |||
179 | } HintAttrs[] = {{nullptr, nullptr}, | |||
180 | {nullptr, nullptr}, | |||
181 | {nullptr, nullptr}, | |||
182 | {nullptr, nullptr}}; | |||
183 | ||||
184 | for (const auto *I : Attrs) { | |||
185 | const LoopHintAttr *LH = dyn_cast<LoopHintAttr>(I); | |||
186 | ||||
187 | // Skip non loop hint attributes | |||
188 | if (!LH) | |||
189 | continue; | |||
190 | ||||
191 | LoopHintAttr::OptionType Option = LH->getOption(); | |||
192 | enum { Vectorize, Interleave, Unroll, Distribute } Category; | |||
193 | switch (Option) { | |||
194 | case LoopHintAttr::Vectorize: | |||
195 | case LoopHintAttr::VectorizeWidth: | |||
196 | Category = Vectorize; | |||
197 | break; | |||
198 | case LoopHintAttr::Interleave: | |||
199 | case LoopHintAttr::InterleaveCount: | |||
200 | Category = Interleave; | |||
201 | break; | |||
202 | case LoopHintAttr::Unroll: | |||
203 | case LoopHintAttr::UnrollCount: | |||
204 | Category = Unroll; | |||
205 | break; | |||
206 | case LoopHintAttr::Distribute: | |||
207 | // Perform the check for duplicated 'distribute' hints. | |||
208 | Category = Distribute; | |||
209 | break; | |||
210 | }; | |||
211 | ||||
212 | auto &CategoryState = HintAttrs[Category]; | |||
213 | const LoopHintAttr *PrevAttr; | |||
214 | if (Option == LoopHintAttr::Vectorize || | |||
215 | Option == LoopHintAttr::Interleave || Option == LoopHintAttr::Unroll || | |||
216 | Option == LoopHintAttr::Distribute) { | |||
217 | // Enable|Disable|AssumeSafety hint. For example, vectorize(enable). | |||
218 | PrevAttr = CategoryState.StateAttr; | |||
219 | CategoryState.StateAttr = LH; | |||
220 | } else { | |||
221 | // Numeric hint. For example, vectorize_width(8). | |||
222 | PrevAttr = CategoryState.NumericAttr; | |||
223 | CategoryState.NumericAttr = LH; | |||
224 | } | |||
225 | ||||
226 | PrintingPolicy Policy(S.Context.getLangOpts()); | |||
227 | SourceLocation OptionLoc = LH->getRange().getBegin(); | |||
228 | if (PrevAttr) | |||
229 | // Cannot specify same type of attribute twice. | |||
230 | S.Diag(OptionLoc, diag::err_pragma_loop_compatibility) | |||
231 | << /*Duplicate=*/true << PrevAttr->getDiagnosticName(Policy) | |||
232 | << LH->getDiagnosticName(Policy); | |||
233 | ||||
234 | if (CategoryState.StateAttr && CategoryState.NumericAttr && | |||
235 | (Category == Unroll || | |||
236 | CategoryState.StateAttr->getState() == LoopHintAttr::Disable)) { | |||
237 | // Disable hints are not compatible with numeric hints of the same | |||
238 | // category. As a special case, numeric unroll hints are also not | |||
239 | // compatible with enable or full form of the unroll pragma because these | |||
240 | // directives indicate full unrolling. | |||
241 | S.Diag(OptionLoc, diag::err_pragma_loop_compatibility) | |||
242 | << /*Duplicate=*/false | |||
243 | << CategoryState.StateAttr->getDiagnosticName(Policy) | |||
244 | << CategoryState.NumericAttr->getDiagnosticName(Policy); | |||
245 | } | |||
246 | } | |||
247 | } | |||
248 | ||||
249 | static Attr *handleOpenCLUnrollHint(Sema &S, Stmt *St, const AttributeList &A, | |||
250 | SourceRange Range) { | |||
251 | // Although the feature was introduced only in OpenCL C v2.0 s6.11.5, it's | |||
252 | // useful for OpenCL 1.x too and doesn't require HW support. | |||
253 | // opencl_unroll_hint can have 0 arguments (compiler | |||
254 | // determines unrolling factor) or 1 argument (the unroll factor provided | |||
255 | // by the user). | |||
256 | ||||
257 | unsigned NumArgs = A.getNumArgs(); | |||
258 | ||||
259 | if (NumArgs > 1) { | |||
260 | S.Diag(A.getLoc(), diag::err_attribute_too_many_arguments) << A.getName() | |||
261 | << 1; | |||
262 | return nullptr; | |||
263 | } | |||
264 | ||||
265 | unsigned UnrollFactor = 0; | |||
266 | ||||
267 | if (NumArgs == 1) { | |||
268 | Expr *E = A.getArgAsExpr(0); | |||
269 | llvm::APSInt ArgVal(32); | |||
270 | ||||
271 | if (!E->isIntegerConstantExpr(ArgVal, S.Context)) { | |||
272 | S.Diag(A.getLoc(), diag::err_attribute_argument_type) | |||
273 | << A.getName() << AANT_ArgumentIntegerConstant << E->getSourceRange(); | |||
274 | return nullptr; | |||
275 | } | |||
276 | ||||
277 | int Val = ArgVal.getSExtValue(); | |||
278 | ||||
279 | if (Val <= 0) { | |||
280 | S.Diag(A.getRange().getBegin(), | |||
281 | diag::err_attribute_requires_positive_integer) | |||
282 | << A.getName(); | |||
283 | return nullptr; | |||
284 | } | |||
285 | UnrollFactor = Val; | |||
286 | } | |||
287 | ||||
288 | return OpenCLUnrollHintAttr::CreateImplicit(S.Context, UnrollFactor); | |||
289 | } | |||
290 | ||||
291 | static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const AttributeList &A, | |||
292 | SourceRange Range) { | |||
293 | switch (A.getKind()) { | |||
| ||||
294 | case AttributeList::UnknownAttribute: | |||
295 | S.Diag(A.getLoc(), A.isDeclspecAttribute() ? | |||
296 | diag::warn_unhandled_ms_attribute_ignored : | |||
297 | diag::warn_unknown_attribute_ignored) << A.getName(); | |||
298 | return nullptr; | |||
299 | case AttributeList::AT_FallThrough: | |||
300 | return handleFallThroughAttr(S, St, A, Range); | |||
301 | case AttributeList::AT_LoopHint: | |||
302 | return handleLoopHintAttr(S, St, A, Range); | |||
303 | case AttributeList::AT_OpenCLUnrollHint: | |||
304 | return handleOpenCLUnrollHint(S, St, A, Range); | |||
305 | case AttributeList::AT_Suppress: | |||
306 | return handleSuppressAttr(S, St, A, Range); | |||
307 | default: | |||
308 | // if we're here, then we parsed a known attribute, but didn't recognize | |||
309 | // it as a statement attribute => it is declaration attribute | |||
310 | S.Diag(A.getRange().getBegin(), diag::err_decl_attribute_invalid_on_stmt) | |||
311 | << A.getName() << St->getLocStart(); | |||
312 | return nullptr; | |||
313 | } | |||
314 | } | |||
315 | ||||
316 | StmtResult Sema::ProcessStmtAttributes(Stmt *S, AttributeList *AttrList, | |||
317 | SourceRange Range) { | |||
318 | SmallVector<const Attr*, 8> Attrs; | |||
319 | for (const AttributeList* l = AttrList; l; l = l->getNext()) { | |||
320 | if (Attr *a = ProcessStmtAttribute(*this, S, *l, Range)) | |||
321 | Attrs.push_back(a); | |||
322 | } | |||
323 | ||||
324 | CheckForIncompatibleAttributes(*this, Attrs); | |||
325 | ||||
326 | if (Attrs.empty()) | |||
327 | return S; | |||
328 | ||||
329 | return ActOnAttributedStmt(Range.getBegin(), Attrs, S); | |||
330 | } |
1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ | |||
2 | |* *| | |||
3 | |* Attribute classes' definitions *| | |||
4 | |* *| | |||
5 | |* Automatically generated file, do not edit! *| | |||
6 | |* *| | |||
7 | \*===----------------------------------------------------------------------===*/ | |||
8 | ||||
9 | #ifndef LLVM_CLANG_ATTR_CLASSES_INC | |||
10 | #define LLVM_CLANG_ATTR_CLASSES_INC | |||
11 | ||||
12 | class AMDGPUFlatWorkGroupSizeAttr : public InheritableAttr { | |||
13 | unsigned min; | |||
14 | ||||
15 | unsigned max; | |||
16 | ||||
17 | public: | |||
18 | static AMDGPUFlatWorkGroupSizeAttr *CreateImplicit(ASTContext &Ctx, unsigned Min, unsigned Max, SourceRange Loc = SourceRange()) { | |||
19 | auto *A = new (Ctx) AMDGPUFlatWorkGroupSizeAttr(Loc, Ctx, Min, Max, 0); | |||
20 | A->setImplicit(true); | |||
21 | return A; | |||
22 | } | |||
23 | ||||
24 | AMDGPUFlatWorkGroupSizeAttr(SourceRange R, ASTContext &Ctx | |||
25 | , unsigned Min | |||
26 | , unsigned Max | |||
27 | , unsigned SI | |||
28 | ) | |||
29 | : InheritableAttr(attr::AMDGPUFlatWorkGroupSize, R, SI, false, false) | |||
30 | , min(Min) | |||
31 | , max(Max) | |||
32 | { | |||
33 | } | |||
34 | ||||
35 | AMDGPUFlatWorkGroupSizeAttr *clone(ASTContext &C) const; | |||
36 | void printPretty(raw_ostream &OS, | |||
37 | const PrintingPolicy &Policy) const; | |||
38 | const char *getSpelling() const; | |||
39 | unsigned getMin() const { | |||
40 | return min; | |||
41 | } | |||
42 | ||||
43 | unsigned getMax() const { | |||
44 | return max; | |||
45 | } | |||
46 | ||||
47 | ||||
48 | ||||
49 | static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUFlatWorkGroupSize; } | |||
50 | }; | |||
51 | ||||
52 | class AMDGPUNumSGPRAttr : public InheritableAttr { | |||
53 | unsigned numSGPR; | |||
54 | ||||
55 | public: | |||
56 | static AMDGPUNumSGPRAttr *CreateImplicit(ASTContext &Ctx, unsigned NumSGPR, SourceRange Loc = SourceRange()) { | |||
57 | auto *A = new (Ctx) AMDGPUNumSGPRAttr(Loc, Ctx, NumSGPR, 0); | |||
58 | A->setImplicit(true); | |||
59 | return A; | |||
60 | } | |||
61 | ||||
62 | AMDGPUNumSGPRAttr(SourceRange R, ASTContext &Ctx | |||
63 | , unsigned NumSGPR | |||
64 | , unsigned SI | |||
65 | ) | |||
66 | : InheritableAttr(attr::AMDGPUNumSGPR, R, SI, false, false) | |||
67 | , numSGPR(NumSGPR) | |||
68 | { | |||
69 | } | |||
70 | ||||
71 | AMDGPUNumSGPRAttr *clone(ASTContext &C) const; | |||
72 | void printPretty(raw_ostream &OS, | |||
73 | const PrintingPolicy &Policy) const; | |||
74 | const char *getSpelling() const; | |||
75 | unsigned getNumSGPR() const { | |||
76 | return numSGPR; | |||
77 | } | |||
78 | ||||
79 | ||||
80 | ||||
81 | static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUNumSGPR; } | |||
82 | }; | |||
83 | ||||
84 | class AMDGPUNumVGPRAttr : public InheritableAttr { | |||
85 | unsigned numVGPR; | |||
86 | ||||
87 | public: | |||
88 | static AMDGPUNumVGPRAttr *CreateImplicit(ASTContext &Ctx, unsigned NumVGPR, SourceRange Loc = SourceRange()) { | |||
89 | auto *A = new (Ctx) AMDGPUNumVGPRAttr(Loc, Ctx, NumVGPR, 0); | |||
90 | A->setImplicit(true); | |||
91 | return A; | |||
92 | } | |||
93 | ||||
94 | AMDGPUNumVGPRAttr(SourceRange R, ASTContext &Ctx | |||
95 | , unsigned NumVGPR | |||
96 | , unsigned SI | |||
97 | ) | |||
98 | : InheritableAttr(attr::AMDGPUNumVGPR, R, SI, false, false) | |||
99 | , numVGPR(NumVGPR) | |||
100 | { | |||
101 | } | |||
102 | ||||
103 | AMDGPUNumVGPRAttr *clone(ASTContext &C) const; | |||
104 | void printPretty(raw_ostream &OS, | |||
105 | const PrintingPolicy &Policy) const; | |||
106 | const char *getSpelling() const; | |||
107 | unsigned getNumVGPR() const { | |||
108 | return numVGPR; | |||
109 | } | |||
110 | ||||
111 | ||||
112 | ||||
113 | static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUNumVGPR; } | |||
114 | }; | |||
115 | ||||
116 | class AMDGPUWavesPerEUAttr : public InheritableAttr { | |||
117 | unsigned min; | |||
118 | ||||
119 | unsigned max; | |||
120 | ||||
121 | public: | |||
122 | static AMDGPUWavesPerEUAttr *CreateImplicit(ASTContext &Ctx, unsigned Min, unsigned Max, SourceRange Loc = SourceRange()) { | |||
123 | auto *A = new (Ctx) AMDGPUWavesPerEUAttr(Loc, Ctx, Min, Max, 0); | |||
124 | A->setImplicit(true); | |||
125 | return A; | |||
126 | } | |||
127 | ||||
128 | AMDGPUWavesPerEUAttr(SourceRange R, ASTContext &Ctx | |||
129 | , unsigned Min | |||
130 | , unsigned Max | |||
131 | , unsigned SI | |||
132 | ) | |||
133 | : InheritableAttr(attr::AMDGPUWavesPerEU, R, SI, false, false) | |||
134 | , min(Min) | |||
135 | , max(Max) | |||
136 | { | |||
137 | } | |||
138 | ||||
139 | AMDGPUWavesPerEUAttr(SourceRange R, ASTContext &Ctx | |||
140 | , unsigned Min | |||
141 | , unsigned SI | |||
142 | ) | |||
143 | : InheritableAttr(attr::AMDGPUWavesPerEU, R, SI, false, false) | |||
144 | , min(Min) | |||
145 | , max() | |||
146 | { | |||
147 | } | |||
148 | ||||
149 | AMDGPUWavesPerEUAttr *clone(ASTContext &C) const; | |||
150 | void printPretty(raw_ostream &OS, | |||
151 | const PrintingPolicy &Policy) const; | |||
152 | const char *getSpelling() const; | |||
153 | unsigned getMin() const { | |||
154 | return min; | |||
155 | } | |||
156 | ||||
157 | unsigned getMax() const { | |||
158 | return max; | |||
159 | } | |||
160 | ||||
161 | ||||
162 | ||||
163 | static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUWavesPerEU; } | |||
164 | }; | |||
165 | ||||
166 | class ARMInterruptAttr : public InheritableAttr { | |||
167 | public: | |||
168 | enum InterruptType { | |||
169 | IRQ, | |||
170 | FIQ, | |||
171 | SWI, | |||
172 | ABORT, | |||
173 | UNDEF, | |||
174 | Generic | |||
175 | }; | |||
176 | private: | |||
177 | InterruptType interrupt; | |||
178 | ||||
179 | public: | |||
180 | static ARMInterruptAttr *CreateImplicit(ASTContext &Ctx, InterruptType Interrupt, SourceRange Loc = SourceRange()) { | |||
181 | auto *A = new (Ctx) ARMInterruptAttr(Loc, Ctx, Interrupt, 0); | |||
182 | A->setImplicit(true); | |||
183 | return A; | |||
184 | } | |||
185 | ||||
186 | ARMInterruptAttr(SourceRange R, ASTContext &Ctx | |||
187 | , InterruptType Interrupt | |||
188 | , unsigned SI | |||
189 | ) | |||
190 | : InheritableAttr(attr::ARMInterrupt, R, SI, false, false) | |||
191 | , interrupt(Interrupt) | |||
192 | { | |||
193 | } | |||
194 | ||||
195 | ARMInterruptAttr(SourceRange R, ASTContext &Ctx | |||
196 | , unsigned SI | |||
197 | ) | |||
198 | : InheritableAttr(attr::ARMInterrupt, R, SI, false, false) | |||
199 | , interrupt(InterruptType(0)) | |||
200 | { | |||
201 | } | |||
202 | ||||
203 | ARMInterruptAttr *clone(ASTContext &C) const; | |||
204 | void printPretty(raw_ostream &OS, | |||
205 | const PrintingPolicy &Policy) const; | |||
206 | const char *getSpelling() const; | |||
207 | InterruptType getInterrupt() const { | |||
208 | return interrupt; | |||
209 | } | |||
210 | ||||
211 | static bool ConvertStrToInterruptType(StringRef Val, InterruptType &Out) { | |||
212 | Optional<InterruptType> R = llvm::StringSwitch<Optional<InterruptType>>(Val) | |||
213 | .Case("IRQ", ARMInterruptAttr::IRQ) | |||
214 | .Case("FIQ", ARMInterruptAttr::FIQ) | |||
215 | .Case("SWI", ARMInterruptAttr::SWI) | |||
216 | .Case("ABORT", ARMInterruptAttr::ABORT) | |||
217 | .Case("UNDEF", ARMInterruptAttr::UNDEF) | |||
218 | .Case("", ARMInterruptAttr::Generic) | |||
219 | .Default(Optional<InterruptType>()); | |||
220 | if (R) { | |||
221 | Out = *R; | |||
222 | return true; | |||
223 | } | |||
224 | return false; | |||
225 | } | |||
226 | ||||
227 | static const char *ConvertInterruptTypeToStr(InterruptType Val) { | |||
228 | switch(Val) { | |||
229 | case ARMInterruptAttr::IRQ: return "IRQ"; | |||
230 | case ARMInterruptAttr::FIQ: return "FIQ"; | |||
231 | case ARMInterruptAttr::SWI: return "SWI"; | |||
232 | case ARMInterruptAttr::ABORT: return "ABORT"; | |||
233 | case ARMInterruptAttr::UNDEF: return "UNDEF"; | |||
234 | case ARMInterruptAttr::Generic: return ""; | |||
235 | } | |||
236 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 236); | |||
237 | } | |||
238 | ||||
239 | ||||
240 | static bool classof(const Attr *A) { return A->getKind() == attr::ARMInterrupt; } | |||
241 | }; | |||
242 | ||||
243 | class AVRInterruptAttr : public InheritableAttr { | |||
244 | public: | |||
245 | static AVRInterruptAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
246 | auto *A = new (Ctx) AVRInterruptAttr(Loc, Ctx, 0); | |||
247 | A->setImplicit(true); | |||
248 | return A; | |||
249 | } | |||
250 | ||||
251 | AVRInterruptAttr(SourceRange R, ASTContext &Ctx | |||
252 | , unsigned SI | |||
253 | ) | |||
254 | : InheritableAttr(attr::AVRInterrupt, R, SI, false, false) | |||
255 | { | |||
256 | } | |||
257 | ||||
258 | AVRInterruptAttr *clone(ASTContext &C) const; | |||
259 | void printPretty(raw_ostream &OS, | |||
260 | const PrintingPolicy &Policy) const; | |||
261 | const char *getSpelling() const; | |||
262 | ||||
263 | ||||
264 | static bool classof(const Attr *A) { return A->getKind() == attr::AVRInterrupt; } | |||
265 | }; | |||
266 | ||||
267 | class AVRSignalAttr : public InheritableAttr { | |||
268 | public: | |||
269 | static AVRSignalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
270 | auto *A = new (Ctx) AVRSignalAttr(Loc, Ctx, 0); | |||
271 | A->setImplicit(true); | |||
272 | return A; | |||
273 | } | |||
274 | ||||
275 | AVRSignalAttr(SourceRange R, ASTContext &Ctx | |||
276 | , unsigned SI | |||
277 | ) | |||
278 | : InheritableAttr(attr::AVRSignal, R, SI, false, false) | |||
279 | { | |||
280 | } | |||
281 | ||||
282 | AVRSignalAttr *clone(ASTContext &C) const; | |||
283 | void printPretty(raw_ostream &OS, | |||
284 | const PrintingPolicy &Policy) const; | |||
285 | const char *getSpelling() const; | |||
286 | ||||
287 | ||||
288 | static bool classof(const Attr *A) { return A->getKind() == attr::AVRSignal; } | |||
289 | }; | |||
290 | ||||
291 | class AbiTagAttr : public Attr { | |||
292 | unsigned tags_Size; | |||
293 | StringRef *tags_; | |||
294 | ||||
295 | public: | |||
296 | static AbiTagAttr *CreateImplicit(ASTContext &Ctx, StringRef *Tags, unsigned TagsSize, SourceRange Loc = SourceRange()) { | |||
297 | auto *A = new (Ctx) AbiTagAttr(Loc, Ctx, Tags, TagsSize, 0); | |||
298 | A->setImplicit(true); | |||
299 | return A; | |||
300 | } | |||
301 | ||||
302 | AbiTagAttr(SourceRange R, ASTContext &Ctx | |||
303 | , StringRef *Tags, unsigned TagsSize | |||
304 | , unsigned SI | |||
305 | ) | |||
306 | : Attr(attr::AbiTag, R, SI, false) | |||
307 | , tags_Size(TagsSize), tags_(new (Ctx, 16) StringRef[tags_Size]) | |||
308 | { | |||
309 | for (size_t I = 0, E = tags_Size; I != E; | |||
310 | ++I) { | |||
311 | StringRef Ref = Tags[I]; | |||
312 | if (!Ref.empty()) { | |||
313 | char *Mem = new (Ctx, 1) char[Ref.size()]; | |||
314 | std::memcpy(Mem, Ref.data(), Ref.size()); | |||
315 | tags_[I] = StringRef(Mem, Ref.size()); | |||
316 | } | |||
317 | } | |||
318 | } | |||
319 | ||||
320 | AbiTagAttr(SourceRange R, ASTContext &Ctx | |||
321 | , unsigned SI | |||
322 | ) | |||
323 | : Attr(attr::AbiTag, R, SI, false) | |||
324 | , tags_Size(0), tags_(nullptr) | |||
325 | { | |||
326 | } | |||
327 | ||||
328 | AbiTagAttr *clone(ASTContext &C) const; | |||
329 | void printPretty(raw_ostream &OS, | |||
330 | const PrintingPolicy &Policy) const; | |||
331 | const char *getSpelling() const; | |||
332 | typedef StringRef* tags_iterator; | |||
333 | tags_iterator tags_begin() const { return tags_; } | |||
334 | tags_iterator tags_end() const { return tags_ + tags_Size; } | |||
335 | unsigned tags_size() const { return tags_Size; } | |||
336 | llvm::iterator_range<tags_iterator> tags() const { return llvm::make_range(tags_begin(), tags_end()); } | |||
337 | ||||
338 | ||||
339 | ||||
340 | ||||
341 | static bool classof(const Attr *A) { return A->getKind() == attr::AbiTag; } | |||
342 | }; | |||
343 | ||||
344 | class AcquireCapabilityAttr : public InheritableAttr { | |||
345 | unsigned args_Size; | |||
346 | Expr * *args_; | |||
347 | ||||
348 | public: | |||
349 | enum Spelling { | |||
350 | GNU_acquire_capability = 0, | |||
351 | CXX11_clang_acquire_capability = 1, | |||
352 | GNU_acquire_shared_capability = 2, | |||
353 | CXX11_clang_acquire_shared_capability = 3, | |||
354 | GNU_exclusive_lock_function = 4, | |||
355 | GNU_shared_lock_function = 5 | |||
356 | }; | |||
357 | ||||
358 | static AcquireCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
359 | auto *A = new (Ctx) AcquireCapabilityAttr(Loc, Ctx, Args, ArgsSize, S); | |||
360 | A->setImplicit(true); | |||
361 | return A; | |||
362 | } | |||
363 | ||||
364 | AcquireCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
365 | , Expr * *Args, unsigned ArgsSize | |||
366 | , unsigned SI | |||
367 | ) | |||
368 | : InheritableAttr(attr::AcquireCapability, R, SI, true, true) | |||
369 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
370 | { | |||
371 | std::copy(Args, Args + args_Size, args_); | |||
372 | } | |||
373 | ||||
374 | AcquireCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
375 | , unsigned SI | |||
376 | ) | |||
377 | : InheritableAttr(attr::AcquireCapability, R, SI, true, true) | |||
378 | , args_Size(0), args_(nullptr) | |||
379 | { | |||
380 | } | |||
381 | ||||
382 | AcquireCapabilityAttr *clone(ASTContext &C) const; | |||
383 | void printPretty(raw_ostream &OS, | |||
384 | const PrintingPolicy &Policy) const; | |||
385 | const char *getSpelling() const; | |||
386 | Spelling getSemanticSpelling() const { | |||
387 | switch (SpellingListIndex) { | |||
388 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 388); | |||
389 | case 0: return GNU_acquire_capability; | |||
390 | case 1: return CXX11_clang_acquire_capability; | |||
391 | case 2: return GNU_acquire_shared_capability; | |||
392 | case 3: return CXX11_clang_acquire_shared_capability; | |||
393 | case 4: return GNU_exclusive_lock_function; | |||
394 | case 5: return GNU_shared_lock_function; | |||
395 | } | |||
396 | } | |||
397 | bool isShared() const { return SpellingListIndex == 2 || | |||
398 | SpellingListIndex == 3 || | |||
399 | SpellingListIndex == 5; } | |||
400 | typedef Expr ** args_iterator; | |||
401 | args_iterator args_begin() const { return args_; } | |||
402 | args_iterator args_end() const { return args_ + args_Size; } | |||
403 | unsigned args_size() const { return args_Size; } | |||
404 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
405 | ||||
406 | ||||
407 | ||||
408 | ||||
409 | static bool classof(const Attr *A) { return A->getKind() == attr::AcquireCapability; } | |||
410 | }; | |||
411 | ||||
412 | class AcquiredAfterAttr : public InheritableAttr { | |||
413 | unsigned args_Size; | |||
414 | Expr * *args_; | |||
415 | ||||
416 | public: | |||
417 | static AcquiredAfterAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
418 | auto *A = new (Ctx) AcquiredAfterAttr(Loc, Ctx, Args, ArgsSize, 0); | |||
419 | A->setImplicit(true); | |||
420 | return A; | |||
421 | } | |||
422 | ||||
423 | AcquiredAfterAttr(SourceRange R, ASTContext &Ctx | |||
424 | , Expr * *Args, unsigned ArgsSize | |||
425 | , unsigned SI | |||
426 | ) | |||
427 | : InheritableAttr(attr::AcquiredAfter, R, SI, true, true) | |||
428 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
429 | { | |||
430 | std::copy(Args, Args + args_Size, args_); | |||
431 | } | |||
432 | ||||
433 | AcquiredAfterAttr(SourceRange R, ASTContext &Ctx | |||
434 | , unsigned SI | |||
435 | ) | |||
436 | : InheritableAttr(attr::AcquiredAfter, R, SI, true, true) | |||
437 | , args_Size(0), args_(nullptr) | |||
438 | { | |||
439 | } | |||
440 | ||||
441 | AcquiredAfterAttr *clone(ASTContext &C) const; | |||
442 | void printPretty(raw_ostream &OS, | |||
443 | const PrintingPolicy &Policy) const; | |||
444 | const char *getSpelling() const; | |||
445 | typedef Expr ** args_iterator; | |||
446 | args_iterator args_begin() const { return args_; } | |||
447 | args_iterator args_end() const { return args_ + args_Size; } | |||
448 | unsigned args_size() const { return args_Size; } | |||
449 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
450 | ||||
451 | ||||
452 | ||||
453 | ||||
454 | static bool classof(const Attr *A) { return A->getKind() == attr::AcquiredAfter; } | |||
455 | }; | |||
456 | ||||
457 | class AcquiredBeforeAttr : public InheritableAttr { | |||
458 | unsigned args_Size; | |||
459 | Expr * *args_; | |||
460 | ||||
461 | public: | |||
462 | static AcquiredBeforeAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
463 | auto *A = new (Ctx) AcquiredBeforeAttr(Loc, Ctx, Args, ArgsSize, 0); | |||
464 | A->setImplicit(true); | |||
465 | return A; | |||
466 | } | |||
467 | ||||
468 | AcquiredBeforeAttr(SourceRange R, ASTContext &Ctx | |||
469 | , Expr * *Args, unsigned ArgsSize | |||
470 | , unsigned SI | |||
471 | ) | |||
472 | : InheritableAttr(attr::AcquiredBefore, R, SI, true, true) | |||
473 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
474 | { | |||
475 | std::copy(Args, Args + args_Size, args_); | |||
476 | } | |||
477 | ||||
478 | AcquiredBeforeAttr(SourceRange R, ASTContext &Ctx | |||
479 | , unsigned SI | |||
480 | ) | |||
481 | : InheritableAttr(attr::AcquiredBefore, R, SI, true, true) | |||
482 | , args_Size(0), args_(nullptr) | |||
483 | { | |||
484 | } | |||
485 | ||||
486 | AcquiredBeforeAttr *clone(ASTContext &C) const; | |||
487 | void printPretty(raw_ostream &OS, | |||
488 | const PrintingPolicy &Policy) const; | |||
489 | const char *getSpelling() const; | |||
490 | typedef Expr ** args_iterator; | |||
491 | args_iterator args_begin() const { return args_; } | |||
492 | args_iterator args_end() const { return args_ + args_Size; } | |||
493 | unsigned args_size() const { return args_Size; } | |||
494 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
495 | ||||
496 | ||||
497 | ||||
498 | ||||
499 | static bool classof(const Attr *A) { return A->getKind() == attr::AcquiredBefore; } | |||
500 | }; | |||
501 | ||||
502 | class AliasAttr : public Attr { | |||
503 | unsigned aliaseeLength; | |||
504 | char *aliasee; | |||
505 | ||||
506 | public: | |||
507 | static AliasAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Aliasee, SourceRange Loc = SourceRange()) { | |||
508 | auto *A = new (Ctx) AliasAttr(Loc, Ctx, Aliasee, 0); | |||
509 | A->setImplicit(true); | |||
510 | return A; | |||
511 | } | |||
512 | ||||
513 | AliasAttr(SourceRange R, ASTContext &Ctx | |||
514 | , llvm::StringRef Aliasee | |||
515 | , unsigned SI | |||
516 | ) | |||
517 | : Attr(attr::Alias, R, SI, false) | |||
518 | , aliaseeLength(Aliasee.size()),aliasee(new (Ctx, 1) char[aliaseeLength]) | |||
519 | { | |||
520 | if (!Aliasee.empty()) | |||
521 | std::memcpy(aliasee, Aliasee.data(), aliaseeLength); | |||
522 | } | |||
523 | ||||
524 | AliasAttr *clone(ASTContext &C) const; | |||
525 | void printPretty(raw_ostream &OS, | |||
526 | const PrintingPolicy &Policy) const; | |||
527 | const char *getSpelling() const; | |||
528 | llvm::StringRef getAliasee() const { | |||
529 | return llvm::StringRef(aliasee, aliaseeLength); | |||
530 | } | |||
531 | unsigned getAliaseeLength() const { | |||
532 | return aliaseeLength; | |||
533 | } | |||
534 | void setAliasee(ASTContext &C, llvm::StringRef S) { | |||
535 | aliaseeLength = S.size(); | |||
536 | this->aliasee = new (C, 1) char [aliaseeLength]; | |||
537 | if (!S.empty()) | |||
538 | std::memcpy(this->aliasee, S.data(), aliaseeLength); | |||
539 | } | |||
540 | ||||
541 | ||||
542 | ||||
543 | static bool classof(const Attr *A) { return A->getKind() == attr::Alias; } | |||
544 | }; | |||
545 | ||||
546 | class AlignMac68kAttr : public InheritableAttr { | |||
547 | public: | |||
548 | static AlignMac68kAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
549 | auto *A = new (Ctx) AlignMac68kAttr(Loc, Ctx, 0); | |||
550 | A->setImplicit(true); | |||
551 | return A; | |||
552 | } | |||
553 | ||||
554 | AlignMac68kAttr(SourceRange R, ASTContext &Ctx | |||
555 | , unsigned SI | |||
556 | ) | |||
557 | : InheritableAttr(attr::AlignMac68k, R, SI, false, false) | |||
558 | { | |||
559 | } | |||
560 | ||||
561 | AlignMac68kAttr *clone(ASTContext &C) const; | |||
562 | void printPretty(raw_ostream &OS, | |||
563 | const PrintingPolicy &Policy) const; | |||
564 | const char *getSpelling() const; | |||
565 | ||||
566 | ||||
567 | static bool classof(const Attr *A) { return A->getKind() == attr::AlignMac68k; } | |||
568 | }; | |||
569 | ||||
570 | class AlignValueAttr : public Attr { | |||
571 | Expr * alignment; | |||
572 | ||||
573 | public: | |||
574 | static AlignValueAttr *CreateImplicit(ASTContext &Ctx, Expr * Alignment, SourceRange Loc = SourceRange()) { | |||
575 | auto *A = new (Ctx) AlignValueAttr(Loc, Ctx, Alignment, 0); | |||
576 | A->setImplicit(true); | |||
577 | return A; | |||
578 | } | |||
579 | ||||
580 | AlignValueAttr(SourceRange R, ASTContext &Ctx | |||
581 | , Expr * Alignment | |||
582 | , unsigned SI | |||
583 | ) | |||
584 | : Attr(attr::AlignValue, R, SI, false) | |||
585 | , alignment(Alignment) | |||
586 | { | |||
587 | } | |||
588 | ||||
589 | AlignValueAttr *clone(ASTContext &C) const; | |||
590 | void printPretty(raw_ostream &OS, | |||
591 | const PrintingPolicy &Policy) const; | |||
592 | const char *getSpelling() const; | |||
593 | Expr * getAlignment() const { | |||
594 | return alignment; | |||
595 | } | |||
596 | ||||
597 | ||||
598 | ||||
599 | static bool classof(const Attr *A) { return A->getKind() == attr::AlignValue; } | |||
600 | }; | |||
601 | ||||
602 | class AlignedAttr : public InheritableAttr { | |||
603 | bool isalignmentExpr; | |||
604 | union { | |||
605 | Expr *alignmentExpr; | |||
606 | TypeSourceInfo *alignmentType; | |||
607 | }; | |||
608 | ||||
609 | public: | |||
610 | enum Spelling { | |||
611 | GNU_aligned = 0, | |||
612 | CXX11_gnu_aligned = 1, | |||
613 | Declspec_align = 2, | |||
614 | Keyword_alignas = 3, | |||
615 | Keyword_Alignas = 4 | |||
616 | }; | |||
617 | ||||
618 | static AlignedAttr *CreateImplicit(ASTContext &Ctx, Spelling S, bool IsAlignmentExpr, void *Alignment, SourceRange Loc = SourceRange()) { | |||
619 | auto *A = new (Ctx) AlignedAttr(Loc, Ctx, IsAlignmentExpr, Alignment, S); | |||
620 | A->setImplicit(true); | |||
621 | return A; | |||
622 | } | |||
623 | ||||
624 | AlignedAttr(SourceRange R, ASTContext &Ctx | |||
625 | , bool IsAlignmentExpr, void *Alignment | |||
626 | , unsigned SI | |||
627 | ) | |||
628 | : InheritableAttr(attr::Aligned, R, SI, false, false) | |||
629 | , isalignmentExpr(IsAlignmentExpr) | |||
630 | { | |||
631 | if (isalignmentExpr) | |||
632 | alignmentExpr = reinterpret_cast<Expr *>(Alignment); | |||
633 | else | |||
634 | alignmentType = reinterpret_cast<TypeSourceInfo *>(Alignment); | |||
635 | } | |||
636 | ||||
637 | AlignedAttr(SourceRange R, ASTContext &Ctx | |||
638 | , unsigned SI | |||
639 | ) | |||
640 | : InheritableAttr(attr::Aligned, R, SI, false, false) | |||
641 | , isalignmentExpr(false) | |||
642 | { | |||
643 | } | |||
644 | ||||
645 | AlignedAttr *clone(ASTContext &C) const; | |||
646 | void printPretty(raw_ostream &OS, | |||
647 | const PrintingPolicy &Policy) const; | |||
648 | const char *getSpelling() const; | |||
649 | Spelling getSemanticSpelling() const { | |||
650 | switch (SpellingListIndex) { | |||
651 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 651); | |||
652 | case 0: return GNU_aligned; | |||
653 | case 1: return CXX11_gnu_aligned; | |||
654 | case 2: return Declspec_align; | |||
655 | case 3: return Keyword_alignas; | |||
656 | case 4: return Keyword_Alignas; | |||
657 | } | |||
658 | } | |||
659 | bool isGNU() const { return SpellingListIndex == 0 || | |||
660 | SpellingListIndex == 1; } | |||
661 | bool isC11() const { return SpellingListIndex == 4; } | |||
662 | bool isAlignas() const { return SpellingListIndex == 3 || | |||
663 | SpellingListIndex == 4; } | |||
664 | bool isDeclspec() const { return SpellingListIndex == 2; } | |||
665 | bool isAlignmentDependent() const; | |||
666 | unsigned getAlignment(ASTContext &Ctx) const; | |||
667 | bool isAlignmentExpr() const { | |||
668 | return isalignmentExpr; | |||
669 | } | |||
670 | Expr *getAlignmentExpr() const { | |||
671 | assert(isalignmentExpr)(static_cast <bool> (isalignmentExpr) ? void (0) : __assert_fail ("isalignmentExpr", "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 671, __extension__ __PRETTY_FUNCTION__)); | |||
672 | return alignmentExpr; | |||
673 | } | |||
674 | TypeSourceInfo *getAlignmentType() const { | |||
675 | assert(!isalignmentExpr)(static_cast <bool> (!isalignmentExpr) ? void (0) : __assert_fail ("!isalignmentExpr", "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 675, __extension__ __PRETTY_FUNCTION__)); | |||
676 | return alignmentType; | |||
677 | } | |||
678 | ||||
679 | ||||
680 | ||||
681 | static bool classof(const Attr *A) { return A->getKind() == attr::Aligned; } | |||
682 | }; | |||
683 | ||||
684 | class AllocAlignAttr : public InheritableAttr { | |||
685 | int paramIndex; | |||
686 | ||||
687 | public: | |||
688 | static AllocAlignAttr *CreateImplicit(ASTContext &Ctx, int ParamIndex, SourceRange Loc = SourceRange()) { | |||
689 | auto *A = new (Ctx) AllocAlignAttr(Loc, Ctx, ParamIndex, 0); | |||
690 | A->setImplicit(true); | |||
691 | return A; | |||
692 | } | |||
693 | ||||
694 | AllocAlignAttr(SourceRange R, ASTContext &Ctx | |||
695 | , int ParamIndex | |||
696 | , unsigned SI | |||
697 | ) | |||
698 | : InheritableAttr(attr::AllocAlign, R, SI, false, false) | |||
699 | , paramIndex(ParamIndex) | |||
700 | { | |||
701 | } | |||
702 | ||||
703 | AllocAlignAttr *clone(ASTContext &C) const; | |||
704 | void printPretty(raw_ostream &OS, | |||
705 | const PrintingPolicy &Policy) const; | |||
706 | const char *getSpelling() const; | |||
707 | int getParamIndex() const { | |||
708 | return paramIndex; | |||
709 | } | |||
710 | ||||
711 | ||||
712 | ||||
713 | static bool classof(const Attr *A) { return A->getKind() == attr::AllocAlign; } | |||
714 | }; | |||
715 | ||||
716 | class AllocSizeAttr : public InheritableAttr { | |||
717 | int elemSizeParam; | |||
718 | ||||
719 | int numElemsParam; | |||
720 | ||||
721 | public: | |||
722 | static AllocSizeAttr *CreateImplicit(ASTContext &Ctx, int ElemSizeParam, int NumElemsParam, SourceRange Loc = SourceRange()) { | |||
723 | auto *A = new (Ctx) AllocSizeAttr(Loc, Ctx, ElemSizeParam, NumElemsParam, 0); | |||
724 | A->setImplicit(true); | |||
725 | return A; | |||
726 | } | |||
727 | ||||
728 | AllocSizeAttr(SourceRange R, ASTContext &Ctx | |||
729 | , int ElemSizeParam | |||
730 | , int NumElemsParam | |||
731 | , unsigned SI | |||
732 | ) | |||
733 | : InheritableAttr(attr::AllocSize, R, SI, false, false) | |||
734 | , elemSizeParam(ElemSizeParam) | |||
735 | , numElemsParam(NumElemsParam) | |||
736 | { | |||
737 | } | |||
738 | ||||
739 | AllocSizeAttr(SourceRange R, ASTContext &Ctx | |||
740 | , int ElemSizeParam | |||
741 | , unsigned SI | |||
742 | ) | |||
743 | : InheritableAttr(attr::AllocSize, R, SI, false, false) | |||
744 | , elemSizeParam(ElemSizeParam) | |||
745 | , numElemsParam() | |||
746 | { | |||
747 | } | |||
748 | ||||
749 | AllocSizeAttr *clone(ASTContext &C) const; | |||
750 | void printPretty(raw_ostream &OS, | |||
751 | const PrintingPolicy &Policy) const; | |||
752 | const char *getSpelling() const; | |||
753 | int getElemSizeParam() const { | |||
754 | return elemSizeParam; | |||
755 | } | |||
756 | ||||
757 | int getNumElemsParam() const { | |||
758 | return numElemsParam; | |||
759 | } | |||
760 | ||||
761 | ||||
762 | ||||
763 | static bool classof(const Attr *A) { return A->getKind() == attr::AllocSize; } | |||
764 | }; | |||
765 | ||||
766 | class AlwaysInlineAttr : public InheritableAttr { | |||
767 | public: | |||
768 | enum Spelling { | |||
769 | GNU_always_inline = 0, | |||
770 | CXX11_gnu_always_inline = 1, | |||
771 | Keyword_forceinline = 2 | |||
772 | }; | |||
773 | ||||
774 | static AlwaysInlineAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
775 | auto *A = new (Ctx) AlwaysInlineAttr(Loc, Ctx, S); | |||
776 | A->setImplicit(true); | |||
777 | return A; | |||
778 | } | |||
779 | ||||
780 | AlwaysInlineAttr(SourceRange R, ASTContext &Ctx | |||
781 | , unsigned SI | |||
782 | ) | |||
783 | : InheritableAttr(attr::AlwaysInline, R, SI, false, false) | |||
784 | { | |||
785 | } | |||
786 | ||||
787 | AlwaysInlineAttr *clone(ASTContext &C) const; | |||
788 | void printPretty(raw_ostream &OS, | |||
789 | const PrintingPolicy &Policy) const; | |||
790 | const char *getSpelling() const; | |||
791 | Spelling getSemanticSpelling() const { | |||
792 | switch (SpellingListIndex) { | |||
793 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 793); | |||
794 | case 0: return GNU_always_inline; | |||
795 | case 1: return CXX11_gnu_always_inline; | |||
796 | case 2: return Keyword_forceinline; | |||
797 | } | |||
798 | } | |||
799 | ||||
800 | ||||
801 | static bool classof(const Attr *A) { return A->getKind() == attr::AlwaysInline; } | |||
802 | }; | |||
803 | ||||
804 | class AnalyzerNoReturnAttr : public InheritableAttr { | |||
805 | public: | |||
806 | static AnalyzerNoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
807 | auto *A = new (Ctx) AnalyzerNoReturnAttr(Loc, Ctx, 0); | |||
808 | A->setImplicit(true); | |||
809 | return A; | |||
810 | } | |||
811 | ||||
812 | AnalyzerNoReturnAttr(SourceRange R, ASTContext &Ctx | |||
813 | , unsigned SI | |||
814 | ) | |||
815 | : InheritableAttr(attr::AnalyzerNoReturn, R, SI, false, false) | |||
816 | { | |||
817 | } | |||
818 | ||||
819 | AnalyzerNoReturnAttr *clone(ASTContext &C) const; | |||
820 | void printPretty(raw_ostream &OS, | |||
821 | const PrintingPolicy &Policy) const; | |||
822 | const char *getSpelling() const; | |||
823 | ||||
824 | ||||
825 | static bool classof(const Attr *A) { return A->getKind() == attr::AnalyzerNoReturn; } | |||
826 | }; | |||
827 | ||||
828 | class AnnotateAttr : public InheritableParamAttr { | |||
829 | unsigned annotationLength; | |||
830 | char *annotation; | |||
831 | ||||
832 | public: | |||
833 | static AnnotateAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Annotation, SourceRange Loc = SourceRange()) { | |||
834 | auto *A = new (Ctx) AnnotateAttr(Loc, Ctx, Annotation, 0); | |||
835 | A->setImplicit(true); | |||
836 | return A; | |||
837 | } | |||
838 | ||||
839 | AnnotateAttr(SourceRange R, ASTContext &Ctx | |||
840 | , llvm::StringRef Annotation | |||
841 | , unsigned SI | |||
842 | ) | |||
843 | : InheritableParamAttr(attr::Annotate, R, SI, false, false) | |||
844 | , annotationLength(Annotation.size()),annotation(new (Ctx, 1) char[annotationLength]) | |||
845 | { | |||
846 | if (!Annotation.empty()) | |||
847 | std::memcpy(annotation, Annotation.data(), annotationLength); | |||
848 | } | |||
849 | ||||
850 | AnnotateAttr *clone(ASTContext &C) const; | |||
851 | void printPretty(raw_ostream &OS, | |||
852 | const PrintingPolicy &Policy) const; | |||
853 | const char *getSpelling() const; | |||
854 | llvm::StringRef getAnnotation() const { | |||
855 | return llvm::StringRef(annotation, annotationLength); | |||
856 | } | |||
857 | unsigned getAnnotationLength() const { | |||
858 | return annotationLength; | |||
859 | } | |||
860 | void setAnnotation(ASTContext &C, llvm::StringRef S) { | |||
861 | annotationLength = S.size(); | |||
862 | this->annotation = new (C, 1) char [annotationLength]; | |||
863 | if (!S.empty()) | |||
864 | std::memcpy(this->annotation, S.data(), annotationLength); | |||
865 | } | |||
866 | ||||
867 | ||||
868 | ||||
869 | static bool classof(const Attr *A) { return A->getKind() == attr::Annotate; } | |||
870 | }; | |||
871 | ||||
872 | class AnyX86InterruptAttr : public InheritableAttr { | |||
873 | public: | |||
874 | static AnyX86InterruptAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
875 | auto *A = new (Ctx) AnyX86InterruptAttr(Loc, Ctx, 0); | |||
876 | A->setImplicit(true); | |||
877 | return A; | |||
878 | } | |||
879 | ||||
880 | AnyX86InterruptAttr(SourceRange R, ASTContext &Ctx | |||
881 | , unsigned SI | |||
882 | ) | |||
883 | : InheritableAttr(attr::AnyX86Interrupt, R, SI, false, false) | |||
884 | { | |||
885 | } | |||
886 | ||||
887 | AnyX86InterruptAttr *clone(ASTContext &C) const; | |||
888 | void printPretty(raw_ostream &OS, | |||
889 | const PrintingPolicy &Policy) const; | |||
890 | const char *getSpelling() const; | |||
891 | ||||
892 | ||||
893 | static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86Interrupt; } | |||
894 | }; | |||
895 | ||||
896 | class AnyX86NoCallerSavedRegistersAttr : public InheritableAttr { | |||
897 | public: | |||
898 | static AnyX86NoCallerSavedRegistersAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
899 | auto *A = new (Ctx) AnyX86NoCallerSavedRegistersAttr(Loc, Ctx, 0); | |||
900 | A->setImplicit(true); | |||
901 | return A; | |||
902 | } | |||
903 | ||||
904 | AnyX86NoCallerSavedRegistersAttr(SourceRange R, ASTContext &Ctx | |||
905 | , unsigned SI | |||
906 | ) | |||
907 | : InheritableAttr(attr::AnyX86NoCallerSavedRegisters, R, SI, false, false) | |||
908 | { | |||
909 | } | |||
910 | ||||
911 | AnyX86NoCallerSavedRegistersAttr *clone(ASTContext &C) const; | |||
912 | void printPretty(raw_ostream &OS, | |||
913 | const PrintingPolicy &Policy) const; | |||
914 | const char *getSpelling() const; | |||
915 | ||||
916 | ||||
917 | static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86NoCallerSavedRegisters; } | |||
918 | }; | |||
919 | ||||
920 | class ArcWeakrefUnavailableAttr : public InheritableAttr { | |||
921 | public: | |||
922 | static ArcWeakrefUnavailableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
923 | auto *A = new (Ctx) ArcWeakrefUnavailableAttr(Loc, Ctx, 0); | |||
924 | A->setImplicit(true); | |||
925 | return A; | |||
926 | } | |||
927 | ||||
928 | ArcWeakrefUnavailableAttr(SourceRange R, ASTContext &Ctx | |||
929 | , unsigned SI | |||
930 | ) | |||
931 | : InheritableAttr(attr::ArcWeakrefUnavailable, R, SI, false, false) | |||
932 | { | |||
933 | } | |||
934 | ||||
935 | ArcWeakrefUnavailableAttr *clone(ASTContext &C) const; | |||
936 | void printPretty(raw_ostream &OS, | |||
937 | const PrintingPolicy &Policy) const; | |||
938 | const char *getSpelling() const; | |||
939 | ||||
940 | ||||
941 | static bool classof(const Attr *A) { return A->getKind() == attr::ArcWeakrefUnavailable; } | |||
942 | }; | |||
943 | ||||
944 | class ArgumentWithTypeTagAttr : public InheritableAttr { | |||
945 | IdentifierInfo * argumentKind; | |||
946 | ||||
947 | unsigned argumentIdx; | |||
948 | ||||
949 | unsigned typeTagIdx; | |||
950 | ||||
951 | bool isPointer; | |||
952 | ||||
953 | public: | |||
954 | enum Spelling { | |||
955 | GNU_argument_with_type_tag = 0, | |||
956 | CXX11_clang_argument_with_type_tag = 1, | |||
957 | C2x_clang_argument_with_type_tag = 2, | |||
958 | GNU_pointer_with_type_tag = 3, | |||
959 | CXX11_clang_pointer_with_type_tag = 4, | |||
960 | C2x_clang_pointer_with_type_tag = 5 | |||
961 | }; | |||
962 | ||||
963 | static ArgumentWithTypeTagAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * ArgumentKind, unsigned ArgumentIdx, unsigned TypeTagIdx, bool IsPointer, SourceRange Loc = SourceRange()) { | |||
964 | auto *A = new (Ctx) ArgumentWithTypeTagAttr(Loc, Ctx, ArgumentKind, ArgumentIdx, TypeTagIdx, IsPointer, S); | |||
965 | A->setImplicit(true); | |||
966 | return A; | |||
967 | } | |||
968 | ||||
969 | static ArgumentWithTypeTagAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * ArgumentKind, unsigned ArgumentIdx, unsigned TypeTagIdx, SourceRange Loc = SourceRange()) { | |||
970 | auto *A = new (Ctx) ArgumentWithTypeTagAttr(Loc, Ctx, ArgumentKind, ArgumentIdx, TypeTagIdx, S); | |||
971 | A->setImplicit(true); | |||
972 | return A; | |||
973 | } | |||
974 | ||||
975 | ArgumentWithTypeTagAttr(SourceRange R, ASTContext &Ctx | |||
976 | , IdentifierInfo * ArgumentKind | |||
977 | , unsigned ArgumentIdx | |||
978 | , unsigned TypeTagIdx | |||
979 | , bool IsPointer | |||
980 | , unsigned SI | |||
981 | ) | |||
982 | : InheritableAttr(attr::ArgumentWithTypeTag, R, SI, false, false) | |||
983 | , argumentKind(ArgumentKind) | |||
984 | , argumentIdx(ArgumentIdx) | |||
985 | , typeTagIdx(TypeTagIdx) | |||
986 | , isPointer(IsPointer) | |||
987 | { | |||
988 | } | |||
989 | ||||
990 | ArgumentWithTypeTagAttr(SourceRange R, ASTContext &Ctx | |||
991 | , IdentifierInfo * ArgumentKind | |||
992 | , unsigned ArgumentIdx | |||
993 | , unsigned TypeTagIdx | |||
994 | , unsigned SI | |||
995 | ) | |||
996 | : InheritableAttr(attr::ArgumentWithTypeTag, R, SI, false, false) | |||
997 | , argumentKind(ArgumentKind) | |||
998 | , argumentIdx(ArgumentIdx) | |||
999 | , typeTagIdx(TypeTagIdx) | |||
1000 | , isPointer() | |||
1001 | { | |||
1002 | } | |||
1003 | ||||
1004 | ArgumentWithTypeTagAttr *clone(ASTContext &C) const; | |||
1005 | void printPretty(raw_ostream &OS, | |||
1006 | const PrintingPolicy &Policy) const; | |||
1007 | const char *getSpelling() const; | |||
1008 | Spelling getSemanticSpelling() const { | |||
1009 | switch (SpellingListIndex) { | |||
1010 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 1010); | |||
1011 | case 0: return GNU_argument_with_type_tag; | |||
1012 | case 1: return CXX11_clang_argument_with_type_tag; | |||
1013 | case 2: return C2x_clang_argument_with_type_tag; | |||
1014 | case 3: return GNU_pointer_with_type_tag; | |||
1015 | case 4: return CXX11_clang_pointer_with_type_tag; | |||
1016 | case 5: return C2x_clang_pointer_with_type_tag; | |||
1017 | } | |||
1018 | } | |||
1019 | IdentifierInfo * getArgumentKind() const { | |||
1020 | return argumentKind; | |||
1021 | } | |||
1022 | ||||
1023 | unsigned getArgumentIdx() const { | |||
1024 | return argumentIdx; | |||
1025 | } | |||
1026 | ||||
1027 | unsigned getTypeTagIdx() const { | |||
1028 | return typeTagIdx; | |||
1029 | } | |||
1030 | ||||
1031 | bool getIsPointer() const { | |||
1032 | return isPointer; | |||
1033 | } | |||
1034 | ||||
1035 | ||||
1036 | ||||
1037 | static bool classof(const Attr *A) { return A->getKind() == attr::ArgumentWithTypeTag; } | |||
1038 | }; | |||
1039 | ||||
1040 | class ArtificialAttr : public InheritableAttr { | |||
1041 | public: | |||
1042 | static ArtificialAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1043 | auto *A = new (Ctx) ArtificialAttr(Loc, Ctx, 0); | |||
1044 | A->setImplicit(true); | |||
1045 | return A; | |||
1046 | } | |||
1047 | ||||
1048 | ArtificialAttr(SourceRange R, ASTContext &Ctx | |||
1049 | , unsigned SI | |||
1050 | ) | |||
1051 | : InheritableAttr(attr::Artificial, R, SI, false, false) | |||
1052 | { | |||
1053 | } | |||
1054 | ||||
1055 | ArtificialAttr *clone(ASTContext &C) const; | |||
1056 | void printPretty(raw_ostream &OS, | |||
1057 | const PrintingPolicy &Policy) const; | |||
1058 | const char *getSpelling() const; | |||
1059 | ||||
1060 | ||||
1061 | static bool classof(const Attr *A) { return A->getKind() == attr::Artificial; } | |||
1062 | }; | |||
1063 | ||||
1064 | class AsmLabelAttr : public InheritableAttr { | |||
1065 | unsigned labelLength; | |||
1066 | char *label; | |||
1067 | ||||
1068 | public: | |||
1069 | static AsmLabelAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Label, SourceRange Loc = SourceRange()) { | |||
1070 | auto *A = new (Ctx) AsmLabelAttr(Loc, Ctx, Label, 0); | |||
1071 | A->setImplicit(true); | |||
1072 | return A; | |||
1073 | } | |||
1074 | ||||
1075 | AsmLabelAttr(SourceRange R, ASTContext &Ctx | |||
1076 | , llvm::StringRef Label | |||
1077 | , unsigned SI | |||
1078 | ) | |||
1079 | : InheritableAttr(attr::AsmLabel, R, SI, false, false) | |||
1080 | , labelLength(Label.size()),label(new (Ctx, 1) char[labelLength]) | |||
1081 | { | |||
1082 | if (!Label.empty()) | |||
1083 | std::memcpy(label, Label.data(), labelLength); | |||
1084 | } | |||
1085 | ||||
1086 | AsmLabelAttr *clone(ASTContext &C) const; | |||
1087 | void printPretty(raw_ostream &OS, | |||
1088 | const PrintingPolicy &Policy) const; | |||
1089 | const char *getSpelling() const; | |||
1090 | llvm::StringRef getLabel() const { | |||
1091 | return llvm::StringRef(label, labelLength); | |||
1092 | } | |||
1093 | unsigned getLabelLength() const { | |||
1094 | return labelLength; | |||
1095 | } | |||
1096 | void setLabel(ASTContext &C, llvm::StringRef S) { | |||
1097 | labelLength = S.size(); | |||
1098 | this->label = new (C, 1) char [labelLength]; | |||
1099 | if (!S.empty()) | |||
1100 | std::memcpy(this->label, S.data(), labelLength); | |||
1101 | } | |||
1102 | ||||
1103 | ||||
1104 | ||||
1105 | static bool classof(const Attr *A) { return A->getKind() == attr::AsmLabel; } | |||
1106 | }; | |||
1107 | ||||
1108 | class AssertCapabilityAttr : public InheritableAttr { | |||
1109 | unsigned args_Size; | |||
1110 | Expr * *args_; | |||
1111 | ||||
1112 | public: | |||
1113 | enum Spelling { | |||
1114 | GNU_assert_capability = 0, | |||
1115 | CXX11_clang_assert_capability = 1, | |||
1116 | GNU_assert_shared_capability = 2, | |||
1117 | CXX11_clang_assert_shared_capability = 3 | |||
1118 | }; | |||
1119 | ||||
1120 | static AssertCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
1121 | auto *A = new (Ctx) AssertCapabilityAttr(Loc, Ctx, Args, ArgsSize, S); | |||
1122 | A->setImplicit(true); | |||
1123 | return A; | |||
1124 | } | |||
1125 | ||||
1126 | AssertCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
1127 | , Expr * *Args, unsigned ArgsSize | |||
1128 | , unsigned SI | |||
1129 | ) | |||
1130 | : InheritableAttr(attr::AssertCapability, R, SI, true, true) | |||
1131 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
1132 | { | |||
1133 | std::copy(Args, Args + args_Size, args_); | |||
1134 | } | |||
1135 | ||||
1136 | AssertCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
1137 | , unsigned SI | |||
1138 | ) | |||
1139 | : InheritableAttr(attr::AssertCapability, R, SI, true, true) | |||
1140 | , args_Size(0), args_(nullptr) | |||
1141 | { | |||
1142 | } | |||
1143 | ||||
1144 | AssertCapabilityAttr *clone(ASTContext &C) const; | |||
1145 | void printPretty(raw_ostream &OS, | |||
1146 | const PrintingPolicy &Policy) const; | |||
1147 | const char *getSpelling() const; | |||
1148 | Spelling getSemanticSpelling() const { | |||
1149 | switch (SpellingListIndex) { | |||
1150 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 1150); | |||
1151 | case 0: return GNU_assert_capability; | |||
1152 | case 1: return CXX11_clang_assert_capability; | |||
1153 | case 2: return GNU_assert_shared_capability; | |||
1154 | case 3: return CXX11_clang_assert_shared_capability; | |||
1155 | } | |||
1156 | } | |||
1157 | bool isShared() const { return SpellingListIndex == 2 || | |||
1158 | SpellingListIndex == 3; } | |||
1159 | typedef Expr ** args_iterator; | |||
1160 | args_iterator args_begin() const { return args_; } | |||
1161 | args_iterator args_end() const { return args_ + args_Size; } | |||
1162 | unsigned args_size() const { return args_Size; } | |||
1163 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
1164 | ||||
1165 | ||||
1166 | ||||
1167 | ||||
1168 | static bool classof(const Attr *A) { return A->getKind() == attr::AssertCapability; } | |||
1169 | }; | |||
1170 | ||||
1171 | class AssertExclusiveLockAttr : public InheritableAttr { | |||
1172 | unsigned args_Size; | |||
1173 | Expr * *args_; | |||
1174 | ||||
1175 | public: | |||
1176 | static AssertExclusiveLockAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
1177 | auto *A = new (Ctx) AssertExclusiveLockAttr(Loc, Ctx, Args, ArgsSize, 0); | |||
1178 | A->setImplicit(true); | |||
1179 | return A; | |||
1180 | } | |||
1181 | ||||
1182 | AssertExclusiveLockAttr(SourceRange R, ASTContext &Ctx | |||
1183 | , Expr * *Args, unsigned ArgsSize | |||
1184 | , unsigned SI | |||
1185 | ) | |||
1186 | : InheritableAttr(attr::AssertExclusiveLock, R, SI, true, true) | |||
1187 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
1188 | { | |||
1189 | std::copy(Args, Args + args_Size, args_); | |||
1190 | } | |||
1191 | ||||
1192 | AssertExclusiveLockAttr(SourceRange R, ASTContext &Ctx | |||
1193 | , unsigned SI | |||
1194 | ) | |||
1195 | : InheritableAttr(attr::AssertExclusiveLock, R, SI, true, true) | |||
1196 | , args_Size(0), args_(nullptr) | |||
1197 | { | |||
1198 | } | |||
1199 | ||||
1200 | AssertExclusiveLockAttr *clone(ASTContext &C) const; | |||
1201 | void printPretty(raw_ostream &OS, | |||
1202 | const PrintingPolicy &Policy) const; | |||
1203 | const char *getSpelling() const; | |||
1204 | typedef Expr ** args_iterator; | |||
1205 | args_iterator args_begin() const { return args_; } | |||
1206 | args_iterator args_end() const { return args_ + args_Size; } | |||
1207 | unsigned args_size() const { return args_Size; } | |||
1208 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
1209 | ||||
1210 | ||||
1211 | ||||
1212 | ||||
1213 | static bool classof(const Attr *A) { return A->getKind() == attr::AssertExclusiveLock; } | |||
1214 | }; | |||
1215 | ||||
1216 | class AssertSharedLockAttr : public InheritableAttr { | |||
1217 | unsigned args_Size; | |||
1218 | Expr * *args_; | |||
1219 | ||||
1220 | public: | |||
1221 | static AssertSharedLockAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
1222 | auto *A = new (Ctx) AssertSharedLockAttr(Loc, Ctx, Args, ArgsSize, 0); | |||
1223 | A->setImplicit(true); | |||
1224 | return A; | |||
1225 | } | |||
1226 | ||||
1227 | AssertSharedLockAttr(SourceRange R, ASTContext &Ctx | |||
1228 | , Expr * *Args, unsigned ArgsSize | |||
1229 | , unsigned SI | |||
1230 | ) | |||
1231 | : InheritableAttr(attr::AssertSharedLock, R, SI, true, true) | |||
1232 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
1233 | { | |||
1234 | std::copy(Args, Args + args_Size, args_); | |||
1235 | } | |||
1236 | ||||
1237 | AssertSharedLockAttr(SourceRange R, ASTContext &Ctx | |||
1238 | , unsigned SI | |||
1239 | ) | |||
1240 | : InheritableAttr(attr::AssertSharedLock, R, SI, true, true) | |||
1241 | , args_Size(0), args_(nullptr) | |||
1242 | { | |||
1243 | } | |||
1244 | ||||
1245 | AssertSharedLockAttr *clone(ASTContext &C) const; | |||
1246 | void printPretty(raw_ostream &OS, | |||
1247 | const PrintingPolicy &Policy) const; | |||
1248 | const char *getSpelling() const; | |||
1249 | typedef Expr ** args_iterator; | |||
1250 | args_iterator args_begin() const { return args_; } | |||
1251 | args_iterator args_end() const { return args_ + args_Size; } | |||
1252 | unsigned args_size() const { return args_Size; } | |||
1253 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
1254 | ||||
1255 | ||||
1256 | ||||
1257 | ||||
1258 | static bool classof(const Attr *A) { return A->getKind() == attr::AssertSharedLock; } | |||
1259 | }; | |||
1260 | ||||
1261 | class AssumeAlignedAttr : public InheritableAttr { | |||
1262 | Expr * alignment; | |||
1263 | ||||
1264 | Expr * offset; | |||
1265 | ||||
1266 | public: | |||
1267 | static AssumeAlignedAttr *CreateImplicit(ASTContext &Ctx, Expr * Alignment, Expr * Offset, SourceRange Loc = SourceRange()) { | |||
1268 | auto *A = new (Ctx) AssumeAlignedAttr(Loc, Ctx, Alignment, Offset, 0); | |||
1269 | A->setImplicit(true); | |||
1270 | return A; | |||
1271 | } | |||
1272 | ||||
1273 | AssumeAlignedAttr(SourceRange R, ASTContext &Ctx | |||
1274 | , Expr * Alignment | |||
1275 | , Expr * Offset | |||
1276 | , unsigned SI | |||
1277 | ) | |||
1278 | : InheritableAttr(attr::AssumeAligned, R, SI, false, false) | |||
1279 | , alignment(Alignment) | |||
1280 | , offset(Offset) | |||
1281 | { | |||
1282 | } | |||
1283 | ||||
1284 | AssumeAlignedAttr(SourceRange R, ASTContext &Ctx | |||
1285 | , Expr * Alignment | |||
1286 | , unsigned SI | |||
1287 | ) | |||
1288 | : InheritableAttr(attr::AssumeAligned, R, SI, false, false) | |||
1289 | , alignment(Alignment) | |||
1290 | , offset() | |||
1291 | { | |||
1292 | } | |||
1293 | ||||
1294 | AssumeAlignedAttr *clone(ASTContext &C) const; | |||
1295 | void printPretty(raw_ostream &OS, | |||
1296 | const PrintingPolicy &Policy) const; | |||
1297 | const char *getSpelling() const; | |||
1298 | Expr * getAlignment() const { | |||
1299 | return alignment; | |||
1300 | } | |||
1301 | ||||
1302 | Expr * getOffset() const { | |||
1303 | return offset; | |||
1304 | } | |||
1305 | ||||
1306 | ||||
1307 | ||||
1308 | static bool classof(const Attr *A) { return A->getKind() == attr::AssumeAligned; } | |||
1309 | }; | |||
1310 | ||||
1311 | class AvailabilityAttr : public InheritableAttr { | |||
1312 | IdentifierInfo * platform; | |||
1313 | ||||
1314 | VersionTuple introduced; | |||
1315 | ||||
1316 | ||||
1317 | VersionTuple deprecated; | |||
1318 | ||||
1319 | ||||
1320 | VersionTuple obsoleted; | |||
1321 | ||||
1322 | ||||
1323 | bool unavailable; | |||
1324 | ||||
1325 | unsigned messageLength; | |||
1326 | char *message; | |||
1327 | ||||
1328 | bool strict; | |||
1329 | ||||
1330 | unsigned replacementLength; | |||
1331 | char *replacement; | |||
1332 | ||||
1333 | public: | |||
1334 | static AvailabilityAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Platform, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool Unavailable, llvm::StringRef Message, bool Strict, llvm::StringRef Replacement, SourceRange Loc = SourceRange()) { | |||
1335 | auto *A = new (Ctx) AvailabilityAttr(Loc, Ctx, Platform, Introduced, Deprecated, Obsoleted, Unavailable, Message, Strict, Replacement, 0); | |||
1336 | A->setImplicit(true); | |||
1337 | return A; | |||
1338 | } | |||
1339 | ||||
1340 | AvailabilityAttr(SourceRange R, ASTContext &Ctx | |||
1341 | , IdentifierInfo * Platform | |||
1342 | , VersionTuple Introduced | |||
1343 | , VersionTuple Deprecated | |||
1344 | , VersionTuple Obsoleted | |||
1345 | , bool Unavailable | |||
1346 | , llvm::StringRef Message | |||
1347 | , bool Strict | |||
1348 | , llvm::StringRef Replacement | |||
1349 | , unsigned SI | |||
1350 | ) | |||
1351 | : InheritableAttr(attr::Availability, R, SI, false, true) | |||
1352 | , platform(Platform) | |||
1353 | , introduced(Introduced) | |||
1354 | , deprecated(Deprecated) | |||
1355 | , obsoleted(Obsoleted) | |||
1356 | , unavailable(Unavailable) | |||
1357 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
1358 | , strict(Strict) | |||
1359 | , replacementLength(Replacement.size()),replacement(new (Ctx, 1) char[replacementLength]) | |||
1360 | { | |||
1361 | if (!Message.empty()) | |||
1362 | std::memcpy(message, Message.data(), messageLength); | |||
1363 | if (!Replacement.empty()) | |||
1364 | std::memcpy(replacement, Replacement.data(), replacementLength); | |||
1365 | } | |||
1366 | ||||
1367 | AvailabilityAttr *clone(ASTContext &C) const; | |||
1368 | void printPretty(raw_ostream &OS, | |||
1369 | const PrintingPolicy &Policy) const; | |||
1370 | const char *getSpelling() const; | |||
1371 | IdentifierInfo * getPlatform() const { | |||
1372 | return platform; | |||
1373 | } | |||
1374 | ||||
1375 | VersionTuple getIntroduced() const { | |||
1376 | return introduced; | |||
1377 | } | |||
1378 | void setIntroduced(ASTContext &C, VersionTuple V) { | |||
1379 | introduced = V; | |||
1380 | } | |||
1381 | ||||
1382 | VersionTuple getDeprecated() const { | |||
1383 | return deprecated; | |||
1384 | } | |||
1385 | void setDeprecated(ASTContext &C, VersionTuple V) { | |||
1386 | deprecated = V; | |||
1387 | } | |||
1388 | ||||
1389 | VersionTuple getObsoleted() const { | |||
1390 | return obsoleted; | |||
1391 | } | |||
1392 | void setObsoleted(ASTContext &C, VersionTuple V) { | |||
1393 | obsoleted = V; | |||
1394 | } | |||
1395 | ||||
1396 | bool getUnavailable() const { | |||
1397 | return unavailable; | |||
1398 | } | |||
1399 | ||||
1400 | llvm::StringRef getMessage() const { | |||
1401 | return llvm::StringRef(message, messageLength); | |||
1402 | } | |||
1403 | unsigned getMessageLength() const { | |||
1404 | return messageLength; | |||
1405 | } | |||
1406 | void setMessage(ASTContext &C, llvm::StringRef S) { | |||
1407 | messageLength = S.size(); | |||
1408 | this->message = new (C, 1) char [messageLength]; | |||
1409 | if (!S.empty()) | |||
1410 | std::memcpy(this->message, S.data(), messageLength); | |||
1411 | } | |||
1412 | ||||
1413 | bool getStrict() const { | |||
1414 | return strict; | |||
1415 | } | |||
1416 | ||||
1417 | llvm::StringRef getReplacement() const { | |||
1418 | return llvm::StringRef(replacement, replacementLength); | |||
1419 | } | |||
1420 | unsigned getReplacementLength() const { | |||
1421 | return replacementLength; | |||
1422 | } | |||
1423 | void setReplacement(ASTContext &C, llvm::StringRef S) { | |||
1424 | replacementLength = S.size(); | |||
1425 | this->replacement = new (C, 1) char [replacementLength]; | |||
1426 | if (!S.empty()) | |||
1427 | std::memcpy(this->replacement, S.data(), replacementLength); | |||
1428 | } | |||
1429 | ||||
1430 | static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) { | |||
1431 | return llvm::StringSwitch<llvm::StringRef>(Platform) | |||
1432 | .Case("android", "Android") | |||
1433 | .Case("ios", "iOS") | |||
1434 | .Case("macos", "macOS") | |||
1435 | .Case("tvos", "tvOS") | |||
1436 | .Case("watchos", "watchOS") | |||
1437 | .Case("ios_app_extension", "iOS (App Extension)") | |||
1438 | .Case("macos_app_extension", "macOS (App Extension)") | |||
1439 | .Case("tvos_app_extension", "tvOS (App Extension)") | |||
1440 | .Case("watchos_app_extension", "watchOS (App Extension)") | |||
1441 | .Default(llvm::StringRef()); | |||
1442 | } | |||
1443 | static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) { | |||
1444 | return llvm::StringSwitch<llvm::StringRef>(Platform) | |||
1445 | .Case("ios", "iOS") | |||
1446 | .Case("macos", "macOS") | |||
1447 | .Case("tvos", "tvOS") | |||
1448 | .Case("watchos", "watchOS") | |||
1449 | .Case("ios_app_extension", "iOSApplicationExtension") | |||
1450 | .Case("macos_app_extension", "macOSApplicationExtension") | |||
1451 | .Case("tvos_app_extension", "tvOSApplicationExtension") | |||
1452 | .Case("watchos_app_extension", "watchOSApplicationExtension") | |||
1453 | .Default(Platform); | |||
1454 | } | |||
1455 | static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) { | |||
1456 | return llvm::StringSwitch<llvm::StringRef>(Platform) | |||
1457 | .Case("iOS", "ios") | |||
1458 | .Case("macOS", "macos") | |||
1459 | .Case("tvOS", "tvos") | |||
1460 | .Case("watchOS", "watchos") | |||
1461 | .Case("iOSApplicationExtension", "ios_app_extension") | |||
1462 | .Case("macOSApplicationExtension", "macos_app_extension") | |||
1463 | .Case("tvOSApplicationExtension", "tvos_app_extension") | |||
1464 | .Case("watchOSApplicationExtension", "watchos_app_extension") | |||
1465 | .Default(Platform); | |||
1466 | } | |||
1467 | ||||
1468 | static bool classof(const Attr *A) { return A->getKind() == attr::Availability; } | |||
1469 | }; | |||
1470 | ||||
1471 | class BlocksAttr : public InheritableAttr { | |||
1472 | public: | |||
1473 | enum BlockType { | |||
1474 | ByRef | |||
1475 | }; | |||
1476 | private: | |||
1477 | BlockType type; | |||
1478 | ||||
1479 | public: | |||
1480 | static BlocksAttr *CreateImplicit(ASTContext &Ctx, BlockType Type, SourceRange Loc = SourceRange()) { | |||
1481 | auto *A = new (Ctx) BlocksAttr(Loc, Ctx, Type, 0); | |||
1482 | A->setImplicit(true); | |||
1483 | return A; | |||
1484 | } | |||
1485 | ||||
1486 | BlocksAttr(SourceRange R, ASTContext &Ctx | |||
1487 | , BlockType Type | |||
1488 | , unsigned SI | |||
1489 | ) | |||
1490 | : InheritableAttr(attr::Blocks, R, SI, false, false) | |||
1491 | , type(Type) | |||
1492 | { | |||
1493 | } | |||
1494 | ||||
1495 | BlocksAttr *clone(ASTContext &C) const; | |||
1496 | void printPretty(raw_ostream &OS, | |||
1497 | const PrintingPolicy &Policy) const; | |||
1498 | const char *getSpelling() const; | |||
1499 | BlockType getType() const { | |||
1500 | return type; | |||
1501 | } | |||
1502 | ||||
1503 | static bool ConvertStrToBlockType(StringRef Val, BlockType &Out) { | |||
1504 | Optional<BlockType> R = llvm::StringSwitch<Optional<BlockType>>(Val) | |||
1505 | .Case("byref", BlocksAttr::ByRef) | |||
1506 | .Default(Optional<BlockType>()); | |||
1507 | if (R) { | |||
1508 | Out = *R; | |||
1509 | return true; | |||
1510 | } | |||
1511 | return false; | |||
1512 | } | |||
1513 | ||||
1514 | static const char *ConvertBlockTypeToStr(BlockType Val) { | |||
1515 | switch(Val) { | |||
1516 | case BlocksAttr::ByRef: return "byref"; | |||
1517 | } | |||
1518 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 1518); | |||
1519 | } | |||
1520 | ||||
1521 | ||||
1522 | static bool classof(const Attr *A) { return A->getKind() == attr::Blocks; } | |||
1523 | }; | |||
1524 | ||||
1525 | class C11NoReturnAttr : public InheritableAttr { | |||
1526 | public: | |||
1527 | static C11NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1528 | auto *A = new (Ctx) C11NoReturnAttr(Loc, Ctx, 0); | |||
1529 | A->setImplicit(true); | |||
1530 | return A; | |||
1531 | } | |||
1532 | ||||
1533 | C11NoReturnAttr(SourceRange R, ASTContext &Ctx | |||
1534 | , unsigned SI | |||
1535 | ) | |||
1536 | : InheritableAttr(attr::C11NoReturn, R, SI, false, false) | |||
1537 | { | |||
1538 | } | |||
1539 | ||||
1540 | C11NoReturnAttr *clone(ASTContext &C) const; | |||
1541 | void printPretty(raw_ostream &OS, | |||
1542 | const PrintingPolicy &Policy) const; | |||
1543 | const char *getSpelling() const; | |||
1544 | ||||
1545 | ||||
1546 | static bool classof(const Attr *A) { return A->getKind() == attr::C11NoReturn; } | |||
1547 | }; | |||
1548 | ||||
1549 | class CDeclAttr : public InheritableAttr { | |||
1550 | public: | |||
1551 | static CDeclAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1552 | auto *A = new (Ctx) CDeclAttr(Loc, Ctx, 0); | |||
1553 | A->setImplicit(true); | |||
1554 | return A; | |||
1555 | } | |||
1556 | ||||
1557 | CDeclAttr(SourceRange R, ASTContext &Ctx | |||
1558 | , unsigned SI | |||
1559 | ) | |||
1560 | : InheritableAttr(attr::CDecl, R, SI, false, false) | |||
1561 | { | |||
1562 | } | |||
1563 | ||||
1564 | CDeclAttr *clone(ASTContext &C) const; | |||
1565 | void printPretty(raw_ostream &OS, | |||
1566 | const PrintingPolicy &Policy) const; | |||
1567 | const char *getSpelling() const; | |||
1568 | ||||
1569 | ||||
1570 | static bool classof(const Attr *A) { return A->getKind() == attr::CDecl; } | |||
1571 | }; | |||
1572 | ||||
1573 | class CFAuditedTransferAttr : public InheritableAttr { | |||
1574 | public: | |||
1575 | static CFAuditedTransferAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1576 | auto *A = new (Ctx) CFAuditedTransferAttr(Loc, Ctx, 0); | |||
1577 | A->setImplicit(true); | |||
1578 | return A; | |||
1579 | } | |||
1580 | ||||
1581 | CFAuditedTransferAttr(SourceRange R, ASTContext &Ctx | |||
1582 | , unsigned SI | |||
1583 | ) | |||
1584 | : InheritableAttr(attr::CFAuditedTransfer, R, SI, false, false) | |||
1585 | { | |||
1586 | } | |||
1587 | ||||
1588 | CFAuditedTransferAttr *clone(ASTContext &C) const; | |||
1589 | void printPretty(raw_ostream &OS, | |||
1590 | const PrintingPolicy &Policy) const; | |||
1591 | const char *getSpelling() const; | |||
1592 | ||||
1593 | ||||
1594 | static bool classof(const Attr *A) { return A->getKind() == attr::CFAuditedTransfer; } | |||
1595 | }; | |||
1596 | ||||
1597 | class CFConsumedAttr : public InheritableParamAttr { | |||
1598 | public: | |||
1599 | static CFConsumedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1600 | auto *A = new (Ctx) CFConsumedAttr(Loc, Ctx, 0); | |||
1601 | A->setImplicit(true); | |||
1602 | return A; | |||
1603 | } | |||
1604 | ||||
1605 | CFConsumedAttr(SourceRange R, ASTContext &Ctx | |||
1606 | , unsigned SI | |||
1607 | ) | |||
1608 | : InheritableParamAttr(attr::CFConsumed, R, SI, false, false) | |||
1609 | { | |||
1610 | } | |||
1611 | ||||
1612 | CFConsumedAttr *clone(ASTContext &C) const; | |||
1613 | void printPretty(raw_ostream &OS, | |||
1614 | const PrintingPolicy &Policy) const; | |||
1615 | const char *getSpelling() const; | |||
1616 | ||||
1617 | ||||
1618 | static bool classof(const Attr *A) { return A->getKind() == attr::CFConsumed; } | |||
1619 | }; | |||
1620 | ||||
1621 | class CFReturnsNotRetainedAttr : public InheritableAttr { | |||
1622 | public: | |||
1623 | static CFReturnsNotRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1624 | auto *A = new (Ctx) CFReturnsNotRetainedAttr(Loc, Ctx, 0); | |||
1625 | A->setImplicit(true); | |||
1626 | return A; | |||
1627 | } | |||
1628 | ||||
1629 | CFReturnsNotRetainedAttr(SourceRange R, ASTContext &Ctx | |||
1630 | , unsigned SI | |||
1631 | ) | |||
1632 | : InheritableAttr(attr::CFReturnsNotRetained, R, SI, false, false) | |||
1633 | { | |||
1634 | } | |||
1635 | ||||
1636 | CFReturnsNotRetainedAttr *clone(ASTContext &C) const; | |||
1637 | void printPretty(raw_ostream &OS, | |||
1638 | const PrintingPolicy &Policy) const; | |||
1639 | const char *getSpelling() const; | |||
1640 | ||||
1641 | ||||
1642 | static bool classof(const Attr *A) { return A->getKind() == attr::CFReturnsNotRetained; } | |||
1643 | }; | |||
1644 | ||||
1645 | class CFReturnsRetainedAttr : public InheritableAttr { | |||
1646 | public: | |||
1647 | static CFReturnsRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1648 | auto *A = new (Ctx) CFReturnsRetainedAttr(Loc, Ctx, 0); | |||
1649 | A->setImplicit(true); | |||
1650 | return A; | |||
1651 | } | |||
1652 | ||||
1653 | CFReturnsRetainedAttr(SourceRange R, ASTContext &Ctx | |||
1654 | , unsigned SI | |||
1655 | ) | |||
1656 | : InheritableAttr(attr::CFReturnsRetained, R, SI, false, false) | |||
1657 | { | |||
1658 | } | |||
1659 | ||||
1660 | CFReturnsRetainedAttr *clone(ASTContext &C) const; | |||
1661 | void printPretty(raw_ostream &OS, | |||
1662 | const PrintingPolicy &Policy) const; | |||
1663 | const char *getSpelling() const; | |||
1664 | ||||
1665 | ||||
1666 | static bool classof(const Attr *A) { return A->getKind() == attr::CFReturnsRetained; } | |||
1667 | }; | |||
1668 | ||||
1669 | class CFUnknownTransferAttr : public InheritableAttr { | |||
1670 | public: | |||
1671 | static CFUnknownTransferAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1672 | auto *A = new (Ctx) CFUnknownTransferAttr(Loc, Ctx, 0); | |||
1673 | A->setImplicit(true); | |||
1674 | return A; | |||
1675 | } | |||
1676 | ||||
1677 | CFUnknownTransferAttr(SourceRange R, ASTContext &Ctx | |||
1678 | , unsigned SI | |||
1679 | ) | |||
1680 | : InheritableAttr(attr::CFUnknownTransfer, R, SI, false, false) | |||
1681 | { | |||
1682 | } | |||
1683 | ||||
1684 | CFUnknownTransferAttr *clone(ASTContext &C) const; | |||
1685 | void printPretty(raw_ostream &OS, | |||
1686 | const PrintingPolicy &Policy) const; | |||
1687 | const char *getSpelling() const; | |||
1688 | ||||
1689 | ||||
1690 | static bool classof(const Attr *A) { return A->getKind() == attr::CFUnknownTransfer; } | |||
1691 | }; | |||
1692 | ||||
1693 | class CUDAConstantAttr : public InheritableAttr { | |||
1694 | public: | |||
1695 | static CUDAConstantAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1696 | auto *A = new (Ctx) CUDAConstantAttr(Loc, Ctx, 0); | |||
1697 | A->setImplicit(true); | |||
1698 | return A; | |||
1699 | } | |||
1700 | ||||
1701 | CUDAConstantAttr(SourceRange R, ASTContext &Ctx | |||
1702 | , unsigned SI | |||
1703 | ) | |||
1704 | : InheritableAttr(attr::CUDAConstant, R, SI, false, false) | |||
1705 | { | |||
1706 | } | |||
1707 | ||||
1708 | CUDAConstantAttr *clone(ASTContext &C) const; | |||
1709 | void printPretty(raw_ostream &OS, | |||
1710 | const PrintingPolicy &Policy) const; | |||
1711 | const char *getSpelling() const; | |||
1712 | ||||
1713 | ||||
1714 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDAConstant; } | |||
1715 | }; | |||
1716 | ||||
1717 | class CUDADeviceAttr : public InheritableAttr { | |||
1718 | public: | |||
1719 | static CUDADeviceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1720 | auto *A = new (Ctx) CUDADeviceAttr(Loc, Ctx, 0); | |||
1721 | A->setImplicit(true); | |||
1722 | return A; | |||
1723 | } | |||
1724 | ||||
1725 | CUDADeviceAttr(SourceRange R, ASTContext &Ctx | |||
1726 | , unsigned SI | |||
1727 | ) | |||
1728 | : InheritableAttr(attr::CUDADevice, R, SI, false, false) | |||
1729 | { | |||
1730 | } | |||
1731 | ||||
1732 | CUDADeviceAttr *clone(ASTContext &C) const; | |||
1733 | void printPretty(raw_ostream &OS, | |||
1734 | const PrintingPolicy &Policy) const; | |||
1735 | const char *getSpelling() const; | |||
1736 | ||||
1737 | ||||
1738 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDADevice; } | |||
1739 | }; | |||
1740 | ||||
1741 | class CUDAGlobalAttr : public InheritableAttr { | |||
1742 | public: | |||
1743 | static CUDAGlobalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1744 | auto *A = new (Ctx) CUDAGlobalAttr(Loc, Ctx, 0); | |||
1745 | A->setImplicit(true); | |||
1746 | return A; | |||
1747 | } | |||
1748 | ||||
1749 | CUDAGlobalAttr(SourceRange R, ASTContext &Ctx | |||
1750 | , unsigned SI | |||
1751 | ) | |||
1752 | : InheritableAttr(attr::CUDAGlobal, R, SI, false, false) | |||
1753 | { | |||
1754 | } | |||
1755 | ||||
1756 | CUDAGlobalAttr *clone(ASTContext &C) const; | |||
1757 | void printPretty(raw_ostream &OS, | |||
1758 | const PrintingPolicy &Policy) const; | |||
1759 | const char *getSpelling() const; | |||
1760 | ||||
1761 | ||||
1762 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDAGlobal; } | |||
1763 | }; | |||
1764 | ||||
1765 | class CUDAHostAttr : public InheritableAttr { | |||
1766 | public: | |||
1767 | static CUDAHostAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1768 | auto *A = new (Ctx) CUDAHostAttr(Loc, Ctx, 0); | |||
1769 | A->setImplicit(true); | |||
1770 | return A; | |||
1771 | } | |||
1772 | ||||
1773 | CUDAHostAttr(SourceRange R, ASTContext &Ctx | |||
1774 | , unsigned SI | |||
1775 | ) | |||
1776 | : InheritableAttr(attr::CUDAHost, R, SI, false, false) | |||
1777 | { | |||
1778 | } | |||
1779 | ||||
1780 | CUDAHostAttr *clone(ASTContext &C) const; | |||
1781 | void printPretty(raw_ostream &OS, | |||
1782 | const PrintingPolicy &Policy) const; | |||
1783 | const char *getSpelling() const; | |||
1784 | ||||
1785 | ||||
1786 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDAHost; } | |||
1787 | }; | |||
1788 | ||||
1789 | class CUDAInvalidTargetAttr : public InheritableAttr { | |||
1790 | public: | |||
1791 | static CUDAInvalidTargetAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1792 | auto *A = new (Ctx) CUDAInvalidTargetAttr(Loc, Ctx, 0); | |||
1793 | A->setImplicit(true); | |||
1794 | return A; | |||
1795 | } | |||
1796 | ||||
1797 | CUDAInvalidTargetAttr(SourceRange R, ASTContext &Ctx | |||
1798 | , unsigned SI | |||
1799 | ) | |||
1800 | : InheritableAttr(attr::CUDAInvalidTarget, R, SI, false, false) | |||
1801 | { | |||
1802 | } | |||
1803 | ||||
1804 | CUDAInvalidTargetAttr *clone(ASTContext &C) const; | |||
1805 | void printPretty(raw_ostream &OS, | |||
1806 | const PrintingPolicy &Policy) const; | |||
1807 | const char *getSpelling() const; | |||
1808 | ||||
1809 | ||||
1810 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDAInvalidTarget; } | |||
1811 | }; | |||
1812 | ||||
1813 | class CUDALaunchBoundsAttr : public InheritableAttr { | |||
1814 | Expr * maxThreads; | |||
1815 | ||||
1816 | Expr * minBlocks; | |||
1817 | ||||
1818 | public: | |||
1819 | static CUDALaunchBoundsAttr *CreateImplicit(ASTContext &Ctx, Expr * MaxThreads, Expr * MinBlocks, SourceRange Loc = SourceRange()) { | |||
1820 | auto *A = new (Ctx) CUDALaunchBoundsAttr(Loc, Ctx, MaxThreads, MinBlocks, 0); | |||
1821 | A->setImplicit(true); | |||
1822 | return A; | |||
1823 | } | |||
1824 | ||||
1825 | CUDALaunchBoundsAttr(SourceRange R, ASTContext &Ctx | |||
1826 | , Expr * MaxThreads | |||
1827 | , Expr * MinBlocks | |||
1828 | , unsigned SI | |||
1829 | ) | |||
1830 | : InheritableAttr(attr::CUDALaunchBounds, R, SI, false, false) | |||
1831 | , maxThreads(MaxThreads) | |||
1832 | , minBlocks(MinBlocks) | |||
1833 | { | |||
1834 | } | |||
1835 | ||||
1836 | CUDALaunchBoundsAttr(SourceRange R, ASTContext &Ctx | |||
1837 | , Expr * MaxThreads | |||
1838 | , unsigned SI | |||
1839 | ) | |||
1840 | : InheritableAttr(attr::CUDALaunchBounds, R, SI, false, false) | |||
1841 | , maxThreads(MaxThreads) | |||
1842 | , minBlocks() | |||
1843 | { | |||
1844 | } | |||
1845 | ||||
1846 | CUDALaunchBoundsAttr *clone(ASTContext &C) const; | |||
1847 | void printPretty(raw_ostream &OS, | |||
1848 | const PrintingPolicy &Policy) const; | |||
1849 | const char *getSpelling() const; | |||
1850 | Expr * getMaxThreads() const { | |||
1851 | return maxThreads; | |||
1852 | } | |||
1853 | ||||
1854 | Expr * getMinBlocks() const { | |||
1855 | return minBlocks; | |||
1856 | } | |||
1857 | ||||
1858 | ||||
1859 | ||||
1860 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDALaunchBounds; } | |||
1861 | }; | |||
1862 | ||||
1863 | class CUDASharedAttr : public InheritableAttr { | |||
1864 | public: | |||
1865 | static CUDASharedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1866 | auto *A = new (Ctx) CUDASharedAttr(Loc, Ctx, 0); | |||
1867 | A->setImplicit(true); | |||
1868 | return A; | |||
1869 | } | |||
1870 | ||||
1871 | CUDASharedAttr(SourceRange R, ASTContext &Ctx | |||
1872 | , unsigned SI | |||
1873 | ) | |||
1874 | : InheritableAttr(attr::CUDAShared, R, SI, false, false) | |||
1875 | { | |||
1876 | } | |||
1877 | ||||
1878 | CUDASharedAttr *clone(ASTContext &C) const; | |||
1879 | void printPretty(raw_ostream &OS, | |||
1880 | const PrintingPolicy &Policy) const; | |||
1881 | const char *getSpelling() const; | |||
1882 | ||||
1883 | ||||
1884 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDAShared; } | |||
1885 | }; | |||
1886 | ||||
1887 | class CXX11NoReturnAttr : public InheritableAttr { | |||
1888 | public: | |||
1889 | static CXX11NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1890 | auto *A = new (Ctx) CXX11NoReturnAttr(Loc, Ctx, 0); | |||
1891 | A->setImplicit(true); | |||
1892 | return A; | |||
1893 | } | |||
1894 | ||||
1895 | CXX11NoReturnAttr(SourceRange R, ASTContext &Ctx | |||
1896 | , unsigned SI | |||
1897 | ) | |||
1898 | : InheritableAttr(attr::CXX11NoReturn, R, SI, false, false) | |||
1899 | { | |||
1900 | } | |||
1901 | ||||
1902 | CXX11NoReturnAttr *clone(ASTContext &C) const; | |||
1903 | void printPretty(raw_ostream &OS, | |||
1904 | const PrintingPolicy &Policy) const; | |||
1905 | const char *getSpelling() const; | |||
1906 | ||||
1907 | ||||
1908 | static bool classof(const Attr *A) { return A->getKind() == attr::CXX11NoReturn; } | |||
1909 | }; | |||
1910 | ||||
1911 | class CallableWhenAttr : public InheritableAttr { | |||
1912 | public: | |||
1913 | enum ConsumedState { | |||
1914 | Unknown, | |||
1915 | Consumed, | |||
1916 | Unconsumed | |||
1917 | }; | |||
1918 | private: | |||
1919 | unsigned callableStates_Size; | |||
1920 | ConsumedState *callableStates_; | |||
1921 | ||||
1922 | public: | |||
1923 | static CallableWhenAttr *CreateImplicit(ASTContext &Ctx, ConsumedState *CallableStates, unsigned CallableStatesSize, SourceRange Loc = SourceRange()) { | |||
1924 | auto *A = new (Ctx) CallableWhenAttr(Loc, Ctx, CallableStates, CallableStatesSize, 0); | |||
1925 | A->setImplicit(true); | |||
1926 | return A; | |||
1927 | } | |||
1928 | ||||
1929 | CallableWhenAttr(SourceRange R, ASTContext &Ctx | |||
1930 | , ConsumedState *CallableStates, unsigned CallableStatesSize | |||
1931 | , unsigned SI | |||
1932 | ) | |||
1933 | : InheritableAttr(attr::CallableWhen, R, SI, false, false) | |||
1934 | , callableStates_Size(CallableStatesSize), callableStates_(new (Ctx, 16) ConsumedState[callableStates_Size]) | |||
1935 | { | |||
1936 | std::copy(CallableStates, CallableStates + callableStates_Size, callableStates_); | |||
1937 | } | |||
1938 | ||||
1939 | CallableWhenAttr(SourceRange R, ASTContext &Ctx | |||
1940 | , unsigned SI | |||
1941 | ) | |||
1942 | : InheritableAttr(attr::CallableWhen, R, SI, false, false) | |||
1943 | , callableStates_Size(0), callableStates_(nullptr) | |||
1944 | { | |||
1945 | } | |||
1946 | ||||
1947 | CallableWhenAttr *clone(ASTContext &C) const; | |||
1948 | void printPretty(raw_ostream &OS, | |||
1949 | const PrintingPolicy &Policy) const; | |||
1950 | const char *getSpelling() const; | |||
1951 | typedef ConsumedState* callableStates_iterator; | |||
1952 | callableStates_iterator callableStates_begin() const { return callableStates_; } | |||
1953 | callableStates_iterator callableStates_end() const { return callableStates_ + callableStates_Size; } | |||
1954 | unsigned callableStates_size() const { return callableStates_Size; } | |||
1955 | llvm::iterator_range<callableStates_iterator> callableStates() const { return llvm::make_range(callableStates_begin(), callableStates_end()); } | |||
1956 | ||||
1957 | ||||
1958 | static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) { | |||
1959 | Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val) | |||
1960 | .Case("unknown", CallableWhenAttr::Unknown) | |||
1961 | .Case("consumed", CallableWhenAttr::Consumed) | |||
1962 | .Case("unconsumed", CallableWhenAttr::Unconsumed) | |||
1963 | .Default(Optional<ConsumedState>()); | |||
1964 | if (R) { | |||
1965 | Out = *R; | |||
1966 | return true; | |||
1967 | } | |||
1968 | return false; | |||
1969 | } | |||
1970 | ||||
1971 | static const char *ConvertConsumedStateToStr(ConsumedState Val) { | |||
1972 | switch(Val) { | |||
1973 | case CallableWhenAttr::Unknown: return "unknown"; | |||
1974 | case CallableWhenAttr::Consumed: return "consumed"; | |||
1975 | case CallableWhenAttr::Unconsumed: return "unconsumed"; | |||
1976 | } | |||
1977 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 1977); | |||
1978 | } | |||
1979 | ||||
1980 | ||||
1981 | static bool classof(const Attr *A) { return A->getKind() == attr::CallableWhen; } | |||
1982 | }; | |||
1983 | ||||
1984 | class CapabilityAttr : public InheritableAttr { | |||
1985 | unsigned nameLength; | |||
1986 | char *name; | |||
1987 | ||||
1988 | public: | |||
1989 | enum Spelling { | |||
1990 | GNU_capability = 0, | |||
1991 | CXX11_clang_capability = 1, | |||
1992 | GNU_shared_capability = 2, | |||
1993 | CXX11_clang_shared_capability = 3 | |||
1994 | }; | |||
1995 | ||||
1996 | static CapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, llvm::StringRef Name, SourceRange Loc = SourceRange()) { | |||
1997 | auto *A = new (Ctx) CapabilityAttr(Loc, Ctx, Name, S); | |||
1998 | A->setImplicit(true); | |||
1999 | return A; | |||
2000 | } | |||
2001 | ||||
2002 | CapabilityAttr(SourceRange R, ASTContext &Ctx | |||
2003 | , llvm::StringRef Name | |||
2004 | , unsigned SI | |||
2005 | ) | |||
2006 | : InheritableAttr(attr::Capability, R, SI, false, false) | |||
2007 | , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength]) | |||
2008 | { | |||
2009 | if (!Name.empty()) | |||
2010 | std::memcpy(name, Name.data(), nameLength); | |||
2011 | } | |||
2012 | ||||
2013 | CapabilityAttr *clone(ASTContext &C) const; | |||
2014 | void printPretty(raw_ostream &OS, | |||
2015 | const PrintingPolicy &Policy) const; | |||
2016 | const char *getSpelling() const; | |||
2017 | Spelling getSemanticSpelling() const { | |||
2018 | switch (SpellingListIndex) { | |||
2019 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 2019); | |||
2020 | case 0: return GNU_capability; | |||
2021 | case 1: return CXX11_clang_capability; | |||
2022 | case 2: return GNU_shared_capability; | |||
2023 | case 3: return CXX11_clang_shared_capability; | |||
2024 | } | |||
2025 | } | |||
2026 | bool isShared() const { return SpellingListIndex == 2 || | |||
2027 | SpellingListIndex == 3; } | |||
2028 | llvm::StringRef getName() const { | |||
2029 | return llvm::StringRef(name, nameLength); | |||
2030 | } | |||
2031 | unsigned getNameLength() const { | |||
2032 | return nameLength; | |||
2033 | } | |||
2034 | void setName(ASTContext &C, llvm::StringRef S) { | |||
2035 | nameLength = S.size(); | |||
2036 | this->name = new (C, 1) char [nameLength]; | |||
2037 | if (!S.empty()) | |||
2038 | std::memcpy(this->name, S.data(), nameLength); | |||
2039 | } | |||
2040 | ||||
2041 | ||||
2042 | bool isMutex() const { return getName().equals_lower("mutex"); } | |||
2043 | bool isRole() const { return getName().equals_lower("role"); } | |||
2044 | ||||
2045 | ||||
2046 | static bool classof(const Attr *A) { return A->getKind() == attr::Capability; } | |||
2047 | }; | |||
2048 | ||||
2049 | class CapturedRecordAttr : public InheritableAttr { | |||
2050 | public: | |||
2051 | static CapturedRecordAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2052 | auto *A = new (Ctx) CapturedRecordAttr(Loc, Ctx, 0); | |||
2053 | A->setImplicit(true); | |||
2054 | return A; | |||
2055 | } | |||
2056 | ||||
2057 | CapturedRecordAttr(SourceRange R, ASTContext &Ctx | |||
2058 | , unsigned SI | |||
2059 | ) | |||
2060 | : InheritableAttr(attr::CapturedRecord, R, SI, false, false) | |||
2061 | { | |||
2062 | } | |||
2063 | ||||
2064 | CapturedRecordAttr *clone(ASTContext &C) const; | |||
2065 | void printPretty(raw_ostream &OS, | |||
2066 | const PrintingPolicy &Policy) const; | |||
2067 | const char *getSpelling() const; | |||
2068 | ||||
2069 | ||||
2070 | static bool classof(const Attr *A) { return A->getKind() == attr::CapturedRecord; } | |||
2071 | }; | |||
2072 | ||||
2073 | class CarriesDependencyAttr : public InheritableParamAttr { | |||
2074 | public: | |||
2075 | static CarriesDependencyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2076 | auto *A = new (Ctx) CarriesDependencyAttr(Loc, Ctx, 0); | |||
2077 | A->setImplicit(true); | |||
2078 | return A; | |||
2079 | } | |||
2080 | ||||
2081 | CarriesDependencyAttr(SourceRange R, ASTContext &Ctx | |||
2082 | , unsigned SI | |||
2083 | ) | |||
2084 | : InheritableParamAttr(attr::CarriesDependency, R, SI, false, false) | |||
2085 | { | |||
2086 | } | |||
2087 | ||||
2088 | CarriesDependencyAttr *clone(ASTContext &C) const; | |||
2089 | void printPretty(raw_ostream &OS, | |||
2090 | const PrintingPolicy &Policy) const; | |||
2091 | const char *getSpelling() const; | |||
2092 | ||||
2093 | ||||
2094 | static bool classof(const Attr *A) { return A->getKind() == attr::CarriesDependency; } | |||
2095 | }; | |||
2096 | ||||
2097 | class CleanupAttr : public InheritableAttr { | |||
2098 | FunctionDecl * functionDecl; | |||
2099 | ||||
2100 | public: | |||
2101 | static CleanupAttr *CreateImplicit(ASTContext &Ctx, FunctionDecl * FunctionDecl, SourceRange Loc = SourceRange()) { | |||
2102 | auto *A = new (Ctx) CleanupAttr(Loc, Ctx, FunctionDecl, 0); | |||
2103 | A->setImplicit(true); | |||
2104 | return A; | |||
2105 | } | |||
2106 | ||||
2107 | CleanupAttr(SourceRange R, ASTContext &Ctx | |||
2108 | , FunctionDecl * FunctionDecl | |||
2109 | , unsigned SI | |||
2110 | ) | |||
2111 | : InheritableAttr(attr::Cleanup, R, SI, false, false) | |||
2112 | , functionDecl(FunctionDecl) | |||
2113 | { | |||
2114 | } | |||
2115 | ||||
2116 | CleanupAttr *clone(ASTContext &C) const; | |||
2117 | void printPretty(raw_ostream &OS, | |||
2118 | const PrintingPolicy &Policy) const; | |||
2119 | const char *getSpelling() const; | |||
2120 | FunctionDecl * getFunctionDecl() const { | |||
2121 | return functionDecl; | |||
2122 | } | |||
2123 | ||||
2124 | ||||
2125 | ||||
2126 | static bool classof(const Attr *A) { return A->getKind() == attr::Cleanup; } | |||
2127 | }; | |||
2128 | ||||
2129 | class ColdAttr : public InheritableAttr { | |||
2130 | public: | |||
2131 | static ColdAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2132 | auto *A = new (Ctx) ColdAttr(Loc, Ctx, 0); | |||
2133 | A->setImplicit(true); | |||
2134 | return A; | |||
2135 | } | |||
2136 | ||||
2137 | ColdAttr(SourceRange R, ASTContext &Ctx | |||
2138 | , unsigned SI | |||
2139 | ) | |||
2140 | : InheritableAttr(attr::Cold, R, SI, false, false) | |||
2141 | { | |||
2142 | } | |||
2143 | ||||
2144 | ColdAttr *clone(ASTContext &C) const; | |||
2145 | void printPretty(raw_ostream &OS, | |||
2146 | const PrintingPolicy &Policy) const; | |||
2147 | const char *getSpelling() const; | |||
2148 | ||||
2149 | ||||
2150 | static bool classof(const Attr *A) { return A->getKind() == attr::Cold; } | |||
2151 | }; | |||
2152 | ||||
2153 | class CommonAttr : public InheritableAttr { | |||
2154 | public: | |||
2155 | static CommonAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2156 | auto *A = new (Ctx) CommonAttr(Loc, Ctx, 0); | |||
2157 | A->setImplicit(true); | |||
2158 | return A; | |||
2159 | } | |||
2160 | ||||
2161 | CommonAttr(SourceRange R, ASTContext &Ctx | |||
2162 | , unsigned SI | |||
2163 | ) | |||
2164 | : InheritableAttr(attr::Common, R, SI, false, false) | |||
2165 | { | |||
2166 | } | |||
2167 | ||||
2168 | CommonAttr *clone(ASTContext &C) const; | |||
2169 | void printPretty(raw_ostream &OS, | |||
2170 | const PrintingPolicy &Policy) const; | |||
2171 | const char *getSpelling() const; | |||
2172 | ||||
2173 | ||||
2174 | static bool classof(const Attr *A) { return A->getKind() == attr::Common; } | |||
2175 | }; | |||
2176 | ||||
2177 | class ConstAttr : public InheritableAttr { | |||
2178 | public: | |||
2179 | static ConstAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2180 | auto *A = new (Ctx) ConstAttr(Loc, Ctx, 0); | |||
2181 | A->setImplicit(true); | |||
2182 | return A; | |||
2183 | } | |||
2184 | ||||
2185 | ConstAttr(SourceRange R, ASTContext &Ctx | |||
2186 | , unsigned SI | |||
2187 | ) | |||
2188 | : InheritableAttr(attr::Const, R, SI, false, false) | |||
2189 | { | |||
2190 | } | |||
2191 | ||||
2192 | ConstAttr *clone(ASTContext &C) const; | |||
2193 | void printPretty(raw_ostream &OS, | |||
2194 | const PrintingPolicy &Policy) const; | |||
2195 | const char *getSpelling() const; | |||
2196 | ||||
2197 | ||||
2198 | static bool classof(const Attr *A) { return A->getKind() == attr::Const; } | |||
2199 | }; | |||
2200 | ||||
2201 | class ConstructorAttr : public InheritableAttr { | |||
2202 | int priority; | |||
2203 | ||||
2204 | public: | |||
2205 | static ConstructorAttr *CreateImplicit(ASTContext &Ctx, int Priority, SourceRange Loc = SourceRange()) { | |||
2206 | auto *A = new (Ctx) ConstructorAttr(Loc, Ctx, Priority, 0); | |||
2207 | A->setImplicit(true); | |||
2208 | return A; | |||
2209 | } | |||
2210 | ||||
2211 | ConstructorAttr(SourceRange R, ASTContext &Ctx | |||
2212 | , int Priority | |||
2213 | , unsigned SI | |||
2214 | ) | |||
2215 | : InheritableAttr(attr::Constructor, R, SI, false, false) | |||
2216 | , priority(Priority) | |||
2217 | { | |||
2218 | } | |||
2219 | ||||
2220 | ConstructorAttr(SourceRange R, ASTContext &Ctx | |||
2221 | , unsigned SI | |||
2222 | ) | |||
2223 | : InheritableAttr(attr::Constructor, R, SI, false, false) | |||
2224 | , priority() | |||
2225 | { | |||
2226 | } | |||
2227 | ||||
2228 | ConstructorAttr *clone(ASTContext &C) const; | |||
2229 | void printPretty(raw_ostream &OS, | |||
2230 | const PrintingPolicy &Policy) const; | |||
2231 | const char *getSpelling() const; | |||
2232 | int getPriority() const { | |||
2233 | return priority; | |||
2234 | } | |||
2235 | ||||
2236 | static const int DefaultPriority = 65535; | |||
2237 | ||||
2238 | ||||
2239 | ||||
2240 | static bool classof(const Attr *A) { return A->getKind() == attr::Constructor; } | |||
2241 | }; | |||
2242 | ||||
2243 | class ConsumableAttr : public InheritableAttr { | |||
2244 | public: | |||
2245 | enum ConsumedState { | |||
2246 | Unknown, | |||
2247 | Consumed, | |||
2248 | Unconsumed | |||
2249 | }; | |||
2250 | private: | |||
2251 | ConsumedState defaultState; | |||
2252 | ||||
2253 | public: | |||
2254 | static ConsumableAttr *CreateImplicit(ASTContext &Ctx, ConsumedState DefaultState, SourceRange Loc = SourceRange()) { | |||
2255 | auto *A = new (Ctx) ConsumableAttr(Loc, Ctx, DefaultState, 0); | |||
2256 | A->setImplicit(true); | |||
2257 | return A; | |||
2258 | } | |||
2259 | ||||
2260 | ConsumableAttr(SourceRange R, ASTContext &Ctx | |||
2261 | , ConsumedState DefaultState | |||
2262 | , unsigned SI | |||
2263 | ) | |||
2264 | : InheritableAttr(attr::Consumable, R, SI, false, false) | |||
2265 | , defaultState(DefaultState) | |||
2266 | { | |||
2267 | } | |||
2268 | ||||
2269 | ConsumableAttr *clone(ASTContext &C) const; | |||
2270 | void printPretty(raw_ostream &OS, | |||
2271 | const PrintingPolicy &Policy) const; | |||
2272 | const char *getSpelling() const; | |||
2273 | ConsumedState getDefaultState() const { | |||
2274 | return defaultState; | |||
2275 | } | |||
2276 | ||||
2277 | static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) { | |||
2278 | Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val) | |||
2279 | .Case("unknown", ConsumableAttr::Unknown) | |||
2280 | .Case("consumed", ConsumableAttr::Consumed) | |||
2281 | .Case("unconsumed", ConsumableAttr::Unconsumed) | |||
2282 | .Default(Optional<ConsumedState>()); | |||
2283 | if (R) { | |||
2284 | Out = *R; | |||
2285 | return true; | |||
2286 | } | |||
2287 | return false; | |||
2288 | } | |||
2289 | ||||
2290 | static const char *ConvertConsumedStateToStr(ConsumedState Val) { | |||
2291 | switch(Val) { | |||
2292 | case ConsumableAttr::Unknown: return "unknown"; | |||
2293 | case ConsumableAttr::Consumed: return "consumed"; | |||
2294 | case ConsumableAttr::Unconsumed: return "unconsumed"; | |||
2295 | } | |||
2296 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 2296); | |||
2297 | } | |||
2298 | ||||
2299 | ||||
2300 | static bool classof(const Attr *A) { return A->getKind() == attr::Consumable; } | |||
2301 | }; | |||
2302 | ||||
2303 | class ConsumableAutoCastAttr : public InheritableAttr { | |||
2304 | public: | |||
2305 | static ConsumableAutoCastAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2306 | auto *A = new (Ctx) ConsumableAutoCastAttr(Loc, Ctx, 0); | |||
2307 | A->setImplicit(true); | |||
2308 | return A; | |||
2309 | } | |||
2310 | ||||
2311 | ConsumableAutoCastAttr(SourceRange R, ASTContext &Ctx | |||
2312 | , unsigned SI | |||
2313 | ) | |||
2314 | : InheritableAttr(attr::ConsumableAutoCast, R, SI, false, false) | |||
2315 | { | |||
2316 | } | |||
2317 | ||||
2318 | ConsumableAutoCastAttr *clone(ASTContext &C) const; | |||
2319 | void printPretty(raw_ostream &OS, | |||
2320 | const PrintingPolicy &Policy) const; | |||
2321 | const char *getSpelling() const; | |||
2322 | ||||
2323 | ||||
2324 | static bool classof(const Attr *A) { return A->getKind() == attr::ConsumableAutoCast; } | |||
2325 | }; | |||
2326 | ||||
2327 | class ConsumableSetOnReadAttr : public InheritableAttr { | |||
2328 | public: | |||
2329 | static ConsumableSetOnReadAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2330 | auto *A = new (Ctx) ConsumableSetOnReadAttr(Loc, Ctx, 0); | |||
2331 | A->setImplicit(true); | |||
2332 | return A; | |||
2333 | } | |||
2334 | ||||
2335 | ConsumableSetOnReadAttr(SourceRange R, ASTContext &Ctx | |||
2336 | , unsigned SI | |||
2337 | ) | |||
2338 | : InheritableAttr(attr::ConsumableSetOnRead, R, SI, false, false) | |||
2339 | { | |||
2340 | } | |||
2341 | ||||
2342 | ConsumableSetOnReadAttr *clone(ASTContext &C) const; | |||
2343 | void printPretty(raw_ostream &OS, | |||
2344 | const PrintingPolicy &Policy) const; | |||
2345 | const char *getSpelling() const; | |||
2346 | ||||
2347 | ||||
2348 | static bool classof(const Attr *A) { return A->getKind() == attr::ConsumableSetOnRead; } | |||
2349 | }; | |||
2350 | ||||
2351 | class ConvergentAttr : public InheritableAttr { | |||
2352 | public: | |||
2353 | static ConvergentAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2354 | auto *A = new (Ctx) ConvergentAttr(Loc, Ctx, 0); | |||
2355 | A->setImplicit(true); | |||
2356 | return A; | |||
2357 | } | |||
2358 | ||||
2359 | ConvergentAttr(SourceRange R, ASTContext &Ctx | |||
2360 | , unsigned SI | |||
2361 | ) | |||
2362 | : InheritableAttr(attr::Convergent, R, SI, false, false) | |||
2363 | { | |||
2364 | } | |||
2365 | ||||
2366 | ConvergentAttr *clone(ASTContext &C) const; | |||
2367 | void printPretty(raw_ostream &OS, | |||
2368 | const PrintingPolicy &Policy) const; | |||
2369 | const char *getSpelling() const; | |||
2370 | ||||
2371 | ||||
2372 | static bool classof(const Attr *A) { return A->getKind() == attr::Convergent; } | |||
2373 | }; | |||
2374 | ||||
2375 | class DLLExportAttr : public InheritableAttr { | |||
2376 | public: | |||
2377 | static DLLExportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2378 | auto *A = new (Ctx) DLLExportAttr(Loc, Ctx, 0); | |||
2379 | A->setImplicit(true); | |||
2380 | return A; | |||
2381 | } | |||
2382 | ||||
2383 | DLLExportAttr(SourceRange R, ASTContext &Ctx | |||
2384 | , unsigned SI | |||
2385 | ) | |||
2386 | : InheritableAttr(attr::DLLExport, R, SI, false, false) | |||
2387 | { | |||
2388 | } | |||
2389 | ||||
2390 | DLLExportAttr *clone(ASTContext &C) const; | |||
2391 | void printPretty(raw_ostream &OS, | |||
2392 | const PrintingPolicy &Policy) const; | |||
2393 | const char *getSpelling() const; | |||
2394 | ||||
2395 | ||||
2396 | static bool classof(const Attr *A) { return A->getKind() == attr::DLLExport; } | |||
2397 | }; | |||
2398 | ||||
2399 | class DLLImportAttr : public InheritableAttr { | |||
2400 | public: | |||
2401 | static DLLImportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2402 | auto *A = new (Ctx) DLLImportAttr(Loc, Ctx, 0); | |||
2403 | A->setImplicit(true); | |||
2404 | return A; | |||
2405 | } | |||
2406 | ||||
2407 | DLLImportAttr(SourceRange R, ASTContext &Ctx | |||
2408 | , unsigned SI | |||
2409 | ) | |||
2410 | : InheritableAttr(attr::DLLImport, R, SI, false, false) | |||
2411 | { | |||
2412 | } | |||
2413 | ||||
2414 | DLLImportAttr *clone(ASTContext &C) const; | |||
2415 | void printPretty(raw_ostream &OS, | |||
2416 | const PrintingPolicy &Policy) const; | |||
2417 | const char *getSpelling() const; | |||
2418 | ||||
2419 | ||||
2420 | static bool classof(const Attr *A) { return A->getKind() == attr::DLLImport; } | |||
2421 | }; | |||
2422 | ||||
2423 | class DeprecatedAttr : public InheritableAttr { | |||
2424 | unsigned messageLength; | |||
2425 | char *message; | |||
2426 | ||||
2427 | unsigned replacementLength; | |||
2428 | char *replacement; | |||
2429 | ||||
2430 | public: | |||
2431 | static DeprecatedAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Message, llvm::StringRef Replacement, SourceRange Loc = SourceRange()) { | |||
2432 | auto *A = new (Ctx) DeprecatedAttr(Loc, Ctx, Message, Replacement, 0); | |||
2433 | A->setImplicit(true); | |||
2434 | return A; | |||
2435 | } | |||
2436 | ||||
2437 | DeprecatedAttr(SourceRange R, ASTContext &Ctx | |||
2438 | , llvm::StringRef Message | |||
2439 | , llvm::StringRef Replacement | |||
2440 | , unsigned SI | |||
2441 | ) | |||
2442 | : InheritableAttr(attr::Deprecated, R, SI, false, false) | |||
2443 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
2444 | , replacementLength(Replacement.size()),replacement(new (Ctx, 1) char[replacementLength]) | |||
2445 | { | |||
2446 | if (!Message.empty()) | |||
2447 | std::memcpy(message, Message.data(), messageLength); | |||
2448 | if (!Replacement.empty()) | |||
2449 | std::memcpy(replacement, Replacement.data(), replacementLength); | |||
2450 | } | |||
2451 | ||||
2452 | DeprecatedAttr(SourceRange R, ASTContext &Ctx | |||
2453 | , unsigned SI | |||
2454 | ) | |||
2455 | : InheritableAttr(attr::Deprecated, R, SI, false, false) | |||
2456 | , messageLength(0),message(nullptr) | |||
2457 | , replacementLength(0),replacement(nullptr) | |||
2458 | { | |||
2459 | } | |||
2460 | ||||
2461 | DeprecatedAttr *clone(ASTContext &C) const; | |||
2462 | void printPretty(raw_ostream &OS, | |||
2463 | const PrintingPolicy &Policy) const; | |||
2464 | const char *getSpelling() const; | |||
2465 | llvm::StringRef getMessage() const { | |||
2466 | return llvm::StringRef(message, messageLength); | |||
2467 | } | |||
2468 | unsigned getMessageLength() const { | |||
2469 | return messageLength; | |||
2470 | } | |||
2471 | void setMessage(ASTContext &C, llvm::StringRef S) { | |||
2472 | messageLength = S.size(); | |||
2473 | this->message = new (C, 1) char [messageLength]; | |||
2474 | if (!S.empty()) | |||
2475 | std::memcpy(this->message, S.data(), messageLength); | |||
2476 | } | |||
2477 | ||||
2478 | llvm::StringRef getReplacement() const { | |||
2479 | return llvm::StringRef(replacement, replacementLength); | |||
2480 | } | |||
2481 | unsigned getReplacementLength() const { | |||
2482 | return replacementLength; | |||
2483 | } | |||
2484 | void setReplacement(ASTContext &C, llvm::StringRef S) { | |||
2485 | replacementLength = S.size(); | |||
2486 | this->replacement = new (C, 1) char [replacementLength]; | |||
2487 | if (!S.empty()) | |||
2488 | std::memcpy(this->replacement, S.data(), replacementLength); | |||
2489 | } | |||
2490 | ||||
2491 | ||||
2492 | ||||
2493 | static bool classof(const Attr *A) { return A->getKind() == attr::Deprecated; } | |||
2494 | }; | |||
2495 | ||||
2496 | class DestructorAttr : public InheritableAttr { | |||
2497 | int priority; | |||
2498 | ||||
2499 | public: | |||
2500 | static DestructorAttr *CreateImplicit(ASTContext &Ctx, int Priority, SourceRange Loc = SourceRange()) { | |||
2501 | auto *A = new (Ctx) DestructorAttr(Loc, Ctx, Priority, 0); | |||
2502 | A->setImplicit(true); | |||
2503 | return A; | |||
2504 | } | |||
2505 | ||||
2506 | DestructorAttr(SourceRange R, ASTContext &Ctx | |||
2507 | , int Priority | |||
2508 | , unsigned SI | |||
2509 | ) | |||
2510 | : InheritableAttr(attr::Destructor, R, SI, false, false) | |||
2511 | , priority(Priority) | |||
2512 | { | |||
2513 | } | |||
2514 | ||||
2515 | DestructorAttr(SourceRange R, ASTContext &Ctx | |||
2516 | , unsigned SI | |||
2517 | ) | |||
2518 | : InheritableAttr(attr::Destructor, R, SI, false, false) | |||
2519 | , priority() | |||
2520 | { | |||
2521 | } | |||
2522 | ||||
2523 | DestructorAttr *clone(ASTContext &C) const; | |||
2524 | void printPretty(raw_ostream &OS, | |||
2525 | const PrintingPolicy &Policy) const; | |||
2526 | const char *getSpelling() const; | |||
2527 | int getPriority() const { | |||
2528 | return priority; | |||
2529 | } | |||
2530 | ||||
2531 | static const int DefaultPriority = 65535; | |||
2532 | ||||
2533 | ||||
2534 | ||||
2535 | static bool classof(const Attr *A) { return A->getKind() == attr::Destructor; } | |||
2536 | }; | |||
2537 | ||||
2538 | class DiagnoseIfAttr : public InheritableAttr { | |||
2539 | Expr * cond; | |||
2540 | ||||
2541 | unsigned messageLength; | |||
2542 | char *message; | |||
2543 | ||||
2544 | public: | |||
2545 | enum DiagnosticType { | |||
2546 | DT_Error, | |||
2547 | DT_Warning | |||
2548 | }; | |||
2549 | private: | |||
2550 | DiagnosticType diagnosticType; | |||
2551 | ||||
2552 | bool argDependent; | |||
2553 | ||||
2554 | NamedDecl * parent; | |||
2555 | ||||
2556 | public: | |||
2557 | static DiagnoseIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, DiagnosticType DiagnosticType, bool ArgDependent, NamedDecl * Parent, SourceRange Loc = SourceRange()) { | |||
2558 | auto *A = new (Ctx) DiagnoseIfAttr(Loc, Ctx, Cond, Message, DiagnosticType, ArgDependent, Parent, 0); | |||
2559 | A->setImplicit(true); | |||
2560 | return A; | |||
2561 | } | |||
2562 | ||||
2563 | static DiagnoseIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, DiagnosticType DiagnosticType, SourceRange Loc = SourceRange()) { | |||
2564 | auto *A = new (Ctx) DiagnoseIfAttr(Loc, Ctx, Cond, Message, DiagnosticType, 0); | |||
2565 | A->setImplicit(true); | |||
2566 | return A; | |||
2567 | } | |||
2568 | ||||
2569 | DiagnoseIfAttr(SourceRange R, ASTContext &Ctx | |||
2570 | , Expr * Cond | |||
2571 | , llvm::StringRef Message | |||
2572 | , DiagnosticType DiagnosticType | |||
2573 | , bool ArgDependent | |||
2574 | , NamedDecl * Parent | |||
2575 | , unsigned SI | |||
2576 | ) | |||
2577 | : InheritableAttr(attr::DiagnoseIf, R, SI, true, true) | |||
2578 | , cond(Cond) | |||
2579 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
2580 | , diagnosticType(DiagnosticType) | |||
2581 | , argDependent(ArgDependent) | |||
2582 | , parent(Parent) | |||
2583 | { | |||
2584 | if (!Message.empty()) | |||
2585 | std::memcpy(message, Message.data(), messageLength); | |||
2586 | } | |||
2587 | ||||
2588 | DiagnoseIfAttr(SourceRange R, ASTContext &Ctx | |||
2589 | , Expr * Cond | |||
2590 | , llvm::StringRef Message | |||
2591 | , DiagnosticType DiagnosticType | |||
2592 | , unsigned SI | |||
2593 | ) | |||
2594 | : InheritableAttr(attr::DiagnoseIf, R, SI, true, true) | |||
2595 | , cond(Cond) | |||
2596 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
2597 | , diagnosticType(DiagnosticType) | |||
2598 | , argDependent() | |||
2599 | , parent() | |||
2600 | { | |||
2601 | if (!Message.empty()) | |||
2602 | std::memcpy(message, Message.data(), messageLength); | |||
2603 | } | |||
2604 | ||||
2605 | DiagnoseIfAttr *clone(ASTContext &C) const; | |||
2606 | void printPretty(raw_ostream &OS, | |||
2607 | const PrintingPolicy &Policy) const; | |||
2608 | const char *getSpelling() const; | |||
2609 | Expr * getCond() const { | |||
2610 | return cond; | |||
2611 | } | |||
2612 | ||||
2613 | llvm::StringRef getMessage() const { | |||
2614 | return llvm::StringRef(message, messageLength); | |||
2615 | } | |||
2616 | unsigned getMessageLength() const { | |||
2617 | return messageLength; | |||
2618 | } | |||
2619 | void setMessage(ASTContext &C, llvm::StringRef S) { | |||
2620 | messageLength = S.size(); | |||
2621 | this->message = new (C, 1) char [messageLength]; | |||
2622 | if (!S.empty()) | |||
2623 | std::memcpy(this->message, S.data(), messageLength); | |||
2624 | } | |||
2625 | ||||
2626 | DiagnosticType getDiagnosticType() const { | |||
2627 | return diagnosticType; | |||
2628 | } | |||
2629 | ||||
2630 | static bool ConvertStrToDiagnosticType(StringRef Val, DiagnosticType &Out) { | |||
2631 | Optional<DiagnosticType> R = llvm::StringSwitch<Optional<DiagnosticType>>(Val) | |||
2632 | .Case("error", DiagnoseIfAttr::DT_Error) | |||
2633 | .Case("warning", DiagnoseIfAttr::DT_Warning) | |||
2634 | .Default(Optional<DiagnosticType>()); | |||
2635 | if (R) { | |||
2636 | Out = *R; | |||
2637 | return true; | |||
2638 | } | |||
2639 | return false; | |||
2640 | } | |||
2641 | ||||
2642 | static const char *ConvertDiagnosticTypeToStr(DiagnosticType Val) { | |||
2643 | switch(Val) { | |||
2644 | case DiagnoseIfAttr::DT_Error: return "error"; | |||
2645 | case DiagnoseIfAttr::DT_Warning: return "warning"; | |||
2646 | } | |||
2647 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 2647); | |||
2648 | } | |||
2649 | bool getArgDependent() const { | |||
2650 | return argDependent; | |||
2651 | } | |||
2652 | ||||
2653 | NamedDecl * getParent() const { | |||
2654 | return parent; | |||
2655 | } | |||
2656 | ||||
2657 | ||||
2658 | bool isError() const { return diagnosticType == DT_Error; } | |||
2659 | bool isWarning() const { return diagnosticType == DT_Warning; } | |||
2660 | ||||
2661 | ||||
2662 | static bool classof(const Attr *A) { return A->getKind() == attr::DiagnoseIf; } | |||
2663 | }; | |||
2664 | ||||
2665 | class DisableTailCallsAttr : public InheritableAttr { | |||
2666 | public: | |||
2667 | static DisableTailCallsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2668 | auto *A = new (Ctx) DisableTailCallsAttr(Loc, Ctx, 0); | |||
2669 | A->setImplicit(true); | |||
2670 | return A; | |||
2671 | } | |||
2672 | ||||
2673 | DisableTailCallsAttr(SourceRange R, ASTContext &Ctx | |||
2674 | , unsigned SI | |||
2675 | ) | |||
2676 | : InheritableAttr(attr::DisableTailCalls, R, SI, false, false) | |||
2677 | { | |||
2678 | } | |||
2679 | ||||
2680 | DisableTailCallsAttr *clone(ASTContext &C) const; | |||
2681 | void printPretty(raw_ostream &OS, | |||
2682 | const PrintingPolicy &Policy) const; | |||
2683 | const char *getSpelling() const; | |||
2684 | ||||
2685 | ||||
2686 | static bool classof(const Attr *A) { return A->getKind() == attr::DisableTailCalls; } | |||
2687 | }; | |||
2688 | ||||
2689 | class EmptyBasesAttr : public InheritableAttr { | |||
2690 | public: | |||
2691 | static EmptyBasesAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2692 | auto *A = new (Ctx) EmptyBasesAttr(Loc, Ctx, 0); | |||
2693 | A->setImplicit(true); | |||
2694 | return A; | |||
2695 | } | |||
2696 | ||||
2697 | EmptyBasesAttr(SourceRange R, ASTContext &Ctx | |||
2698 | , unsigned SI | |||
2699 | ) | |||
2700 | : InheritableAttr(attr::EmptyBases, R, SI, false, false) | |||
2701 | { | |||
2702 | } | |||
2703 | ||||
2704 | EmptyBasesAttr *clone(ASTContext &C) const; | |||
2705 | void printPretty(raw_ostream &OS, | |||
2706 | const PrintingPolicy &Policy) const; | |||
2707 | const char *getSpelling() const; | |||
2708 | ||||
2709 | ||||
2710 | static bool classof(const Attr *A) { return A->getKind() == attr::EmptyBases; } | |||
2711 | }; | |||
2712 | ||||
2713 | class EnableIfAttr : public InheritableAttr { | |||
2714 | Expr * cond; | |||
2715 | ||||
2716 | unsigned messageLength; | |||
2717 | char *message; | |||
2718 | ||||
2719 | public: | |||
2720 | static EnableIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, SourceRange Loc = SourceRange()) { | |||
2721 | auto *A = new (Ctx) EnableIfAttr(Loc, Ctx, Cond, Message, 0); | |||
2722 | A->setImplicit(true); | |||
2723 | return A; | |||
2724 | } | |||
2725 | ||||
2726 | EnableIfAttr(SourceRange R, ASTContext &Ctx | |||
2727 | , Expr * Cond | |||
2728 | , llvm::StringRef Message | |||
2729 | , unsigned SI | |||
2730 | ) | |||
2731 | : InheritableAttr(attr::EnableIf, R, SI, false, false) | |||
2732 | , cond(Cond) | |||
2733 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
2734 | { | |||
2735 | if (!Message.empty()) | |||
2736 | std::memcpy(message, Message.data(), messageLength); | |||
2737 | } | |||
2738 | ||||
2739 | EnableIfAttr *clone(ASTContext &C) const; | |||
2740 | void printPretty(raw_ostream &OS, | |||
2741 | const PrintingPolicy &Policy) const; | |||
2742 | const char *getSpelling() const; | |||
2743 | Expr * getCond() const { | |||
2744 | return cond; | |||
2745 | } | |||
2746 | ||||
2747 | llvm::StringRef getMessage() const { | |||
2748 | return llvm::StringRef(message, messageLength); | |||
2749 | } | |||
2750 | unsigned getMessageLength() const { | |||
2751 | return messageLength; | |||
2752 | } | |||
2753 | void setMessage(ASTContext &C, llvm::StringRef S) { | |||
2754 | messageLength = S.size(); | |||
2755 | this->message = new (C, 1) char [messageLength]; | |||
2756 | if (!S.empty()) | |||
2757 | std::memcpy(this->message, S.data(), messageLength); | |||
2758 | } | |||
2759 | ||||
2760 | ||||
2761 | ||||
2762 | static bool classof(const Attr *A) { return A->getKind() == attr::EnableIf; } | |||
2763 | }; | |||
2764 | ||||
2765 | class EnumExtensibilityAttr : public InheritableAttr { | |||
2766 | public: | |||
2767 | enum Kind { | |||
2768 | Closed, | |||
2769 | Open | |||
2770 | }; | |||
2771 | private: | |||
2772 | Kind extensibility; | |||
2773 | ||||
2774 | public: | |||
2775 | static EnumExtensibilityAttr *CreateImplicit(ASTContext &Ctx, Kind Extensibility, SourceRange Loc = SourceRange()) { | |||
2776 | auto *A = new (Ctx) EnumExtensibilityAttr(Loc, Ctx, Extensibility, 0); | |||
2777 | A->setImplicit(true); | |||
2778 | return A; | |||
2779 | } | |||
2780 | ||||
2781 | EnumExtensibilityAttr(SourceRange R, ASTContext &Ctx | |||
2782 | , Kind Extensibility | |||
2783 | , unsigned SI | |||
2784 | ) | |||
2785 | : InheritableAttr(attr::EnumExtensibility, R, SI, false, false) | |||
2786 | , extensibility(Extensibility) | |||
2787 | { | |||
2788 | } | |||
2789 | ||||
2790 | EnumExtensibilityAttr *clone(ASTContext &C) const; | |||
2791 | void printPretty(raw_ostream &OS, | |||
2792 | const PrintingPolicy &Policy) const; | |||
2793 | const char *getSpelling() const; | |||
2794 | Kind getExtensibility() const { | |||
2795 | return extensibility; | |||
2796 | } | |||
2797 | ||||
2798 | static bool ConvertStrToKind(StringRef Val, Kind &Out) { | |||
2799 | Optional<Kind> R = llvm::StringSwitch<Optional<Kind>>(Val) | |||
2800 | .Case("closed", EnumExtensibilityAttr::Closed) | |||
2801 | .Case("open", EnumExtensibilityAttr::Open) | |||
2802 | .Default(Optional<Kind>()); | |||
2803 | if (R) { | |||
2804 | Out = *R; | |||
2805 | return true; | |||
2806 | } | |||
2807 | return false; | |||
2808 | } | |||
2809 | ||||
2810 | static const char *ConvertKindToStr(Kind Val) { | |||
2811 | switch(Val) { | |||
2812 | case EnumExtensibilityAttr::Closed: return "closed"; | |||
2813 | case EnumExtensibilityAttr::Open: return "open"; | |||
2814 | } | |||
2815 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 2815); | |||
2816 | } | |||
2817 | ||||
2818 | ||||
2819 | static bool classof(const Attr *A) { return A->getKind() == attr::EnumExtensibility; } | |||
2820 | }; | |||
2821 | ||||
2822 | class ExclusiveTrylockFunctionAttr : public InheritableAttr { | |||
2823 | Expr * successValue; | |||
2824 | ||||
2825 | unsigned args_Size; | |||
2826 | Expr * *args_; | |||
2827 | ||||
2828 | public: | |||
2829 | static ExclusiveTrylockFunctionAttr *CreateImplicit(ASTContext &Ctx, Expr * SuccessValue, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
2830 | auto *A = new (Ctx) ExclusiveTrylockFunctionAttr(Loc, Ctx, SuccessValue, Args, ArgsSize, 0); | |||
2831 | A->setImplicit(true); | |||
2832 | return A; | |||
2833 | } | |||
2834 | ||||
2835 | ExclusiveTrylockFunctionAttr(SourceRange R, ASTContext &Ctx | |||
2836 | , Expr * SuccessValue | |||
2837 | , Expr * *Args, unsigned ArgsSize | |||
2838 | , unsigned SI | |||
2839 | ) | |||
2840 | : InheritableAttr(attr::ExclusiveTrylockFunction, R, SI, true, true) | |||
2841 | , successValue(SuccessValue) | |||
2842 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
2843 | { | |||
2844 | std::copy(Args, Args + args_Size, args_); | |||
2845 | } | |||
2846 | ||||
2847 | ExclusiveTrylockFunctionAttr(SourceRange R, ASTContext &Ctx | |||
2848 | , Expr * SuccessValue | |||
2849 | , unsigned SI | |||
2850 | ) | |||
2851 | : InheritableAttr(attr::ExclusiveTrylockFunction, R, SI, true, true) | |||
2852 | , successValue(SuccessValue) | |||
2853 | , args_Size(0), args_(nullptr) | |||
2854 | { | |||
2855 | } | |||
2856 | ||||
2857 | ExclusiveTrylockFunctionAttr *clone(ASTContext &C) const; | |||
2858 | void printPretty(raw_ostream &OS, | |||
2859 | const PrintingPolicy &Policy) const; | |||
2860 | const char *getSpelling() const; | |||
2861 | Expr * getSuccessValue() const { | |||
2862 | return successValue; | |||
2863 | } | |||
2864 | ||||
2865 | typedef Expr ** args_iterator; | |||
2866 | args_iterator args_begin() const { return args_; } | |||
2867 | args_iterator args_end() const { return args_ + args_Size; } | |||
2868 | unsigned args_size() const { return args_Size; } | |||
2869 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
2870 | ||||
2871 | ||||
2872 | ||||
2873 | ||||
2874 | static bool classof(const Attr *A) { return A->getKind() == attr::ExclusiveTrylockFunction; } | |||
2875 | }; | |||
2876 | ||||
2877 | class ExternalSourceSymbolAttr : public InheritableAttr { | |||
2878 | unsigned languageLength; | |||
2879 | char *language; | |||
2880 | ||||
2881 | unsigned definedInLength; | |||
2882 | char *definedIn; | |||
2883 | ||||
2884 | bool generatedDeclaration; | |||
2885 | ||||
2886 | public: | |||
2887 | static ExternalSourceSymbolAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Language, llvm::StringRef DefinedIn, bool GeneratedDeclaration, SourceRange Loc = SourceRange()) { | |||
2888 | auto *A = new (Ctx) ExternalSourceSymbolAttr(Loc, Ctx, Language, DefinedIn, GeneratedDeclaration, 0); | |||
2889 | A->setImplicit(true); | |||
2890 | return A; | |||
2891 | } | |||
2892 | ||||
2893 | ExternalSourceSymbolAttr(SourceRange R, ASTContext &Ctx | |||
2894 | , llvm::StringRef Language | |||
2895 | , llvm::StringRef DefinedIn | |||
2896 | , bool GeneratedDeclaration | |||
2897 | , unsigned SI | |||
2898 | ) | |||
2899 | : InheritableAttr(attr::ExternalSourceSymbol, R, SI, false, false) | |||
2900 | , languageLength(Language.size()),language(new (Ctx, 1) char[languageLength]) | |||
2901 | , definedInLength(DefinedIn.size()),definedIn(new (Ctx, 1) char[definedInLength]) | |||
2902 | , generatedDeclaration(GeneratedDeclaration) | |||
2903 | { | |||
2904 | if (!Language.empty()) | |||
2905 | std::memcpy(language, Language.data(), languageLength); | |||
2906 | if (!DefinedIn.empty()) | |||
2907 | std::memcpy(definedIn, DefinedIn.data(), definedInLength); | |||
2908 | } | |||
2909 | ||||
2910 | ExternalSourceSymbolAttr(SourceRange R, ASTContext &Ctx | |||
2911 | , unsigned SI | |||
2912 | ) | |||
2913 | : InheritableAttr(attr::ExternalSourceSymbol, R, SI, false, false) | |||
2914 | , languageLength(0),language(nullptr) | |||
2915 | , definedInLength(0),definedIn(nullptr) | |||
2916 | , generatedDeclaration() | |||
2917 | { | |||
2918 | } | |||
2919 | ||||
2920 | ExternalSourceSymbolAttr *clone(ASTContext &C) const; | |||
2921 | void printPretty(raw_ostream &OS, | |||
2922 | const PrintingPolicy &Policy) const; | |||
2923 | const char *getSpelling() const; | |||
2924 | llvm::StringRef getLanguage() const { | |||
2925 | return llvm::StringRef(language, languageLength); | |||
2926 | } | |||
2927 | unsigned getLanguageLength() const { | |||
2928 | return languageLength; | |||
2929 | } | |||
2930 | void setLanguage(ASTContext &C, llvm::StringRef S) { | |||
2931 | languageLength = S.size(); | |||
2932 | this->language = new (C, 1) char [languageLength]; | |||
2933 | if (!S.empty()) | |||
2934 | std::memcpy(this->language, S.data(), languageLength); | |||
2935 | } | |||
2936 | ||||
2937 | llvm::StringRef getDefinedIn() const { | |||
2938 | return llvm::StringRef(definedIn, definedInLength); | |||
2939 | } | |||
2940 | unsigned getDefinedInLength() const { | |||
2941 | return definedInLength; | |||
2942 | } | |||
2943 | void setDefinedIn(ASTContext &C, llvm::StringRef S) { | |||
2944 | definedInLength = S.size(); | |||
2945 | this->definedIn = new (C, 1) char [definedInLength]; | |||
2946 | if (!S.empty()) | |||
2947 | std::memcpy(this->definedIn, S.data(), definedInLength); | |||
2948 | } | |||
2949 | ||||
2950 | bool getGeneratedDeclaration() const { | |||
2951 | return generatedDeclaration; | |||
2952 | } | |||
2953 | ||||
2954 | ||||
2955 | ||||
2956 | static bool classof(const Attr *A) { return A->getKind() == attr::ExternalSourceSymbol; } | |||
2957 | }; | |||
2958 | ||||
2959 | class FallThroughAttr : public StmtAttr { | |||
2960 | public: | |||
2961 | static FallThroughAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2962 | auto *A = new (Ctx) FallThroughAttr(Loc, Ctx, 0); | |||
2963 | A->setImplicit(true); | |||
2964 | return A; | |||
2965 | } | |||
2966 | ||||
2967 | FallThroughAttr(SourceRange R, ASTContext &Ctx | |||
2968 | , unsigned SI | |||
2969 | ) | |||
2970 | : StmtAttr(attr::FallThrough, R, SI, false) | |||
2971 | { | |||
2972 | } | |||
2973 | ||||
2974 | FallThroughAttr *clone(ASTContext &C) const; | |||
2975 | void printPretty(raw_ostream &OS, | |||
2976 | const PrintingPolicy &Policy) const; | |||
2977 | const char *getSpelling() const; | |||
2978 | ||||
2979 | ||||
2980 | static bool classof(const Attr *A) { return A->getKind() == attr::FallThrough; } | |||
2981 | }; | |||
2982 | ||||
2983 | class FastCallAttr : public InheritableAttr { | |||
2984 | public: | |||
2985 | static FastCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2986 | auto *A = new (Ctx) FastCallAttr(Loc, Ctx, 0); | |||
2987 | A->setImplicit(true); | |||
2988 | return A; | |||
2989 | } | |||
2990 | ||||
2991 | FastCallAttr(SourceRange R, ASTContext &Ctx | |||
2992 | , unsigned SI | |||
2993 | ) | |||
2994 | : InheritableAttr(attr::FastCall, R, SI, false, false) | |||
2995 | { | |||
2996 | } | |||
2997 | ||||
2998 | FastCallAttr *clone(ASTContext &C) const; | |||
2999 | void printPretty(raw_ostream &OS, | |||
3000 | const PrintingPolicy &Policy) const; | |||
3001 | const char *getSpelling() const; | |||
3002 | ||||
3003 | ||||
3004 | static bool classof(const Attr *A) { return A->getKind() == attr::FastCall; } | |||
3005 | }; | |||
3006 | ||||
3007 | class FinalAttr : public InheritableAttr { | |||
3008 | public: | |||
3009 | enum Spelling { | |||
3010 | Keyword_final = 0, | |||
3011 | Keyword_sealed = 1 | |||
3012 | }; | |||
3013 | ||||
3014 | static FinalAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
3015 | auto *A = new (Ctx) FinalAttr(Loc, Ctx, S); | |||
3016 | A->setImplicit(true); | |||
3017 | return A; | |||
3018 | } | |||
3019 | ||||
3020 | FinalAttr(SourceRange R, ASTContext &Ctx | |||
3021 | , unsigned SI | |||
3022 | ) | |||
3023 | : InheritableAttr(attr::Final, R, SI, false, false) | |||
3024 | { | |||
3025 | } | |||
3026 | ||||
3027 | FinalAttr *clone(ASTContext &C) const; | |||
3028 | void printPretty(raw_ostream &OS, | |||
3029 | const PrintingPolicy &Policy) const; | |||
3030 | const char *getSpelling() const; | |||
3031 | Spelling getSemanticSpelling() const { | |||
3032 | switch (SpellingListIndex) { | |||
3033 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3033); | |||
3034 | case 0: return Keyword_final; | |||
3035 | case 1: return Keyword_sealed; | |||
3036 | } | |||
3037 | } | |||
3038 | bool isSpelledAsSealed() const { return SpellingListIndex == 1; } | |||
3039 | ||||
3040 | ||||
3041 | static bool classof(const Attr *A) { return A->getKind() == attr::Final; } | |||
3042 | }; | |||
3043 | ||||
3044 | class FlagEnumAttr : public InheritableAttr { | |||
3045 | public: | |||
3046 | static FlagEnumAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3047 | auto *A = new (Ctx) FlagEnumAttr(Loc, Ctx, 0); | |||
3048 | A->setImplicit(true); | |||
3049 | return A; | |||
3050 | } | |||
3051 | ||||
3052 | FlagEnumAttr(SourceRange R, ASTContext &Ctx | |||
3053 | , unsigned SI | |||
3054 | ) | |||
3055 | : InheritableAttr(attr::FlagEnum, R, SI, false, false) | |||
3056 | { | |||
3057 | } | |||
3058 | ||||
3059 | FlagEnumAttr *clone(ASTContext &C) const; | |||
3060 | void printPretty(raw_ostream &OS, | |||
3061 | const PrintingPolicy &Policy) const; | |||
3062 | const char *getSpelling() const; | |||
3063 | ||||
3064 | ||||
3065 | static bool classof(const Attr *A) { return A->getKind() == attr::FlagEnum; } | |||
3066 | }; | |||
3067 | ||||
3068 | class FlattenAttr : public InheritableAttr { | |||
3069 | public: | |||
3070 | static FlattenAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3071 | auto *A = new (Ctx) FlattenAttr(Loc, Ctx, 0); | |||
3072 | A->setImplicit(true); | |||
3073 | return A; | |||
3074 | } | |||
3075 | ||||
3076 | FlattenAttr(SourceRange R, ASTContext &Ctx | |||
3077 | , unsigned SI | |||
3078 | ) | |||
3079 | : InheritableAttr(attr::Flatten, R, SI, false, false) | |||
3080 | { | |||
3081 | } | |||
3082 | ||||
3083 | FlattenAttr *clone(ASTContext &C) const; | |||
3084 | void printPretty(raw_ostream &OS, | |||
3085 | const PrintingPolicy &Policy) const; | |||
3086 | const char *getSpelling() const; | |||
3087 | ||||
3088 | ||||
3089 | static bool classof(const Attr *A) { return A->getKind() == attr::Flatten; } | |||
3090 | }; | |||
3091 | ||||
3092 | class FormatAttr : public InheritableAttr { | |||
3093 | IdentifierInfo * type; | |||
3094 | ||||
3095 | int formatIdx; | |||
3096 | ||||
3097 | int firstArg; | |||
3098 | ||||
3099 | public: | |||
3100 | static FormatAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Type, int FormatIdx, int FirstArg, SourceRange Loc = SourceRange()) { | |||
3101 | auto *A = new (Ctx) FormatAttr(Loc, Ctx, Type, FormatIdx, FirstArg, 0); | |||
3102 | A->setImplicit(true); | |||
3103 | return A; | |||
3104 | } | |||
3105 | ||||
3106 | FormatAttr(SourceRange R, ASTContext &Ctx | |||
3107 | , IdentifierInfo * Type | |||
3108 | , int FormatIdx | |||
3109 | , int FirstArg | |||
3110 | , unsigned SI | |||
3111 | ) | |||
3112 | : InheritableAttr(attr::Format, R, SI, false, false) | |||
3113 | , type(Type) | |||
3114 | , formatIdx(FormatIdx) | |||
3115 | , firstArg(FirstArg) | |||
3116 | { | |||
3117 | } | |||
3118 | ||||
3119 | FormatAttr *clone(ASTContext &C) const; | |||
3120 | void printPretty(raw_ostream &OS, | |||
3121 | const PrintingPolicy &Policy) const; | |||
3122 | const char *getSpelling() const; | |||
3123 | IdentifierInfo * getType() const { | |||
3124 | return type; | |||
3125 | } | |||
3126 | ||||
3127 | int getFormatIdx() const { | |||
3128 | return formatIdx; | |||
3129 | } | |||
3130 | ||||
3131 | int getFirstArg() const { | |||
3132 | return firstArg; | |||
3133 | } | |||
3134 | ||||
3135 | ||||
3136 | ||||
3137 | static bool classof(const Attr *A) { return A->getKind() == attr::Format; } | |||
3138 | }; | |||
3139 | ||||
3140 | class FormatArgAttr : public InheritableAttr { | |||
3141 | int formatIdx; | |||
3142 | ||||
3143 | public: | |||
3144 | static FormatArgAttr *CreateImplicit(ASTContext &Ctx, int FormatIdx, SourceRange Loc = SourceRange()) { | |||
3145 | auto *A = new (Ctx) FormatArgAttr(Loc, Ctx, FormatIdx, 0); | |||
3146 | A->setImplicit(true); | |||
3147 | return A; | |||
3148 | } | |||
3149 | ||||
3150 | FormatArgAttr(SourceRange R, ASTContext &Ctx | |||
3151 | , int FormatIdx | |||
3152 | , unsigned SI | |||
3153 | ) | |||
3154 | : InheritableAttr(attr::FormatArg, R, SI, false, false) | |||
3155 | , formatIdx(FormatIdx) | |||
3156 | { | |||
3157 | } | |||
3158 | ||||
3159 | FormatArgAttr *clone(ASTContext &C) const; | |||
3160 | void printPretty(raw_ostream &OS, | |||
3161 | const PrintingPolicy &Policy) const; | |||
3162 | const char *getSpelling() const; | |||
3163 | int getFormatIdx() const { | |||
3164 | return formatIdx; | |||
3165 | } | |||
3166 | ||||
3167 | ||||
3168 | ||||
3169 | static bool classof(const Attr *A) { return A->getKind() == attr::FormatArg; } | |||
3170 | }; | |||
3171 | ||||
3172 | class GNUInlineAttr : public InheritableAttr { | |||
3173 | public: | |||
3174 | static GNUInlineAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3175 | auto *A = new (Ctx) GNUInlineAttr(Loc, Ctx, 0); | |||
3176 | A->setImplicit(true); | |||
3177 | return A; | |||
3178 | } | |||
3179 | ||||
3180 | GNUInlineAttr(SourceRange R, ASTContext &Ctx | |||
3181 | , unsigned SI | |||
3182 | ) | |||
3183 | : InheritableAttr(attr::GNUInline, R, SI, false, false) | |||
3184 | { | |||
3185 | } | |||
3186 | ||||
3187 | GNUInlineAttr *clone(ASTContext &C) const; | |||
3188 | void printPretty(raw_ostream &OS, | |||
3189 | const PrintingPolicy &Policy) const; | |||
3190 | const char *getSpelling() const; | |||
3191 | ||||
3192 | ||||
3193 | static bool classof(const Attr *A) { return A->getKind() == attr::GNUInline; } | |||
3194 | }; | |||
3195 | ||||
3196 | class GuardedByAttr : public InheritableAttr { | |||
3197 | Expr * arg; | |||
3198 | ||||
3199 | public: | |||
3200 | static GuardedByAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) { | |||
3201 | auto *A = new (Ctx) GuardedByAttr(Loc, Ctx, Arg, 0); | |||
3202 | A->setImplicit(true); | |||
3203 | return A; | |||
3204 | } | |||
3205 | ||||
3206 | GuardedByAttr(SourceRange R, ASTContext &Ctx | |||
3207 | , Expr * Arg | |||
3208 | , unsigned SI | |||
3209 | ) | |||
3210 | : InheritableAttr(attr::GuardedBy, R, SI, true, true) | |||
3211 | , arg(Arg) | |||
3212 | { | |||
3213 | } | |||
3214 | ||||
3215 | GuardedByAttr *clone(ASTContext &C) const; | |||
3216 | void printPretty(raw_ostream &OS, | |||
3217 | const PrintingPolicy &Policy) const; | |||
3218 | const char *getSpelling() const; | |||
3219 | Expr * getArg() const { | |||
3220 | return arg; | |||
3221 | } | |||
3222 | ||||
3223 | ||||
3224 | ||||
3225 | static bool classof(const Attr *A) { return A->getKind() == attr::GuardedBy; } | |||
3226 | }; | |||
3227 | ||||
3228 | class GuardedVarAttr : public InheritableAttr { | |||
3229 | public: | |||
3230 | static GuardedVarAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3231 | auto *A = new (Ctx) GuardedVarAttr(Loc, Ctx, 0); | |||
3232 | A->setImplicit(true); | |||
3233 | return A; | |||
3234 | } | |||
3235 | ||||
3236 | GuardedVarAttr(SourceRange R, ASTContext &Ctx | |||
3237 | , unsigned SI | |||
3238 | ) | |||
3239 | : InheritableAttr(attr::GuardedVar, R, SI, false, false) | |||
3240 | { | |||
3241 | } | |||
3242 | ||||
3243 | GuardedVarAttr *clone(ASTContext &C) const; | |||
3244 | void printPretty(raw_ostream &OS, | |||
3245 | const PrintingPolicy &Policy) const; | |||
3246 | const char *getSpelling() const; | |||
3247 | ||||
3248 | ||||
3249 | static bool classof(const Attr *A) { return A->getKind() == attr::GuardedVar; } | |||
3250 | }; | |||
3251 | ||||
3252 | class HotAttr : public InheritableAttr { | |||
3253 | public: | |||
3254 | static HotAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3255 | auto *A = new (Ctx) HotAttr(Loc, Ctx, 0); | |||
3256 | A->setImplicit(true); | |||
3257 | return A; | |||
3258 | } | |||
3259 | ||||
3260 | HotAttr(SourceRange R, ASTContext &Ctx | |||
3261 | , unsigned SI | |||
3262 | ) | |||
3263 | : InheritableAttr(attr::Hot, R, SI, false, false) | |||
3264 | { | |||
3265 | } | |||
3266 | ||||
3267 | HotAttr *clone(ASTContext &C) const; | |||
3268 | void printPretty(raw_ostream &OS, | |||
3269 | const PrintingPolicy &Policy) const; | |||
3270 | const char *getSpelling() const; | |||
3271 | ||||
3272 | ||||
3273 | static bool classof(const Attr *A) { return A->getKind() == attr::Hot; } | |||
3274 | }; | |||
3275 | ||||
3276 | class IBActionAttr : public InheritableAttr { | |||
3277 | public: | |||
3278 | static IBActionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3279 | auto *A = new (Ctx) IBActionAttr(Loc, Ctx, 0); | |||
3280 | A->setImplicit(true); | |||
3281 | return A; | |||
3282 | } | |||
3283 | ||||
3284 | IBActionAttr(SourceRange R, ASTContext &Ctx | |||
3285 | , unsigned SI | |||
3286 | ) | |||
3287 | : InheritableAttr(attr::IBAction, R, SI, false, false) | |||
3288 | { | |||
3289 | } | |||
3290 | ||||
3291 | IBActionAttr *clone(ASTContext &C) const; | |||
3292 | void printPretty(raw_ostream &OS, | |||
3293 | const PrintingPolicy &Policy) const; | |||
3294 | const char *getSpelling() const; | |||
3295 | ||||
3296 | ||||
3297 | static bool classof(const Attr *A) { return A->getKind() == attr::IBAction; } | |||
3298 | }; | |||
3299 | ||||
3300 | class IBOutletAttr : public InheritableAttr { | |||
3301 | public: | |||
3302 | static IBOutletAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3303 | auto *A = new (Ctx) IBOutletAttr(Loc, Ctx, 0); | |||
3304 | A->setImplicit(true); | |||
3305 | return A; | |||
3306 | } | |||
3307 | ||||
3308 | IBOutletAttr(SourceRange R, ASTContext &Ctx | |||
3309 | , unsigned SI | |||
3310 | ) | |||
3311 | : InheritableAttr(attr::IBOutlet, R, SI, false, false) | |||
3312 | { | |||
3313 | } | |||
3314 | ||||
3315 | IBOutletAttr *clone(ASTContext &C) const; | |||
3316 | void printPretty(raw_ostream &OS, | |||
3317 | const PrintingPolicy &Policy) const; | |||
3318 | const char *getSpelling() const; | |||
3319 | ||||
3320 | ||||
3321 | static bool classof(const Attr *A) { return A->getKind() == attr::IBOutlet; } | |||
3322 | }; | |||
3323 | ||||
3324 | class IBOutletCollectionAttr : public InheritableAttr { | |||
3325 | TypeSourceInfo * interface_; | |||
3326 | ||||
3327 | public: | |||
3328 | static IBOutletCollectionAttr *CreateImplicit(ASTContext &Ctx, TypeSourceInfo * Interface, SourceRange Loc = SourceRange()) { | |||
3329 | auto *A = new (Ctx) IBOutletCollectionAttr(Loc, Ctx, Interface, 0); | |||
3330 | A->setImplicit(true); | |||
3331 | return A; | |||
3332 | } | |||
3333 | ||||
3334 | IBOutletCollectionAttr(SourceRange R, ASTContext &Ctx | |||
3335 | , TypeSourceInfo * Interface | |||
3336 | , unsigned SI | |||
3337 | ) | |||
3338 | : InheritableAttr(attr::IBOutletCollection, R, SI, false, false) | |||
3339 | , interface_(Interface) | |||
3340 | { | |||
3341 | } | |||
3342 | ||||
3343 | IBOutletCollectionAttr(SourceRange R, ASTContext &Ctx | |||
3344 | , unsigned SI | |||
3345 | ) | |||
3346 | : InheritableAttr(attr::IBOutletCollection, R, SI, false, false) | |||
3347 | , interface_() | |||
3348 | { | |||
3349 | } | |||
3350 | ||||
3351 | IBOutletCollectionAttr *clone(ASTContext &C) const; | |||
3352 | void printPretty(raw_ostream &OS, | |||
3353 | const PrintingPolicy &Policy) const; | |||
3354 | const char *getSpelling() const; | |||
3355 | QualType getInterface() const { | |||
3356 | return interface_->getType(); | |||
3357 | } TypeSourceInfo * getInterfaceLoc() const { | |||
3358 | return interface_; | |||
3359 | } | |||
3360 | ||||
3361 | ||||
3362 | ||||
3363 | static bool classof(const Attr *A) { return A->getKind() == attr::IBOutletCollection; } | |||
3364 | }; | |||
3365 | ||||
3366 | class IFuncAttr : public Attr { | |||
3367 | unsigned resolverLength; | |||
3368 | char *resolver; | |||
3369 | ||||
3370 | public: | |||
3371 | static IFuncAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Resolver, SourceRange Loc = SourceRange()) { | |||
3372 | auto *A = new (Ctx) IFuncAttr(Loc, Ctx, Resolver, 0); | |||
3373 | A->setImplicit(true); | |||
3374 | return A; | |||
3375 | } | |||
3376 | ||||
3377 | IFuncAttr(SourceRange R, ASTContext &Ctx | |||
3378 | , llvm::StringRef Resolver | |||
3379 | , unsigned SI | |||
3380 | ) | |||
3381 | : Attr(attr::IFunc, R, SI, false) | |||
3382 | , resolverLength(Resolver.size()),resolver(new (Ctx, 1) char[resolverLength]) | |||
3383 | { | |||
3384 | if (!Resolver.empty()) | |||
3385 | std::memcpy(resolver, Resolver.data(), resolverLength); | |||
3386 | } | |||
3387 | ||||
3388 | IFuncAttr *clone(ASTContext &C) const; | |||
3389 | void printPretty(raw_ostream &OS, | |||
3390 | const PrintingPolicy &Policy) const; | |||
3391 | const char *getSpelling() const; | |||
3392 | llvm::StringRef getResolver() const { | |||
3393 | return llvm::StringRef(resolver, resolverLength); | |||
3394 | } | |||
3395 | unsigned getResolverLength() const { | |||
3396 | return resolverLength; | |||
3397 | } | |||
3398 | void setResolver(ASTContext &C, llvm::StringRef S) { | |||
3399 | resolverLength = S.size(); | |||
3400 | this->resolver = new (C, 1) char [resolverLength]; | |||
3401 | if (!S.empty()) | |||
3402 | std::memcpy(this->resolver, S.data(), resolverLength); | |||
3403 | } | |||
3404 | ||||
3405 | ||||
3406 | ||||
3407 | static bool classof(const Attr *A) { return A->getKind() == attr::IFunc; } | |||
3408 | }; | |||
3409 | ||||
3410 | class InitPriorityAttr : public InheritableAttr { | |||
3411 | unsigned priority; | |||
3412 | ||||
3413 | public: | |||
3414 | static InitPriorityAttr *CreateImplicit(ASTContext &Ctx, unsigned Priority, SourceRange Loc = SourceRange()) { | |||
3415 | auto *A = new (Ctx) InitPriorityAttr(Loc, Ctx, Priority, 0); | |||
3416 | A->setImplicit(true); | |||
3417 | return A; | |||
3418 | } | |||
3419 | ||||
3420 | InitPriorityAttr(SourceRange R, ASTContext &Ctx | |||
3421 | , unsigned Priority | |||
3422 | , unsigned SI | |||
3423 | ) | |||
3424 | : InheritableAttr(attr::InitPriority, R, SI, false, false) | |||
3425 | , priority(Priority) | |||
3426 | { | |||
3427 | } | |||
3428 | ||||
3429 | InitPriorityAttr *clone(ASTContext &C) const; | |||
3430 | void printPretty(raw_ostream &OS, | |||
3431 | const PrintingPolicy &Policy) const; | |||
3432 | const char *getSpelling() const; | |||
3433 | unsigned getPriority() const { | |||
3434 | return priority; | |||
3435 | } | |||
3436 | ||||
3437 | ||||
3438 | ||||
3439 | static bool classof(const Attr *A) { return A->getKind() == attr::InitPriority; } | |||
3440 | }; | |||
3441 | ||||
3442 | class InitSegAttr : public Attr { | |||
3443 | unsigned sectionLength; | |||
3444 | char *section; | |||
3445 | ||||
3446 | public: | |||
3447 | static InitSegAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Section, SourceRange Loc = SourceRange()) { | |||
3448 | auto *A = new (Ctx) InitSegAttr(Loc, Ctx, Section, 0); | |||
3449 | A->setImplicit(true); | |||
3450 | return A; | |||
3451 | } | |||
3452 | ||||
3453 | InitSegAttr(SourceRange R, ASTContext &Ctx | |||
3454 | , llvm::StringRef Section | |||
3455 | , unsigned SI | |||
3456 | ) | |||
3457 | : Attr(attr::InitSeg, R, SI, false) | |||
3458 | , sectionLength(Section.size()),section(new (Ctx, 1) char[sectionLength]) | |||
3459 | { | |||
3460 | if (!Section.empty()) | |||
3461 | std::memcpy(section, Section.data(), sectionLength); | |||
3462 | } | |||
3463 | ||||
3464 | InitSegAttr *clone(ASTContext &C) const; | |||
3465 | void printPretty(raw_ostream &OS, | |||
3466 | const PrintingPolicy &Policy) const; | |||
3467 | const char *getSpelling() const; | |||
3468 | llvm::StringRef getSection() const { | |||
3469 | return llvm::StringRef(section, sectionLength); | |||
3470 | } | |||
3471 | unsigned getSectionLength() const { | |||
3472 | return sectionLength; | |||
3473 | } | |||
3474 | void setSection(ASTContext &C, llvm::StringRef S) { | |||
3475 | sectionLength = S.size(); | |||
3476 | this->section = new (C, 1) char [sectionLength]; | |||
3477 | if (!S.empty()) | |||
3478 | std::memcpy(this->section, S.data(), sectionLength); | |||
3479 | } | |||
3480 | ||||
3481 | ||||
3482 | void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const { | |||
3483 | OS << " (" << getSection() << ')'; | |||
3484 | } | |||
3485 | ||||
3486 | ||||
3487 | static bool classof(const Attr *A) { return A->getKind() == attr::InitSeg; } | |||
3488 | }; | |||
3489 | ||||
3490 | class IntelOclBiccAttr : public InheritableAttr { | |||
3491 | public: | |||
3492 | static IntelOclBiccAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3493 | auto *A = new (Ctx) IntelOclBiccAttr(Loc, Ctx, 0); | |||
3494 | A->setImplicit(true); | |||
3495 | return A; | |||
3496 | } | |||
3497 | ||||
3498 | IntelOclBiccAttr(SourceRange R, ASTContext &Ctx | |||
3499 | , unsigned SI | |||
3500 | ) | |||
3501 | : InheritableAttr(attr::IntelOclBicc, R, SI, false, false) | |||
3502 | { | |||
3503 | } | |||
3504 | ||||
3505 | IntelOclBiccAttr *clone(ASTContext &C) const; | |||
3506 | void printPretty(raw_ostream &OS, | |||
3507 | const PrintingPolicy &Policy) const; | |||
3508 | const char *getSpelling() const; | |||
3509 | ||||
3510 | ||||
3511 | static bool classof(const Attr *A) { return A->getKind() == attr::IntelOclBicc; } | |||
3512 | }; | |||
3513 | ||||
3514 | class InternalLinkageAttr : public InheritableAttr { | |||
3515 | public: | |||
3516 | static InternalLinkageAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3517 | auto *A = new (Ctx) InternalLinkageAttr(Loc, Ctx, 0); | |||
3518 | A->setImplicit(true); | |||
3519 | return A; | |||
3520 | } | |||
3521 | ||||
3522 | InternalLinkageAttr(SourceRange R, ASTContext &Ctx | |||
3523 | , unsigned SI | |||
3524 | ) | |||
3525 | : InheritableAttr(attr::InternalLinkage, R, SI, false, false) | |||
3526 | { | |||
3527 | } | |||
3528 | ||||
3529 | InternalLinkageAttr *clone(ASTContext &C) const; | |||
3530 | void printPretty(raw_ostream &OS, | |||
3531 | const PrintingPolicy &Policy) const; | |||
3532 | const char *getSpelling() const; | |||
3533 | ||||
3534 | ||||
3535 | static bool classof(const Attr *A) { return A->getKind() == attr::InternalLinkage; } | |||
3536 | }; | |||
3537 | ||||
3538 | class LTOVisibilityPublicAttr : public InheritableAttr { | |||
3539 | public: | |||
3540 | static LTOVisibilityPublicAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3541 | auto *A = new (Ctx) LTOVisibilityPublicAttr(Loc, Ctx, 0); | |||
3542 | A->setImplicit(true); | |||
3543 | return A; | |||
3544 | } | |||
3545 | ||||
3546 | LTOVisibilityPublicAttr(SourceRange R, ASTContext &Ctx | |||
3547 | , unsigned SI | |||
3548 | ) | |||
3549 | : InheritableAttr(attr::LTOVisibilityPublic, R, SI, false, false) | |||
3550 | { | |||
3551 | } | |||
3552 | ||||
3553 | LTOVisibilityPublicAttr *clone(ASTContext &C) const; | |||
3554 | void printPretty(raw_ostream &OS, | |||
3555 | const PrintingPolicy &Policy) const; | |||
3556 | const char *getSpelling() const; | |||
3557 | ||||
3558 | ||||
3559 | static bool classof(const Attr *A) { return A->getKind() == attr::LTOVisibilityPublic; } | |||
3560 | }; | |||
3561 | ||||
3562 | class LayoutVersionAttr : public InheritableAttr { | |||
3563 | unsigned version; | |||
3564 | ||||
3565 | public: | |||
3566 | static LayoutVersionAttr *CreateImplicit(ASTContext &Ctx, unsigned Version, SourceRange Loc = SourceRange()) { | |||
3567 | auto *A = new (Ctx) LayoutVersionAttr(Loc, Ctx, Version, 0); | |||
3568 | A->setImplicit(true); | |||
3569 | return A; | |||
3570 | } | |||
3571 | ||||
3572 | LayoutVersionAttr(SourceRange R, ASTContext &Ctx | |||
3573 | , unsigned Version | |||
3574 | , unsigned SI | |||
3575 | ) | |||
3576 | : InheritableAttr(attr::LayoutVersion, R, SI, false, false) | |||
3577 | , version(Version) | |||
3578 | { | |||
3579 | } | |||
3580 | ||||
3581 | LayoutVersionAttr *clone(ASTContext &C) const; | |||
3582 | void printPretty(raw_ostream &OS, | |||
3583 | const PrintingPolicy &Policy) const; | |||
3584 | const char *getSpelling() const; | |||
3585 | unsigned getVersion() const { | |||
3586 | return version; | |||
3587 | } | |||
3588 | ||||
3589 | ||||
3590 | ||||
3591 | static bool classof(const Attr *A) { return A->getKind() == attr::LayoutVersion; } | |||
3592 | }; | |||
3593 | ||||
3594 | class LockReturnedAttr : public InheritableAttr { | |||
3595 | Expr * arg; | |||
3596 | ||||
3597 | public: | |||
3598 | static LockReturnedAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) { | |||
3599 | auto *A = new (Ctx) LockReturnedAttr(Loc, Ctx, Arg, 0); | |||
3600 | A->setImplicit(true); | |||
3601 | return A; | |||
3602 | } | |||
3603 | ||||
3604 | LockReturnedAttr(SourceRange R, ASTContext &Ctx | |||
3605 | , Expr * Arg | |||
3606 | , unsigned SI | |||
3607 | ) | |||
3608 | : InheritableAttr(attr::LockReturned, R, SI, true, false) | |||
3609 | , arg(Arg) | |||
3610 | { | |||
3611 | } | |||
3612 | ||||
3613 | LockReturnedAttr *clone(ASTContext &C) const; | |||
3614 | void printPretty(raw_ostream &OS, | |||
3615 | const PrintingPolicy &Policy) const; | |||
3616 | const char *getSpelling() const; | |||
3617 | Expr * getArg() const { | |||
3618 | return arg; | |||
3619 | } | |||
3620 | ||||
3621 | ||||
3622 | ||||
3623 | static bool classof(const Attr *A) { return A->getKind() == attr::LockReturned; } | |||
3624 | }; | |||
3625 | ||||
3626 | class LocksExcludedAttr : public InheritableAttr { | |||
3627 | unsigned args_Size; | |||
3628 | Expr * *args_; | |||
3629 | ||||
3630 | public: | |||
3631 | static LocksExcludedAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
3632 | auto *A = new (Ctx) LocksExcludedAttr(Loc, Ctx, Args, ArgsSize, 0); | |||
3633 | A->setImplicit(true); | |||
3634 | return A; | |||
3635 | } | |||
3636 | ||||
3637 | LocksExcludedAttr(SourceRange R, ASTContext &Ctx | |||
3638 | , Expr * *Args, unsigned ArgsSize | |||
3639 | , unsigned SI | |||
3640 | ) | |||
3641 | : InheritableAttr(attr::LocksExcluded, R, SI, true, true) | |||
3642 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
3643 | { | |||
3644 | std::copy(Args, Args + args_Size, args_); | |||
3645 | } | |||
3646 | ||||
3647 | LocksExcludedAttr(SourceRange R, ASTContext &Ctx | |||
3648 | , unsigned SI | |||
3649 | ) | |||
3650 | : InheritableAttr(attr::LocksExcluded, R, SI, true, true) | |||
3651 | , args_Size(0), args_(nullptr) | |||
3652 | { | |||
3653 | } | |||
3654 | ||||
3655 | LocksExcludedAttr *clone(ASTContext &C) const; | |||
3656 | void printPretty(raw_ostream &OS, | |||
3657 | const PrintingPolicy &Policy) const; | |||
3658 | const char *getSpelling() const; | |||
3659 | typedef Expr ** args_iterator; | |||
3660 | args_iterator args_begin() const { return args_; } | |||
3661 | args_iterator args_end() const { return args_ + args_Size; } | |||
3662 | unsigned args_size() const { return args_Size; } | |||
3663 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
3664 | ||||
3665 | ||||
3666 | ||||
3667 | ||||
3668 | static bool classof(const Attr *A) { return A->getKind() == attr::LocksExcluded; } | |||
3669 | }; | |||
3670 | ||||
3671 | class LoopHintAttr : public Attr { | |||
3672 | public: | |||
3673 | enum OptionType { | |||
3674 | Vectorize, | |||
3675 | VectorizeWidth, | |||
3676 | Interleave, | |||
3677 | InterleaveCount, | |||
3678 | Unroll, | |||
3679 | UnrollCount, | |||
3680 | Distribute | |||
3681 | }; | |||
3682 | private: | |||
3683 | OptionType option; | |||
3684 | ||||
3685 | public: | |||
3686 | enum LoopHintState { | |||
3687 | Enable, | |||
3688 | Disable, | |||
3689 | Numeric, | |||
3690 | AssumeSafety, | |||
3691 | Full | |||
3692 | }; | |||
3693 | private: | |||
3694 | LoopHintState state; | |||
3695 | ||||
3696 | Expr * value; | |||
3697 | ||||
3698 | public: | |||
3699 | enum Spelling { | |||
3700 | Pragma_clang_loop = 0, | |||
3701 | Pragma_unroll = 1, | |||
3702 | Pragma_nounroll = 2 | |||
3703 | }; | |||
3704 | ||||
3705 | static LoopHintAttr *CreateImplicit(ASTContext &Ctx, Spelling S, OptionType Option, LoopHintState State, Expr * Value, SourceRange Loc = SourceRange()) { | |||
3706 | auto *A = new (Ctx) LoopHintAttr(Loc, Ctx, Option, State, Value, S); | |||
3707 | A->setImplicit(true); | |||
3708 | return A; | |||
3709 | } | |||
3710 | ||||
3711 | LoopHintAttr(SourceRange R, ASTContext &Ctx | |||
3712 | , OptionType Option | |||
3713 | , LoopHintState State | |||
3714 | , Expr * Value | |||
3715 | , unsigned SI | |||
3716 | ) | |||
3717 | : Attr(attr::LoopHint, R, SI, false) | |||
3718 | , option(Option) | |||
3719 | , state(State) | |||
3720 | , value(Value) | |||
3721 | { | |||
3722 | } | |||
3723 | ||||
3724 | LoopHintAttr *clone(ASTContext &C) const; | |||
3725 | void printPretty(raw_ostream &OS, | |||
3726 | const PrintingPolicy &Policy) const; | |||
3727 | const char *getSpelling() const; | |||
3728 | Spelling getSemanticSpelling() const { | |||
3729 | switch (SpellingListIndex) { | |||
3730 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3730); | |||
3731 | case 0: return Pragma_clang_loop; | |||
3732 | case 1: return Pragma_unroll; | |||
3733 | case 2: return Pragma_nounroll; | |||
3734 | } | |||
3735 | } | |||
3736 | OptionType getOption() const { | |||
3737 | return option; | |||
3738 | } | |||
3739 | ||||
3740 | static bool ConvertStrToOptionType(StringRef Val, OptionType &Out) { | |||
3741 | Optional<OptionType> R = llvm::StringSwitch<Optional<OptionType>>(Val) | |||
3742 | .Case("vectorize", LoopHintAttr::Vectorize) | |||
3743 | .Case("vectorize_width", LoopHintAttr::VectorizeWidth) | |||
3744 | .Case("interleave", LoopHintAttr::Interleave) | |||
3745 | .Case("interleave_count", LoopHintAttr::InterleaveCount) | |||
3746 | .Case("unroll", LoopHintAttr::Unroll) | |||
3747 | .Case("unroll_count", LoopHintAttr::UnrollCount) | |||
3748 | .Case("distribute", LoopHintAttr::Distribute) | |||
3749 | .Default(Optional<OptionType>()); | |||
3750 | if (R) { | |||
3751 | Out = *R; | |||
3752 | return true; | |||
3753 | } | |||
3754 | return false; | |||
3755 | } | |||
3756 | ||||
3757 | static const char *ConvertOptionTypeToStr(OptionType Val) { | |||
3758 | switch(Val) { | |||
3759 | case LoopHintAttr::Vectorize: return "vectorize"; | |||
3760 | case LoopHintAttr::VectorizeWidth: return "vectorize_width"; | |||
3761 | case LoopHintAttr::Interleave: return "interleave"; | |||
3762 | case LoopHintAttr::InterleaveCount: return "interleave_count"; | |||
3763 | case LoopHintAttr::Unroll: return "unroll"; | |||
3764 | case LoopHintAttr::UnrollCount: return "unroll_count"; | |||
3765 | case LoopHintAttr::Distribute: return "distribute"; | |||
3766 | } | |||
3767 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3767); | |||
3768 | } | |||
3769 | LoopHintState getState() const { | |||
3770 | return state; | |||
3771 | } | |||
3772 | ||||
3773 | static bool ConvertStrToLoopHintState(StringRef Val, LoopHintState &Out) { | |||
3774 | Optional<LoopHintState> R = llvm::StringSwitch<Optional<LoopHintState>>(Val) | |||
3775 | .Case("enable", LoopHintAttr::Enable) | |||
3776 | .Case("disable", LoopHintAttr::Disable) | |||
3777 | .Case("numeric", LoopHintAttr::Numeric) | |||
3778 | .Case("assume_safety", LoopHintAttr::AssumeSafety) | |||
3779 | .Case("full", LoopHintAttr::Full) | |||
3780 | .Default(Optional<LoopHintState>()); | |||
3781 | if (R) { | |||
3782 | Out = *R; | |||
3783 | return true; | |||
3784 | } | |||
3785 | return false; | |||
3786 | } | |||
3787 | ||||
3788 | static const char *ConvertLoopHintStateToStr(LoopHintState Val) { | |||
3789 | switch(Val) { | |||
3790 | case LoopHintAttr::Enable: return "enable"; | |||
3791 | case LoopHintAttr::Disable: return "disable"; | |||
3792 | case LoopHintAttr::Numeric: return "numeric"; | |||
3793 | case LoopHintAttr::AssumeSafety: return "assume_safety"; | |||
3794 | case LoopHintAttr::Full: return "full"; | |||
3795 | } | |||
3796 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3796); | |||
3797 | } | |||
3798 | Expr * getValue() const { | |||
3799 | return value; | |||
3800 | } | |||
3801 | ||||
3802 | ||||
3803 | static const char *getOptionName(int Option) { | |||
3804 | switch(Option) { | |||
3805 | case Vectorize: return "vectorize"; | |||
3806 | case VectorizeWidth: return "vectorize_width"; | |||
3807 | case Interleave: return "interleave"; | |||
3808 | case InterleaveCount: return "interleave_count"; | |||
3809 | case Unroll: return "unroll"; | |||
3810 | case UnrollCount: return "unroll_count"; | |||
3811 | case Distribute: return "distribute"; | |||
3812 | } | |||
3813 | llvm_unreachable("Unhandled LoopHint option.")::llvm::llvm_unreachable_internal("Unhandled LoopHint option." , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3813); | |||
3814 | } | |||
3815 | ||||
3816 | void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const { | |||
3817 | unsigned SpellingIndex = getSpellingListIndex(); | |||
3818 | // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or | |||
3819 | // "nounroll" is already emitted as the pragma name. | |||
3820 | if (SpellingIndex == Pragma_nounroll) | |||
3821 | return; | |||
3822 | else if (SpellingIndex == Pragma_unroll) { | |||
3823 | OS << ' ' << getValueString(Policy); | |||
3824 | return; | |||
3825 | } | |||
3826 | ||||
3827 | assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling")(static_cast <bool> (SpellingIndex == Pragma_clang_loop && "Unexpected spelling") ? void (0) : __assert_fail ("SpellingIndex == Pragma_clang_loop && \"Unexpected spelling\"" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3827, __extension__ __PRETTY_FUNCTION__)); | |||
3828 | OS << ' ' << getOptionName(option) << getValueString(Policy); | |||
3829 | } | |||
3830 | ||||
3831 | // Return a string containing the loop hint argument including the | |||
3832 | // enclosing parentheses. | |||
3833 | std::string getValueString(const PrintingPolicy &Policy) const { | |||
3834 | std::string ValueName; | |||
3835 | llvm::raw_string_ostream OS(ValueName); | |||
3836 | OS << "("; | |||
3837 | if (state == Numeric) | |||
3838 | value->printPretty(OS, nullptr, Policy); | |||
3839 | else if (state == Enable) | |||
3840 | OS << "enable"; | |||
3841 | else if (state == Full) | |||
3842 | OS << "full"; | |||
3843 | else if (state == AssumeSafety) | |||
3844 | OS << "assume_safety"; | |||
3845 | else | |||
3846 | OS << "disable"; | |||
3847 | OS << ")"; | |||
3848 | return OS.str(); | |||
3849 | } | |||
3850 | ||||
3851 | // Return a string suitable for identifying this attribute in diagnostics. | |||
3852 | std::string getDiagnosticName(const PrintingPolicy &Policy) const { | |||
3853 | unsigned SpellingIndex = getSpellingListIndex(); | |||
3854 | if (SpellingIndex == Pragma_nounroll) | |||
3855 | return "#pragma nounroll"; | |||
3856 | else if (SpellingIndex == Pragma_unroll) | |||
3857 | return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : ""); | |||
3858 | ||||
3859 | assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling")(static_cast <bool> (SpellingIndex == Pragma_clang_loop && "Unexpected spelling") ? void (0) : __assert_fail ("SpellingIndex == Pragma_clang_loop && \"Unexpected spelling\"" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3859, __extension__ __PRETTY_FUNCTION__)); | |||
3860 | return getOptionName(option) + getValueString(Policy); | |||
3861 | } | |||
3862 | ||||
3863 | ||||
3864 | static bool classof(const Attr *A) { return A->getKind() == attr::LoopHint; } | |||
3865 | }; | |||
3866 | ||||
3867 | class MSABIAttr : public InheritableAttr { | |||
3868 | public: | |||
3869 | static MSABIAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3870 | auto *A = new (Ctx) MSABIAttr(Loc, Ctx, 0); | |||
3871 | A->setImplicit(true); | |||
3872 | return A; | |||
3873 | } | |||
3874 | ||||
3875 | MSABIAttr(SourceRange R, ASTContext &Ctx | |||
3876 | , unsigned SI | |||
3877 | ) | |||
3878 | : InheritableAttr(attr::MSABI, R, SI, false, false) | |||
3879 | { | |||
3880 | } | |||
3881 | ||||
3882 | MSABIAttr *clone(ASTContext &C) const; | |||
3883 | void printPretty(raw_ostream &OS, | |||
3884 | const PrintingPolicy &Policy) const; | |||
3885 | const char *getSpelling() const; | |||
3886 | ||||
3887 | ||||
3888 | static bool classof(const Attr *A) { return A->getKind() == attr::MSABI; } | |||
3889 | }; | |||
3890 | ||||
3891 | class MSInheritanceAttr : public InheritableAttr { | |||
3892 | bool bestCase; | |||
3893 | ||||
3894 | public: | |||
3895 | enum Spelling { | |||
3896 | Keyword_single_inheritance = 0, | |||
3897 | Keyword_multiple_inheritance = 1, | |||
3898 | Keyword_virtual_inheritance = 2, | |||
3899 | Keyword_unspecified_inheritance = 3 | |||
3900 | }; | |||
3901 | ||||
3902 | static MSInheritanceAttr *CreateImplicit(ASTContext &Ctx, Spelling S, bool BestCase, SourceRange Loc = SourceRange()) { | |||
3903 | auto *A = new (Ctx) MSInheritanceAttr(Loc, Ctx, BestCase, S); | |||
3904 | A->setImplicit(true); | |||
3905 | return A; | |||
3906 | } | |||
3907 | ||||
3908 | MSInheritanceAttr(SourceRange R, ASTContext &Ctx | |||
3909 | , bool BestCase | |||
3910 | , unsigned SI | |||
3911 | ) | |||
3912 | : InheritableAttr(attr::MSInheritance, R, SI, false, false) | |||
3913 | , bestCase(BestCase) | |||
3914 | { | |||
3915 | } | |||
3916 | ||||
3917 | MSInheritanceAttr(SourceRange R, ASTContext &Ctx | |||
3918 | , unsigned SI | |||
3919 | ) | |||
3920 | : InheritableAttr(attr::MSInheritance, R, SI, false, false) | |||
3921 | , bestCase() | |||
3922 | { | |||
3923 | } | |||
3924 | ||||
3925 | MSInheritanceAttr *clone(ASTContext &C) const; | |||
3926 | void printPretty(raw_ostream &OS, | |||
3927 | const PrintingPolicy &Policy) const; | |||
3928 | const char *getSpelling() const; | |||
3929 | Spelling getSemanticSpelling() const { | |||
3930 | switch (SpellingListIndex) { | |||
3931 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3931); | |||
3932 | case 0: return Keyword_single_inheritance; | |||
3933 | case 1: return Keyword_multiple_inheritance; | |||
3934 | case 2: return Keyword_virtual_inheritance; | |||
3935 | case 3: return Keyword_unspecified_inheritance; | |||
3936 | } | |||
3937 | } | |||
3938 | bool getBestCase() const { | |||
3939 | return bestCase; | |||
3940 | } | |||
3941 | ||||
3942 | static const bool DefaultBestCase = true; | |||
3943 | ||||
3944 | ||||
3945 | static bool hasVBPtrOffsetField(Spelling Inheritance) { | |||
3946 | return Inheritance == Keyword_unspecified_inheritance; | |||
3947 | } | |||
3948 | ||||
3949 | // Only member pointers to functions need a this adjustment, since it can be | |||
3950 | // combined with the field offset for data pointers. | |||
3951 | static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) { | |||
3952 | return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance; | |||
3953 | } | |||
3954 | ||||
3955 | static bool hasVBTableOffsetField(Spelling Inheritance) { | |||
3956 | return Inheritance >= Keyword_virtual_inheritance; | |||
3957 | } | |||
3958 | ||||
3959 | static bool hasOnlyOneField(bool IsMemberFunction, | |||
3960 | Spelling Inheritance) { | |||
3961 | if (IsMemberFunction) | |||
3962 | return Inheritance <= Keyword_single_inheritance; | |||
3963 | return Inheritance <= Keyword_multiple_inheritance; | |||
3964 | } | |||
3965 | ||||
3966 | ||||
3967 | static bool classof(const Attr *A) { return A->getKind() == attr::MSInheritance; } | |||
3968 | }; | |||
3969 | ||||
3970 | class MSNoVTableAttr : public InheritableAttr { | |||
3971 | public: | |||
3972 | static MSNoVTableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3973 | auto *A = new (Ctx) MSNoVTableAttr(Loc, Ctx, 0); | |||
3974 | A->setImplicit(true); | |||
3975 | return A; | |||
3976 | } | |||
3977 | ||||
3978 | MSNoVTableAttr(SourceRange R, ASTContext &Ctx | |||
3979 | , unsigned SI | |||
3980 | ) | |||
3981 | : InheritableAttr(attr::MSNoVTable, R, SI, false, false) | |||
3982 | { | |||
3983 | } | |||
3984 | ||||
3985 | MSNoVTableAttr *clone(ASTContext &C) const; | |||
3986 | void printPretty(raw_ostream &OS, | |||
3987 | const PrintingPolicy &Policy) const; | |||
3988 | const char *getSpelling() const; | |||
3989 | ||||
3990 | ||||
3991 | static bool classof(const Attr *A) { return A->getKind() == attr::MSNoVTable; } | |||
3992 | }; | |||
3993 | ||||
3994 | class MSP430InterruptAttr : public InheritableAttr { | |||
3995 | unsigned number; | |||
3996 | ||||
3997 | public: | |||
3998 | static MSP430InterruptAttr *CreateImplicit(ASTContext &Ctx, unsigned Number, SourceRange Loc = SourceRange()) { | |||
3999 | auto *A = new (Ctx) MSP430InterruptAttr(Loc, Ctx, Number, 0); | |||
4000 | A->setImplicit(true); | |||
4001 | return A; | |||
4002 | } | |||
4003 | ||||
4004 | MSP430InterruptAttr(SourceRange R, ASTContext &Ctx | |||
4005 | , unsigned Number | |||
4006 | , unsigned SI | |||
4007 | ) | |||
4008 | : InheritableAttr(attr::MSP430Interrupt, R, SI, false, false) | |||
4009 | , number(Number) | |||
4010 | { | |||
4011 | } | |||
4012 | ||||
4013 | MSP430InterruptAttr *clone(ASTContext &C) const; | |||
4014 | void printPretty(raw_ostream &OS, | |||
4015 | const PrintingPolicy &Policy) const; | |||
4016 | const char *getSpelling() const; | |||
4017 | unsigned getNumber() const { | |||
4018 | return number; | |||
4019 | } | |||
4020 | ||||
4021 | ||||
4022 | ||||
4023 | static bool classof(const Attr *A) { return A->getKind() == attr::MSP430Interrupt; } | |||
4024 | }; | |||
4025 | ||||
4026 | class MSStructAttr : public InheritableAttr { | |||
4027 | public: | |||
4028 | static MSStructAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4029 | auto *A = new (Ctx) MSStructAttr(Loc, Ctx, 0); | |||
4030 | A->setImplicit(true); | |||
4031 | return A; | |||
4032 | } | |||
4033 | ||||
4034 | MSStructAttr(SourceRange R, ASTContext &Ctx | |||
4035 | , unsigned SI | |||
4036 | ) | |||
4037 | : InheritableAttr(attr::MSStruct, R, SI, false, false) | |||
4038 | { | |||
4039 | } | |||
4040 | ||||
4041 | MSStructAttr *clone(ASTContext &C) const; | |||
4042 | void printPretty(raw_ostream &OS, | |||
4043 | const PrintingPolicy &Policy) const; | |||
4044 | const char *getSpelling() const; | |||
4045 | ||||
4046 | ||||
4047 | static bool classof(const Attr *A) { return A->getKind() == attr::MSStruct; } | |||
4048 | }; | |||
4049 | ||||
4050 | class MSVtorDispAttr : public InheritableAttr { | |||
4051 | unsigned vdm; | |||
4052 | ||||
4053 | public: | |||
4054 | static MSVtorDispAttr *CreateImplicit(ASTContext &Ctx, unsigned Vdm, SourceRange Loc = SourceRange()) { | |||
4055 | auto *A = new (Ctx) MSVtorDispAttr(Loc, Ctx, Vdm, 0); | |||
4056 | A->setImplicit(true); | |||
4057 | return A; | |||
4058 | } | |||
4059 | ||||
4060 | MSVtorDispAttr(SourceRange R, ASTContext &Ctx | |||
4061 | , unsigned Vdm | |||
4062 | , unsigned SI | |||
4063 | ) | |||
4064 | : InheritableAttr(attr::MSVtorDisp, R, SI, false, false) | |||
4065 | , vdm(Vdm) | |||
4066 | { | |||
4067 | } | |||
4068 | ||||
4069 | MSVtorDispAttr *clone(ASTContext &C) const; | |||
4070 | void printPretty(raw_ostream &OS, | |||
4071 | const PrintingPolicy &Policy) const; | |||
4072 | const char *getSpelling() const; | |||
4073 | unsigned getVdm() const { | |||
4074 | return vdm; | |||
4075 | } | |||
4076 | ||||
4077 | ||||
4078 | enum Mode { | |||
4079 | Never, | |||
4080 | ForVBaseOverride, | |||
4081 | ForVFTable | |||
4082 | }; | |||
4083 | ||||
4084 | Mode getVtorDispMode() const { return Mode(vdm); } | |||
4085 | ||||
4086 | ||||
4087 | static bool classof(const Attr *A) { return A->getKind() == attr::MSVtorDisp; } | |||
4088 | }; | |||
4089 | ||||
4090 | class MaxFieldAlignmentAttr : public InheritableAttr { | |||
4091 | unsigned alignment; | |||
4092 | ||||
4093 | public: | |||
4094 | static MaxFieldAlignmentAttr *CreateImplicit(ASTContext &Ctx, unsigned Alignment, SourceRange Loc = SourceRange()) { | |||
4095 | auto *A = new (Ctx) MaxFieldAlignmentAttr(Loc, Ctx, Alignment, 0); | |||
4096 | A->setImplicit(true); | |||
4097 | return A; | |||
4098 | } | |||
4099 | ||||
4100 | MaxFieldAlignmentAttr(SourceRange R, ASTContext &Ctx | |||
4101 | , unsigned Alignment | |||
4102 | , unsigned SI | |||
4103 | ) | |||
4104 | : InheritableAttr(attr::MaxFieldAlignment, R, SI, false, false) | |||
4105 | , alignment(Alignment) | |||
4106 | { | |||
4107 | } | |||
4108 | ||||
4109 | MaxFieldAlignmentAttr *clone(ASTContext &C) const; | |||
4110 | void printPretty(raw_ostream &OS, | |||
4111 | const PrintingPolicy &Policy) const; | |||
4112 | const char *getSpelling() const; | |||
4113 | unsigned getAlignment() const { | |||
4114 | return alignment; | |||
4115 | } | |||
4116 | ||||
4117 | ||||
4118 | ||||
4119 | static bool classof(const Attr *A) { return A->getKind() == attr::MaxFieldAlignment; } | |||
4120 | }; | |||
4121 | ||||
4122 | class MayAliasAttr : public InheritableAttr { | |||
4123 | public: | |||
4124 | static MayAliasAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4125 | auto *A = new (Ctx) MayAliasAttr(Loc, Ctx, 0); | |||
4126 | A->setImplicit(true); | |||
4127 | return A; | |||
4128 | } | |||
4129 | ||||
4130 | MayAliasAttr(SourceRange R, ASTContext &Ctx | |||
4131 | , unsigned SI | |||
4132 | ) | |||
4133 | : InheritableAttr(attr::MayAlias, R, SI, false, false) | |||
4134 | { | |||
4135 | } | |||
4136 | ||||
4137 | MayAliasAttr *clone(ASTContext &C) const; | |||
4138 | void printPretty(raw_ostream &OS, | |||
4139 | const PrintingPolicy &Policy) const; | |||
4140 | const char *getSpelling() const; | |||
4141 | ||||
4142 | ||||
4143 | static bool classof(const Attr *A) { return A->getKind() == attr::MayAlias; } | |||
4144 | }; | |||
4145 | ||||
4146 | class MicroMipsAttr : public InheritableAttr { | |||
4147 | public: | |||
4148 | static MicroMipsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4149 | auto *A = new (Ctx) MicroMipsAttr(Loc, Ctx, 0); | |||
4150 | A->setImplicit(true); | |||
4151 | return A; | |||
4152 | } | |||
4153 | ||||
4154 | MicroMipsAttr(SourceRange R, ASTContext &Ctx | |||
4155 | , unsigned SI | |||
4156 | ) | |||
4157 | : InheritableAttr(attr::MicroMips, R, SI, false, false) | |||
4158 | { | |||
4159 | } | |||
4160 | ||||
4161 | MicroMipsAttr *clone(ASTContext &C) const; | |||
4162 | void printPretty(raw_ostream &OS, | |||
4163 | const PrintingPolicy &Policy) const; | |||
4164 | const char *getSpelling() const; | |||
4165 | ||||
4166 | ||||
4167 | static bool classof(const Attr *A) { return A->getKind() == attr::MicroMips; } | |||
4168 | }; | |||
4169 | ||||
4170 | class MinSizeAttr : public InheritableAttr { | |||
4171 | public: | |||
4172 | static MinSizeAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4173 | auto *A = new (Ctx) MinSizeAttr(Loc, Ctx, 0); | |||
4174 | A->setImplicit(true); | |||
4175 | return A; | |||
4176 | } | |||
4177 | ||||
4178 | MinSizeAttr(SourceRange R, ASTContext &Ctx | |||
4179 | , unsigned SI | |||
4180 | ) | |||
4181 | : InheritableAttr(attr::MinSize, R, SI, false, false) | |||
4182 | { | |||
4183 | } | |||
4184 | ||||
4185 | MinSizeAttr *clone(ASTContext &C) const; | |||
4186 | void printPretty(raw_ostream &OS, | |||
4187 | const PrintingPolicy &Policy) const; | |||
4188 | const char *getSpelling() const; | |||
4189 | ||||
4190 | ||||
4191 | static bool classof(const Attr *A) { return A->getKind() == attr::MinSize; } | |||
4192 | }; | |||
4193 | ||||
4194 | class Mips16Attr : public InheritableAttr { | |||
4195 | public: | |||
4196 | static Mips16Attr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4197 | auto *A = new (Ctx) Mips16Attr(Loc, Ctx, 0); | |||
4198 | A->setImplicit(true); | |||
4199 | return A; | |||
4200 | } | |||
4201 | ||||
4202 | Mips16Attr(SourceRange R, ASTContext &Ctx | |||
4203 | , unsigned SI | |||
4204 | ) | |||
4205 | : InheritableAttr(attr::Mips16, R, SI, false, false) | |||
4206 | { | |||
4207 | } | |||
4208 | ||||
4209 | Mips16Attr *clone(ASTContext &C) const; | |||
4210 | void printPretty(raw_ostream &OS, | |||
4211 | const PrintingPolicy &Policy) const; | |||
4212 | const char *getSpelling() const; | |||
4213 | ||||
4214 | ||||
4215 | static bool classof(const Attr *A) { return A->getKind() == attr::Mips16; } | |||
4216 | }; | |||
4217 | ||||
4218 | class MipsInterruptAttr : public InheritableAttr { | |||
4219 | public: | |||
4220 | enum InterruptType { | |||
4221 | sw0, | |||
4222 | sw1, | |||
4223 | hw0, | |||
4224 | hw1, | |||
4225 | hw2, | |||
4226 | hw3, | |||
4227 | hw4, | |||
4228 | hw5, | |||
4229 | eic | |||
4230 | }; | |||
4231 | private: | |||
4232 | InterruptType interrupt; | |||
4233 | ||||
4234 | public: | |||
4235 | static MipsInterruptAttr *CreateImplicit(ASTContext &Ctx, InterruptType Interrupt, SourceRange Loc = SourceRange()) { | |||
4236 | auto *A = new (Ctx) MipsInterruptAttr(Loc, Ctx, Interrupt, 0); | |||
4237 | A->setImplicit(true); | |||
4238 | return A; | |||
4239 | } | |||
4240 | ||||
4241 | MipsInterruptAttr(SourceRange R, ASTContext &Ctx | |||
4242 | , InterruptType Interrupt | |||
4243 | , unsigned SI | |||
4244 | ) | |||
4245 | : InheritableAttr(attr::MipsInterrupt, R, SI, false, false) | |||
4246 | , interrupt(Interrupt) | |||
4247 | { | |||
4248 | } | |||
4249 | ||||
4250 | MipsInterruptAttr *clone(ASTContext &C) const; | |||
4251 | void printPretty(raw_ostream &OS, | |||
4252 | const PrintingPolicy &Policy) const; | |||
4253 | const char *getSpelling() const; | |||
4254 | InterruptType getInterrupt() const { | |||
4255 | return interrupt; | |||
4256 | } | |||
4257 | ||||
4258 | static bool ConvertStrToInterruptType(StringRef Val, InterruptType &Out) { | |||
4259 | Optional<InterruptType> R = llvm::StringSwitch<Optional<InterruptType>>(Val) | |||
4260 | .Case("vector=sw0", MipsInterruptAttr::sw0) | |||
4261 | .Case("vector=sw1", MipsInterruptAttr::sw1) | |||
4262 | .Case("vector=hw0", MipsInterruptAttr::hw0) | |||
4263 | .Case("vector=hw1", MipsInterruptAttr::hw1) | |||
4264 | .Case("vector=hw2", MipsInterruptAttr::hw2) | |||
4265 | .Case("vector=hw3", MipsInterruptAttr::hw3) | |||
4266 | .Case("vector=hw4", MipsInterruptAttr::hw4) | |||
4267 | .Case("vector=hw5", MipsInterruptAttr::hw5) | |||
4268 | .Case("eic", MipsInterruptAttr::eic) | |||
4269 | .Case("", MipsInterruptAttr::eic) | |||
4270 | .Default(Optional<InterruptType>()); | |||
4271 | if (R) { | |||
4272 | Out = *R; | |||
4273 | return true; | |||
4274 | } | |||
4275 | return false; | |||
4276 | } | |||
4277 | ||||
4278 | static const char *ConvertInterruptTypeToStr(InterruptType Val) { | |||
4279 | switch(Val) { | |||
4280 | case MipsInterruptAttr::sw0: return "vector=sw0"; | |||
4281 | case MipsInterruptAttr::sw1: return "vector=sw1"; | |||
4282 | case MipsInterruptAttr::hw0: return "vector=hw0"; | |||
4283 | case MipsInterruptAttr::hw1: return "vector=hw1"; | |||
4284 | case MipsInterruptAttr::hw2: return "vector=hw2"; | |||
4285 | case MipsInterruptAttr::hw3: return "vector=hw3"; | |||
4286 | case MipsInterruptAttr::hw4: return "vector=hw4"; | |||
4287 | case MipsInterruptAttr::hw5: return "vector=hw5"; | |||
4288 | case MipsInterruptAttr::eic: return "eic"; | |||
4289 | } | |||
4290 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 4290); | |||
4291 | } | |||
4292 | ||||
4293 | ||||
4294 | static bool classof(const Attr *A) { return A->getKind() == attr::MipsInterrupt; } | |||
4295 | }; | |||
4296 | ||||
4297 | class MipsLongCallAttr : public InheritableAttr { | |||
4298 | public: | |||
4299 | enum Spelling { | |||
4300 | GNU_long_call = 0, | |||
4301 | CXX11_gnu_long_call = 1, | |||
4302 | GNU_far = 2, | |||
4303 | CXX11_gnu_far = 3 | |||
4304 | }; | |||
4305 | ||||
4306 | static MipsLongCallAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
4307 | auto *A = new (Ctx) MipsLongCallAttr(Loc, Ctx, S); | |||
4308 | A->setImplicit(true); | |||
4309 | return A; | |||
4310 | } | |||
4311 | ||||
4312 | MipsLongCallAttr(SourceRange R, ASTContext &Ctx | |||
4313 | , unsigned SI | |||
4314 | ) | |||
4315 | : InheritableAttr(attr::MipsLongCall, R, SI, false, false) | |||
4316 | { | |||
4317 | } | |||
4318 | ||||
4319 | MipsLongCallAttr *clone(ASTContext &C) const; | |||
4320 | void printPretty(raw_ostream &OS, | |||
4321 | const PrintingPolicy &Policy) const; | |||
4322 | const char *getSpelling() const; | |||
4323 | Spelling getSemanticSpelling() const { | |||
4324 | switch (SpellingListIndex) { | |||
4325 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 4325); | |||
4326 | case 0: return GNU_long_call; | |||
4327 | case 1: return CXX11_gnu_long_call; | |||
4328 | case 2: return GNU_far; | |||
4329 | case 3: return CXX11_gnu_far; | |||
4330 | } | |||
4331 | } | |||
4332 | ||||
4333 | ||||
4334 | static bool classof(const Attr *A) { return A->getKind() == attr::MipsLongCall; } | |||
4335 | }; | |||
4336 | ||||
4337 | class MipsShortCallAttr : public InheritableAttr { | |||
4338 | public: | |||
4339 | enum Spelling { | |||
4340 | GNU_short_call = 0, | |||
4341 | CXX11_gnu_short_call = 1, | |||
4342 | GNU_near = 2, | |||
4343 | CXX11_gnu_near = 3 | |||
4344 | }; | |||
4345 | ||||
4346 | static MipsShortCallAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
4347 | auto *A = new (Ctx) MipsShortCallAttr(Loc, Ctx, S); | |||
4348 | A->setImplicit(true); | |||
4349 | return A; | |||
4350 | } | |||
4351 | ||||
4352 | MipsShortCallAttr(SourceRange R, ASTContext &Ctx | |||
4353 | , unsigned SI | |||
4354 | ) | |||
4355 | : InheritableAttr(attr::MipsShortCall, R, SI, false, false) | |||
4356 | { | |||
4357 | } | |||
4358 | ||||
4359 | MipsShortCallAttr *clone(ASTContext &C) const; | |||
4360 | void printPretty(raw_ostream &OS, | |||
4361 | const PrintingPolicy &Policy) const; | |||
4362 | const char *getSpelling() const; | |||
4363 | Spelling getSemanticSpelling() const { | |||
4364 | switch (SpellingListIndex) { | |||
4365 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 4365); | |||
4366 | case 0: return GNU_short_call; | |||
4367 | case 1: return CXX11_gnu_short_call; | |||
4368 | case 2: return GNU_near; | |||
4369 | case 3: return CXX11_gnu_near; | |||
4370 | } | |||
4371 | } | |||
4372 | ||||
4373 | ||||
4374 | static bool classof(const Attr *A) { return A->getKind() == attr::MipsShortCall; } | |||
4375 | }; | |||
4376 | ||||
4377 | class ModeAttr : public Attr { | |||
4378 | IdentifierInfo * mode; | |||
4379 | ||||
4380 | public: | |||
4381 | static ModeAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Mode, SourceRange Loc = SourceRange()) { | |||
4382 | auto *A = new (Ctx) ModeAttr(Loc, Ctx, Mode, 0); | |||
4383 | A->setImplicit(true); | |||
4384 | return A; | |||
4385 | } | |||
4386 | ||||
4387 | ModeAttr(SourceRange R, ASTContext &Ctx | |||
4388 | , IdentifierInfo * Mode | |||
4389 | , unsigned SI | |||
4390 | ) | |||
4391 | : Attr(attr::Mode, R, SI, false) | |||
4392 | , mode(Mode) | |||
4393 | { | |||
4394 | } | |||
4395 | ||||
4396 | ModeAttr *clone(ASTContext &C) const; | |||
4397 | void printPretty(raw_ostream &OS, | |||
4398 | const PrintingPolicy &Policy) const; | |||
4399 | const char *getSpelling() const; | |||
4400 | IdentifierInfo * getMode() const { | |||
4401 | return mode; | |||
4402 | } | |||
4403 | ||||
4404 | ||||
4405 | ||||
4406 | static bool classof(const Attr *A) { return A->getKind() == attr::Mode; } | |||
4407 | }; | |||
4408 | ||||
4409 | class NSConsumedAttr : public InheritableParamAttr { | |||
4410 | public: | |||
4411 | static NSConsumedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4412 | auto *A = new (Ctx) NSConsumedAttr(Loc, Ctx, 0); | |||
4413 | A->setImplicit(true); | |||
4414 | return A; | |||
4415 | } | |||
4416 | ||||
4417 | NSConsumedAttr(SourceRange R, ASTContext &Ctx | |||
4418 | , unsigned SI | |||
4419 | ) | |||
4420 | : InheritableParamAttr(attr::NSConsumed, R, SI, false, false) | |||
4421 | { | |||
4422 | } | |||
4423 | ||||
4424 | NSConsumedAttr *clone(ASTContext &C) const; | |||
4425 | void printPretty(raw_ostream &OS, | |||
4426 | const PrintingPolicy &Policy) const; | |||
4427 | const char *getSpelling() const; | |||
4428 | ||||
4429 | ||||
4430 | static bool classof(const Attr *A) { return A->getKind() == attr::NSConsumed; } | |||
4431 | }; | |||
4432 | ||||
4433 | class NSConsumesSelfAttr : public InheritableAttr { | |||
4434 | public: | |||
4435 | static NSConsumesSelfAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4436 | auto *A = new (Ctx) NSConsumesSelfAttr(Loc, Ctx, 0); | |||
4437 | A->setImplicit(true); | |||
4438 | return A; | |||
4439 | } | |||
4440 | ||||
4441 | NSConsumesSelfAttr(SourceRange R, ASTContext &Ctx | |||
4442 | , unsigned SI | |||
4443 | ) | |||
4444 | : InheritableAttr(attr::NSConsumesSelf, R, SI, false, false) | |||
4445 | { | |||
4446 | } | |||
4447 | ||||
4448 | NSConsumesSelfAttr *clone(ASTContext &C) const; | |||
4449 | void printPretty(raw_ostream &OS, | |||
4450 | const PrintingPolicy &Policy) const; | |||
4451 | const char *getSpelling() const; | |||
4452 | ||||
4453 | ||||
4454 | static bool classof(const Attr *A) { return A->getKind() == attr::NSConsumesSelf; } | |||
4455 | }; | |||
4456 | ||||
4457 | class NSReturnsAutoreleasedAttr : public InheritableAttr { | |||
4458 | public: | |||
4459 | static NSReturnsAutoreleasedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4460 | auto *A = new (Ctx) NSReturnsAutoreleasedAttr(Loc, Ctx, 0); | |||
4461 | A->setImplicit(true); | |||
4462 | return A; | |||
4463 | } | |||
4464 | ||||
4465 | NSReturnsAutoreleasedAttr(SourceRange R, ASTContext &Ctx | |||
4466 | , unsigned SI | |||
4467 | ) | |||
4468 | : InheritableAttr(attr::NSReturnsAutoreleased, R, SI, false, false) | |||
4469 | { | |||
4470 | } | |||
4471 | ||||
4472 | NSReturnsAutoreleasedAttr *clone(ASTContext &C) const; | |||
4473 | void printPretty(raw_ostream &OS, | |||
4474 | const PrintingPolicy &Policy) const; | |||
4475 | const char *getSpelling() const; | |||
4476 | ||||
4477 | ||||
4478 | static bool classof(const Attr *A) { return A->getKind() == attr::NSReturnsAutoreleased; } | |||
4479 | }; | |||
4480 | ||||
4481 | class NSReturnsNotRetainedAttr : public InheritableAttr { | |||
4482 | public: | |||
4483 | static NSReturnsNotRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4484 | auto *A = new (Ctx) NSReturnsNotRetainedAttr(Loc, Ctx, 0); | |||
4485 | A->setImplicit(true); | |||
4486 | return A; | |||
4487 | } | |||
4488 | ||||
4489 | NSReturnsNotRetainedAttr(SourceRange R, ASTContext &Ctx | |||
4490 | , unsigned SI | |||
4491 | ) | |||
4492 | : InheritableAttr(attr::NSReturnsNotRetained, R, SI, false, false) | |||
4493 | { | |||
4494 | } | |||
4495 | ||||
4496 | NSReturnsNotRetainedAttr *clone(ASTContext &C) const; | |||
4497 | void printPretty(raw_ostream &OS, | |||
4498 | const PrintingPolicy &Policy) const; | |||
4499 | const char *getSpelling() const; | |||
4500 | ||||
4501 | ||||
4502 | static bool classof(const Attr *A) { return A->getKind() == attr::NSReturnsNotRetained; } | |||
4503 | }; | |||
4504 | ||||
4505 | class NSReturnsRetainedAttr : public InheritableAttr { | |||
4506 | public: | |||
4507 | static NSReturnsRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4508 | auto *A = new (Ctx) NSReturnsRetainedAttr(Loc, Ctx, 0); | |||
4509 | A->setImplicit(true); | |||
4510 | return A; | |||
4511 | } | |||
4512 | ||||
4513 | NSReturnsRetainedAttr(SourceRange R, ASTContext &Ctx | |||
4514 | , unsigned SI | |||
4515 | ) | |||
4516 | : InheritableAttr(attr::NSReturnsRetained, R, SI, false, false) | |||
4517 | { | |||
4518 | } | |||
4519 | ||||
4520 | NSReturnsRetainedAttr *clone(ASTContext &C) const; | |||
4521 | void printPretty(raw_ostream &OS, | |||
4522 | const PrintingPolicy &Policy) const; | |||
4523 | const char *getSpelling() const; | |||
4524 | ||||
4525 | ||||
4526 | static bool classof(const Attr *A) { return A->getKind() == attr::NSReturnsRetained; } | |||
4527 | }; | |||
4528 | ||||
4529 | class NakedAttr : public InheritableAttr { | |||
4530 | public: | |||
4531 | static NakedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4532 | auto *A = new (Ctx) NakedAttr(Loc, Ctx, 0); | |||
4533 | A->setImplicit(true); | |||
4534 | return A; | |||
4535 | } | |||
4536 | ||||
4537 | NakedAttr(SourceRange R, ASTContext &Ctx | |||
4538 | , unsigned SI | |||
4539 | ) | |||
4540 | : InheritableAttr(attr::Naked, R, SI, false, false) | |||
4541 | { | |||
4542 | } | |||
4543 | ||||
4544 | NakedAttr *clone(ASTContext &C) const; | |||
4545 | void printPretty(raw_ostream &OS, | |||
4546 | const PrintingPolicy &Policy) const; | |||
4547 | const char *getSpelling() const; | |||
4548 | ||||
4549 | ||||
4550 | static bool classof(const Attr *A) { return A->getKind() == attr::Naked; } | |||
4551 | }; | |||
4552 | ||||
4553 | class NoAliasAttr : public InheritableAttr { | |||
4554 | public: | |||
4555 | static NoAliasAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4556 | auto *A = new (Ctx) NoAliasAttr(Loc, Ctx, 0); | |||
4557 | A->setImplicit(true); | |||
4558 | return A; | |||
4559 | } | |||
4560 | ||||
4561 | NoAliasAttr(SourceRange R, ASTContext &Ctx | |||
4562 | , unsigned SI | |||
4563 | ) | |||
4564 | : InheritableAttr(attr::NoAlias, R, SI, false, false) | |||
4565 | { | |||
4566 | } | |||
4567 | ||||
4568 | NoAliasAttr *clone(ASTContext &C) const; | |||
4569 | void printPretty(raw_ostream &OS, | |||
4570 | const PrintingPolicy &Policy) const; | |||
4571 | const char *getSpelling() const; | |||
4572 | ||||
4573 | ||||
4574 | static bool classof(const Attr *A) { return A->getKind() == attr::NoAlias; } | |||
4575 | }; | |||
4576 | ||||
4577 | class NoCommonAttr : public InheritableAttr { | |||
4578 | public: | |||
4579 | static NoCommonAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4580 | auto *A = new (Ctx) NoCommonAttr(Loc, Ctx, 0); | |||
4581 | A->setImplicit(true); | |||
4582 | return A; | |||
4583 | } | |||
4584 | ||||
4585 | NoCommonAttr(SourceRange R, ASTContext &Ctx | |||
4586 | , unsigned SI | |||
4587 | ) | |||
4588 | : InheritableAttr(attr::NoCommon, R, SI, false, false) | |||
4589 | { | |||
4590 | } | |||
4591 | ||||
4592 | NoCommonAttr *clone(ASTContext &C) const; | |||
4593 | void printPretty(raw_ostream &OS, | |||
4594 | const PrintingPolicy &Policy) const; | |||
4595 | const char *getSpelling() const; | |||
4596 | ||||
4597 | ||||
4598 | static bool classof(const Attr *A) { return A->getKind() == attr::NoCommon; } | |||
4599 | }; | |||
4600 | ||||
4601 | class NoDebugAttr : public InheritableAttr { | |||
4602 | public: | |||
4603 | static NoDebugAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4604 | auto *A = new (Ctx) NoDebugAttr(Loc, Ctx, 0); | |||
4605 | A->setImplicit(true); | |||
4606 | return A; | |||
4607 | } | |||
4608 | ||||
4609 | NoDebugAttr(SourceRange R, ASTContext &Ctx | |||
4610 | , unsigned SI | |||
4611 | ) | |||
4612 | : InheritableAttr(attr::NoDebug, R, SI, false, false) | |||
4613 | { | |||
4614 | } | |||
4615 | ||||
4616 | NoDebugAttr *clone(ASTContext &C) const; | |||
4617 | void printPretty(raw_ostream &OS, | |||
4618 | const PrintingPolicy &Policy) const; | |||
4619 | const char *getSpelling() const; | |||
4620 | ||||
4621 | ||||
4622 | static bool classof(const Attr *A) { return A->getKind() == attr::NoDebug; } | |||
4623 | }; | |||
4624 | ||||
4625 | class NoDuplicateAttr : public InheritableAttr { | |||
4626 | public: | |||
4627 | static NoDuplicateAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4628 | auto *A = new (Ctx) NoDuplicateAttr(Loc, Ctx, 0); | |||
4629 | A->setImplicit(true); | |||
4630 | return A; | |||
4631 | } | |||
4632 | ||||
4633 | NoDuplicateAttr(SourceRange R, ASTContext &Ctx | |||
4634 | , unsigned SI | |||
4635 | ) | |||
4636 | : InheritableAttr(attr::NoDuplicate, R, SI, false, false) | |||
4637 | { | |||
4638 | } | |||
4639 | ||||
4640 | NoDuplicateAttr *clone(ASTContext &C) const; | |||
4641 | void printPretty(raw_ostream &OS, | |||
4642 | const PrintingPolicy &Policy) const; | |||
4643 | const char *getSpelling() const; | |||
4644 | ||||
4645 | ||||
4646 | static bool classof(const Attr *A) { return A->getKind() == attr::NoDuplicate; } | |||
4647 | }; | |||
4648 | ||||
4649 | class NoEscapeAttr : public Attr { | |||
4650 | public: | |||
4651 | static NoEscapeAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4652 | auto *A = new (Ctx) NoEscapeAttr(Loc, Ctx, 0); | |||
4653 | A->setImplicit(true); | |||
4654 | return A; | |||
4655 | } | |||
4656 | ||||
4657 | NoEscapeAttr(SourceRange R, ASTContext &Ctx | |||
4658 | , unsigned SI | |||
4659 | ) | |||
4660 | : Attr(attr::NoEscape, R, SI, false) | |||
4661 | { | |||
4662 | } | |||
4663 | ||||
4664 | NoEscapeAttr *clone(ASTContext &C) const; | |||
4665 | void printPretty(raw_ostream &OS, | |||
4666 | const PrintingPolicy &Policy) const; | |||
4667 | const char *getSpelling() const; | |||
4668 | ||||
4669 | ||||
4670 | static bool classof(const Attr *A) { return A->getKind() == attr::NoEscape; } | |||
4671 | }; | |||
4672 | ||||
4673 | class NoInlineAttr : public InheritableAttr { | |||
4674 | public: | |||
4675 | static NoInlineAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4676 | auto *A = new (Ctx) NoInlineAttr(Loc, Ctx, 0); | |||
4677 | A->setImplicit(true); | |||
4678 | return A; | |||
4679 | } | |||
4680 | ||||
4681 | NoInlineAttr(SourceRange R, ASTContext &Ctx | |||
4682 | , unsigned SI | |||
4683 | ) | |||
4684 | : InheritableAttr(attr::NoInline, R, SI, false, false) | |||
4685 | { | |||
4686 | } | |||
4687 | ||||
4688 | NoInlineAttr *clone(ASTContext &C) const; | |||
4689 | void printPretty(raw_ostream &OS, | |||
4690 | const PrintingPolicy &Policy) const; | |||
4691 | const char *getSpelling() const; | |||
4692 | ||||
4693 | ||||
4694 | static bool classof(const Attr *A) { return A->getKind() == attr::NoInline; } | |||
4695 | }; | |||
4696 | ||||
4697 | class NoInstrumentFunctionAttr : public InheritableAttr { | |||
4698 | public: | |||
4699 | static NoInstrumentFunctionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4700 | auto *A = new (Ctx) NoInstrumentFunctionAttr(Loc, Ctx, 0); | |||
4701 | A->setImplicit(true); | |||
4702 | return A; | |||
4703 | } | |||
4704 | ||||
4705 | NoInstrumentFunctionAttr(SourceRange R, ASTContext &Ctx | |||
4706 | , unsigned SI | |||
4707 | ) | |||
4708 | : InheritableAttr(attr::NoInstrumentFunction, R, SI, false, false) | |||
4709 | { | |||
4710 | } | |||
4711 | ||||
4712 | NoInstrumentFunctionAttr *clone(ASTContext &C) const; | |||
4713 | void printPretty(raw_ostream &OS, | |||
4714 | const PrintingPolicy &Policy) const; | |||
4715 | const char *getSpelling() const; | |||
4716 | ||||
4717 | ||||
4718 | static bool classof(const Attr *A) { return A->getKind() == attr::NoInstrumentFunction; } | |||
4719 | }; | |||
4720 | ||||
4721 | class NoMicroMipsAttr : public InheritableAttr { | |||
4722 | public: | |||
4723 | static NoMicroMipsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4724 | auto *A = new (Ctx) NoMicroMipsAttr(Loc, Ctx, 0); | |||
4725 | A->setImplicit(true); | |||
4726 | return A; | |||
4727 | } | |||
4728 | ||||
4729 | NoMicroMipsAttr(SourceRange R, ASTContext &Ctx | |||
4730 | , unsigned SI | |||
4731 | ) | |||
4732 | : InheritableAttr(attr::NoMicroMips, R, SI, false, false) | |||
4733 | { | |||
4734 | } | |||
4735 | ||||
4736 | NoMicroMipsAttr *clone(ASTContext &C) const; | |||
4737 | void printPretty(raw_ostream &OS, | |||
4738 | const PrintingPolicy &Policy) const; | |||
4739 | const char *getSpelling() const; | |||
4740 | ||||
4741 | ||||
4742 | static bool classof(const Attr *A) { return A->getKind() == attr::NoMicroMips; } | |||
4743 | }; | |||
4744 | ||||
4745 | class NoMips16Attr : public InheritableAttr { | |||
4746 | public: | |||
4747 | static NoMips16Attr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4748 | auto *A = new (Ctx) NoMips16Attr(Loc, Ctx, 0); | |||
4749 | A->setImplicit(true); | |||
4750 | return A; | |||
4751 | } | |||
4752 | ||||
4753 | NoMips16Attr(SourceRange R, ASTContext &Ctx | |||
4754 | , unsigned SI | |||
4755 | ) | |||
4756 | : InheritableAttr(attr::NoMips16, R, SI, false, false) | |||
4757 | { | |||
4758 | } | |||
4759 | ||||
4760 | NoMips16Attr *clone(ASTContext &C) const; | |||
4761 | void printPretty(raw_ostream &OS, | |||
4762 | const PrintingPolicy &Policy) const; | |||
4763 | const char *getSpelling() const; | |||
4764 | ||||
4765 | ||||
4766 | static bool classof(const Attr *A) { return A->getKind() == attr::NoMips16; } | |||
4767 | }; | |||
4768 | ||||
4769 | class NoReturnAttr : public InheritableAttr { | |||
4770 | public: | |||
4771 | static NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4772 | auto *A = new (Ctx) NoReturnAttr(Loc, Ctx, 0); | |||
4773 | A->setImplicit(true); | |||
4774 | return A; | |||
4775 | } | |||
4776 | ||||
4777 | NoReturnAttr(SourceRange R, ASTContext &Ctx | |||
4778 | , unsigned SI | |||
4779 | ) | |||
4780 | : InheritableAttr(attr::NoReturn, R, SI, false, false) | |||
4781 | { | |||
4782 | } | |||
4783 | ||||
4784 | NoReturnAttr *clone(ASTContext &C) const; | |||
4785 | void printPretty(raw_ostream &OS, | |||
4786 | const PrintingPolicy &Policy) const; | |||
4787 | const char *getSpelling() const; | |||
4788 | ||||
4789 | ||||
4790 | static bool classof(const Attr *A) { return A->getKind() == attr::NoReturn; } | |||
4791 | }; | |||
4792 | ||||
4793 | class NoSanitizeAttr : public InheritableAttr { | |||
4794 | unsigned sanitizers_Size; | |||
4795 | StringRef *sanitizers_; | |||
4796 | ||||
4797 | public: | |||
4798 | static NoSanitizeAttr *CreateImplicit(ASTContext &Ctx, StringRef *Sanitizers, unsigned SanitizersSize, SourceRange Loc = SourceRange()) { | |||
4799 | auto *A = new (Ctx) NoSanitizeAttr(Loc, Ctx, Sanitizers, SanitizersSize, 0); | |||
4800 | A->setImplicit(true); | |||
4801 | return A; | |||
4802 | } | |||
4803 | ||||
4804 | NoSanitizeAttr(SourceRange R, ASTContext &Ctx | |||
4805 | , StringRef *Sanitizers, unsigned SanitizersSize | |||
4806 | , unsigned SI | |||
4807 | ) | |||
4808 | : InheritableAttr(attr::NoSanitize, R, SI, false, false) | |||
4809 | , sanitizers_Size(SanitizersSize), sanitizers_(new (Ctx, 16) StringRef[sanitizers_Size]) | |||
4810 | { | |||
4811 | for (size_t I = 0, E = sanitizers_Size; I != E; | |||
4812 | ++I) { | |||
4813 | StringRef Ref = Sanitizers[I]; | |||
4814 | if (!Ref.empty()) { | |||
4815 | char *Mem = new (Ctx, 1) char[Ref.size()]; | |||
4816 | std::memcpy(Mem, Ref.data(), Ref.size()); | |||
4817 | sanitizers_[I] = StringRef(Mem, Ref.size()); | |||
4818 | } | |||
4819 | } | |||
4820 | } | |||
4821 | ||||
4822 | NoSanitizeAttr(SourceRange R, ASTContext &Ctx | |||
4823 | , unsigned SI | |||
4824 | ) | |||
4825 | : InheritableAttr(attr::NoSanitize, R, SI, false, false) | |||
4826 | , sanitizers_Size(0), sanitizers_(nullptr) | |||
4827 | { | |||
4828 | } | |||
4829 | ||||
4830 | NoSanitizeAttr *clone(ASTContext &C) const; | |||
4831 | void printPretty(raw_ostream &OS, | |||
4832 | const PrintingPolicy &Policy) const; | |||
4833 | const char *getSpelling() const; | |||
4834 | typedef StringRef* sanitizers_iterator; | |||
4835 | sanitizers_iterator sanitizers_begin() const { return sanitizers_; } | |||
4836 | sanitizers_iterator sanitizers_end() const { return sanitizers_ + sanitizers_Size; } | |||
4837 | unsigned sanitizers_size() const { return sanitizers_Size; } | |||
4838 | llvm::iterator_range<sanitizers_iterator> sanitizers() const { return llvm::make_range(sanitizers_begin(), sanitizers_end()); } | |||
4839 | ||||
4840 | ||||
4841 | ||||
4842 | SanitizerMask getMask() const { | |||
4843 | SanitizerMask Mask = 0; | |||
4844 | for (auto SanitizerName : sanitizers()) { | |||
4845 | SanitizerMask ParsedMask = | |||
4846 | parseSanitizerValue(SanitizerName, /*AllowGroups=*/true); | |||
4847 | Mask |= expandSanitizerGroups(ParsedMask); | |||
4848 | } | |||
4849 | return Mask; | |||
4850 | } | |||
4851 | ||||
4852 | ||||
4853 | static bool classof(const Attr *A) { return A->getKind() == attr::NoSanitize; } | |||
4854 | }; | |||
4855 | ||||
4856 | class NoSplitStackAttr : public InheritableAttr { | |||
4857 | public: | |||
4858 | static NoSplitStackAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4859 | auto *A = new (Ctx) NoSplitStackAttr(Loc, Ctx, 0); | |||
4860 | A->setImplicit(true); | |||
4861 | return A; | |||
4862 | } | |||
4863 | ||||
4864 | NoSplitStackAttr(SourceRange R, ASTContext &Ctx | |||
4865 | , unsigned SI | |||
4866 | ) | |||
4867 | : InheritableAttr(attr::NoSplitStack, R, SI, false, false) | |||
4868 | { | |||
4869 | } | |||
4870 | ||||
4871 | NoSplitStackAttr *clone(ASTContext &C) const; | |||
4872 | void printPretty(raw_ostream &OS, | |||
4873 | const PrintingPolicy &Policy) const; | |||
4874 | const char *getSpelling() const; | |||
4875 | ||||
4876 | ||||
4877 | static bool classof(const Attr *A) { return A->getKind() == attr::NoSplitStack; } | |||
4878 | }; | |||
4879 | ||||
4880 | class NoThreadSafetyAnalysisAttr : public InheritableAttr { | |||
4881 | public: | |||
4882 | static NoThreadSafetyAnalysisAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4883 | auto *A = new (Ctx) NoThreadSafetyAnalysisAttr(Loc, Ctx, 0); | |||
4884 | A->setImplicit(true); | |||
4885 | return A; | |||
4886 | } | |||
4887 | ||||
4888 | NoThreadSafetyAnalysisAttr(SourceRange R, ASTContext &Ctx | |||
4889 | , unsigned SI | |||
4890 | ) | |||
4891 | : InheritableAttr(attr::NoThreadSafetyAnalysis, R, SI, false, false) | |||
4892 | { | |||
4893 | } | |||
4894 | ||||
4895 | NoThreadSafetyAnalysisAttr *clone(ASTContext &C) const; | |||
4896 | void printPretty(raw_ostream &OS, | |||
4897 | const PrintingPolicy &Policy) const; | |||
4898 | const char *getSpelling() const; | |||
4899 | ||||
4900 | ||||
4901 | static bool classof(const Attr *A) { return A->getKind() == attr::NoThreadSafetyAnalysis; } | |||
4902 | }; | |||
4903 | ||||
4904 | class NoThrowAttr : public InheritableAttr { | |||
4905 | public: | |||
4906 | static NoThrowAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4907 | auto *A = new (Ctx) NoThrowAttr(Loc, Ctx, 0); | |||
4908 | A->setImplicit(true); | |||
4909 | return A; | |||
4910 | } | |||
4911 | ||||
4912 | NoThrowAttr(SourceRange R, ASTContext &Ctx | |||
4913 | , unsigned SI | |||
4914 | ) | |||
4915 | : InheritableAttr(attr::NoThrow, R, SI, false, false) | |||
4916 | { | |||
4917 | } | |||
4918 | ||||
4919 | NoThrowAttr *clone(ASTContext &C) const; | |||
4920 | void printPretty(raw_ostream &OS, | |||
4921 | const PrintingPolicy &Policy) const; | |||
4922 | const char *getSpelling() const; | |||
4923 | ||||
4924 | ||||
4925 | static bool classof(const Attr *A) { return A->getKind() == attr::NoThrow; } | |||
4926 | }; | |||
4927 | ||||
4928 | class NonNullAttr : public InheritableParamAttr { | |||
4929 | unsigned args_Size; | |||
4930 | unsigned *args_; | |||
4931 | ||||
4932 | public: | |||
4933 | static NonNullAttr *CreateImplicit(ASTContext &Ctx, unsigned *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
4934 | auto *A = new (Ctx) NonNullAttr(Loc, Ctx, Args, ArgsSize, 0); | |||
4935 | A->setImplicit(true); | |||
4936 | return A; | |||
4937 | } | |||
4938 | ||||
4939 | NonNullAttr(SourceRange R, ASTContext &Ctx | |||
4940 | , unsigned *Args, unsigned ArgsSize | |||
4941 | , unsigned SI | |||
4942 | ) | |||
4943 | : InheritableParamAttr(attr::NonNull, R, SI, false, true) | |||
4944 | , args_Size(ArgsSize), args_(new (Ctx, 16) unsigned[args_Size]) | |||
4945 | { | |||
4946 | std::copy(Args, Args + args_Size, args_); | |||
4947 | } | |||
4948 | ||||
4949 | NonNullAttr(SourceRange R, ASTContext &Ctx | |||
4950 | , unsigned SI | |||
4951 | ) | |||
4952 | : InheritableParamAttr(attr::NonNull, R, SI, false, true) | |||
4953 | , args_Size(0), args_(nullptr) | |||
4954 | { | |||
4955 | } | |||
4956 | ||||
4957 | NonNullAttr *clone(ASTContext &C) const; | |||
4958 | void printPretty(raw_ostream &OS, | |||
4959 | const PrintingPolicy &Policy) const; | |||
4960 | const char *getSpelling() const; | |||
4961 | typedef unsigned* args_iterator; | |||
4962 | args_iterator args_begin() const { return args_; } | |||
4963 | args_iterator args_end() const { return args_ + args_Size; } | |||
4964 | unsigned args_size() const { return args_Size; } | |||
4965 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
4966 | ||||
4967 | ||||
4968 | bool isNonNull(unsigned idx) const { | |||
4969 | if (!args_size()) | |||
4970 | return true; | |||
4971 | for (const auto &V : args()) | |||
4972 | if (V == idx) | |||
4973 | return true; | |||
4974 | return false; | |||
4975 | } | |||
4976 | ||||
4977 | static bool classof(const Attr *A) { return A->getKind() == attr::NonNull; } | |||
4978 | }; | |||
4979 | ||||
4980 | class NotTailCalledAttr : public InheritableAttr { | |||
4981 | public: | |||
4982 | static NotTailCalledAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4983 | auto *A = new (Ctx) NotTailCalledAttr(Loc, Ctx, 0); | |||
4984 | A->setImplicit(true); | |||
4985 | return A; | |||
4986 | } | |||
4987 | ||||
4988 | NotTailCalledAttr(SourceRange R, ASTContext &Ctx | |||
4989 | , unsigned SI | |||
4990 | ) | |||
4991 | : InheritableAttr(attr::NotTailCalled, R, SI, false, false) | |||
4992 | { | |||
4993 | } | |||
4994 | ||||
4995 | NotTailCalledAttr *clone(ASTContext &C) const; | |||
4996 | void printPretty(raw_ostream &OS, | |||
4997 | const PrintingPolicy &Policy) const; | |||
4998 | const char *getSpelling() const; | |||
4999 | ||||
5000 | ||||
5001 | static bool classof(const Attr *A) { return A->getKind() == attr::NotTailCalled; } | |||
5002 | }; | |||
5003 | ||||
5004 | class OMPCaptureKindAttr : public Attr { | |||
5005 | unsigned captureKind; | |||
5006 | ||||
5007 | public: | |||
5008 | static OMPCaptureKindAttr *CreateImplicit(ASTContext &Ctx, unsigned CaptureKind, SourceRange Loc = SourceRange()) { | |||
5009 | auto *A = new (Ctx) OMPCaptureKindAttr(Loc, Ctx, CaptureKind, 0); | |||
5010 | A->setImplicit(true); | |||
5011 | return A; | |||
5012 | } | |||
5013 | ||||
5014 | OMPCaptureKindAttr(SourceRange R, ASTContext &Ctx | |||
5015 | , unsigned CaptureKind | |||
5016 | , unsigned SI | |||
5017 | ) | |||
5018 | : Attr(attr::OMPCaptureKind, R, SI, false) | |||
5019 | , captureKind(CaptureKind) | |||
5020 | { | |||
5021 | } | |||
5022 | ||||
5023 | OMPCaptureKindAttr *clone(ASTContext &C) const; | |||
5024 | void printPretty(raw_ostream &OS, | |||
5025 | const PrintingPolicy &Policy) const; | |||
5026 | const char *getSpelling() const; | |||
5027 | unsigned getCaptureKind() const { | |||
5028 | return captureKind; | |||
5029 | } | |||
5030 | ||||
5031 | ||||
5032 | ||||
5033 | static bool classof(const Attr *A) { return A->getKind() == attr::OMPCaptureKind; } | |||
5034 | }; | |||
5035 | ||||
5036 | class OMPCaptureNoInitAttr : public InheritableAttr { | |||
5037 | public: | |||
5038 | static OMPCaptureNoInitAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5039 | auto *A = new (Ctx) OMPCaptureNoInitAttr(Loc, Ctx, 0); | |||
5040 | A->setImplicit(true); | |||
5041 | return A; | |||
5042 | } | |||
5043 | ||||
5044 | OMPCaptureNoInitAttr(SourceRange R, ASTContext &Ctx | |||
5045 | , unsigned SI | |||
5046 | ) | |||
5047 | : InheritableAttr(attr::OMPCaptureNoInit, R, SI, false, false) | |||
5048 | { | |||
5049 | } | |||
5050 | ||||
5051 | OMPCaptureNoInitAttr *clone(ASTContext &C) const; | |||
5052 | void printPretty(raw_ostream &OS, | |||
5053 | const PrintingPolicy &Policy) const; | |||
5054 | const char *getSpelling() const; | |||
5055 | ||||
5056 | ||||
5057 | static bool classof(const Attr *A) { return A->getKind() == attr::OMPCaptureNoInit; } | |||
5058 | }; | |||
5059 | ||||
5060 | class OMPDeclareSimdDeclAttr : public Attr { | |||
5061 | public: | |||
5062 | enum BranchStateTy { | |||
5063 | BS_Undefined, | |||
5064 | BS_Inbranch, | |||
5065 | BS_Notinbranch | |||
5066 | }; | |||
5067 | private: | |||
5068 | BranchStateTy branchState; | |||
5069 | ||||
5070 | Expr * simdlen; | |||
5071 | ||||
5072 | unsigned uniforms_Size; | |||
5073 | Expr * *uniforms_; | |||
5074 | ||||
5075 | unsigned aligneds_Size; | |||
5076 | Expr * *aligneds_; | |||
5077 | ||||
5078 | unsigned alignments_Size; | |||
5079 | Expr * *alignments_; | |||
5080 | ||||
5081 | unsigned linears_Size; | |||
5082 | Expr * *linears_; | |||
5083 | ||||
5084 | unsigned modifiers_Size; | |||
5085 | unsigned *modifiers_; | |||
5086 | ||||
5087 | unsigned steps_Size; | |||
5088 | Expr * *steps_; | |||
5089 | ||||
5090 | public: | |||
5091 | static OMPDeclareSimdDeclAttr *CreateImplicit(ASTContext &Ctx, BranchStateTy BranchState, Expr * Simdlen, Expr * *Uniforms, unsigned UniformsSize, Expr * *Aligneds, unsigned AlignedsSize, Expr * *Alignments, unsigned AlignmentsSize, Expr * *Linears, unsigned LinearsSize, unsigned *Modifiers, unsigned ModifiersSize, Expr * *Steps, unsigned StepsSize, SourceRange Loc = SourceRange()) { | |||
5092 | auto *A = new (Ctx) OMPDeclareSimdDeclAttr(Loc, Ctx, BranchState, Simdlen, Uniforms, UniformsSize, Aligneds, AlignedsSize, Alignments, AlignmentsSize, Linears, LinearsSize, Modifiers, ModifiersSize, Steps, StepsSize, 0); | |||
5093 | A->setImplicit(true); | |||
5094 | return A; | |||
5095 | } | |||
5096 | ||||
5097 | OMPDeclareSimdDeclAttr(SourceRange R, ASTContext &Ctx | |||
5098 | , BranchStateTy BranchState | |||
5099 | , Expr * Simdlen | |||
5100 | , Expr * *Uniforms, unsigned UniformsSize | |||
5101 | , Expr * *Aligneds, unsigned AlignedsSize | |||
5102 | , Expr * *Alignments, unsigned AlignmentsSize | |||
5103 | , Expr * *Linears, unsigned LinearsSize | |||
5104 | , unsigned *Modifiers, unsigned ModifiersSize | |||
5105 | , Expr * *Steps, unsigned StepsSize | |||
5106 | , unsigned SI | |||
5107 | ) | |||
5108 | : Attr(attr::OMPDeclareSimdDecl, R, SI, false) | |||
5109 | , branchState(BranchState) | |||
5110 | , simdlen(Simdlen) | |||
5111 | , uniforms_Size(UniformsSize), uniforms_(new (Ctx, 16) Expr *[uniforms_Size]) | |||
5112 | , aligneds_Size(AlignedsSize), aligneds_(new (Ctx, 16) Expr *[aligneds_Size]) | |||
5113 | , alignments_Size(AlignmentsSize), alignments_(new (Ctx, 16) Expr *[alignments_Size]) | |||
5114 | , linears_Size(LinearsSize), linears_(new (Ctx, 16) Expr *[linears_Size]) | |||
5115 | , modifiers_Size(ModifiersSize), modifiers_(new (Ctx, 16) unsigned[modifiers_Size]) | |||
5116 | , steps_Size(StepsSize), steps_(new (Ctx, 16) Expr *[steps_Size]) | |||
5117 | { | |||
5118 | std::copy(Uniforms, Uniforms + uniforms_Size, uniforms_); | |||
5119 | std::copy(Aligneds, Aligneds + aligneds_Size, aligneds_); | |||
5120 | std::copy(Alignments, Alignments + alignments_Size, alignments_); | |||
5121 | std::copy(Linears, Linears + linears_Size, linears_); | |||
5122 | std::copy(Modifiers, Modifiers + modifiers_Size, modifiers_); | |||
5123 | std::copy(Steps, Steps + steps_Size, steps_); | |||
5124 | } | |||
5125 | ||||
5126 | OMPDeclareSimdDeclAttr(SourceRange R, ASTContext &Ctx | |||
5127 | , BranchStateTy BranchState | |||
5128 | , Expr * Simdlen | |||
5129 | , unsigned SI | |||
5130 | ) | |||
5131 | : Attr(attr::OMPDeclareSimdDecl, R, SI, false) | |||
5132 | , branchState(BranchState) | |||
5133 | , simdlen(Simdlen) | |||
5134 | , uniforms_Size(0), uniforms_(nullptr) | |||
5135 | , aligneds_Size(0), aligneds_(nullptr) | |||
5136 | , alignments_Size(0), alignments_(nullptr) | |||
5137 | , linears_Size(0), linears_(nullptr) | |||
5138 | , modifiers_Size(0), modifiers_(nullptr) | |||
5139 | , steps_Size(0), steps_(nullptr) | |||
5140 | { | |||
5141 | } | |||
5142 | ||||
5143 | OMPDeclareSimdDeclAttr *clone(ASTContext &C) const; | |||
5144 | void printPretty(raw_ostream &OS, | |||
5145 | const PrintingPolicy &Policy) const; | |||
5146 | const char *getSpelling() const; | |||
5147 | BranchStateTy getBranchState() const { | |||
5148 | return branchState; | |||
5149 | } | |||
5150 | ||||
5151 | static bool ConvertStrToBranchStateTy(StringRef Val, BranchStateTy &Out) { | |||
5152 | Optional<BranchStateTy> R = llvm::StringSwitch<Optional<BranchStateTy>>(Val) | |||
5153 | .Case("", OMPDeclareSimdDeclAttr::BS_Undefined) | |||
5154 | .Case("inbranch", OMPDeclareSimdDeclAttr::BS_Inbranch) | |||
5155 | .Case("notinbranch", OMPDeclareSimdDeclAttr::BS_Notinbranch) | |||
5156 | .Default(Optional<BranchStateTy>()); | |||
5157 | if (R) { | |||
5158 | Out = *R; | |||
5159 | return true; | |||
5160 | } | |||
5161 | return false; | |||
5162 | } | |||
5163 | ||||
5164 | static const char *ConvertBranchStateTyToStr(BranchStateTy Val) { | |||
5165 | switch(Val) { | |||
5166 | case OMPDeclareSimdDeclAttr::BS_Undefined: return ""; | |||
5167 | case OMPDeclareSimdDeclAttr::BS_Inbranch: return "inbranch"; | |||
5168 | case OMPDeclareSimdDeclAttr::BS_Notinbranch: return "notinbranch"; | |||
5169 | } | |||
5170 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 5170); | |||
5171 | } | |||
5172 | Expr * getSimdlen() const { | |||
5173 | return simdlen; | |||
5174 | } | |||
5175 | ||||
5176 | typedef Expr ** uniforms_iterator; | |||
5177 | uniforms_iterator uniforms_begin() const { return uniforms_; } | |||
5178 | uniforms_iterator uniforms_end() const { return uniforms_ + uniforms_Size; } | |||
5179 | unsigned uniforms_size() const { return uniforms_Size; } | |||
5180 | llvm::iterator_range<uniforms_iterator> uniforms() const { return llvm::make_range(uniforms_begin(), uniforms_end()); } | |||
5181 | ||||
5182 | ||||
5183 | typedef Expr ** aligneds_iterator; | |||
5184 | aligneds_iterator aligneds_begin() const { return aligneds_; } | |||
5185 | aligneds_iterator aligneds_end() const { return aligneds_ + aligneds_Size; } | |||
5186 | unsigned aligneds_size() const { return aligneds_Size; } | |||
5187 | llvm::iterator_range<aligneds_iterator> aligneds() const { return llvm::make_range(aligneds_begin(), aligneds_end()); } | |||
5188 | ||||
5189 | ||||
5190 | typedef Expr ** alignments_iterator; | |||
5191 | alignments_iterator alignments_begin() const { return alignments_; } | |||
5192 | alignments_iterator alignments_end() const { return alignments_ + alignments_Size; } | |||
5193 | unsigned alignments_size() const { return alignments_Size; } | |||
5194 | llvm::iterator_range<alignments_iterator> alignments() const { return llvm::make_range(alignments_begin(), alignments_end()); } | |||
5195 | ||||
5196 | ||||
5197 | typedef Expr ** linears_iterator; | |||
5198 | linears_iterator linears_begin() const { return linears_; } | |||
5199 | linears_iterator linears_end() const { return linears_ + linears_Size; } | |||
5200 | unsigned linears_size() const { return linears_Size; } | |||
5201 | llvm::iterator_range<linears_iterator> linears() const { return llvm::make_range(linears_begin(), linears_end()); } | |||
5202 | ||||
5203 | ||||
5204 | typedef unsigned* modifiers_iterator; | |||
5205 | modifiers_iterator modifiers_begin() const { return modifiers_; } | |||
5206 | modifiers_iterator modifiers_end() const { return modifiers_ + modifiers_Size; } | |||
5207 | unsigned modifiers_size() const { return modifiers_Size; } | |||
5208 | llvm::iterator_range<modifiers_iterator> modifiers() const { return llvm::make_range(modifiers_begin(), modifiers_end()); } | |||
5209 | ||||
5210 | ||||
5211 | typedef Expr ** steps_iterator; | |||
5212 | steps_iterator steps_begin() const { return steps_; } | |||
5213 | steps_iterator steps_end() const { return steps_ + steps_Size; } | |||
5214 | unsigned steps_size() const { return steps_Size; } | |||
5215 | llvm::iterator_range<steps_iterator> steps() const { return llvm::make_range(steps_begin(), steps_end()); } | |||
5216 | ||||
5217 | ||||
5218 | ||||
5219 | void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy) | |||
5220 | const { | |||
5221 | if (getBranchState() != BS_Undefined) | |||
5222 | OS << ' ' << ConvertBranchStateTyToStr(getBranchState()); | |||
5223 | if (auto *E = getSimdlen()) { | |||
5224 | OS << " simdlen("; | |||
5225 | E->printPretty(OS, nullptr, Policy); | |||
5226 | OS << ")"; | |||
5227 | } | |||
5228 | if (uniforms_size() > 0) { | |||
5229 | OS << " uniform"; | |||
5230 | StringRef Sep = "("; | |||
5231 | for (auto *E : uniforms()) { | |||
5232 | OS << Sep; | |||
5233 | E->printPretty(OS, nullptr, Policy); | |||
5234 | Sep = ", "; | |||
5235 | } | |||
5236 | OS << ")"; | |||
5237 | } | |||
5238 | alignments_iterator NI = alignments_begin(); | |||
5239 | for (auto *E : aligneds()) { | |||
5240 | OS << " aligned("; | |||
5241 | E->printPretty(OS, nullptr, Policy); | |||
5242 | if (*NI) { | |||
5243 | OS << ": "; | |||
5244 | (*NI)->printPretty(OS, nullptr, Policy); | |||
5245 | } | |||
5246 | OS << ")"; | |||
5247 | ++NI; | |||
5248 | } | |||
5249 | steps_iterator I = steps_begin(); | |||
5250 | modifiers_iterator MI = modifiers_begin(); | |||
5251 | for (auto *E : linears()) { | |||
5252 | OS << " linear("; | |||
5253 | if (*MI != OMPC_LINEAR_unknown) | |||
5254 | OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "("; | |||
5255 | E->printPretty(OS, nullptr, Policy); | |||
5256 | if (*MI != OMPC_LINEAR_unknown) | |||
5257 | OS << ")"; | |||
5258 | if (*I) { | |||
5259 | OS << ": "; | |||
5260 | (*I)->printPretty(OS, nullptr, Policy); | |||
5261 | } | |||
5262 | OS << ")"; | |||
5263 | ++I; | |||
5264 | ++MI; | |||
5265 | } | |||
5266 | } | |||
5267 | ||||
5268 | ||||
5269 | static bool classof(const Attr *A) { return A->getKind() == attr::OMPDeclareSimdDecl; } | |||
5270 | }; | |||
5271 | ||||
5272 | class OMPDeclareTargetDeclAttr : public Attr { | |||
5273 | public: | |||
5274 | enum MapTypeTy { | |||
5275 | MT_To, | |||
5276 | MT_Link | |||
5277 | }; | |||
5278 | private: | |||
5279 | MapTypeTy mapType; | |||
5280 | ||||
5281 | public: | |||
5282 | static OMPDeclareTargetDeclAttr *CreateImplicit(ASTContext &Ctx, MapTypeTy MapType, SourceRange Loc = SourceRange()) { | |||
5283 | auto *A = new (Ctx) OMPDeclareTargetDeclAttr(Loc, Ctx, MapType, 0); | |||
5284 | A->setImplicit(true); | |||
5285 | return A; | |||
5286 | } | |||
5287 | ||||
5288 | OMPDeclareTargetDeclAttr(SourceRange R, ASTContext &Ctx | |||
5289 | , MapTypeTy MapType | |||
5290 | , unsigned SI | |||
5291 | ) | |||
5292 | : Attr(attr::OMPDeclareTargetDecl, R, SI, false) | |||
5293 | , mapType(MapType) | |||
5294 | { | |||
5295 | } | |||
5296 | ||||
5297 | OMPDeclareTargetDeclAttr *clone(ASTContext &C) const; | |||
5298 | void printPretty(raw_ostream &OS, | |||
5299 | const PrintingPolicy &Policy) const; | |||
5300 | const char *getSpelling() const; | |||
5301 | MapTypeTy getMapType() const { | |||
5302 | return mapType; | |||
5303 | } | |||
5304 | ||||
5305 | static bool ConvertStrToMapTypeTy(StringRef Val, MapTypeTy &Out) { | |||
5306 | Optional<MapTypeTy> R = llvm::StringSwitch<Optional<MapTypeTy>>(Val) | |||
5307 | .Case("to", OMPDeclareTargetDeclAttr::MT_To) | |||
5308 | .Case("link", OMPDeclareTargetDeclAttr::MT_Link) | |||
5309 | .Default(Optional<MapTypeTy>()); | |||
5310 | if (R) { | |||
5311 | Out = *R; | |||
5312 | return true; | |||
5313 | } | |||
5314 | return false; | |||
5315 | } | |||
5316 | ||||
5317 | static const char *ConvertMapTypeTyToStr(MapTypeTy Val) { | |||
5318 | switch(Val) { | |||
5319 | case OMPDeclareTargetDeclAttr::MT_To: return "to"; | |||
5320 | case OMPDeclareTargetDeclAttr::MT_Link: return "link"; | |||
5321 | } | |||
5322 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 5322); | |||
5323 | } | |||
5324 | ||||
5325 | void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const { | |||
5326 | // Use fake syntax because it is for testing and debugging purpose only. | |||
5327 | if (getMapType() != MT_To) | |||
5328 | OS << ' ' << ConvertMapTypeTyToStr(getMapType()); | |||
5329 | } | |||
5330 | ||||
5331 | ||||
5332 | static bool classof(const Attr *A) { return A->getKind() == attr::OMPDeclareTargetDecl; } | |||
5333 | }; | |||
5334 | ||||
5335 | class OMPThreadPrivateDeclAttr : public InheritableAttr { | |||
5336 | public: | |||
5337 | static OMPThreadPrivateDeclAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5338 | auto *A = new (Ctx) OMPThreadPrivateDeclAttr(Loc, Ctx, 0); | |||
5339 | A->setImplicit(true); | |||
5340 | return A; | |||
5341 | } | |||
5342 | ||||
5343 | OMPThreadPrivateDeclAttr(SourceRange R, ASTContext &Ctx | |||
5344 | , unsigned SI | |||
5345 | ) | |||
5346 | : InheritableAttr(attr::OMPThreadPrivateDecl, R, SI, false, false) | |||
5347 | { | |||
5348 | } | |||
5349 | ||||
5350 | OMPThreadPrivateDeclAttr *clone(ASTContext &C) const; | |||
5351 | void printPretty(raw_ostream &OS, | |||
5352 | const PrintingPolicy &Policy) const; | |||
5353 | const char *getSpelling() const; | |||
5354 | ||||
5355 | ||||
5356 | static bool classof(const Attr *A) { return A->getKind() == attr::OMPThreadPrivateDecl; } | |||
5357 | }; | |||
5358 | ||||
5359 | class ObjCBoxableAttr : public Attr { | |||
5360 | public: | |||
5361 | static ObjCBoxableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5362 | auto *A = new (Ctx) ObjCBoxableAttr(Loc, Ctx, 0); | |||
5363 | A->setImplicit(true); | |||
5364 | return A; | |||
5365 | } | |||
5366 | ||||
5367 | ObjCBoxableAttr(SourceRange R, ASTContext &Ctx | |||
5368 | , unsigned SI | |||
5369 | ) | |||
5370 | : Attr(attr::ObjCBoxable, R, SI, false) | |||
5371 | { | |||
5372 | } | |||
5373 | ||||
5374 | ObjCBoxableAttr *clone(ASTContext &C) const; | |||
5375 | void printPretty(raw_ostream &OS, | |||
5376 | const PrintingPolicy &Policy) const; | |||
5377 | const char *getSpelling() const; | |||
5378 | ||||
5379 | ||||
5380 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCBoxable; } | |||
5381 | }; | |||
5382 | ||||
5383 | class ObjCBridgeAttr : public InheritableAttr { | |||
5384 | IdentifierInfo * bridgedType; | |||
5385 | ||||
5386 | public: | |||
5387 | static ObjCBridgeAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * BridgedType, SourceRange Loc = SourceRange()) { | |||
5388 | auto *A = new (Ctx) ObjCBridgeAttr(Loc, Ctx, BridgedType, 0); | |||
5389 | A->setImplicit(true); | |||
5390 | return A; | |||
5391 | } | |||
5392 | ||||
5393 | ObjCBridgeAttr(SourceRange R, ASTContext &Ctx | |||
5394 | , IdentifierInfo * BridgedType | |||
5395 | , unsigned SI | |||
5396 | ) | |||
5397 | : InheritableAttr(attr::ObjCBridge, R, SI, false, false) | |||
5398 | , bridgedType(BridgedType) | |||
5399 | { | |||
5400 | } | |||
5401 | ||||
5402 | ObjCBridgeAttr *clone(ASTContext &C) const; | |||
5403 | void printPretty(raw_ostream &OS, | |||
5404 | const PrintingPolicy &Policy) const; | |||
5405 | const char *getSpelling() const; | |||
5406 | IdentifierInfo * getBridgedType() const { | |||
5407 | return bridgedType; | |||
5408 | } | |||
5409 | ||||
5410 | ||||
5411 | ||||
5412 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCBridge; } | |||
5413 | }; | |||
5414 | ||||
5415 | class ObjCBridgeMutableAttr : public InheritableAttr { | |||
5416 | IdentifierInfo * bridgedType; | |||
5417 | ||||
5418 | public: | |||
5419 | static ObjCBridgeMutableAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * BridgedType, SourceRange Loc = SourceRange()) { | |||
5420 | auto *A = new (Ctx) ObjCBridgeMutableAttr(Loc, Ctx, BridgedType, 0); | |||
5421 | A->setImplicit(true); | |||
5422 | return A; | |||
5423 | } | |||
5424 | ||||
5425 | ObjCBridgeMutableAttr(SourceRange R, ASTContext &Ctx | |||
5426 | , IdentifierInfo * BridgedType | |||
5427 | , unsigned SI | |||
5428 | ) | |||
5429 | : InheritableAttr(attr::ObjCBridgeMutable, R, SI, false, false) | |||
5430 | , bridgedType(BridgedType) | |||
5431 | { | |||
5432 | } | |||
5433 | ||||
5434 | ObjCBridgeMutableAttr *clone(ASTContext &C) const; | |||
5435 | void printPretty(raw_ostream &OS, | |||
5436 | const PrintingPolicy &Policy) const; | |||
5437 | const char *getSpelling() const; | |||
5438 | IdentifierInfo * getBridgedType() const { | |||
5439 | return bridgedType; | |||
5440 | } | |||
5441 | ||||
5442 | ||||
5443 | ||||
5444 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCBridgeMutable; } | |||
5445 | }; | |||
5446 | ||||
5447 | class ObjCBridgeRelatedAttr : public InheritableAttr { | |||
5448 | IdentifierInfo * relatedClass; | |||
5449 | ||||
5450 | IdentifierInfo * classMethod; | |||
5451 | ||||
5452 | IdentifierInfo * instanceMethod; | |||
5453 | ||||
5454 | public: | |||
5455 | static ObjCBridgeRelatedAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * RelatedClass, IdentifierInfo * ClassMethod, IdentifierInfo * InstanceMethod, SourceRange Loc = SourceRange()) { | |||
5456 | auto *A = new (Ctx) ObjCBridgeRelatedAttr(Loc, Ctx, RelatedClass, ClassMethod, InstanceMethod, 0); | |||
5457 | A->setImplicit(true); | |||
5458 | return A; | |||
5459 | } | |||
5460 | ||||
5461 | ObjCBridgeRelatedAttr(SourceRange R, ASTContext &Ctx | |||
5462 | , IdentifierInfo * RelatedClass | |||
5463 | , IdentifierInfo * ClassMethod | |||
5464 | , IdentifierInfo * InstanceMethod | |||
5465 | , unsigned SI | |||
5466 | ) | |||
5467 | : InheritableAttr(attr::ObjCBridgeRelated, R, SI, false, false) | |||
5468 | , relatedClass(RelatedClass) | |||
5469 | , classMethod(ClassMethod) | |||
5470 | , instanceMethod(InstanceMethod) | |||
5471 | { | |||
5472 | } | |||
5473 | ||||
5474 | ObjCBridgeRelatedAttr(SourceRange R, ASTContext &Ctx | |||
5475 | , IdentifierInfo * RelatedClass | |||
5476 | , unsigned SI | |||
5477 | ) | |||
5478 | : InheritableAttr(attr::ObjCBridgeRelated, R, SI, false, false) | |||
5479 | , relatedClass(RelatedClass) | |||
5480 | , classMethod() | |||
5481 | , instanceMethod() | |||
5482 | { | |||
5483 | } | |||
5484 | ||||
5485 | ObjCBridgeRelatedAttr *clone(ASTContext &C) const; | |||
5486 | void printPretty(raw_ostream &OS, | |||
5487 | const PrintingPolicy &Policy) const; | |||
5488 | const char *getSpelling() const; | |||
5489 | IdentifierInfo * getRelatedClass() const { | |||
5490 | return relatedClass; | |||
5491 | } | |||
5492 | ||||
5493 | IdentifierInfo * getClassMethod() const { | |||
5494 | return classMethod; | |||
5495 | } | |||
5496 | ||||
5497 | IdentifierInfo * getInstanceMethod() const { | |||
5498 | return instanceMethod; | |||
5499 | } | |||
5500 | ||||
5501 | ||||
5502 | ||||
5503 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCBridgeRelated; } | |||
5504 | }; | |||
5505 | ||||
5506 | class ObjCDesignatedInitializerAttr : public Attr { | |||
5507 | public: | |||
5508 | static ObjCDesignatedInitializerAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5509 | auto *A = new (Ctx) ObjCDesignatedInitializerAttr(Loc, Ctx, 0); | |||
5510 | A->setImplicit(true); | |||
5511 | return A; | |||
5512 | } | |||
5513 | ||||
5514 | ObjCDesignatedInitializerAttr(SourceRange R, ASTContext &Ctx | |||
5515 | , unsigned SI | |||
5516 | ) | |||
5517 | : Attr(attr::ObjCDesignatedInitializer, R, SI, false) | |||
5518 | { | |||
5519 | } | |||
5520 | ||||
5521 | ObjCDesignatedInitializerAttr *clone(ASTContext &C) const; | |||
5522 | void printPretty(raw_ostream &OS, | |||
5523 | const PrintingPolicy &Policy) const; | |||
5524 | const char *getSpelling() const; | |||
5525 | ||||
5526 | ||||
5527 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCDesignatedInitializer; } | |||
5528 | }; | |||
5529 | ||||
5530 | class ObjCExceptionAttr : public InheritableAttr { | |||
5531 | public: | |||
5532 | static ObjCExceptionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5533 | auto *A = new (Ctx) ObjCExceptionAttr(Loc, Ctx, 0); | |||
5534 | A->setImplicit(true); | |||
5535 | return A; | |||
5536 | } | |||
5537 | ||||
5538 | ObjCExceptionAttr(SourceRange R, ASTContext &Ctx | |||
5539 | , unsigned SI | |||
5540 | ) | |||
5541 | : InheritableAttr(attr::ObjCException, R, SI, false, false) | |||
5542 | { | |||
5543 | } | |||
5544 | ||||
5545 | ObjCExceptionAttr *clone(ASTContext &C) const; | |||
5546 | void printPretty(raw_ostream &OS, | |||
5547 | const PrintingPolicy &Policy) const; | |||
5548 | const char *getSpelling() const; | |||
5549 | ||||
5550 | ||||
5551 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCException; } | |||
5552 | }; | |||
5553 | ||||
5554 | class ObjCExplicitProtocolImplAttr : public InheritableAttr { | |||
5555 | public: | |||
5556 | static ObjCExplicitProtocolImplAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5557 | auto *A = new (Ctx) ObjCExplicitProtocolImplAttr(Loc, Ctx, 0); | |||
5558 | A->setImplicit(true); | |||
5559 | return A; | |||
5560 | } | |||
5561 | ||||
5562 | ObjCExplicitProtocolImplAttr(SourceRange R, ASTContext &Ctx | |||
5563 | , unsigned SI | |||
5564 | ) | |||
5565 | : InheritableAttr(attr::ObjCExplicitProtocolImpl, R, SI, false, false) | |||
5566 | { | |||
5567 | } | |||
5568 | ||||
5569 | ObjCExplicitProtocolImplAttr *clone(ASTContext &C) const; | |||
5570 | void printPretty(raw_ostream &OS, | |||
5571 | const PrintingPolicy &Policy) const; | |||
5572 | const char *getSpelling() const; | |||
5573 | ||||
5574 | ||||
5575 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCExplicitProtocolImpl; } | |||
5576 | }; | |||
5577 | ||||
5578 | class ObjCIndependentClassAttr : public InheritableAttr { | |||
5579 | public: | |||
5580 | static ObjCIndependentClassAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5581 | auto *A = new (Ctx) ObjCIndependentClassAttr(Loc, Ctx, 0); | |||
5582 | A->setImplicit(true); | |||
5583 | return A; | |||
5584 | } | |||
5585 | ||||
5586 | ObjCIndependentClassAttr(SourceRange R, ASTContext &Ctx | |||
5587 | , unsigned SI | |||
5588 | ) | |||
5589 | : InheritableAttr(attr::ObjCIndependentClass, R, SI, false, false) | |||
5590 | { | |||
5591 | } | |||
5592 | ||||
5593 | ObjCIndependentClassAttr *clone(ASTContext &C) const; | |||
5594 | void printPretty(raw_ostream &OS, | |||
5595 | const PrintingPolicy &Policy) const; | |||
5596 | const char *getSpelling() const; | |||
5597 | ||||
5598 | ||||
5599 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCIndependentClass; } | |||
5600 | }; | |||
5601 | ||||
5602 | class ObjCMethodFamilyAttr : public InheritableAttr { | |||
5603 | public: | |||
5604 | enum FamilyKind { | |||
5605 | OMF_None, | |||
5606 | OMF_alloc, | |||
5607 | OMF_copy, | |||
5608 | OMF_init, | |||
5609 | OMF_mutableCopy, | |||
5610 | OMF_new | |||
5611 | }; | |||
5612 | private: | |||
5613 | FamilyKind family; | |||
5614 | ||||
5615 | public: | |||
5616 | static ObjCMethodFamilyAttr *CreateImplicit(ASTContext &Ctx, FamilyKind Family, SourceRange Loc = SourceRange()) { | |||
5617 | auto *A = new (Ctx) ObjCMethodFamilyAttr(Loc, Ctx, Family, 0); | |||
5618 | A->setImplicit(true); | |||
5619 | return A; | |||
5620 | } | |||
5621 | ||||
5622 | ObjCMethodFamilyAttr(SourceRange R, ASTContext &Ctx | |||
5623 | , FamilyKind Family | |||
5624 | , unsigned SI | |||
5625 | ) | |||
5626 | : InheritableAttr(attr::ObjCMethodFamily, R, SI, false, false) | |||
5627 | , family(Family) | |||
5628 | { | |||
5629 | } | |||
5630 | ||||
5631 | ObjCMethodFamilyAttr *clone(ASTContext &C) const; | |||
5632 | void printPretty(raw_ostream &OS, | |||
5633 | const PrintingPolicy &Policy) const; | |||
5634 | const char *getSpelling() const; | |||
5635 | FamilyKind getFamily() const { | |||
5636 | return family; | |||
5637 | } | |||
5638 | ||||
5639 | static bool ConvertStrToFamilyKind(StringRef Val, FamilyKind &Out) { | |||
5640 | Optional<FamilyKind> R = llvm::StringSwitch<Optional<FamilyKind>>(Val) | |||
5641 | .Case("none", ObjCMethodFamilyAttr::OMF_None) | |||
5642 | .Case("alloc", ObjCMethodFamilyAttr::OMF_alloc) | |||
5643 | .Case("copy", ObjCMethodFamilyAttr::OMF_copy) | |||
5644 | .Case("init", ObjCMethodFamilyAttr::OMF_init) | |||
5645 | .Case("mutableCopy", ObjCMethodFamilyAttr::OMF_mutableCopy) | |||
5646 | .Case("new", ObjCMethodFamilyAttr::OMF_new) | |||
5647 | .Default(Optional<FamilyKind>()); | |||
5648 | if (R) { | |||
5649 | Out = *R; | |||
5650 | return true; | |||
5651 | } | |||
5652 | return false; | |||
5653 | } | |||
5654 | ||||
5655 | static const char *ConvertFamilyKindToStr(FamilyKind Val) { | |||
5656 | switch(Val) { | |||
5657 | case ObjCMethodFamilyAttr::OMF_None: return "none"; | |||
5658 | case ObjCMethodFamilyAttr::OMF_alloc: return "alloc"; | |||
5659 | case ObjCMethodFamilyAttr::OMF_copy: return "copy"; | |||
5660 | case ObjCMethodFamilyAttr::OMF_init: return "init"; | |||
5661 | case ObjCMethodFamilyAttr::OMF_mutableCopy: return "mutableCopy"; | |||
5662 | case ObjCMethodFamilyAttr::OMF_new: return "new"; | |||
5663 | } | |||
5664 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 5664); | |||
5665 | } | |||
5666 | ||||
5667 | ||||
5668 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCMethodFamily; } | |||
5669 | }; | |||
5670 | ||||
5671 | class ObjCNSObjectAttr : public InheritableAttr { | |||
5672 | public: | |||
5673 | static ObjCNSObjectAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5674 | auto *A = new (Ctx) ObjCNSObjectAttr(Loc, Ctx, 0); | |||
5675 | A->setImplicit(true); | |||
5676 | return A; | |||
5677 | } | |||
5678 | ||||
5679 | ObjCNSObjectAttr(SourceRange R, ASTContext &Ctx | |||
5680 | , unsigned SI | |||
5681 | ) | |||
5682 | : InheritableAttr(attr::ObjCNSObject, R, SI, false, false) | |||
5683 | { | |||
5684 | } | |||
5685 | ||||
5686 | ObjCNSObjectAttr *clone(ASTContext &C) const; | |||
5687 | void printPretty(raw_ostream &OS, | |||
5688 | const PrintingPolicy &Policy) const; | |||
5689 | const char *getSpelling() const; | |||
5690 | ||||
5691 | ||||
5692 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCNSObject; } | |||
5693 | }; | |||
5694 | ||||
5695 | class ObjCPreciseLifetimeAttr : public InheritableAttr { | |||
5696 | public: | |||
5697 | static ObjCPreciseLifetimeAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5698 | auto *A = new (Ctx) ObjCPreciseLifetimeAttr(Loc, Ctx, 0); | |||
5699 | A->setImplicit(true); | |||
5700 | return A; | |||
5701 | } | |||
5702 | ||||
5703 | ObjCPreciseLifetimeAttr(SourceRange R, ASTContext &Ctx | |||
5704 | , unsigned SI | |||
5705 | ) | |||
5706 | : InheritableAttr(attr::ObjCPreciseLifetime, R, SI, false, false) | |||
5707 | { | |||
5708 | } | |||
5709 | ||||
5710 | ObjCPreciseLifetimeAttr *clone(ASTContext &C) const; | |||
5711 | void printPretty(raw_ostream &OS, | |||
5712 | const PrintingPolicy &Policy) const; | |||
5713 | const char *getSpelling() const; | |||
5714 | ||||
5715 | ||||
5716 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCPreciseLifetime; } | |||
5717 | }; | |||
5718 | ||||
5719 | class ObjCRequiresPropertyDefsAttr : public InheritableAttr { | |||
5720 | public: | |||
5721 | static ObjCRequiresPropertyDefsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5722 | auto *A = new (Ctx) ObjCRequiresPropertyDefsAttr(Loc, Ctx, 0); | |||
5723 | A->setImplicit(true); | |||
5724 | return A; | |||
5725 | } | |||
5726 | ||||
5727 | ObjCRequiresPropertyDefsAttr(SourceRange R, ASTContext &Ctx | |||
5728 | , unsigned SI | |||
5729 | ) | |||
5730 | : InheritableAttr(attr::ObjCRequiresPropertyDefs, R, SI, false, false) | |||
5731 | { | |||
5732 | } | |||
5733 | ||||
5734 | ObjCRequiresPropertyDefsAttr *clone(ASTContext &C) const; | |||
5735 | void printPretty(raw_ostream &OS, | |||
5736 | const PrintingPolicy &Policy) const; | |||
5737 | const char *getSpelling() const; | |||
5738 | ||||
5739 | ||||
5740 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRequiresPropertyDefs; } | |||
5741 | }; | |||
5742 | ||||
5743 | class ObjCRequiresSuperAttr : public InheritableAttr { | |||
5744 | public: | |||
5745 | static ObjCRequiresSuperAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5746 | auto *A = new (Ctx) ObjCRequiresSuperAttr(Loc, Ctx, 0); | |||
5747 | A->setImplicit(true); | |||
5748 | return A; | |||
5749 | } | |||
5750 | ||||
5751 | ObjCRequiresSuperAttr(SourceRange R, ASTContext &Ctx | |||
5752 | , unsigned SI | |||
5753 | ) | |||
5754 | : InheritableAttr(attr::ObjCRequiresSuper, R, SI, false, false) | |||
5755 | { | |||
5756 | } | |||
5757 | ||||
5758 | ObjCRequiresSuperAttr *clone(ASTContext &C) const; | |||
5759 | void printPretty(raw_ostream &OS, | |||
5760 | const PrintingPolicy &Policy) const; | |||
5761 | const char *getSpelling() const; | |||
5762 | ||||
5763 | ||||
5764 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRequiresSuper; } | |||
5765 | }; | |||
5766 | ||||
5767 | class ObjCReturnsInnerPointerAttr : public InheritableAttr { | |||
5768 | public: | |||
5769 | static ObjCReturnsInnerPointerAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5770 | auto *A = new (Ctx) ObjCReturnsInnerPointerAttr(Loc, Ctx, 0); | |||
5771 | A->setImplicit(true); | |||
5772 | return A; | |||
5773 | } | |||
5774 | ||||
5775 | ObjCReturnsInnerPointerAttr(SourceRange R, ASTContext &Ctx | |||
5776 | , unsigned SI | |||
5777 | ) | |||
5778 | : InheritableAttr(attr::ObjCReturnsInnerPointer, R, SI, false, false) | |||
5779 | { | |||
5780 | } | |||
5781 | ||||
5782 | ObjCReturnsInnerPointerAttr *clone(ASTContext &C) const; | |||
5783 | void printPretty(raw_ostream &OS, | |||
5784 | const PrintingPolicy &Policy) const; | |||
5785 | const char *getSpelling() const; | |||
5786 | ||||
5787 | ||||
5788 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCReturnsInnerPointer; } | |||
5789 | }; | |||
5790 | ||||
5791 | class ObjCRootClassAttr : public InheritableAttr { | |||
5792 | public: | |||
5793 | static ObjCRootClassAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5794 | auto *A = new (Ctx) ObjCRootClassAttr(Loc, Ctx, 0); | |||
5795 | A->setImplicit(true); | |||
5796 | return A; | |||
5797 | } | |||
5798 | ||||
5799 | ObjCRootClassAttr(SourceRange R, ASTContext &Ctx | |||
5800 | , unsigned SI | |||
5801 | ) | |||
5802 | : InheritableAttr(attr::ObjCRootClass, R, SI, false, false) | |||
5803 | { | |||
5804 | } | |||
5805 | ||||
5806 | ObjCRootClassAttr *clone(ASTContext &C) const; | |||
5807 | void printPretty(raw_ostream &OS, | |||
5808 | const PrintingPolicy &Policy) const; | |||
5809 | const char *getSpelling() const; | |||
5810 | ||||
5811 | ||||
5812 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRootClass; } | |||
5813 | }; | |||
5814 | ||||
5815 | class ObjCRuntimeNameAttr : public Attr { | |||
5816 | unsigned metadataNameLength; | |||
5817 | char *metadataName; | |||
5818 | ||||
5819 | public: | |||
5820 | static ObjCRuntimeNameAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef MetadataName, SourceRange Loc = SourceRange()) { | |||
5821 | auto *A = new (Ctx) ObjCRuntimeNameAttr(Loc, Ctx, MetadataName, 0); | |||
5822 | A->setImplicit(true); | |||
5823 | return A; | |||
5824 | } | |||
5825 | ||||
5826 | ObjCRuntimeNameAttr(SourceRange R, ASTContext &Ctx | |||
5827 | , llvm::StringRef MetadataName | |||
5828 | , unsigned SI | |||
5829 | ) | |||
5830 | : Attr(attr::ObjCRuntimeName, R, SI, false) | |||
5831 | , metadataNameLength(MetadataName.size()),metadataName(new (Ctx, 1) char[metadataNameLength]) | |||
5832 | { | |||
5833 | if (!MetadataName.empty()) | |||
5834 | std::memcpy(metadataName, MetadataName.data(), metadataNameLength); | |||
5835 | } | |||
5836 | ||||
5837 | ObjCRuntimeNameAttr *clone(ASTContext &C) const; | |||
5838 | void printPretty(raw_ostream &OS, | |||
5839 | const PrintingPolicy &Policy) const; | |||
5840 | const char *getSpelling() const; | |||
5841 | llvm::StringRef getMetadataName() const { | |||
5842 | return llvm::StringRef(metadataName, metadataNameLength); | |||
5843 | } | |||
5844 | unsigned getMetadataNameLength() const { | |||
5845 | return metadataNameLength; | |||
5846 | } | |||
5847 | void setMetadataName(ASTContext &C, llvm::StringRef S) { | |||
5848 | metadataNameLength = S.size(); | |||
5849 | this->metadataName = new (C, 1) char [metadataNameLength]; | |||
5850 | if (!S.empty()) | |||
5851 | std::memcpy(this->metadataName, S.data(), metadataNameLength); | |||
5852 | } | |||
5853 | ||||
5854 | ||||
5855 | ||||
5856 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRuntimeName; } | |||
5857 | }; | |||
5858 | ||||
5859 | class ObjCRuntimeVisibleAttr : public Attr { | |||
5860 | public: | |||
5861 | static ObjCRuntimeVisibleAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5862 | auto *A = new (Ctx) ObjCRuntimeVisibleAttr(Loc, Ctx, 0); | |||
5863 | A->setImplicit(true); | |||
5864 | return A; | |||
5865 | } | |||
5866 | ||||
5867 | ObjCRuntimeVisibleAttr(SourceRange R, ASTContext &Ctx | |||
5868 | , unsigned SI | |||
5869 | ) | |||
5870 | : Attr(attr::ObjCRuntimeVisible, R, SI, false) | |||
5871 | { | |||
5872 | } | |||
5873 | ||||
5874 | ObjCRuntimeVisibleAttr *clone(ASTContext &C) const; | |||
5875 | void printPretty(raw_ostream &OS, | |||
5876 | const PrintingPolicy &Policy) const; | |||
5877 | const char *getSpelling() const; | |||
5878 | ||||
5879 | ||||
5880 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRuntimeVisible; } | |||
5881 | }; | |||
5882 | ||||
5883 | class ObjCSubclassingRestrictedAttr : public InheritableAttr { | |||
5884 | public: | |||
5885 | static ObjCSubclassingRestrictedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5886 | auto *A = new (Ctx) ObjCSubclassingRestrictedAttr(Loc, Ctx, 0); | |||
5887 | A->setImplicit(true); | |||
5888 | return A; | |||
5889 | } | |||
5890 | ||||
5891 | ObjCSubclassingRestrictedAttr(SourceRange R, ASTContext &Ctx | |||
5892 | , unsigned SI | |||
5893 | ) | |||
5894 | : InheritableAttr(attr::ObjCSubclassingRestricted, R, SI, false, false) | |||
5895 | { | |||
5896 | } | |||
5897 | ||||
5898 | ObjCSubclassingRestrictedAttr *clone(ASTContext &C) const; | |||
5899 | void printPretty(raw_ostream &OS, | |||
5900 | const PrintingPolicy &Policy) const; | |||
5901 | const char *getSpelling() const; | |||
5902 | ||||
5903 | ||||
5904 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCSubclassingRestricted; } | |||
5905 | }; | |||
5906 | ||||
5907 | class OpenCLAccessAttr : public Attr { | |||
5908 | public: | |||
5909 | enum Spelling { | |||
5910 | Keyword_read_only = 0, | |||
5911 | Keyword_write_only = 2, | |||
5912 | Keyword_read_write = 4 | |||
5913 | }; | |||
5914 | ||||
5915 | static OpenCLAccessAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
5916 | auto *A = new (Ctx) OpenCLAccessAttr(Loc, Ctx, S); | |||
5917 | A->setImplicit(true); | |||
5918 | return A; | |||
5919 | } | |||
5920 | ||||
5921 | OpenCLAccessAttr(SourceRange R, ASTContext &Ctx | |||
5922 | , unsigned SI | |||
5923 | ) | |||
5924 | : Attr(attr::OpenCLAccess, R, SI, false) | |||
5925 | { | |||
5926 | } | |||
5927 | ||||
5928 | OpenCLAccessAttr *clone(ASTContext &C) const; | |||
5929 | void printPretty(raw_ostream &OS, | |||
5930 | const PrintingPolicy &Policy) const; | |||
5931 | const char *getSpelling() const; | |||
5932 | Spelling getSemanticSpelling() const { | |||
5933 | switch (SpellingListIndex) { | |||
5934 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 5934); | |||
5935 | case 0: return Keyword_read_only; | |||
5936 | case 1: return Keyword_read_only; | |||
5937 | case 2: return Keyword_write_only; | |||
5938 | case 3: return Keyword_write_only; | |||
5939 | case 4: return Keyword_read_write; | |||
5940 | case 5: return Keyword_read_write; | |||
5941 | } | |||
5942 | } | |||
5943 | bool isReadOnly() const { return SpellingListIndex == 0 || | |||
5944 | SpellingListIndex == 1; } | |||
5945 | bool isReadWrite() const { return SpellingListIndex == 4 || | |||
5946 | SpellingListIndex == 5; } | |||
5947 | bool isWriteOnly() const { return SpellingListIndex == 2 || | |||
5948 | SpellingListIndex == 3; } | |||
5949 | ||||
5950 | ||||
5951 | static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLAccess; } | |||
5952 | }; | |||
5953 | ||||
5954 | class OpenCLIntelReqdSubGroupSizeAttr : public InheritableAttr { | |||
5955 | unsigned subGroupSize; | |||
5956 | ||||
5957 | public: | |||
5958 | static OpenCLIntelReqdSubGroupSizeAttr *CreateImplicit(ASTContext &Ctx, unsigned SubGroupSize, SourceRange Loc = SourceRange()) { | |||
5959 | auto *A = new (Ctx) OpenCLIntelReqdSubGroupSizeAttr(Loc, Ctx, SubGroupSize, 0); | |||
5960 | A->setImplicit(true); | |||
5961 | return A; | |||
5962 | } | |||
5963 | ||||
5964 | OpenCLIntelReqdSubGroupSizeAttr(SourceRange R, ASTContext &Ctx | |||
5965 | , unsigned SubGroupSize | |||
5966 | , unsigned SI | |||
5967 | ) | |||
5968 | : InheritableAttr(attr::OpenCLIntelReqdSubGroupSize, R, SI, false, false) | |||
5969 | , subGroupSize(SubGroupSize) | |||
5970 | { | |||
5971 | } | |||
5972 | ||||
5973 | OpenCLIntelReqdSubGroupSizeAttr *clone(ASTContext &C) const; | |||
5974 | void printPretty(raw_ostream &OS, | |||
5975 | const PrintingPolicy &Policy) const; | |||
5976 | const char *getSpelling() const; | |||
5977 | unsigned getSubGroupSize() const { | |||
5978 | return subGroupSize; | |||
5979 | } | |||
5980 | ||||
5981 | ||||
5982 | ||||
5983 | static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLIntelReqdSubGroupSize; } | |||
5984 | }; | |||
5985 | ||||
5986 | class OpenCLKernelAttr : public InheritableAttr { | |||
5987 | public: | |||
5988 | static OpenCLKernelAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5989 | auto *A = new (Ctx) OpenCLKernelAttr(Loc, Ctx, 0); | |||
5990 | A->setImplicit(true); | |||
5991 | return A; | |||
5992 | } | |||
5993 | ||||
5994 | OpenCLKernelAttr(SourceRange R, ASTContext &Ctx | |||
5995 | , unsigned SI | |||
5996 | ) | |||
5997 | : InheritableAttr(attr::OpenCLKernel, R, SI, false, false) | |||
5998 | { | |||
5999 | } | |||
6000 | ||||
6001 | OpenCLKernelAttr *clone(ASTContext &C) const; | |||
6002 | void printPretty(raw_ostream &OS, | |||
6003 | const PrintingPolicy &Policy) const; | |||
6004 | const char *getSpelling() const; | |||
6005 | ||||
6006 | ||||
6007 | static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLKernel; } | |||
6008 | }; | |||
6009 | ||||
6010 | class OpenCLUnrollHintAttr : public InheritableAttr { | |||
6011 | unsigned unrollHint; | |||
6012 | ||||
6013 | public: | |||
6014 | static OpenCLUnrollHintAttr *CreateImplicit(ASTContext &Ctx, unsigned UnrollHint, SourceRange Loc = SourceRange()) { | |||
6015 | auto *A = new (Ctx) OpenCLUnrollHintAttr(Loc, Ctx, UnrollHint, 0); | |||
6016 | A->setImplicit(true); | |||
6017 | return A; | |||
6018 | } | |||
6019 | ||||
6020 | OpenCLUnrollHintAttr(SourceRange R, ASTContext &Ctx | |||
6021 | , unsigned UnrollHint | |||
6022 | , unsigned SI | |||
6023 | ) | |||
6024 | : InheritableAttr(attr::OpenCLUnrollHint, R, SI, false, false) | |||
6025 | , unrollHint(UnrollHint) | |||
6026 | { | |||
6027 | } | |||
6028 | ||||
6029 | OpenCLUnrollHintAttr *clone(ASTContext &C) const; | |||
6030 | void printPretty(raw_ostream &OS, | |||
6031 | const PrintingPolicy &Policy) const; | |||
6032 | const char *getSpelling() const; | |||
6033 | unsigned getUnrollHint() const { | |||
6034 | return unrollHint; | |||
6035 | } | |||
6036 | ||||
6037 | ||||
6038 | ||||
6039 | static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLUnrollHint; } | |||
6040 | }; | |||
6041 | ||||
6042 | class OptimizeNoneAttr : public InheritableAttr { | |||
6043 | public: | |||
6044 | static OptimizeNoneAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6045 | auto *A = new (Ctx) OptimizeNoneAttr(Loc, Ctx, 0); | |||
6046 | A->setImplicit(true); | |||
6047 | return A; | |||
6048 | } | |||
6049 | ||||
6050 | OptimizeNoneAttr(SourceRange R, ASTContext &Ctx | |||
6051 | , unsigned SI | |||
6052 | ) | |||
6053 | : InheritableAttr(attr::OptimizeNone, R, SI, false, false) | |||
6054 | { | |||
6055 | } | |||
6056 | ||||
6057 | OptimizeNoneAttr *clone(ASTContext &C) const; | |||
6058 | void printPretty(raw_ostream &OS, | |||
6059 | const PrintingPolicy &Policy) const; | |||
6060 | const char *getSpelling() const; | |||
6061 | ||||
6062 | ||||
6063 | static bool classof(const Attr *A) { return A->getKind() == attr::OptimizeNone; } | |||
6064 | }; | |||
6065 | ||||
6066 | class OverloadableAttr : public Attr { | |||
6067 | public: | |||
6068 | static OverloadableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6069 | auto *A = new (Ctx) OverloadableAttr(Loc, Ctx, 0); | |||
6070 | A->setImplicit(true); | |||
6071 | return A; | |||
6072 | } | |||
6073 | ||||
6074 | OverloadableAttr(SourceRange R, ASTContext &Ctx | |||
6075 | , unsigned SI | |||
6076 | ) | |||
6077 | : Attr(attr::Overloadable, R, SI, false) | |||
6078 | { | |||
6079 | } | |||
6080 | ||||
6081 | OverloadableAttr *clone(ASTContext &C) const; | |||
6082 | void printPretty(raw_ostream &OS, | |||
6083 | const PrintingPolicy &Policy) const; | |||
6084 | const char *getSpelling() const; | |||
6085 | ||||
6086 | ||||
6087 | static bool classof(const Attr *A) { return A->getKind() == attr::Overloadable; } | |||
6088 | }; | |||
6089 | ||||
6090 | class OverrideAttr : public InheritableAttr { | |||
6091 | public: | |||
6092 | static OverrideAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6093 | auto *A = new (Ctx) OverrideAttr(Loc, Ctx, 0); | |||
6094 | A->setImplicit(true); | |||
6095 | return A; | |||
6096 | } | |||
6097 | ||||
6098 | OverrideAttr(SourceRange R, ASTContext &Ctx | |||
6099 | , unsigned SI | |||
6100 | ) | |||
6101 | : InheritableAttr(attr::Override, R, SI, false, false) | |||
6102 | { | |||
6103 | } | |||
6104 | ||||
6105 | OverrideAttr *clone(ASTContext &C) const; | |||
6106 | void printPretty(raw_ostream &OS, | |||
6107 | const PrintingPolicy &Policy) const; | |||
6108 | const char *getSpelling() const; | |||
6109 | ||||
6110 | ||||
6111 | static bool classof(const Attr *A) { return A->getKind() == attr::Override; } | |||
6112 | }; | |||
6113 | ||||
6114 | class OwnershipAttr : public InheritableAttr { | |||
6115 | IdentifierInfo * module; | |||
6116 | ||||
6117 | unsigned args_Size; | |||
6118 | unsigned *args_; | |||
6119 | ||||
6120 | public: | |||
6121 | enum Spelling { | |||
6122 | GNU_ownership_holds = 0, | |||
6123 | CXX11_clang_ownership_holds = 1, | |||
6124 | C2x_clang_ownership_holds = 2, | |||
6125 | GNU_ownership_returns = 3, | |||
6126 | CXX11_clang_ownership_returns = 4, | |||
6127 | C2x_clang_ownership_returns = 5, | |||
6128 | GNU_ownership_takes = 6, | |||
6129 | CXX11_clang_ownership_takes = 7, | |||
6130 | C2x_clang_ownership_takes = 8 | |||
6131 | }; | |||
6132 | ||||
6133 | static OwnershipAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * Module, unsigned *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
6134 | auto *A = new (Ctx) OwnershipAttr(Loc, Ctx, Module, Args, ArgsSize, S); | |||
6135 | A->setImplicit(true); | |||
6136 | return A; | |||
6137 | } | |||
6138 | ||||
6139 | OwnershipAttr(SourceRange R, ASTContext &Ctx | |||
6140 | , IdentifierInfo * Module | |||
6141 | , unsigned *Args, unsigned ArgsSize | |||
6142 | , unsigned SI | |||
6143 | ) | |||
6144 | : InheritableAttr(attr::Ownership, R, SI, false, false) | |||
6145 | , module(Module) | |||
6146 | , args_Size(ArgsSize), args_(new (Ctx, 16) unsigned[args_Size]) | |||
6147 | { | |||
6148 | std::copy(Args, Args + args_Size, args_); | |||
6149 | } | |||
6150 | ||||
6151 | OwnershipAttr(SourceRange R, ASTContext &Ctx | |||
6152 | , IdentifierInfo * Module | |||
6153 | , unsigned SI | |||
6154 | ) | |||
6155 | : InheritableAttr(attr::Ownership, R, SI, false, false) | |||
6156 | , module(Module) | |||
6157 | , args_Size(0), args_(nullptr) | |||
6158 | { | |||
6159 | } | |||
6160 | ||||
6161 | OwnershipAttr *clone(ASTContext &C) const; | |||
6162 | void printPretty(raw_ostream &OS, | |||
6163 | const PrintingPolicy &Policy) const; | |||
6164 | const char *getSpelling() const; | |||
6165 | Spelling getSemanticSpelling() const { | |||
6166 | switch (SpellingListIndex) { | |||
6167 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 6167); | |||
6168 | case 0: return GNU_ownership_holds; | |||
6169 | case 1: return CXX11_clang_ownership_holds; | |||
6170 | case 2: return C2x_clang_ownership_holds; | |||
6171 | case 3: return GNU_ownership_returns; | |||
6172 | case 4: return CXX11_clang_ownership_returns; | |||
6173 | case 5: return C2x_clang_ownership_returns; | |||
6174 | case 6: return GNU_ownership_takes; | |||
6175 | case 7: return CXX11_clang_ownership_takes; | |||
6176 | case 8: return C2x_clang_ownership_takes; | |||
6177 | } | |||
6178 | } | |||
6179 | bool isHolds() const { return SpellingListIndex == 0 || | |||
6180 | SpellingListIndex == 1 || | |||
6181 | SpellingListIndex == 2; } | |||
6182 | bool isReturns() const { return SpellingListIndex == 3 || | |||
6183 | SpellingListIndex == 4 || | |||
6184 | SpellingListIndex == 5; } | |||
6185 | bool isTakes() const { return SpellingListIndex == 6 || | |||
6186 | SpellingListIndex == 7 || | |||
6187 | SpellingListIndex == 8; } | |||
6188 | IdentifierInfo * getModule() const { | |||
6189 | return module; | |||
6190 | } | |||
6191 | ||||
6192 | typedef unsigned* args_iterator; | |||
6193 | args_iterator args_begin() const { return args_; } | |||
6194 | args_iterator args_end() const { return args_ + args_Size; } | |||
6195 | unsigned args_size() const { return args_Size; } | |||
6196 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
6197 | ||||
6198 | ||||
6199 | ||||
6200 | enum OwnershipKind { Holds, Returns, Takes }; | |||
6201 | OwnershipKind getOwnKind() const { | |||
6202 | return isHolds() ? Holds : | |||
6203 | isTakes() ? Takes : | |||
6204 | Returns; | |||
6205 | } | |||
6206 | ||||
6207 | ||||
6208 | static bool classof(const Attr *A) { return A->getKind() == attr::Ownership; } | |||
6209 | }; | |||
6210 | ||||
6211 | class PackedAttr : public InheritableAttr { | |||
6212 | public: | |||
6213 | static PackedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6214 | auto *A = new (Ctx) PackedAttr(Loc, Ctx, 0); | |||
6215 | A->setImplicit(true); | |||
6216 | return A; | |||
6217 | } | |||
6218 | ||||
6219 | PackedAttr(SourceRange R, ASTContext &Ctx | |||
6220 | , unsigned SI | |||
6221 | ) | |||
6222 | : InheritableAttr(attr::Packed, R, SI, false, false) | |||
6223 | { | |||
6224 | } | |||
6225 | ||||
6226 | PackedAttr *clone(ASTContext &C) const; | |||
6227 | void printPretty(raw_ostream &OS, | |||
6228 | const PrintingPolicy &Policy) const; | |||
6229 | const char *getSpelling() const; | |||
6230 | ||||
6231 | ||||
6232 | static bool classof(const Attr *A) { return A->getKind() == attr::Packed; } | |||
6233 | }; | |||
6234 | ||||
6235 | class ParamTypestateAttr : public InheritableAttr { | |||
6236 | public: | |||
6237 | enum ConsumedState { | |||
6238 | Unknown, | |||
6239 | Consumed, | |||
6240 | Unconsumed | |||
6241 | }; | |||
6242 | private: | |||
6243 | ConsumedState paramState; | |||
6244 | ||||
6245 | public: | |||
6246 | static ParamTypestateAttr *CreateImplicit(ASTContext &Ctx, ConsumedState ParamState, SourceRange Loc = SourceRange()) { | |||
6247 | auto *A = new (Ctx) ParamTypestateAttr(Loc, Ctx, ParamState, 0); | |||
6248 | A->setImplicit(true); | |||
6249 | return A; | |||
6250 | } | |||
6251 | ||||
6252 | ParamTypestateAttr(SourceRange R, ASTContext &Ctx | |||
6253 | , ConsumedState ParamState | |||
6254 | , unsigned SI | |||
6255 | ) | |||
6256 | : InheritableAttr(attr::ParamTypestate, R, SI, false, false) | |||
6257 | , paramState(ParamState) | |||
6258 | { | |||
6259 | } | |||
6260 | ||||
6261 | ParamTypestateAttr *clone(ASTContext &C) const; | |||
6262 | void printPretty(raw_ostream &OS, | |||
6263 | const PrintingPolicy &Policy) const; | |||
6264 | const char *getSpelling() const; | |||
6265 | ConsumedState getParamState() const { | |||
6266 | return paramState; | |||
6267 | } | |||
6268 | ||||
6269 | static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) { | |||
6270 | Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val) | |||
6271 | .Case("unknown", ParamTypestateAttr::Unknown) | |||
6272 | .Case("consumed", ParamTypestateAttr::Consumed) | |||
6273 | .Case("unconsumed", ParamTypestateAttr::Unconsumed) | |||
6274 | .Default(Optional<ConsumedState>()); | |||
6275 | if (R) { | |||
6276 | Out = *R; | |||
6277 | return true; | |||
6278 | } | |||
6279 | return false; | |||
6280 | } | |||
6281 | ||||
6282 | static const char *ConvertConsumedStateToStr(ConsumedState Val) { | |||
6283 | switch(Val) { | |||
6284 | case ParamTypestateAttr::Unknown: return "unknown"; | |||
6285 | case ParamTypestateAttr::Consumed: return "consumed"; | |||
6286 | case ParamTypestateAttr::Unconsumed: return "unconsumed"; | |||
6287 | } | |||
6288 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 6288); | |||
6289 | } | |||
6290 | ||||
6291 | ||||
6292 | static bool classof(const Attr *A) { return A->getKind() == attr::ParamTypestate; } | |||
6293 | }; | |||
6294 | ||||
6295 | class PascalAttr : public InheritableAttr { | |||
6296 | public: | |||
6297 | static PascalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6298 | auto *A = new (Ctx) PascalAttr(Loc, Ctx, 0); | |||
6299 | A->setImplicit(true); | |||
6300 | return A; | |||
6301 | } | |||
6302 | ||||
6303 | PascalAttr(SourceRange R, ASTContext &Ctx | |||
6304 | , unsigned SI | |||
6305 | ) | |||
6306 | : InheritableAttr(attr::Pascal, R, SI, false, false) | |||
6307 | { | |||
6308 | } | |||
6309 | ||||
6310 | PascalAttr *clone(ASTContext &C) const; | |||
6311 | void printPretty(raw_ostream &OS, | |||
6312 | const PrintingPolicy &Policy) const; | |||
6313 | const char *getSpelling() const; | |||
6314 | ||||
6315 | ||||
6316 | static bool classof(const Attr *A) { return A->getKind() == attr::Pascal; } | |||
6317 | }; | |||
6318 | ||||
6319 | class PassObjectSizeAttr : public InheritableParamAttr { | |||
6320 | int type; | |||
6321 | ||||
6322 | public: | |||
6323 | static PassObjectSizeAttr *CreateImplicit(ASTContext &Ctx, int Type, SourceRange Loc = SourceRange()) { | |||
6324 | auto *A = new (Ctx) PassObjectSizeAttr(Loc, Ctx, Type, 0); | |||
6325 | A->setImplicit(true); | |||
6326 | return A; | |||
6327 | } | |||
6328 | ||||
6329 | PassObjectSizeAttr(SourceRange R, ASTContext &Ctx | |||
6330 | , int Type | |||
6331 | , unsigned SI | |||
6332 | ) | |||
6333 | : InheritableParamAttr(attr::PassObjectSize, R, SI, false, false) | |||
6334 | , type(Type) | |||
6335 | { | |||
6336 | } | |||
6337 | ||||
6338 | PassObjectSizeAttr *clone(ASTContext &C) const; | |||
6339 | void printPretty(raw_ostream &OS, | |||
6340 | const PrintingPolicy &Policy) const; | |||
6341 | const char *getSpelling() const; | |||
6342 | int getType() const { | |||
6343 | return type; | |||
6344 | } | |||
6345 | ||||
6346 | ||||
6347 | ||||
6348 | static bool classof(const Attr *A) { return A->getKind() == attr::PassObjectSize; } | |||
6349 | }; | |||
6350 | ||||
6351 | class PcsAttr : public InheritableAttr { | |||
6352 | public: | |||
6353 | enum PCSType { | |||
6354 | AAPCS, | |||
6355 | AAPCS_VFP | |||
6356 | }; | |||
6357 | private: | |||
6358 | PCSType pCS; | |||
6359 | ||||
6360 | public: | |||
6361 | static PcsAttr *CreateImplicit(ASTContext &Ctx, PCSType PCS, SourceRange Loc = SourceRange()) { | |||
6362 | auto *A = new (Ctx) PcsAttr(Loc, Ctx, PCS, 0); | |||
6363 | A->setImplicit(true); | |||
6364 | return A; | |||
6365 | } | |||
6366 | ||||
6367 | PcsAttr(SourceRange R, ASTContext &Ctx | |||
6368 | , PCSType PCS | |||
6369 | , unsigned SI | |||
6370 | ) | |||
6371 | : InheritableAttr(attr::Pcs, R, SI, false, false) | |||
6372 | , pCS(PCS) | |||
6373 | { | |||
6374 | } | |||
6375 | ||||
6376 | PcsAttr *clone(ASTContext &C) const; | |||
6377 | void printPretty(raw_ostream &OS, | |||
6378 | const PrintingPolicy &Policy) const; | |||
6379 | const char *getSpelling() const; | |||
6380 | PCSType getPCS() const { | |||
6381 | return pCS; | |||
6382 | } | |||
6383 | ||||
6384 | static bool ConvertStrToPCSType(StringRef Val, PCSType &Out) { | |||
6385 | Optional<PCSType> R = llvm::StringSwitch<Optional<PCSType>>(Val) | |||
6386 | .Case("aapcs", PcsAttr::AAPCS) | |||
6387 | .Case("aapcs-vfp", PcsAttr::AAPCS_VFP) | |||
6388 | .Default(Optional<PCSType>()); | |||
6389 | if (R) { | |||
6390 | Out = *R; | |||
6391 | return true; | |||
6392 | } | |||
6393 | return false; | |||
6394 | } | |||
6395 | ||||
6396 | static const char *ConvertPCSTypeToStr(PCSType Val) { | |||
6397 | switch(Val) { | |||
6398 | case PcsAttr::AAPCS: return "aapcs"; | |||
6399 | case PcsAttr::AAPCS_VFP: return "aapcs-vfp"; | |||
6400 | } | |||
6401 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 6401); | |||
6402 | } | |||
6403 | ||||
6404 | ||||
6405 | static bool classof(const Attr *A) { return A->getKind() == attr::Pcs; } | |||
6406 | }; | |||
6407 | ||||
6408 | class PragmaClangBSSSectionAttr : public InheritableAttr { | |||
6409 | unsigned nameLength; | |||
6410 | char *name; | |||
6411 | ||||
6412 | public: | |||
6413 | static PragmaClangBSSSectionAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) { | |||
6414 | auto *A = new (Ctx) PragmaClangBSSSectionAttr(Loc, Ctx, Name, 0); | |||
6415 | A->setImplicit(true); | |||
6416 | return A; | |||
6417 | } | |||
6418 | ||||
6419 | PragmaClangBSSSectionAttr(SourceRange R, ASTContext &Ctx | |||
6420 | , llvm::StringRef Name | |||
6421 | , unsigned SI | |||
6422 | ) | |||
6423 | : InheritableAttr(attr::PragmaClangBSSSection, R, SI, false, false) | |||
6424 | , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength]) | |||
6425 | { | |||
6426 | if (!Name.empty()) | |||
6427 | std::memcpy(name, Name.data(), nameLength); | |||
6428 | } | |||
6429 | ||||
6430 | PragmaClangBSSSectionAttr *clone(ASTContext &C) const; | |||
6431 | void printPretty(raw_ostream &OS, | |||
6432 | const PrintingPolicy &Policy) const; | |||
6433 | const char *getSpelling() const; | |||
6434 | llvm::StringRef getName() const { | |||
6435 | return llvm::StringRef(name, nameLength); | |||
6436 | } | |||
6437 | unsigned getNameLength() const { | |||
6438 | return nameLength; | |||
6439 | } | |||
6440 | void setName(ASTContext &C, llvm::StringRef S) { | |||
6441 | nameLength = S.size(); | |||
6442 | this->name = new (C, 1) char [nameLength]; | |||
6443 | if (!S.empty()) | |||
6444 | std::memcpy(this->name, S.data(), nameLength); | |||
6445 | } | |||
6446 | ||||
6447 | ||||
6448 | ||||
6449 | static bool classof(const Attr *A) { return A->getKind() == attr::PragmaClangBSSSection; } | |||
6450 | }; | |||
6451 | ||||
6452 | class PragmaClangDataSectionAttr : public InheritableAttr { | |||
6453 | unsigned nameLength; | |||
6454 | char *name; | |||
6455 | ||||
6456 | public: | |||
6457 | static PragmaClangDataSectionAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) { | |||
6458 | auto *A = new (Ctx) PragmaClangDataSectionAttr(Loc, Ctx, Name, 0); | |||
6459 | A->setImplicit(true); | |||
6460 | return A; | |||
6461 | } | |||
6462 | ||||
6463 | PragmaClangDataSectionAttr(SourceRange R, ASTContext &Ctx | |||
6464 | , llvm::StringRef Name | |||
6465 | , unsigned SI | |||
6466 | ) | |||
6467 | : InheritableAttr(attr::PragmaClangDataSection, R, SI, false, false) | |||
6468 | , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength]) | |||
6469 | { | |||
6470 | if (!Name.empty()) | |||
6471 | std::memcpy(name, Name.data(), nameLength); | |||
6472 | } | |||
6473 | ||||
6474 | PragmaClangDataSectionAttr *clone(ASTContext &C) const; | |||
6475 | void printPretty(raw_ostream &OS, | |||
6476 | const PrintingPolicy &Policy) const; | |||
6477 | const char *getSpelling() const; | |||
6478 | llvm::StringRef getName() const { | |||
6479 | return llvm::StringRef(name, nameLength); | |||
6480 | } | |||
6481 | unsigned getNameLength() const { | |||
6482 | return nameLength; | |||
6483 | } | |||
6484 | void setName(ASTContext &C, llvm::StringRef S) { | |||
6485 | nameLength = S.size(); | |||
6486 | this->name = new (C, 1) char [nameLength]; | |||
6487 | if (!S.empty()) | |||
6488 | std::memcpy(this->name, S.data(), nameLength); | |||
6489 | } | |||
6490 | ||||
6491 | ||||
6492 | ||||
6493 | static bool classof(const Attr *A) { return A->getKind() == attr::PragmaClangDataSection; } | |||
6494 | }; | |||
6495 | ||||
6496 | class PragmaClangRodataSectionAttr : public InheritableAttr { | |||
6497 | unsigned nameLength; | |||
6498 | char *name; | |||
6499 | ||||
6500 | public: | |||
6501 | static PragmaClangRodataSectionAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) { | |||
6502 | auto *A = new (Ctx) PragmaClangRodataSectionAttr(Loc, Ctx, Name, 0); | |||
6503 | A->setImplicit(true); | |||
6504 | return A; | |||
6505 | } | |||
6506 | ||||
6507 | PragmaClangRodataSectionAttr(SourceRange R, ASTContext &Ctx | |||
6508 | , llvm::StringRef Name | |||
6509 | , unsigned SI | |||
6510 | ) | |||
6511 | : InheritableAttr(attr::PragmaClangRodataSection, R, SI, false, false) | |||
6512 | , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength]) | |||
6513 | { | |||
6514 | if (!Name.empty()) | |||
6515 | std::memcpy(name, Name.data(), nameLength); | |||
6516 | } | |||
6517 | ||||
6518 | PragmaClangRodataSectionAttr *clone(ASTContext &C) const; | |||
6519 | void printPretty(raw_ostream &OS, | |||
6520 | const PrintingPolicy &Policy) const; | |||
6521 | const char *getSpelling() const; | |||
6522 | llvm::StringRef getName() const { | |||
6523 | return llvm::StringRef(name, nameLength); | |||
6524 | } | |||
6525 | unsigned getNameLength() const { | |||
6526 | return nameLength; | |||
6527 | } | |||
6528 | void setName(ASTContext &C, llvm::StringRef S) { | |||
6529 | nameLength = S.size(); | |||
6530 | this->name = new (C, 1) char [nameLength]; | |||
6531 | if (!S.empty()) | |||
6532 | std::memcpy(this->name, S.data(), nameLength); | |||
6533 | } | |||
6534 | ||||
6535 | ||||
6536 | ||||
6537 | static bool classof(const Attr *A) { return A->getKind() == attr::PragmaClangRodataSection; } | |||
6538 | }; | |||
6539 | ||||
6540 | class PragmaClangTextSectionAttr : public InheritableAttr { | |||
6541 | unsigned nameLength; | |||
6542 | char *name; | |||
6543 | ||||
6544 | public: | |||
6545 | static PragmaClangTextSectionAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) { | |||
6546 | auto *A = new (Ctx) PragmaClangTextSectionAttr(Loc, Ctx, Name, 0); | |||
6547 | A->setImplicit(true); | |||
6548 | return A; | |||
6549 | } | |||
6550 | ||||
6551 | PragmaClangTextSectionAttr(SourceRange R, ASTContext &Ctx | |||
6552 | , llvm::StringRef Name | |||
6553 | , unsigned SI | |||
6554 | ) | |||
6555 | : InheritableAttr(attr::PragmaClangTextSection, R, SI, false, false) | |||
6556 | , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength]) | |||
6557 | { | |||
6558 | if (!Name.empty()) | |||
6559 | std::memcpy(name, Name.data(), nameLength); | |||
6560 | } | |||
6561 | ||||
6562 | PragmaClangTextSectionAttr *clone(ASTContext &C) const; | |||
6563 | void printPretty(raw_ostream &OS, | |||
6564 | const PrintingPolicy &Policy) const; | |||
6565 | const char *getSpelling() const; | |||
6566 | llvm::StringRef getName() const { | |||
6567 | return llvm::StringRef(name, nameLength); | |||
6568 | } | |||
6569 | unsigned getNameLength() const { | |||
6570 | return nameLength; | |||
6571 | } | |||
6572 | void setName(ASTContext &C, llvm::StringRef S) { | |||
6573 | nameLength = S.size(); | |||
6574 | this->name = new (C, 1) char [nameLength]; | |||
6575 | if (!S.empty()) | |||
6576 | std::memcpy(this->name, S.data(), nameLength); | |||
6577 | } | |||
6578 | ||||
6579 | ||||
6580 | ||||
6581 | static bool classof(const Attr *A) { return A->getKind() == attr::PragmaClangTextSection; } | |||
6582 | }; | |||
6583 | ||||
6584 | class PreserveAllAttr : public InheritableAttr { | |||
6585 | public: | |||
6586 | static PreserveAllAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6587 | auto *A = new (Ctx) PreserveAllAttr(Loc, Ctx, 0); | |||
6588 | A->setImplicit(true); | |||
6589 | return A; | |||
6590 | } | |||
6591 | ||||
6592 | PreserveAllAttr(SourceRange R, ASTContext &Ctx | |||
6593 | , unsigned SI | |||
6594 | ) | |||
6595 | : InheritableAttr(attr::PreserveAll, R, SI, false, false) | |||
6596 | { | |||
6597 | } | |||
6598 | ||||
6599 | PreserveAllAttr *clone(ASTContext &C) const; | |||
6600 | void printPretty(raw_ostream &OS, | |||
6601 | const PrintingPolicy &Policy) const; | |||
6602 | const char *getSpelling() const; | |||
6603 | ||||
6604 | ||||
6605 | static bool classof(const Attr *A) { return A->getKind() == attr::PreserveAll; } | |||
6606 | }; | |||
6607 | ||||
6608 | class PreserveMostAttr : public InheritableAttr { | |||
6609 | public: | |||
6610 | static PreserveMostAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6611 | auto *A = new (Ctx) PreserveMostAttr(Loc, Ctx, 0); | |||
6612 | A->setImplicit(true); | |||
6613 | return A; | |||
6614 | } | |||
6615 | ||||
6616 | PreserveMostAttr(SourceRange R, ASTContext &Ctx | |||
6617 | , unsigned SI | |||
6618 | ) | |||
6619 | : InheritableAttr(attr::PreserveMost, R, SI, false, false) | |||
6620 | { | |||
6621 | } | |||
6622 | ||||
6623 | PreserveMostAttr *clone(ASTContext &C) const; | |||
6624 | void printPretty(raw_ostream &OS, | |||
6625 | const PrintingPolicy &Policy) const; | |||
6626 | const char *getSpelling() const; | |||
6627 | ||||
6628 | ||||
6629 | static bool classof(const Attr *A) { return A->getKind() == attr::PreserveMost; } | |||
6630 | }; | |||
6631 | ||||
6632 | class PtGuardedByAttr : public InheritableAttr { | |||
6633 | Expr * arg; | |||
6634 | ||||
6635 | public: | |||
6636 | static PtGuardedByAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) { | |||
6637 | auto *A = new (Ctx) PtGuardedByAttr(Loc, Ctx, Arg, 0); | |||
6638 | A->setImplicit(true); | |||
6639 | return A; | |||
6640 | } | |||
6641 | ||||
6642 | PtGuardedByAttr(SourceRange R, ASTContext &Ctx | |||
6643 | , Expr * Arg | |||
6644 | , unsigned SI | |||
6645 | ) | |||
6646 | : InheritableAttr(attr::PtGuardedBy, R, SI, true, true) | |||
6647 | , arg(Arg) | |||
6648 | { | |||
6649 | } | |||
6650 | ||||
6651 | PtGuardedByAttr *clone(ASTContext &C) const; | |||
6652 | void printPretty(raw_ostream &OS, | |||
6653 | const PrintingPolicy &Policy) const; | |||
6654 | const char *getSpelling() const; | |||
6655 | Expr * getArg() const { | |||
6656 | return arg; | |||
6657 | } | |||
6658 | ||||
6659 | ||||
6660 | ||||
6661 | static bool classof(const Attr *A) { return A->getKind() == attr::PtGuardedBy; } | |||
6662 | }; | |||
6663 | ||||
6664 | class PtGuardedVarAttr : public InheritableAttr { | |||
6665 | public: | |||
6666 | static PtGuardedVarAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6667 | auto *A = new (Ctx) PtGuardedVarAttr(Loc, Ctx, 0); | |||
6668 | A->setImplicit(true); | |||
6669 | return A; | |||
6670 | } | |||
6671 | ||||
6672 | PtGuardedVarAttr(SourceRange R, ASTContext &Ctx | |||
6673 | , unsigned SI | |||
6674 | ) | |||
6675 | : InheritableAttr(attr::PtGuardedVar, R, SI, false, false) | |||
6676 | { | |||
6677 | } | |||
6678 | ||||
6679 | PtGuardedVarAttr *clone(ASTContext &C) const; | |||
6680 | void printPretty(raw_ostream &OS, | |||
6681 | const PrintingPolicy &Policy) const; | |||
6682 | const char *getSpelling() const; | |||
6683 | ||||
6684 | ||||
6685 | static bool classof(const Attr *A) { return A->getKind() == attr::PtGuardedVar; } | |||
6686 | }; | |||
6687 | ||||
6688 | class PureAttr : public InheritableAttr { | |||
6689 | public: | |||
6690 | static PureAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6691 | auto *A = new (Ctx) PureAttr(Loc, Ctx, 0); | |||
6692 | A->setImplicit(true); | |||
6693 | return A; | |||
6694 | } | |||
6695 | ||||
6696 | PureAttr(SourceRange R, ASTContext &Ctx | |||
6697 | , unsigned SI | |||
6698 | ) | |||
6699 | : InheritableAttr(attr::Pure, R, SI, false, false) | |||
6700 | { | |||
6701 | } | |||
6702 | ||||
6703 | PureAttr *clone(ASTContext &C) const; | |||
6704 | void printPretty(raw_ostream &OS, | |||
6705 | const PrintingPolicy &Policy) const; | |||
6706 | const char *getSpelling() const; | |||
6707 | ||||
6708 | ||||
6709 | static bool classof(const Attr *A) { return A->getKind() == attr::Pure; } | |||
6710 | }; | |||
6711 | ||||
6712 | class RegCallAttr : public InheritableAttr { | |||
6713 | public: | |||
6714 | static RegCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6715 | auto *A = new (Ctx) RegCallAttr(Loc, Ctx, 0); | |||
6716 | A->setImplicit(true); | |||
6717 | return A; | |||
6718 | } | |||
6719 | ||||
6720 | RegCallAttr(SourceRange R, ASTContext &Ctx | |||
6721 | , unsigned SI | |||
6722 | ) | |||
6723 | : InheritableAttr(attr::RegCall, R, SI, false, false) | |||
6724 | { | |||
6725 | } | |||
6726 | ||||
6727 | RegCallAttr *clone(ASTContext &C) const; | |||
6728 | void printPretty(raw_ostream &OS, | |||
6729 | const PrintingPolicy &Policy) const; | |||
6730 | const char *getSpelling() const; | |||
6731 | ||||
6732 | ||||
6733 | static bool classof(const Attr *A) { return A->getKind() == attr::RegCall; } | |||
6734 | }; | |||
6735 | ||||
6736 | class ReleaseCapabilityAttr : public InheritableAttr { | |||
6737 | unsigned args_Size; | |||
6738 | Expr * *args_; | |||
6739 | ||||
6740 | public: | |||
6741 | enum Spelling { | |||
6742 | GNU_release_capability = 0, | |||
6743 | CXX11_clang_release_capability = 1, | |||
6744 | GNU_release_shared_capability = 2, | |||
6745 | CXX11_clang_release_shared_capability = 3, | |||
6746 | GNU_release_generic_capability = 4, | |||
6747 | CXX11_clang_release_generic_capability = 5, | |||
6748 | GNU_unlock_function = 6, | |||
6749 | CXX11_clang_unlock_function = 7 | |||
6750 | }; | |||
6751 | ||||
6752 | static ReleaseCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
6753 | auto *A = new (Ctx) ReleaseCapabilityAttr(Loc, Ctx, Args, ArgsSize, S); | |||
6754 | A->setImplicit(true); | |||
6755 | return A; | |||
6756 | } | |||
6757 | ||||
6758 | ReleaseCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
6759 | , Expr * *Args, unsigned ArgsSize | |||
6760 | , unsigned SI | |||
6761 | ) | |||
6762 | : InheritableAttr(attr::ReleaseCapability, R, SI, true, true) | |||
6763 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
6764 | { | |||
6765 | std::copy(Args, Args + args_Size, args_); | |||
6766 | } | |||
6767 | ||||
6768 | ReleaseCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
6769 | , unsigned SI | |||
6770 | ) | |||
6771 | : InheritableAttr(attr::ReleaseCapability, R, SI, true, true) | |||
6772 | , args_Size(0), args_(nullptr) | |||
6773 | { | |||
6774 | } | |||
6775 | ||||
6776 | ReleaseCapabilityAttr *clone(ASTContext &C) const; | |||
6777 | void printPretty(raw_ostream &OS, | |||
6778 | const PrintingPolicy &Policy) const; | |||
6779 | const char *getSpelling() const; | |||
6780 | Spelling getSemanticSpelling() const { | |||
6781 | switch (SpellingListIndex) { | |||
6782 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 6782); | |||
6783 | case 0: return GNU_release_capability; | |||
6784 | case 1: return CXX11_clang_release_capability; | |||
6785 | case 2: return GNU_release_shared_capability; | |||
6786 | case 3: return CXX11_clang_release_shared_capability; | |||
6787 | case 4: return GNU_release_generic_capability; | |||
6788 | case 5: return CXX11_clang_release_generic_capability; | |||
6789 | case 6: return GNU_unlock_function; | |||
6790 | case 7: return CXX11_clang_unlock_function; | |||
6791 | } | |||
6792 | } | |||
6793 | bool isShared() const { return SpellingListIndex == 2 || | |||
6794 | SpellingListIndex == 3; } | |||
6795 | bool isGeneric() const { return SpellingListIndex == 4 || | |||
6796 | SpellingListIndex == 5 || | |||
6797 | SpellingListIndex == 6 || | |||
6798 | SpellingListIndex == 7; } | |||
6799 | typedef Expr ** args_iterator; | |||
6800 | args_iterator args_begin() const { return args_; } | |||
6801 | args_iterator args_end() const { return args_ + args_Size; } | |||
6802 | unsigned args_size() const { return args_Size; } | |||
6803 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
6804 | ||||
6805 | ||||
6806 | ||||
6807 | ||||
6808 | static bool classof(const Attr *A) { return A->getKind() == attr::ReleaseCapability; } | |||
6809 | }; | |||
6810 | ||||
6811 | class RenderScriptKernelAttr : public Attr { | |||
6812 | public: | |||
6813 | static RenderScriptKernelAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6814 | auto *A = new (Ctx) RenderScriptKernelAttr(Loc, Ctx, 0); | |||
6815 | A->setImplicit(true); | |||
6816 | return A; | |||
6817 | } | |||
6818 | ||||
6819 | RenderScriptKernelAttr(SourceRange R, ASTContext &Ctx | |||
6820 | , unsigned SI | |||
6821 | ) | |||
6822 | : Attr(attr::RenderScriptKernel, R, SI, false) | |||
6823 | { | |||
6824 | } | |||
6825 | ||||
6826 | RenderScriptKernelAttr *clone(ASTContext &C) const; | |||
6827 | void printPretty(raw_ostream &OS, | |||
6828 | const PrintingPolicy &Policy) const; | |||
6829 | const char *getSpelling() const; | |||
6830 | ||||
6831 | ||||
6832 | static bool classof(const Attr *A) { return A->getKind() == attr::RenderScriptKernel; } | |||
6833 | }; | |||
6834 | ||||
6835 | class ReqdWorkGroupSizeAttr : public InheritableAttr { | |||
6836 | unsigned xDim; | |||
6837 | ||||
6838 | unsigned yDim; | |||
6839 | ||||
6840 | unsigned zDim; | |||
6841 | ||||
6842 | public: | |||
6843 | static ReqdWorkGroupSizeAttr *CreateImplicit(ASTContext &Ctx, unsigned XDim, unsigned YDim, unsigned ZDim, SourceRange Loc = SourceRange()) { | |||
6844 | auto *A = new (Ctx) ReqdWorkGroupSizeAttr(Loc, Ctx, XDim, YDim, ZDim, 0); | |||
6845 | A->setImplicit(true); | |||
6846 | return A; | |||
6847 | } | |||
6848 | ||||
6849 | ReqdWorkGroupSizeAttr(SourceRange R, ASTContext &Ctx | |||
6850 | , unsigned XDim | |||
6851 | , unsigned YDim | |||
6852 | , unsigned ZDim | |||
6853 | , unsigned SI | |||
6854 | ) | |||
6855 | : InheritableAttr(attr::ReqdWorkGroupSize, R, SI, false, false) | |||
6856 | , xDim(XDim) | |||
6857 | , yDim(YDim) | |||
6858 | , zDim(ZDim) | |||
6859 | { | |||
6860 | } | |||
6861 | ||||
6862 | ReqdWorkGroupSizeAttr *clone(ASTContext &C) const; | |||
6863 | void printPretty(raw_ostream &OS, | |||
6864 | const PrintingPolicy &Policy) const; | |||
6865 | const char *getSpelling() const; | |||
6866 | unsigned getXDim() const { | |||
6867 | return xDim; | |||
6868 | } | |||
6869 | ||||
6870 | unsigned getYDim() const { | |||
6871 | return yDim; | |||
6872 | } | |||
6873 | ||||
6874 | unsigned getZDim() const { | |||
6875 | return zDim; | |||
6876 | } | |||
6877 | ||||
6878 | ||||
6879 | ||||
6880 | static bool classof(const Attr *A) { return A->getKind() == attr::ReqdWorkGroupSize; } | |||
6881 | }; | |||
6882 | ||||
6883 | class RequireConstantInitAttr : public InheritableAttr { | |||
6884 | public: | |||
6885 | static RequireConstantInitAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6886 | auto *A = new (Ctx) RequireConstantInitAttr(Loc, Ctx, 0); | |||
6887 | A->setImplicit(true); | |||
6888 | return A; | |||
6889 | } | |||
6890 | ||||
6891 | RequireConstantInitAttr(SourceRange R, ASTContext &Ctx | |||
6892 | , unsigned SI | |||
6893 | ) | |||
6894 | : InheritableAttr(attr::RequireConstantInit, R, SI, false, false) | |||
6895 | { | |||
6896 | } | |||
6897 | ||||
6898 | RequireConstantInitAttr *clone(ASTContext &C) const; | |||
6899 | void printPretty(raw_ostream &OS, | |||
6900 | const PrintingPolicy &Policy) const; | |||
6901 | const char *getSpelling() const; | |||
6902 | ||||
6903 | ||||
6904 | static bool classof(const Attr *A) { return A->getKind() == attr::RequireConstantInit; } | |||
6905 | }; | |||
6906 | ||||
6907 | class RequiresCapabilityAttr : public InheritableAttr { | |||
6908 | unsigned args_Size; | |||
6909 | Expr * *args_; | |||
6910 | ||||
6911 | public: | |||
6912 | enum Spelling { | |||
6913 | GNU_requires_capability = 0, | |||
6914 | CXX11_clang_requires_capability = 1, | |||
6915 | GNU_exclusive_locks_required = 2, | |||
6916 | CXX11_clang_exclusive_locks_required = 3, | |||
6917 | GNU_requires_shared_capability = 4, | |||
6918 | CXX11_clang_requires_shared_capability = 5, | |||
6919 | GNU_shared_locks_required = 6, | |||
6920 | CXX11_clang_shared_locks_required = 7 | |||
6921 | }; | |||
6922 | ||||
6923 | static RequiresCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
6924 | auto *A = new (Ctx) RequiresCapabilityAttr(Loc, Ctx, Args, ArgsSize, S); | |||
6925 | A->setImplicit(true); | |||
6926 | return A; | |||
6927 | } | |||
6928 | ||||
6929 | RequiresCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
6930 | , Expr * *Args, unsigned ArgsSize | |||
6931 | , unsigned SI | |||
6932 | ) | |||
6933 | : InheritableAttr(attr::RequiresCapability, R, SI, true, true) | |||
6934 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
6935 | { | |||
6936 | std::copy(Args, Args + args_Size, args_); | |||
6937 | } | |||
6938 | ||||
6939 | RequiresCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
6940 | , unsigned SI | |||
6941 | ) | |||
6942 | : InheritableAttr(attr::RequiresCapability, R, SI, true, true) | |||
6943 | , args_Size(0), args_(nullptr) | |||
6944 | { | |||
6945 | } | |||
6946 | ||||
6947 | RequiresCapabilityAttr *clone(ASTContext &C) const; | |||
6948 | void printPretty(raw_ostream &OS, | |||
6949 | const PrintingPolicy &Policy) const; | |||
6950 | const char *getSpelling() const; | |||
6951 | Spelling getSemanticSpelling() const { | |||
6952 | switch (SpellingListIndex) { | |||
6953 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 6953); | |||
6954 | case 0: return GNU_requires_capability; | |||
6955 | case 1: return CXX11_clang_requires_capability; | |||
6956 | case 2: return GNU_exclusive_locks_required; | |||
6957 | case 3: return CXX11_clang_exclusive_locks_required; | |||
6958 | case 4: return GNU_requires_shared_capability; | |||
6959 | case 5: return CXX11_clang_requires_shared_capability; | |||
6960 | case 6: return GNU_shared_locks_required; | |||
6961 | case 7: return CXX11_clang_shared_locks_required; | |||
6962 | } | |||
6963 | } | |||
6964 | bool isShared() const { return SpellingListIndex == 4 || | |||
6965 | SpellingListIndex == 5 || | |||
6966 | SpellingListIndex == 6 || | |||
6967 | SpellingListIndex == 7; } | |||
6968 | typedef Expr ** args_iterator; | |||
6969 | args_iterator args_begin() const { return args_; } | |||
6970 | args_iterator args_end() const { return args_ + args_Size; } | |||
6971 | unsigned args_size() const { return args_Size; } | |||
6972 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
6973 | ||||
6974 | ||||
6975 | ||||
6976 | ||||
6977 | static bool classof(const Attr *A) { return A->getKind() == attr::RequiresCapability; } | |||
6978 | }; | |||
6979 | ||||
6980 | class RestrictAttr : public InheritableAttr { | |||
6981 | public: | |||
6982 | enum Spelling { | |||
6983 | Declspec_restrict = 0, | |||
6984 | GNU_malloc = 1, | |||
6985 | CXX11_gnu_malloc = 2 | |||
6986 | }; | |||
6987 | ||||
6988 | static RestrictAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
6989 | auto *A = new (Ctx) RestrictAttr(Loc, Ctx, S); | |||
6990 | A->setImplicit(true); | |||
6991 | return A; | |||
6992 | } | |||
6993 | ||||
6994 | RestrictAttr(SourceRange R, ASTContext &Ctx | |||
6995 | , unsigned SI | |||
6996 | ) | |||
6997 | : InheritableAttr(attr::Restrict, R, SI, false, false) | |||
6998 | { | |||
6999 | } | |||
7000 | ||||
7001 | RestrictAttr *clone(ASTContext &C) const; | |||
7002 | void printPretty(raw_ostream &OS, | |||
7003 | const PrintingPolicy &Policy) const; | |||
7004 | const char *getSpelling() const; | |||
7005 | Spelling getSemanticSpelling() const { | |||
7006 | switch (SpellingListIndex) { | |||
7007 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 7007); | |||
7008 | case 0: return Declspec_restrict; | |||
7009 | case 1: return GNU_malloc; | |||
7010 | case 2: return CXX11_gnu_malloc; | |||
7011 | } | |||
7012 | } | |||
7013 | ||||
7014 | ||||
7015 | static bool classof(const Attr *A) { return A->getKind() == attr::Restrict; } | |||
7016 | }; | |||
7017 | ||||
7018 | class ReturnTypestateAttr : public InheritableAttr { | |||
7019 | public: | |||
7020 | enum ConsumedState { | |||
7021 | Unknown, | |||
7022 | Consumed, | |||
7023 | Unconsumed | |||
7024 | }; | |||
7025 | private: | |||
7026 | ConsumedState state; | |||
7027 | ||||
7028 | public: | |||
7029 | static ReturnTypestateAttr *CreateImplicit(ASTContext &Ctx, ConsumedState State, SourceRange Loc = SourceRange()) { | |||
7030 | auto *A = new (Ctx) ReturnTypestateAttr(Loc, Ctx, State, 0); | |||
7031 | A->setImplicit(true); | |||
7032 | return A; | |||
7033 | } | |||
7034 | ||||
7035 | ReturnTypestateAttr(SourceRange R, ASTContext &Ctx | |||
7036 | , ConsumedState State | |||
7037 | , unsigned SI | |||
7038 | ) | |||
7039 | : InheritableAttr(attr::ReturnTypestate, R, SI, false, false) | |||
7040 | , state(State) | |||
7041 | { | |||
7042 | } | |||
7043 | ||||
7044 | ReturnTypestateAttr *clone(ASTContext &C) const; | |||
7045 | void printPretty(raw_ostream &OS, | |||
7046 | const PrintingPolicy &Policy) const; | |||
7047 | const char *getSpelling() const; | |||
7048 | ConsumedState getState() const { | |||
7049 | return state; | |||
7050 | } | |||
7051 | ||||
7052 | static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) { | |||
7053 | Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val) | |||
7054 | .Case("unknown", ReturnTypestateAttr::Unknown) | |||
7055 | .Case("consumed", ReturnTypestateAttr::Consumed) | |||
7056 | .Case("unconsumed", ReturnTypestateAttr::Unconsumed) | |||
7057 | .Default(Optional<ConsumedState>()); | |||
7058 | if (R) { | |||
7059 | Out = *R; | |||
7060 | return true; | |||
7061 | } | |||
7062 | return false; | |||
7063 | } | |||
7064 | ||||
7065 | static const char *ConvertConsumedStateToStr(ConsumedState Val) { | |||
7066 | switch(Val) { | |||
7067 | case ReturnTypestateAttr::Unknown: return "unknown"; | |||
7068 | case ReturnTypestateAttr::Consumed: return "consumed"; | |||
7069 | case ReturnTypestateAttr::Unconsumed: return "unconsumed"; | |||
7070 | } | |||
7071 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 7071); | |||
7072 | } | |||
7073 | ||||
7074 | ||||
7075 | static bool classof(const Attr *A) { return A->getKind() == attr::ReturnTypestate; } | |||
7076 | }; | |||
7077 | ||||
7078 | class ReturnsNonNullAttr : public InheritableAttr { | |||
7079 | public: | |||
7080 | static ReturnsNonNullAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7081 | auto *A = new (Ctx) ReturnsNonNullAttr(Loc, Ctx, 0); | |||
7082 | A->setImplicit(true); | |||
7083 | return A; | |||
7084 | } | |||
7085 | ||||
7086 | ReturnsNonNullAttr(SourceRange R, ASTContext &Ctx | |||
7087 | , unsigned SI | |||
7088 | ) | |||
7089 | : InheritableAttr(attr::ReturnsNonNull, R, SI, false, false) | |||
7090 | { | |||
7091 | } | |||
7092 | ||||
7093 | ReturnsNonNullAttr *clone(ASTContext &C) const; | |||
7094 | void printPretty(raw_ostream &OS, | |||
7095 | const PrintingPolicy &Policy) const; | |||
7096 | const char *getSpelling() const; | |||
7097 | ||||
7098 | ||||
7099 | static bool classof(const Attr *A) { return A->getKind() == attr::ReturnsNonNull; } | |||
7100 | }; | |||
7101 | ||||
7102 | class ReturnsTwiceAttr : public InheritableAttr { | |||
7103 | public: | |||
7104 | static ReturnsTwiceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7105 | auto *A = new (Ctx) ReturnsTwiceAttr(Loc, Ctx, 0); | |||
7106 | A->setImplicit(true); | |||
7107 | return A; | |||
7108 | } | |||
7109 | ||||
7110 | ReturnsTwiceAttr(SourceRange R, ASTContext &Ctx | |||
7111 | , unsigned SI | |||
7112 | ) | |||
7113 | : InheritableAttr(attr::ReturnsTwice, R, SI, false, false) | |||
7114 | { | |||
7115 | } | |||
7116 | ||||
7117 | ReturnsTwiceAttr *clone(ASTContext &C) const; | |||
7118 | void printPretty(raw_ostream &OS, | |||
7119 | const PrintingPolicy &Policy) const; | |||
7120 | const char *getSpelling() const; | |||
7121 | ||||
7122 | ||||
7123 | static bool classof(const Attr *A) { return A->getKind() == attr::ReturnsTwice; } | |||
7124 | }; | |||
7125 | ||||
7126 | class ScopedLockableAttr : public InheritableAttr { | |||
7127 | public: | |||
7128 | static ScopedLockableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7129 | auto *A = new (Ctx) ScopedLockableAttr(Loc, Ctx, 0); | |||
7130 | A->setImplicit(true); | |||
7131 | return A; | |||
7132 | } | |||
7133 | ||||
7134 | ScopedLockableAttr(SourceRange R, ASTContext &Ctx | |||
7135 | , unsigned SI | |||
7136 | ) | |||
7137 | : InheritableAttr(attr::ScopedLockable, R, SI, false, false) | |||
7138 | { | |||
7139 | } | |||
7140 | ||||
7141 | ScopedLockableAttr *clone(ASTContext &C) const; | |||
7142 | void printPretty(raw_ostream &OS, | |||
7143 | const PrintingPolicy &Policy) const; | |||
7144 | const char *getSpelling() const; | |||
7145 | ||||
7146 | ||||
7147 | static bool classof(const Attr *A) { return A->getKind() == attr::ScopedLockable; } | |||
7148 | }; | |||
7149 | ||||
7150 | class SectionAttr : public InheritableAttr { | |||
7151 | unsigned nameLength; | |||
7152 | char *name; | |||
7153 | ||||
7154 | public: | |||
7155 | enum Spelling { | |||
7156 | GNU_section = 0, | |||
7157 | CXX11_gnu_section = 1, | |||
7158 | Declspec_allocate = 2 | |||
7159 | }; | |||
7160 | ||||
7161 | static SectionAttr *CreateImplicit(ASTContext &Ctx, Spelling S, llvm::StringRef Name, SourceRange Loc = SourceRange()) { | |||
7162 | auto *A = new (Ctx) SectionAttr(Loc, Ctx, Name, S); | |||
7163 | A->setImplicit(true); | |||
7164 | return A; | |||
7165 | } | |||
7166 | ||||
7167 | SectionAttr(SourceRange R, ASTContext &Ctx | |||
7168 | , llvm::StringRef Name | |||
7169 | , unsigned SI | |||
7170 | ) | |||
7171 | : InheritableAttr(attr::Section, R, SI, false, false) | |||
7172 | , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength]) | |||
7173 | { | |||
7174 | if (!Name.empty()) | |||
7175 | std::memcpy(name, Name.data(), nameLength); | |||
7176 | } | |||
7177 | ||||
7178 | SectionAttr *clone(ASTContext &C) const; | |||
7179 | void printPretty(raw_ostream &OS, | |||
7180 | const PrintingPolicy &Policy) const; | |||
7181 | const char *getSpelling() const; | |||
7182 | Spelling getSemanticSpelling() const { | |||
7183 | switch (SpellingListIndex) { | |||
7184 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 7184); | |||
7185 | case 0: return GNU_section; | |||
7186 | case 1: return CXX11_gnu_section; | |||
7187 | case 2: return Declspec_allocate; | |||
7188 | } | |||
7189 | } | |||
7190 | llvm::StringRef getName() const { | |||
7191 | return llvm::StringRef(name, nameLength); | |||
7192 | } | |||
7193 | unsigned getNameLength() const { | |||
7194 | return nameLength; | |||
7195 | } | |||
7196 | void setName(ASTContext &C, llvm::StringRef S) { | |||
7197 | nameLength = S.size(); | |||
7198 | this->name = new (C, 1) char [nameLength]; | |||
7199 | if (!S.empty()) | |||
7200 | std::memcpy(this->name, S.data(), nameLength); | |||
7201 | } | |||
7202 | ||||
7203 | ||||
7204 | ||||
7205 | static bool classof(const Attr *A) { return A->getKind() == attr::Section; } | |||
7206 | }; | |||
7207 | ||||
7208 | class SelectAnyAttr : public InheritableAttr { | |||
7209 | public: | |||
7210 | static SelectAnyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7211 | auto *A = new (Ctx) SelectAnyAttr(Loc, Ctx, 0); | |||
7212 | A->setImplicit(true); | |||
7213 | return A; | |||
7214 | } | |||
7215 | ||||
7216 | SelectAnyAttr(SourceRange R, ASTContext &Ctx | |||
7217 | , unsigned SI | |||
7218 | ) | |||
7219 | : InheritableAttr(attr::SelectAny, R, SI, false, false) | |||
7220 | { | |||
7221 | } | |||
7222 | ||||
7223 | SelectAnyAttr *clone(ASTContext &C) const; | |||
7224 | void printPretty(raw_ostream &OS, | |||
7225 | const PrintingPolicy &Policy) const; | |||
7226 | const char *getSpelling() const; | |||
7227 | ||||
7228 | ||||
7229 | static bool classof(const Attr *A) { return A->getKind() == attr::SelectAny; } | |||
7230 | }; | |||
7231 | ||||
7232 | class SentinelAttr : public InheritableAttr { | |||
7233 | int sentinel; | |||
7234 | ||||
7235 | int nullPos; | |||
7236 | ||||
7237 | public: | |||
7238 | static SentinelAttr *CreateImplicit(ASTContext &Ctx, int Sentinel, int NullPos, SourceRange Loc = SourceRange()) { | |||
7239 | auto *A = new (Ctx) SentinelAttr(Loc, Ctx, Sentinel, NullPos, 0); | |||
7240 | A->setImplicit(true); | |||
7241 | return A; | |||
7242 | } | |||
7243 | ||||
7244 | SentinelAttr(SourceRange R, ASTContext &Ctx | |||
7245 | , int Sentinel | |||
7246 | , int NullPos | |||
7247 | , unsigned SI | |||
7248 | ) | |||
7249 | : InheritableAttr(attr::Sentinel, R, SI, false, false) | |||
7250 | , sentinel(Sentinel) | |||
7251 | , nullPos(NullPos) | |||
7252 | { | |||
7253 | } | |||
7254 | ||||
7255 | SentinelAttr(SourceRange R, ASTContext &Ctx | |||
7256 | , unsigned SI | |||
7257 | ) | |||
7258 | : InheritableAttr(attr::Sentinel, R, SI, false, false) | |||
7259 | , sentinel() | |||
7260 | , nullPos() | |||
7261 | { | |||
7262 | } | |||
7263 | ||||
7264 | SentinelAttr *clone(ASTContext &C) const; | |||
7265 | void printPretty(raw_ostream &OS, | |||
7266 | const PrintingPolicy &Policy) const; | |||
7267 | const char *getSpelling() const; | |||
7268 | int getSentinel() const { | |||
7269 | return sentinel; | |||
7270 | } | |||
7271 | ||||
7272 | static const int DefaultSentinel = 0; | |||
7273 | ||||
7274 | int getNullPos() const { | |||
7275 | return nullPos; | |||
7276 | } | |||
7277 | ||||
7278 | static const int DefaultNullPos = 0; | |||
7279 | ||||
7280 | ||||
7281 | ||||
7282 | static bool classof(const Attr *A) { return A->getKind() == attr::Sentinel; } | |||
7283 | }; | |||
7284 | ||||
7285 | class SetTypestateAttr : public InheritableAttr { | |||
7286 | public: | |||
7287 | enum ConsumedState { | |||
7288 | Unknown, | |||
7289 | Consumed, | |||
7290 | Unconsumed | |||
7291 | }; | |||
7292 | private: | |||
7293 | ConsumedState newState; | |||
7294 | ||||
7295 | public: | |||
7296 | static SetTypestateAttr *CreateImplicit(ASTContext &Ctx, ConsumedState NewState, SourceRange Loc = SourceRange()) { | |||
7297 | auto *A = new (Ctx) SetTypestateAttr(Loc, Ctx, NewState, 0); | |||
7298 | A->setImplicit(true); | |||
7299 | return A; | |||
7300 | } | |||
7301 | ||||
7302 | SetTypestateAttr(SourceRange R, ASTContext &Ctx | |||
7303 | , ConsumedState NewState | |||
7304 | , unsigned SI | |||
7305 | ) | |||
7306 | : InheritableAttr(attr::SetTypestate, R, SI, false, false) | |||
7307 | , newState(NewState) | |||
7308 | { | |||
7309 | } | |||
7310 | ||||
7311 | SetTypestateAttr *clone(ASTContext &C) const; | |||
7312 | void printPretty(raw_ostream &OS, | |||
7313 | const PrintingPolicy &Policy) const; | |||
7314 | const char *getSpelling() const; | |||
7315 | ConsumedState getNewState() const { | |||
7316 | return newState; | |||
7317 | } | |||
7318 | ||||
7319 | static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) { | |||
7320 | Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val) | |||
7321 | .Case("unknown", SetTypestateAttr::Unknown) | |||
7322 | .Case("consumed", SetTypestateAttr::Consumed) | |||
7323 | .Case("unconsumed", SetTypestateAttr::Unconsumed) | |||
7324 | .Default(Optional<ConsumedState>()); | |||
7325 | if (R) { | |||
7326 | Out = *R; | |||
7327 | return true; | |||
7328 | } | |||
7329 | return false; | |||
7330 | } | |||
7331 | ||||
7332 | static const char *ConvertConsumedStateToStr(ConsumedState Val) { | |||
7333 | switch(Val) { | |||
7334 | case SetTypestateAttr::Unknown: return "unknown"; | |||
7335 | case SetTypestateAttr::Consumed: return "consumed"; | |||
7336 | case SetTypestateAttr::Unconsumed: return "unconsumed"; | |||
7337 | } | |||
7338 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 7338); | |||
7339 | } | |||
7340 | ||||
7341 | ||||
7342 | static bool classof(const Attr *A) { return A->getKind() == attr::SetTypestate; } | |||
7343 | }; | |||
7344 | ||||
7345 | class SharedTrylockFunctionAttr : public InheritableAttr { | |||
7346 | Expr * successValue; | |||
7347 | ||||
7348 | unsigned args_Size; | |||
7349 | Expr * *args_; | |||
7350 | ||||
7351 | public: | |||
7352 | static SharedTrylockFunctionAttr *CreateImplicit(ASTContext &Ctx, Expr * SuccessValue, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
7353 | auto *A = new (Ctx) SharedTrylockFunctionAttr(Loc, Ctx, SuccessValue, Args, ArgsSize, 0); | |||
7354 | A->setImplicit(true); | |||
7355 | return A; | |||
7356 | } | |||
7357 | ||||
7358 | SharedTrylockFunctionAttr(SourceRange R, ASTContext &Ctx | |||
7359 | , Expr * SuccessValue | |||
7360 | , Expr * *Args, unsigned ArgsSize | |||
7361 | , unsigned SI | |||
7362 | ) | |||
7363 | : InheritableAttr(attr::SharedTrylockFunction, R, SI, true, true) | |||
7364 | , successValue(SuccessValue) | |||
7365 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
7366 | { | |||
7367 | std::copy(Args, Args + args_Size, args_); | |||
7368 | } | |||
7369 | ||||
7370 | SharedTrylockFunctionAttr(SourceRange R, ASTContext &Ctx | |||
7371 | , Expr * SuccessValue | |||
7372 | , unsigned SI | |||
7373 | ) | |||
7374 | : InheritableAttr(attr::SharedTrylockFunction, R, SI, true, true) | |||
7375 | , successValue(SuccessValue) | |||
7376 | , args_Size(0), args_(nullptr) | |||
7377 | { | |||
7378 | } | |||
7379 | ||||
7380 | SharedTrylockFunctionAttr *clone(ASTContext &C) const; | |||
7381 | void printPretty(raw_ostream &OS, | |||
7382 | const PrintingPolicy &Policy) const; | |||
7383 | const char *getSpelling() const; | |||
7384 | Expr * getSuccessValue() const { | |||
7385 | return successValue; | |||
7386 | } | |||
7387 | ||||
7388 | typedef Expr ** args_iterator; | |||
7389 | args_iterator args_begin() const { return args_; } | |||
7390 | args_iterator args_end() const { return args_ + args_Size; } | |||
7391 | unsigned args_size() const { return args_Size; } | |||
7392 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
7393 | ||||
7394 | ||||
7395 | ||||
7396 | ||||
7397 | static bool classof(const Attr *A) { return A->getKind() == attr::SharedTrylockFunction; } | |||
7398 | }; | |||
7399 | ||||
7400 | class StdCallAttr : public InheritableAttr { | |||
7401 | public: | |||
7402 | static StdCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7403 | auto *A = new (Ctx) StdCallAttr(Loc, Ctx, 0); | |||
7404 | A->setImplicit(true); | |||
7405 | return A; | |||
7406 | } | |||
7407 | ||||
7408 | StdCallAttr(SourceRange R, ASTContext &Ctx | |||
7409 | , unsigned SI | |||
7410 | ) | |||
7411 | : InheritableAttr(attr::StdCall, R, SI, false, false) | |||
7412 | { | |||
7413 | } | |||
7414 | ||||
7415 | StdCallAttr *clone(ASTContext &C) const; | |||
7416 | void printPretty(raw_ostream &OS, | |||
7417 | const PrintingPolicy &Policy) const; | |||
7418 | const char *getSpelling() const; | |||
7419 | ||||
7420 | ||||
7421 | static bool classof(const Attr *A) { return A->getKind() == attr::StdCall; } | |||
7422 | }; | |||
7423 | ||||
7424 | class SuppressAttr : public StmtAttr { | |||
7425 | unsigned diagnosticIdentifiers_Size; | |||
7426 | StringRef *diagnosticIdentifiers_; | |||
7427 | ||||
7428 | public: | |||
7429 | static SuppressAttr *CreateImplicit(ASTContext &Ctx, StringRef *DiagnosticIdentifiers, unsigned DiagnosticIdentifiersSize, SourceRange Loc = SourceRange()) { | |||
7430 | auto *A = new (Ctx) SuppressAttr(Loc, Ctx, DiagnosticIdentifiers, DiagnosticIdentifiersSize, 0); | |||
7431 | A->setImplicit(true); | |||
7432 | return A; | |||
7433 | } | |||
7434 | ||||
7435 | SuppressAttr(SourceRange R, ASTContext &Ctx | |||
7436 | , StringRef *DiagnosticIdentifiers, unsigned DiagnosticIdentifiersSize | |||
7437 | , unsigned SI | |||
7438 | ) | |||
7439 | : StmtAttr(attr::Suppress, R, SI, false) | |||
7440 | , diagnosticIdentifiers_Size(DiagnosticIdentifiersSize), diagnosticIdentifiers_(new (Ctx, 16) StringRef[diagnosticIdentifiers_Size]) | |||
7441 | { | |||
7442 | for (size_t I = 0, E = diagnosticIdentifiers_Size; I != E; | |||
7443 | ++I) { | |||
7444 | StringRef Ref = DiagnosticIdentifiers[I]; | |||
7445 | if (!Ref.empty()) { | |||
7446 | char *Mem = new (Ctx, 1) char[Ref.size()]; | |||
7447 | std::memcpy(Mem, Ref.data(), Ref.size()); | |||
7448 | diagnosticIdentifiers_[I] = StringRef(Mem, Ref.size()); | |||
| ||||
7449 | } | |||
7450 | } | |||
7451 | } | |||
7452 | ||||
7453 | SuppressAttr(SourceRange R, ASTContext &Ctx | |||
7454 | , unsigned SI | |||
7455 | ) | |||
7456 | : StmtAttr(attr::Suppress, R, SI, false) | |||
7457 | , diagnosticIdentifiers_Size(0), diagnosticIdentifiers_(nullptr) | |||
7458 | { | |||
7459 | } | |||
7460 | ||||
7461 | SuppressAttr *clone(ASTContext &C) const; | |||
7462 | void printPretty(raw_ostream &OS, | |||
7463 | const PrintingPolicy &Policy) const; | |||
7464 | const char *getSpelling() const; | |||
7465 | typedef StringRef* diagnosticIdentifiers_iterator; | |||
7466 | diagnosticIdentifiers_iterator diagnosticIdentifiers_begin() const { return diagnosticIdentifiers_; } | |||
7467 | diagnosticIdentifiers_iterator diagnosticIdentifiers_end() const { return diagnosticIdentifiers_ + diagnosticIdentifiers_Size; } | |||
7468 | unsigned diagnosticIdentifiers_size() const { return diagnosticIdentifiers_Size; } | |||
7469 | llvm::iterator_range<diagnosticIdentifiers_iterator> diagnosticIdentifiers() const { return llvm::make_range(diagnosticIdentifiers_begin(), diagnosticIdentifiers_end()); } | |||
7470 | ||||
7471 | ||||
7472 | ||||
7473 | ||||
7474 | static bool classof(const Attr *A) { return A->getKind() == attr::Suppress; } | |||
7475 | }; | |||
7476 | ||||
7477 | class SwiftCallAttr : public InheritableAttr { | |||
7478 | public: | |||
7479 | static SwiftCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7480 | auto *A = new (Ctx) SwiftCallAttr(Loc, Ctx, 0); | |||
7481 | A->setImplicit(true); | |||
7482 | return A; | |||
7483 | } | |||
7484 | ||||
7485 | SwiftCallAttr(SourceRange R, ASTContext &Ctx | |||
7486 | , unsigned SI | |||
7487 | ) | |||
7488 | : InheritableAttr(attr::SwiftCall, R, SI, false, false) | |||
7489 | { | |||
7490 | } | |||
7491 | ||||
7492 | SwiftCallAttr *clone(ASTContext &C) const; | |||
7493 | void printPretty(raw_ostream &OS, | |||
7494 | const PrintingPolicy &Policy) const; | |||
7495 | const char *getSpelling() const; | |||
7496 | ||||
7497 | ||||
7498 | static bool classof(const Attr *A) { return A->getKind() == attr::SwiftCall; } | |||
7499 | }; | |||
7500 | ||||
7501 | class SwiftContextAttr : public ParameterABIAttr { | |||
7502 | public: | |||
7503 | static SwiftContextAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7504 | auto *A = new (Ctx) SwiftContextAttr(Loc, Ctx, 0); | |||
7505 | A->setImplicit(true); | |||
7506 | return A; | |||
7507 | } | |||
7508 | ||||
7509 | SwiftContextAttr(SourceRange R, ASTContext &Ctx | |||
7510 | , unsigned SI | |||
7511 | ) | |||
7512 | : ParameterABIAttr(attr::SwiftContext, R, SI, false, false) | |||
7513 | { | |||
7514 | } | |||
7515 | ||||
7516 | SwiftContextAttr *clone(ASTContext &C) const; | |||
7517 | void printPretty(raw_ostream &OS, | |||
7518 | const PrintingPolicy &Policy) const; | |||
7519 | const char *getSpelling() const; | |||
7520 | ||||
7521 | ||||
7522 | static bool classof(const Attr *A) { return A->getKind() == attr::SwiftContext; } | |||
7523 | }; | |||
7524 | ||||
7525 | class SwiftErrorResultAttr : public ParameterABIAttr { | |||
7526 | public: | |||
7527 | static SwiftErrorResultAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7528 | auto *A = new (Ctx) SwiftErrorResultAttr(Loc, Ctx, 0); | |||
7529 | A->setImplicit(true); | |||
7530 | return A; | |||
7531 | } | |||
7532 | ||||
7533 | SwiftErrorResultAttr(SourceRange R, ASTContext &Ctx | |||
7534 | , unsigned SI | |||
7535 | ) | |||
7536 | : ParameterABIAttr(attr::SwiftErrorResult, R, SI, false, false) | |||
7537 | { | |||
7538 | } | |||
7539 | ||||
7540 | SwiftErrorResultAttr *clone(ASTContext &C) const; | |||
7541 | void printPretty(raw_ostream &OS, | |||
7542 | const PrintingPolicy &Policy) const; | |||
7543 | const char *getSpelling() const; | |||
7544 | ||||
7545 | ||||
7546 | static bool classof(const Attr *A) { return A->getKind() == attr::SwiftErrorResult; } | |||
7547 | }; | |||
7548 | ||||
7549 | class SwiftIndirectResultAttr : public ParameterABIAttr { | |||
7550 | public: | |||
7551 | static SwiftIndirectResultAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7552 | auto *A = new (Ctx) SwiftIndirectResultAttr(Loc, Ctx, 0); | |||
7553 | A->setImplicit(true); | |||
7554 | return A; | |||
7555 | } | |||
7556 | ||||
7557 | SwiftIndirectResultAttr(SourceRange R, ASTContext &Ctx | |||
7558 | , unsigned SI | |||
7559 | ) | |||
7560 | : ParameterABIAttr(attr::SwiftIndirectResult, R, SI, false, false) | |||
7561 | { | |||
7562 | } | |||
7563 | ||||
7564 | SwiftIndirectResultAttr *clone(ASTContext &C) const; | |||
7565 | void printPretty(raw_ostream &OS, | |||
7566 | const PrintingPolicy &Policy) const; | |||
7567 | const char *getSpelling() const; | |||
7568 | ||||
7569 | ||||
7570 | static bool classof(const Attr *A) { return A->getKind() == attr::SwiftIndirectResult; } | |||
7571 | }; | |||
7572 | ||||
7573 | class SysVABIAttr : public InheritableAttr { | |||
7574 | public: | |||
7575 | static SysVABIAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7576 | auto *A = new (Ctx) SysVABIAttr(Loc, Ctx, 0); | |||
7577 | A->setImplicit(true); | |||
7578 | return A; | |||
7579 | } | |||
7580 | ||||
7581 | SysVABIAttr(SourceRange R, ASTContext &Ctx | |||
7582 | , unsigned SI | |||
7583 | ) | |||
7584 | : InheritableAttr(attr::SysVABI, R, SI, false, false) | |||
7585 | { | |||
7586 | } | |||
7587 | ||||
7588 | SysVABIAttr *clone(ASTContext &C) const; | |||
7589 | void printPretty(raw_ostream &OS, | |||
7590 | const PrintingPolicy &Policy) const; | |||
7591 | const char *getSpelling() const; | |||
7592 | ||||
7593 | ||||
7594 | static bool classof(const Attr *A) { return A->getKind() == attr::SysVABI; } | |||
7595 | }; | |||
7596 | ||||
7597 | class TLSModelAttr : public InheritableAttr { | |||
7598 | unsigned modelLength; | |||
7599 | char *model; | |||
7600 | ||||
7601 | public: | |||
7602 | static TLSModelAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Model, SourceRange Loc = SourceRange()) { | |||
7603 | auto *A = new (Ctx) TLSModelAttr(Loc, Ctx, Model, 0); | |||
7604 | A->setImplicit(true); | |||
7605 | return A; | |||
7606 | } | |||
7607 | ||||
7608 | TLSModelAttr(SourceRange R, ASTContext &Ctx | |||
7609 | , llvm::StringRef Model | |||
7610 | , unsigned SI | |||
7611 | ) | |||
7612 | : InheritableAttr(attr::TLSModel, R, SI, false, false) | |||
7613 | , modelLength(Model.size()),model(new (Ctx, 1) char[modelLength]) | |||
7614 | { | |||
7615 | if (!Model.empty()) | |||
7616 | std::memcpy(model, Model.data(), modelLength); | |||
7617 | } | |||
7618 | ||||
7619 | TLSModelAttr *clone(ASTContext &C) const; | |||
7620 | void printPretty(raw_ostream &OS, | |||
7621 | const PrintingPolicy &Policy) const; | |||
7622 | const char *getSpelling() const; | |||
7623 | llvm::StringRef getModel() const { | |||
7624 | return llvm::StringRef(model, modelLength); | |||
7625 | } | |||
7626 | unsigned getModelLength() const { | |||
7627 | return modelLength; | |||
7628 | } | |||
7629 | void setModel(ASTContext &C, llvm::StringRef S) { | |||
7630 | modelLength = S.size(); | |||
7631 | this->model = new (C, 1) char [modelLength]; | |||
7632 | if (!S.empty()) | |||
7633 | std::memcpy(this->model, S.data(), modelLength); | |||
7634 | } | |||
7635 | ||||
7636 | ||||
7637 | ||||
7638 | static bool classof(const Attr *A) { return A->getKind() == attr::TLSModel; } | |||
7639 | }; | |||
7640 | ||||
7641 | class TargetAttr : public InheritableAttr { | |||
7642 | unsigned featuresStrLength; | |||
7643 | char *featuresStr; | |||
7644 | ||||
7645 | public: | |||
7646 | static TargetAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef FeaturesStr, SourceRange Loc = SourceRange()) { | |||
7647 | auto *A = new (Ctx) TargetAttr(Loc, Ctx, FeaturesStr, 0); | |||
7648 | A->setImplicit(true); | |||
7649 | return A; | |||
7650 | } | |||
7651 | ||||
7652 | TargetAttr(SourceRange R, ASTContext &Ctx | |||
7653 | , llvm::StringRef FeaturesStr | |||
7654 | , unsigned SI | |||
7655 | ) | |||
7656 | : InheritableAttr(attr::Target, R, SI, false, false) | |||
7657 | , featuresStrLength(FeaturesStr.size()),featuresStr(new (Ctx, 1) char[featuresStrLength]) | |||
7658 | { | |||
7659 | if (!FeaturesStr.empty()) | |||
7660 | std::memcpy(featuresStr, FeaturesStr.data(), featuresStrLength); | |||
7661 | } | |||
7662 | ||||
7663 | TargetAttr *clone(ASTContext &C) const; | |||
7664 | void printPretty(raw_ostream &OS, | |||
7665 | const PrintingPolicy &Policy) const; | |||
7666 | const char *getSpelling() const; | |||
7667 | llvm::StringRef getFeaturesStr() const { | |||
7668 | return llvm::StringRef(featuresStr, featuresStrLength); | |||
7669 | } | |||
7670 | unsigned getFeaturesStrLength() const { | |||
7671 | return featuresStrLength; | |||
7672 | } | |||
7673 | void setFeaturesStr(ASTContext &C, llvm::StringRef S) { | |||
7674 | featuresStrLength = S.size(); | |||
7675 | this->featuresStr = new (C, 1) char [featuresStrLength]; | |||
7676 | if (!S.empty()) | |||
7677 | std::memcpy(this->featuresStr, S.data(), featuresStrLength); | |||
7678 | } | |||
7679 | ||||
7680 | ||||
7681 | struct ParsedTargetAttr { | |||
7682 | std::vector<std::string> Features; | |||
7683 | StringRef Architecture; | |||
7684 | bool DuplicateArchitecture = false; | |||
7685 | bool operator ==(const ParsedTargetAttr &Other) const { | |||
7686 | return DuplicateArchitecture == Other.DuplicateArchitecture && | |||
7687 | Architecture == Other.Architecture && Features == Other.Features; | |||
7688 | } | |||
7689 | }; | |||
7690 | ParsedTargetAttr parse() const { | |||
7691 | return parse(getFeaturesStr()); | |||
7692 | } | |||
7693 | ||||
7694 | template<class Compare> | |||
7695 | ParsedTargetAttr parse(Compare cmp) const { | |||
7696 | ParsedTargetAttr Attrs = parse(); | |||
7697 | std::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp); | |||
7698 | return Attrs; | |||
7699 | } | |||
7700 | ||||
7701 | bool isDefaultVersion() const { return getFeaturesStr() == "default"; } | |||
7702 | ||||
7703 | static ParsedTargetAttr parse(StringRef Features) { | |||
7704 | ParsedTargetAttr Ret; | |||
7705 | if (Features == "default") return Ret; | |||
7706 | SmallVector<StringRef, 1> AttrFeatures; | |||
7707 | Features.split(AttrFeatures, ","); | |||
7708 | ||||
7709 | // Grab the various features and prepend a "+" to turn on the feature to | |||
7710 | // the backend and add them to our existing set of features. | |||
7711 | for (auto &Feature : AttrFeatures) { | |||
7712 | // Go ahead and trim whitespace rather than either erroring or | |||
7713 | // accepting it weirdly. | |||
7714 | Feature = Feature.trim(); | |||
7715 | ||||
7716 | // We don't support cpu tuning this way currently. | |||
7717 | // TODO: Support the fpmath option. It will require checking | |||
7718 | // overall feature validity for the function with the rest of the | |||
7719 | // attributes on the function. | |||
7720 | if (Feature.startswith("fpmath=") || Feature.startswith("tune=")) | |||
7721 | continue; | |||
7722 | ||||
7723 | // While we're here iterating check for a different target cpu. | |||
7724 | if (Feature.startswith("arch=")) { | |||
7725 | if (!Ret.Architecture.empty()) | |||
7726 | Ret.DuplicateArchitecture = true; | |||
7727 | else | |||
7728 | Ret.Architecture = Feature.split("=").second.trim(); | |||
7729 | } else if (Feature.startswith("no-")) | |||
7730 | Ret.Features.push_back("-" + Feature.split("-").second.str()); | |||
7731 | else | |||
7732 | Ret.Features.push_back("+" + Feature.str()); | |||
7733 | } | |||
7734 | return Ret; | |||
7735 | } | |||
7736 | ||||
7737 | ||||
7738 | static bool classof(const Attr *A) { return A->getKind() == attr::Target; } | |||
7739 | }; | |||
7740 | ||||
7741 | class TestTypestateAttr : public InheritableAttr { | |||
7742 | public: | |||
7743 | enum ConsumedState { | |||
7744 | Consumed, | |||
7745 | Unconsumed | |||
7746 | }; | |||
7747 | private: | |||
7748 | ConsumedState testState; | |||
7749 | ||||
7750 | public: | |||
7751 | static TestTypestateAttr *CreateImplicit(ASTContext &Ctx, ConsumedState TestState, SourceRange Loc = SourceRange()) { | |||
7752 | auto *A = new (Ctx) TestTypestateAttr(Loc, Ctx, TestState, 0); | |||
7753 | A->setImplicit(true); | |||
7754 | return A; | |||
7755 | } | |||
7756 | ||||
7757 | TestTypestateAttr(SourceRange R, ASTContext &Ctx | |||
7758 | , ConsumedState TestState | |||
7759 | , unsigned SI | |||
7760 | ) | |||
7761 | : InheritableAttr(attr::TestTypestate, R, SI, false, false) | |||
7762 | , testState(TestState) | |||
7763 | { | |||
7764 | } | |||
7765 | ||||
7766 | TestTypestateAttr *clone(ASTContext &C) const; | |||
7767 | void printPretty(raw_ostream &OS, | |||
7768 | const PrintingPolicy &Policy) const; | |||
7769 | const char *getSpelling() const; | |||
7770 | ConsumedState getTestState() const { | |||
7771 | return testState; | |||
7772 | } | |||
7773 | ||||
7774 | static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) { | |||
7775 | Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val) | |||
7776 | .Case("consumed", TestTypestateAttr::Consumed) | |||
7777 | .Case("unconsumed", TestTypestateAttr::Unconsumed) | |||
7778 | .Default(Optional<ConsumedState>()); | |||
7779 | if (R) { | |||
7780 | Out = *R; | |||
7781 | return true; | |||
7782 | } | |||
7783 | return false; | |||
7784 | } | |||
7785 | ||||
7786 | static const char *ConvertConsumedStateToStr(ConsumedState Val) { | |||
7787 | switch(Val) { | |||
7788 | case TestTypestateAttr::Consumed: return "consumed"; | |||
7789 | case TestTypestateAttr::Unconsumed: return "unconsumed"; | |||
7790 | } | |||
7791 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 7791); | |||
7792 | } | |||
7793 | ||||
7794 | ||||
7795 | static bool classof(const Attr *A) { return A->getKind() == attr::TestTypestate; } | |||
7796 | }; | |||
7797 | ||||
7798 | class ThisCallAttr : public InheritableAttr { | |||
7799 | public: | |||
7800 | static ThisCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7801 | auto *A = new (Ctx) ThisCallAttr(Loc, Ctx, 0); | |||
7802 | A->setImplicit(true); | |||
7803 | return A; | |||
7804 | } | |||
7805 | ||||
7806 | ThisCallAttr(SourceRange R, ASTContext &Ctx | |||
7807 | , unsigned SI | |||
7808 | ) | |||
7809 | : InheritableAttr(attr::ThisCall, R, SI, false, false) | |||
7810 | { | |||
7811 | } | |||
7812 | ||||
7813 | ThisCallAttr *clone(ASTContext &C) const; | |||
7814 | void printPretty(raw_ostream &OS, | |||
7815 | const PrintingPolicy &Policy) const; | |||
7816 | const char *getSpelling() const; | |||
7817 | ||||
7818 | ||||
7819 | static bool classof(const Attr *A) { return A->getKind() == attr::ThisCall; } | |||
7820 | }; | |||
7821 | ||||
7822 | class ThreadAttr : public Attr { | |||
7823 | public: | |||
7824 | static ThreadAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7825 | auto *A = new (Ctx) ThreadAttr(Loc, Ctx, 0); | |||
7826 | A->setImplicit(true); | |||
7827 | return A; | |||
7828 | } | |||
7829 | ||||
7830 | ThreadAttr(SourceRange R, ASTContext &Ctx | |||
7831 | , unsigned SI | |||
7832 | ) | |||
7833 | : Attr(attr::Thread, R, SI, false) | |||
7834 | { | |||
7835 | } | |||
7836 | ||||
7837 | ThreadAttr *clone(ASTContext &C) const; | |||
7838 | void printPretty(raw_ostream &OS, | |||
7839 | const PrintingPolicy &Policy) const; | |||
7840 | const char *getSpelling() const; | |||
7841 | ||||
7842 | ||||
7843 | static bool classof(const Attr *A) { return A->getKind() == attr::Thread; } | |||
7844 | }; | |||
7845 | ||||
7846 | class TransparentUnionAttr : public InheritableAttr { | |||
7847 | public: | |||
7848 | static TransparentUnionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7849 | auto *A = new (Ctx) TransparentUnionAttr(Loc, Ctx, 0); | |||
7850 | A->setImplicit(true); | |||
7851 | return A; | |||
7852 | } | |||
7853 | ||||
7854 | TransparentUnionAttr(SourceRange R, ASTContext &Ctx | |||
7855 | , unsigned SI | |||
7856 | ) | |||
7857 | : InheritableAttr(attr::TransparentUnion, R, SI, false, false) | |||
7858 | { | |||
7859 | } | |||
7860 | ||||
7861 | TransparentUnionAttr *clone(ASTContext &C) const; | |||
7862 | void printPretty(raw_ostream &OS, | |||
7863 | const PrintingPolicy &Policy) const; | |||
7864 | const char *getSpelling() const; | |||
7865 | ||||
7866 | ||||
7867 | static bool classof(const Attr *A) { return A->getKind() == attr::TransparentUnion; } | |||
7868 | }; | |||
7869 | ||||
7870 | class TrivialABIAttr : public InheritableAttr { | |||
7871 | public: | |||
7872 | static TrivialABIAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7873 | auto *A = new (Ctx) TrivialABIAttr(Loc, Ctx, 0); | |||
7874 | A->setImplicit(true); | |||
7875 | return A; | |||
7876 | } | |||
7877 | ||||
7878 | TrivialABIAttr(SourceRange R, ASTContext &Ctx | |||
7879 | , unsigned SI | |||
7880 | ) | |||
7881 | : InheritableAttr(attr::TrivialABI, R, SI, false, false) | |||
7882 | { | |||
7883 | } | |||
7884 | ||||
7885 | TrivialABIAttr *clone(ASTContext &C) const; | |||
7886 | void printPretty(raw_ostream &OS, | |||
7887 | const PrintingPolicy &Policy) const; | |||
7888 | const char *getSpelling() const; | |||
7889 | ||||
7890 | ||||
7891 | static bool classof(const Attr *A) { return A->getKind() == attr::TrivialABI; } | |||
7892 | }; | |||
7893 | ||||
7894 | class TryAcquireCapabilityAttr : public InheritableAttr { | |||
7895 | Expr * successValue; | |||
7896 | ||||
7897 | unsigned args_Size; | |||
7898 | Expr * *args_; | |||
7899 | ||||
7900 | public: | |||
7901 | enum Spelling { | |||
7902 | GNU_try_acquire_capability = 0, | |||
7903 | CXX11_clang_try_acquire_capability = 1, | |||
7904 | GNU_try_acquire_shared_capability = 2, | |||
7905 | CXX11_clang_try_acquire_shared_capability = 3 | |||
7906 | }; | |||
7907 | ||||
7908 | static TryAcquireCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * SuccessValue, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
7909 | auto *A = new (Ctx) TryAcquireCapabilityAttr(Loc, Ctx, SuccessValue, Args, ArgsSize, S); | |||
7910 | A->setImplicit(true); | |||
7911 | return A; | |||
7912 | } | |||
7913 | ||||
7914 | TryAcquireCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
7915 | , Expr * SuccessValue | |||
7916 | , Expr * *Args, unsigned ArgsSize | |||
7917 | , unsigned SI | |||
7918 | ) | |||
7919 | : InheritableAttr(attr::TryAcquireCapability, R, SI, true, true) | |||
7920 | , successValue(SuccessValue) | |||
7921 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
7922 | { | |||
7923 | std::copy(Args, Args + args_Size, args_); | |||
7924 | } | |||
7925 | ||||
7926 | TryAcquireCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
7927 | , Expr * SuccessValue | |||
7928 | , unsigned SI | |||
7929 | ) | |||
7930 | : InheritableAttr(attr::TryAcquireCapability, R, SI, true, true) | |||
7931 | , successValue(SuccessValue) | |||
7932 | , args_Size(0), args_(nullptr) | |||
7933 | { | |||
7934 | } | |||
7935 | ||||
7936 | TryAcquireCapabilityAttr *clone(ASTContext &C) const; | |||
7937 | void printPretty(raw_ostream &OS, | |||
7938 | const PrintingPolicy &Policy) const; | |||
7939 | const char *getSpelling() const; | |||
7940 | Spelling getSemanticSpelling() const { | |||
7941 | switch (SpellingListIndex) { | |||
7942 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 7942); | |||
7943 | case 0: return GNU_try_acquire_capability; | |||
7944 | case 1: return CXX11_clang_try_acquire_capability; | |||
7945 | case 2: return GNU_try_acquire_shared_capability; | |||
7946 | case 3: return CXX11_clang_try_acquire_shared_capability; | |||
7947 | } | |||
7948 | } | |||
7949 | bool isShared() const { return SpellingListIndex == 2 || | |||
7950 | SpellingListIndex == 3; } | |||
7951 | Expr * getSuccessValue() const { | |||
7952 | return successValue; | |||
7953 | } | |||
7954 | ||||
7955 | typedef Expr ** args_iterator; | |||
7956 | args_iterator args_begin() const { return args_; } | |||
7957 | args_iterator args_end() const { return args_ + args_Size; } | |||
7958 | unsigned args_size() const { return args_Size; } | |||
7959 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
7960 | ||||
7961 | ||||
7962 | ||||
7963 | ||||
7964 | static bool classof(const Attr *A) { return A->getKind() == attr::TryAcquireCapability; } | |||
7965 | }; | |||
7966 | ||||
7967 | class TypeTagForDatatypeAttr : public InheritableAttr { | |||
7968 | IdentifierInfo * argumentKind; | |||
7969 | ||||
7970 | TypeSourceInfo * matchingCType; | |||
7971 | ||||
7972 | bool layoutCompatible; | |||
7973 | ||||
7974 | bool mustBeNull; | |||
7975 | ||||
7976 | public: | |||
7977 | static TypeTagForDatatypeAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * ArgumentKind, TypeSourceInfo * MatchingCType, bool LayoutCompatible, bool MustBeNull, SourceRange Loc = SourceRange()) { | |||
7978 | auto *A = new (Ctx) TypeTagForDatatypeAttr(Loc, Ctx, ArgumentKind, MatchingCType, LayoutCompatible, MustBeNull, 0); | |||
7979 | A->setImplicit(true); | |||
7980 | return A; | |||
7981 | } | |||
7982 | ||||
7983 | TypeTagForDatatypeAttr(SourceRange R, ASTContext &Ctx | |||
7984 | , IdentifierInfo * ArgumentKind | |||
7985 | , TypeSourceInfo * MatchingCType | |||
7986 | , bool LayoutCompatible | |||
7987 | , bool MustBeNull | |||
7988 | , unsigned SI | |||
7989 | ) | |||
7990 | : InheritableAttr(attr::TypeTagForDatatype, R, SI, false, false) | |||
7991 | , argumentKind(ArgumentKind) | |||
7992 | , matchingCType(MatchingCType) | |||
7993 | , layoutCompatible(LayoutCompatible) | |||
7994 | , mustBeNull(MustBeNull) | |||
7995 | { | |||
7996 | } | |||
7997 | ||||
7998 | TypeTagForDatatypeAttr *clone(ASTContext &C) const; | |||
7999 | void printPretty(raw_ostream &OS, | |||
8000 | const PrintingPolicy &Policy) const; | |||
8001 | const char *getSpelling() const; | |||
8002 | IdentifierInfo * getArgumentKind() const { | |||
8003 | return argumentKind; | |||
8004 | } | |||
8005 | ||||
8006 | QualType getMatchingCType() const { | |||
8007 | return matchingCType->getType(); | |||
8008 | } TypeSourceInfo * getMatchingCTypeLoc() const { | |||
8009 | return matchingCType; | |||
8010 | } | |||
8011 | ||||
8012 | bool getLayoutCompatible() const { | |||
8013 | return layoutCompatible; | |||
8014 | } | |||
8015 | ||||
8016 | bool getMustBeNull() const { | |||
8017 | return mustBeNull; | |||
8018 | } | |||
8019 | ||||
8020 | ||||
8021 | ||||
8022 | static bool classof(const Attr *A) { return A->getKind() == attr::TypeTagForDatatype; } | |||
8023 | }; | |||
8024 | ||||
8025 | class TypeVisibilityAttr : public InheritableAttr { | |||
8026 | public: | |||
8027 | enum VisibilityType { | |||
8028 | Default, | |||
8029 | Hidden, | |||
8030 | Protected | |||
8031 | }; | |||
8032 | private: | |||
8033 | VisibilityType visibility; | |||
8034 | ||||
8035 | public: | |||
8036 | static TypeVisibilityAttr *CreateImplicit(ASTContext &Ctx, VisibilityType Visibility, SourceRange Loc = SourceRange()) { | |||
8037 | auto *A = new (Ctx) TypeVisibilityAttr(Loc, Ctx, Visibility, 0); | |||
8038 | A->setImplicit(true); | |||
8039 | return A; | |||
8040 | } | |||
8041 | ||||
8042 | TypeVisibilityAttr(SourceRange R, ASTContext &Ctx | |||
8043 | , VisibilityType Visibility | |||
8044 | , unsigned SI | |||
8045 | ) | |||
8046 | : InheritableAttr(attr::TypeVisibility, R, SI, false, false) | |||
8047 | , visibility(Visibility) | |||
8048 | { | |||
8049 | } | |||
8050 | ||||
8051 | TypeVisibilityAttr *clone(ASTContext &C) const; | |||
8052 | void printPretty(raw_ostream &OS, | |||
8053 | const PrintingPolicy &Policy) const; | |||
8054 | const char *getSpelling() const; | |||
8055 | VisibilityType getVisibility() const { | |||
8056 | return visibility; | |||
8057 | } | |||
8058 | ||||
8059 | static bool ConvertStrToVisibilityType(StringRef Val, VisibilityType &Out) { | |||
8060 | Optional<VisibilityType> R = llvm::StringSwitch<Optional<VisibilityType>>(Val) | |||
8061 | .Case("default", TypeVisibilityAttr::Default) | |||
8062 | .Case("hidden", TypeVisibilityAttr::Hidden) | |||
8063 | .Case("internal", TypeVisibilityAttr::Hidden) | |||
8064 | .Case("protected", TypeVisibilityAttr::Protected) | |||
8065 | .Default(Optional<VisibilityType>()); | |||
8066 | if (R) { | |||
8067 | Out = *R; | |||
8068 | return true; | |||
8069 | } | |||
8070 | return false; | |||
8071 | } | |||
8072 | ||||
8073 | static const char *ConvertVisibilityTypeToStr(VisibilityType Val) { | |||
8074 | switch(Val) { | |||
8075 | case TypeVisibilityAttr::Default: return "default"; | |||
8076 | case TypeVisibilityAttr::Hidden: return "hidden"; | |||
8077 | case TypeVisibilityAttr::Protected: return "protected"; | |||
8078 | } | |||
8079 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 8079); | |||
8080 | } | |||
8081 | ||||
8082 | ||||
8083 | static bool classof(const Attr *A) { return A->getKind() == attr::TypeVisibility; } | |||
8084 | }; | |||
8085 | ||||
8086 | class UnavailableAttr : public InheritableAttr { | |||
8087 | unsigned messageLength; | |||
8088 | char *message; | |||
8089 | ||||
8090 | public: | |||
8091 | enum ImplicitReason { | |||
8092 | IR_None, | |||
8093 | IR_ARCForbiddenType, | |||
8094 | IR_ForbiddenWeak, | |||
8095 | IR_ARCForbiddenConversion, | |||
8096 | IR_ARCInitReturnsUnrelated, | |||
8097 | IR_ARCFieldWithOwnership | |||
8098 | }; | |||
8099 | private: | |||
8100 | ImplicitReason implicitReason; | |||
8101 | ||||
8102 | public: | |||
8103 | static UnavailableAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Message, ImplicitReason ImplicitReason, SourceRange Loc = SourceRange()) { | |||
8104 | auto *A = new (Ctx) UnavailableAttr(Loc, Ctx, Message, ImplicitReason, 0); | |||
8105 | A->setImplicit(true); | |||
8106 | return A; | |||
8107 | } | |||
8108 | ||||
8109 | static UnavailableAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Message, SourceRange Loc = SourceRange()) { | |||
8110 | auto *A = new (Ctx) UnavailableAttr(Loc, Ctx, Message, 0); | |||
8111 | A->setImplicit(true); | |||
8112 | return A; | |||
8113 | } | |||
8114 | ||||
8115 | UnavailableAttr(SourceRange R, ASTContext &Ctx | |||
8116 | , llvm::StringRef Message | |||
8117 | , ImplicitReason ImplicitReason | |||
8118 | , unsigned SI | |||
8119 | ) | |||
8120 | : InheritableAttr(attr::Unavailable, R, SI, false, false) | |||
8121 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
8122 | , implicitReason(ImplicitReason) | |||
8123 | { | |||
8124 | if (!Message.empty()) | |||
8125 | std::memcpy(message, Message.data(), messageLength); | |||
8126 | } | |||
8127 | ||||
8128 | UnavailableAttr(SourceRange R, ASTContext &Ctx | |||
8129 | , llvm::StringRef Message | |||
8130 | , unsigned SI | |||
8131 | ) | |||
8132 | : InheritableAttr(attr::Unavailable, R, SI, false, false) | |||
8133 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
8134 | , implicitReason(ImplicitReason(0)) | |||
8135 | { | |||
8136 | if (!Message.empty()) | |||
8137 | std::memcpy(message, Message.data(), messageLength); | |||
8138 | } | |||
8139 | ||||
8140 | UnavailableAttr(SourceRange R, ASTContext &Ctx | |||
8141 | , unsigned SI | |||
8142 | ) | |||
8143 | : InheritableAttr(attr::Unavailable, R, SI, false, false) | |||
8144 | , messageLength(0),message(nullptr) | |||
8145 | , implicitReason(ImplicitReason(0)) | |||
8146 | { | |||
8147 | } | |||
8148 | ||||
8149 | UnavailableAttr *clone(ASTContext &C) const; | |||
8150 | void printPretty(raw_ostream &OS, | |||
8151 | const PrintingPolicy &Policy) const; | |||
8152 | const char *getSpelling() const; | |||
8153 | llvm::StringRef getMessage() const { | |||
8154 | return llvm::StringRef(message, messageLength); | |||
8155 | } | |||
8156 | unsigned getMessageLength() const { | |||
8157 | return messageLength; | |||
8158 | } | |||
8159 | void setMessage(ASTContext &C, llvm::StringRef S) { | |||
8160 | messageLength = S.size(); | |||
8161 | this->message = new (C, 1) char [messageLength]; | |||
8162 | if (!S.empty()) | |||
8163 | std::memcpy(this->message, S.data(), messageLength); | |||
8164 | } | |||
8165 | ||||
8166 | ImplicitReason getImplicitReason() const { | |||
8167 | return implicitReason; | |||
8168 | } | |||
8169 | ||||
8170 | ||||
8171 | ||||
8172 | static bool classof(const Attr *A) { return A->getKind() == attr::Unavailable; } | |||
8173 | }; | |||
8174 | ||||
8175 | class UnusedAttr : public InheritableAttr { | |||
8176 | public: | |||
8177 | enum Spelling { | |||
8178 | CXX11_maybe_unused = 0, | |||
8179 | GNU_unused = 1, | |||
8180 | CXX11_gnu_unused = 2, | |||
8181 | C2x_maybe_unused = 3 | |||
8182 | }; | |||
8183 | ||||
8184 | static UnusedAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
8185 | auto *A = new (Ctx) UnusedAttr(Loc, Ctx, S); | |||
8186 | A->setImplicit(true); | |||
8187 | return A; | |||
8188 | } | |||
8189 | ||||
8190 | UnusedAttr(SourceRange R, ASTContext &Ctx | |||
8191 | , unsigned SI | |||
8192 | ) | |||
8193 | : InheritableAttr(attr::Unused, R, SI, false, false) | |||
8194 | { | |||
8195 | } | |||
8196 | ||||
8197 | UnusedAttr *clone(ASTContext &C) const; | |||
8198 | void printPretty(raw_ostream &OS, | |||
8199 | const PrintingPolicy &Policy) const; | |||
8200 | const char *getSpelling() const; | |||
8201 | Spelling getSemanticSpelling() const { | |||
8202 | switch (SpellingListIndex) { | |||
8203 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 8203); | |||
8204 | case 0: return CXX11_maybe_unused; | |||
8205 | case 1: return GNU_unused; | |||
8206 | case 2: return CXX11_gnu_unused; | |||
8207 | case 3: return C2x_maybe_unused; | |||
8208 | } | |||
8209 | } | |||
8210 | ||||
8211 | ||||
8212 | static bool classof(const Attr *A) { return A->getKind() == attr::Unused; } | |||
8213 | }; | |||
8214 | ||||
8215 | class UsedAttr : public InheritableAttr { | |||
8216 | public: | |||
8217 | static UsedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8218 | auto *A = new (Ctx) UsedAttr(Loc, Ctx, 0); | |||
8219 | A->setImplicit(true); | |||
8220 | return A; | |||
8221 | } | |||
8222 | ||||
8223 | UsedAttr(SourceRange R, ASTContext &Ctx | |||
8224 | , unsigned SI | |||
8225 | ) | |||
8226 | : InheritableAttr(attr::Used, R, SI, false, false) | |||
8227 | { | |||
8228 | } | |||
8229 | ||||
8230 | UsedAttr *clone(ASTContext &C) const; | |||
8231 | void printPretty(raw_ostream &OS, | |||
8232 | const PrintingPolicy &Policy) const; | |||
8233 | const char *getSpelling() const; | |||
8234 | ||||
8235 | ||||
8236 | static bool classof(const Attr *A) { return A->getKind() == attr::Used; } | |||
8237 | }; | |||
8238 | ||||
8239 | class UuidAttr : public InheritableAttr { | |||
8240 | unsigned guidLength; | |||
8241 | char *guid; | |||
8242 | ||||
8243 | public: | |||
8244 | static UuidAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Guid, SourceRange Loc = SourceRange()) { | |||
8245 | auto *A = new (Ctx) UuidAttr(Loc, Ctx, Guid, 0); | |||
8246 | A->setImplicit(true); | |||
8247 | return A; | |||
8248 | } | |||
8249 | ||||
8250 | UuidAttr(SourceRange R, ASTContext &Ctx | |||
8251 | , llvm::StringRef Guid | |||
8252 | , unsigned SI | |||
8253 | ) | |||
8254 | : InheritableAttr(attr::Uuid, R, SI, false, false) | |||
8255 | , guidLength(Guid.size()),guid(new (Ctx, 1) char[guidLength]) | |||
8256 | { | |||
8257 | if (!Guid.empty()) | |||
8258 | std::memcpy(guid, Guid.data(), guidLength); | |||
8259 | } | |||
8260 | ||||
8261 | UuidAttr *clone(ASTContext &C) const; | |||
8262 | void printPretty(raw_ostream &OS, | |||
8263 | const PrintingPolicy &Policy) const; | |||
8264 | const char *getSpelling() const; | |||
8265 | llvm::StringRef getGuid() const { | |||
8266 | return llvm::StringRef(guid, guidLength); | |||
8267 | } | |||
8268 | unsigned getGuidLength() const { | |||
8269 | return guidLength; | |||
8270 | } | |||
8271 | void setGuid(ASTContext &C, llvm::StringRef S) { | |||
8272 | guidLength = S.size(); | |||
8273 | this->guid = new (C, 1) char [guidLength]; | |||
8274 | if (!S.empty()) | |||
8275 | std::memcpy(this->guid, S.data(), guidLength); | |||
8276 | } | |||
8277 | ||||
8278 | ||||
8279 | ||||
8280 | static bool classof(const Attr *A) { return A->getKind() == attr::Uuid; } | |||
8281 | }; | |||
8282 | ||||
8283 | class VecReturnAttr : public InheritableAttr { | |||
8284 | public: | |||
8285 | static VecReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8286 | auto *A = new (Ctx) VecReturnAttr(Loc, Ctx, 0); | |||
8287 | A->setImplicit(true); | |||
8288 | return A; | |||
8289 | } | |||
8290 | ||||
8291 | VecReturnAttr(SourceRange R, ASTContext &Ctx | |||
8292 | , unsigned SI | |||
8293 | ) | |||
8294 | : InheritableAttr(attr::VecReturn, R, SI, false, false) | |||
8295 | { | |||
8296 | } | |||
8297 | ||||
8298 | VecReturnAttr *clone(ASTContext &C) const; | |||
8299 | void printPretty(raw_ostream &OS, | |||
8300 | const PrintingPolicy &Policy) const; | |||
8301 | const char *getSpelling() const; | |||
8302 | ||||
8303 | ||||
8304 | static bool classof(const Attr *A) { return A->getKind() == attr::VecReturn; } | |||
8305 | }; | |||
8306 | ||||
8307 | class VecTypeHintAttr : public InheritableAttr { | |||
8308 | TypeSourceInfo * typeHint; | |||
8309 | ||||
8310 | public: | |||
8311 | static VecTypeHintAttr *CreateImplicit(ASTContext &Ctx, TypeSourceInfo * TypeHint, SourceRange Loc = SourceRange()) { | |||
8312 | auto *A = new (Ctx) VecTypeHintAttr(Loc, Ctx, TypeHint, 0); | |||
8313 | A->setImplicit(true); | |||
8314 | return A; | |||
8315 | } | |||
8316 | ||||
8317 | VecTypeHintAttr(SourceRange R, ASTContext &Ctx | |||
8318 | , TypeSourceInfo * TypeHint | |||
8319 | , unsigned SI | |||
8320 | ) | |||
8321 | : InheritableAttr(attr::VecTypeHint, R, SI, false, false) | |||
8322 | , typeHint(TypeHint) | |||
8323 | { | |||
8324 | } | |||
8325 | ||||
8326 | VecTypeHintAttr *clone(ASTContext &C) const; | |||
8327 | void printPretty(raw_ostream &OS, | |||
8328 | const PrintingPolicy &Policy) const; | |||
8329 | const char *getSpelling() const; | |||
8330 | QualType getTypeHint() const { | |||
8331 | return typeHint->getType(); | |||
8332 | } TypeSourceInfo * getTypeHintLoc() const { | |||
8333 | return typeHint; | |||
8334 | } | |||
8335 | ||||
8336 | ||||
8337 | ||||
8338 | static bool classof(const Attr *A) { return A->getKind() == attr::VecTypeHint; } | |||
8339 | }; | |||
8340 | ||||
8341 | class VectorCallAttr : public InheritableAttr { | |||
8342 | public: | |||
8343 | static VectorCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8344 | auto *A = new (Ctx) VectorCallAttr(Loc, Ctx, 0); | |||
8345 | A->setImplicit(true); | |||
8346 | return A; | |||
8347 | } | |||
8348 | ||||
8349 | VectorCallAttr(SourceRange R, ASTContext &Ctx | |||
8350 | , unsigned SI | |||
8351 | ) | |||
8352 | : InheritableAttr(attr::VectorCall, R, SI, false, false) | |||
8353 | { | |||
8354 | } | |||
8355 | ||||
8356 | VectorCallAttr *clone(ASTContext &C) const; | |||
8357 | void printPretty(raw_ostream &OS, | |||
8358 | const PrintingPolicy &Policy) const; | |||
8359 | const char *getSpelling() const; | |||
8360 | ||||
8361 | ||||
8362 | static bool classof(const Attr *A) { return A->getKind() == attr::VectorCall; } | |||
8363 | }; | |||
8364 | ||||
8365 | class VisibilityAttr : public InheritableAttr { | |||
8366 | public: | |||
8367 | enum VisibilityType { | |||
8368 | Default, | |||
8369 | Hidden, | |||
8370 | Protected | |||
8371 | }; | |||
8372 | private: | |||
8373 | VisibilityType visibility; | |||
8374 | ||||
8375 | public: | |||
8376 | static VisibilityAttr *CreateImplicit(ASTContext &Ctx, VisibilityType Visibility, SourceRange Loc = SourceRange()) { | |||
8377 | auto *A = new (Ctx) VisibilityAttr(Loc, Ctx, Visibility, 0); | |||
8378 | A->setImplicit(true); | |||
8379 | return A; | |||
8380 | } | |||
8381 | ||||
8382 | VisibilityAttr(SourceRange R, ASTContext &Ctx | |||
8383 | , VisibilityType Visibility | |||
8384 | , unsigned SI | |||
8385 | ) | |||
8386 | : InheritableAttr(attr::Visibility, R, SI, false, false) | |||
8387 | , visibility(Visibility) | |||
8388 | { | |||
8389 | } | |||
8390 | ||||
8391 | VisibilityAttr *clone(ASTContext &C) const; | |||
8392 | void printPretty(raw_ostream &OS, | |||
8393 | const PrintingPolicy &Policy) const; | |||
8394 | const char *getSpelling() const; | |||
8395 | VisibilityType getVisibility() const { | |||
8396 | return visibility; | |||
8397 | } | |||
8398 | ||||
8399 | static bool ConvertStrToVisibilityType(StringRef Val, VisibilityType &Out) { | |||
8400 | Optional<VisibilityType> R = llvm::StringSwitch<Optional<VisibilityType>>(Val) | |||
8401 | .Case("default", VisibilityAttr::Default) | |||
8402 | .Case("hidden", VisibilityAttr::Hidden) | |||
8403 | .Case("internal", VisibilityAttr::Hidden) | |||
8404 | .Case("protected", VisibilityAttr::Protected) | |||
8405 | .Default(Optional<VisibilityType>()); | |||
8406 | if (R) { | |||
8407 | Out = *R; | |||
8408 | return true; | |||
8409 | } | |||
8410 | return false; | |||
8411 | } | |||
8412 | ||||
8413 | static const char *ConvertVisibilityTypeToStr(VisibilityType Val) { | |||
8414 | switch(Val) { | |||
8415 | case VisibilityAttr::Default: return "default"; | |||
8416 | case VisibilityAttr::Hidden: return "hidden"; | |||
8417 | case VisibilityAttr::Protected: return "protected"; | |||
8418 | } | |||
8419 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 8419); | |||
8420 | } | |||
8421 | ||||
8422 | ||||
8423 | static bool classof(const Attr *A) { return A->getKind() == attr::Visibility; } | |||
8424 | }; | |||
8425 | ||||
8426 | class WarnUnusedAttr : public InheritableAttr { | |||
8427 | public: | |||
8428 | static WarnUnusedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8429 | auto *A = new (Ctx) WarnUnusedAttr(Loc, Ctx, 0); | |||
8430 | A->setImplicit(true); | |||
8431 | return A; | |||
8432 | } | |||
8433 | ||||
8434 | WarnUnusedAttr(SourceRange R, ASTContext &Ctx | |||
8435 | , unsigned SI | |||
8436 | ) | |||
8437 | : InheritableAttr(attr::WarnUnused, R, SI, false, false) | |||
8438 | { | |||
8439 | } | |||
8440 | ||||
8441 | WarnUnusedAttr *clone(ASTContext &C) const; | |||
8442 | void printPretty(raw_ostream &OS, | |||
8443 | const PrintingPolicy &Policy) const; | |||
8444 | const char *getSpelling() const; | |||
8445 | ||||
8446 | ||||
8447 | static bool classof(const Attr *A) { return A->getKind() == attr::WarnUnused; } | |||
8448 | }; | |||
8449 | ||||
8450 | class WarnUnusedResultAttr : public InheritableAttr { | |||
8451 | public: | |||
8452 | enum Spelling { | |||
8453 | CXX11_nodiscard = 0, | |||
8454 | C2x_nodiscard = 1, | |||
8455 | CXX11_clang_warn_unused_result = 2, | |||
8456 | GNU_warn_unused_result = 3, | |||
8457 | CXX11_gnu_warn_unused_result = 4 | |||
8458 | }; | |||
8459 | ||||
8460 | static WarnUnusedResultAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
8461 | auto *A = new (Ctx) WarnUnusedResultAttr(Loc, Ctx, S); | |||
8462 | A->setImplicit(true); | |||
8463 | return A; | |||
8464 | } | |||
8465 | ||||
8466 | WarnUnusedResultAttr(SourceRange R, ASTContext &Ctx | |||
8467 | , unsigned SI | |||
8468 | ) | |||
8469 | : InheritableAttr(attr::WarnUnusedResult, R, SI, false, false) | |||
8470 | { | |||
8471 | } | |||
8472 | ||||
8473 | WarnUnusedResultAttr *clone(ASTContext &C) const; | |||
8474 | void printPretty(raw_ostream &OS, | |||
8475 | const PrintingPolicy &Policy) const; | |||
8476 | const char *getSpelling() const; | |||
8477 | Spelling getSemanticSpelling() const { | |||
8478 | switch (SpellingListIndex) { | |||
8479 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 8479); | |||
8480 | case 0: return CXX11_nodiscard; | |||
8481 | case 1: return C2x_nodiscard; | |||
8482 | case 2: return CXX11_clang_warn_unused_result; | |||
8483 | case 3: return GNU_warn_unused_result; | |||
8484 | case 4: return CXX11_gnu_warn_unused_result; | |||
8485 | } | |||
8486 | } | |||
8487 | ||||
8488 | ||||
8489 | static bool classof(const Attr *A) { return A->getKind() == attr::WarnUnusedResult; } | |||
8490 | }; | |||
8491 | ||||
8492 | class WeakAttr : public InheritableAttr { | |||
8493 | public: | |||
8494 | static WeakAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8495 | auto *A = new (Ctx) WeakAttr(Loc, Ctx, 0); | |||
8496 | A->setImplicit(true); | |||
8497 | return A; | |||
8498 | } | |||
8499 | ||||
8500 | WeakAttr(SourceRange R, ASTContext &Ctx | |||
8501 | , unsigned SI | |||
8502 | ) | |||
8503 | : InheritableAttr(attr::Weak, R, SI, false, false) | |||
8504 | { | |||
8505 | } | |||
8506 | ||||
8507 | WeakAttr *clone(ASTContext &C) const; | |||
8508 | void printPretty(raw_ostream &OS, | |||
8509 | const PrintingPolicy &Policy) const; | |||
8510 | const char *getSpelling() const; | |||
8511 | ||||
8512 | ||||
8513 | static bool classof(const Attr *A) { return A->getKind() == attr::Weak; } | |||
8514 | }; | |||
8515 | ||||
8516 | class WeakImportAttr : public InheritableAttr { | |||
8517 | public: | |||
8518 | static WeakImportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8519 | auto *A = new (Ctx) WeakImportAttr(Loc, Ctx, 0); | |||
8520 | A->setImplicit(true); | |||
8521 | return A; | |||
8522 | } | |||
8523 | ||||
8524 | WeakImportAttr(SourceRange R, ASTContext &Ctx | |||
8525 | , unsigned SI | |||
8526 | ) | |||
8527 | : InheritableAttr(attr::WeakImport, R, SI, false, false) | |||
8528 | { | |||
8529 | } | |||
8530 | ||||
8531 | WeakImportAttr *clone(ASTContext &C) const; | |||
8532 | void printPretty(raw_ostream &OS, | |||
8533 | const PrintingPolicy &Policy) const; | |||
8534 | const char *getSpelling() const; | |||
8535 | ||||
8536 | ||||
8537 | static bool classof(const Attr *A) { return A->getKind() == attr::WeakImport; } | |||
8538 | }; | |||
8539 | ||||
8540 | class WeakRefAttr : public InheritableAttr { | |||
8541 | unsigned aliaseeLength; | |||
8542 | char *aliasee; | |||
8543 | ||||
8544 | public: | |||
8545 | static WeakRefAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Aliasee, SourceRange Loc = SourceRange()) { | |||
8546 | auto *A = new (Ctx) WeakRefAttr(Loc, Ctx, Aliasee, 0); | |||
8547 | A->setImplicit(true); | |||
8548 | return A; | |||
8549 | } | |||
8550 | ||||
8551 | WeakRefAttr(SourceRange R, ASTContext &Ctx | |||
8552 | , llvm::StringRef Aliasee | |||
8553 | , unsigned SI | |||
8554 | ) | |||
8555 | : InheritableAttr(attr::WeakRef, R, SI, false, false) | |||
8556 | , aliaseeLength(Aliasee.size()),aliasee(new (Ctx, 1) char[aliaseeLength]) | |||
8557 | { | |||
8558 | if (!Aliasee.empty()) | |||
8559 | std::memcpy(aliasee, Aliasee.data(), aliaseeLength); | |||
8560 | } | |||
8561 | ||||
8562 | WeakRefAttr(SourceRange R, ASTContext &Ctx | |||
8563 | , unsigned SI | |||
8564 | ) | |||
8565 | : InheritableAttr(attr::WeakRef, R, SI, false, false) | |||
8566 | , aliaseeLength(0),aliasee(nullptr) | |||
8567 | { | |||
8568 | } | |||
8569 | ||||
8570 | WeakRefAttr *clone(ASTContext &C) const; | |||
8571 | void printPretty(raw_ostream &OS, | |||
8572 | const PrintingPolicy &Policy) const; | |||
8573 | const char *getSpelling() const; | |||
8574 | llvm::StringRef getAliasee() const { | |||
8575 | return llvm::StringRef(aliasee, aliaseeLength); | |||
8576 | } | |||
8577 | unsigned getAliaseeLength() const { | |||
8578 | return aliaseeLength; | |||
8579 | } | |||
8580 | void setAliasee(ASTContext &C, llvm::StringRef S) { | |||
8581 | aliaseeLength = S.size(); | |||
8582 | this->aliasee = new (C, 1) char [aliaseeLength]; | |||
8583 | if (!S.empty()) | |||
8584 | std::memcpy(this->aliasee, S.data(), aliaseeLength); | |||
8585 | } | |||
8586 | ||||
8587 | ||||
8588 | ||||
8589 | static bool classof(const Attr *A) { return A->getKind() == attr::WeakRef; } | |||
8590 | }; | |||
8591 | ||||
8592 | class WorkGroupSizeHintAttr : public InheritableAttr { | |||
8593 | unsigned xDim; | |||
8594 | ||||
8595 | unsigned yDim; | |||
8596 | ||||
8597 | unsigned zDim; | |||
8598 | ||||
8599 | public: | |||
8600 | static WorkGroupSizeHintAttr *CreateImplicit(ASTContext &Ctx, unsigned XDim, unsigned YDim, unsigned ZDim, SourceRange Loc = SourceRange()) { | |||
8601 | auto *A = new (Ctx) WorkGroupSizeHintAttr(Loc, Ctx, XDim, YDim, ZDim, 0); | |||
8602 | A->setImplicit(true); | |||
8603 | return A; | |||
8604 | } | |||
8605 | ||||
8606 | WorkGroupSizeHintAttr(SourceRange R, ASTContext &Ctx | |||
8607 | , unsigned XDim | |||
8608 | , unsigned YDim | |||
8609 | , unsigned ZDim | |||
8610 | , unsigned SI | |||
8611 | ) | |||
8612 | : InheritableAttr(attr::WorkGroupSizeHint, R, SI, false, false) | |||
8613 | , xDim(XDim) | |||
8614 | , yDim(YDim) | |||
8615 | , zDim(ZDim) | |||
8616 | { | |||
8617 | } | |||
8618 | ||||
8619 | WorkGroupSizeHintAttr *clone(ASTContext &C) const; | |||
8620 | void printPretty(raw_ostream &OS, | |||
8621 | const PrintingPolicy &Policy) const; | |||
8622 | const char *getSpelling() const; | |||
8623 | unsigned getXDim() const { | |||
8624 | return xDim; | |||
8625 | } | |||
8626 | ||||
8627 | unsigned getYDim() const { | |||
8628 | return yDim; | |||
8629 | } | |||
8630 | ||||
8631 | unsigned getZDim() const { | |||
8632 | return zDim; | |||
8633 | } | |||
8634 | ||||
8635 | ||||
8636 | ||||
8637 | static bool classof(const Attr *A) { return A->getKind() == attr::WorkGroupSizeHint; } | |||
8638 | }; | |||
8639 | ||||
8640 | class X86ForceAlignArgPointerAttr : public InheritableAttr { | |||
8641 | public: | |||
8642 | static X86ForceAlignArgPointerAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8643 | auto *A = new (Ctx) X86ForceAlignArgPointerAttr(Loc, Ctx, 0); | |||
8644 | A->setImplicit(true); | |||
8645 | return A; | |||
8646 | } | |||
8647 | ||||
8648 | X86ForceAlignArgPointerAttr(SourceRange R, ASTContext &Ctx | |||
8649 | , unsigned SI | |||
8650 | ) | |||
8651 | : InheritableAttr(attr::X86ForceAlignArgPointer, R, SI, false, false) | |||
8652 | { | |||
8653 | } | |||
8654 | ||||
8655 | X86ForceAlignArgPointerAttr *clone(ASTContext &C) const; | |||
8656 | void printPretty(raw_ostream &OS, | |||
8657 | const PrintingPolicy &Policy) const; | |||
8658 | const char *getSpelling() const; | |||
8659 | ||||
8660 | ||||
8661 | static bool classof(const Attr *A) { return A->getKind() == attr::X86ForceAlignArgPointer; } | |||
8662 | }; | |||
8663 | ||||
8664 | class XRayInstrumentAttr : public InheritableAttr { | |||
8665 | public: | |||
8666 | enum Spelling { | |||
8667 | GNU_xray_always_instrument = 0, | |||
8668 | CXX11_clang_xray_always_instrument = 1, | |||
8669 | C2x_clang_xray_always_instrument = 2, | |||
8670 | GNU_xray_never_instrument = 3, | |||
8671 | CXX11_clang_xray_never_instrument = 4, | |||
8672 | C2x_clang_xray_never_instrument = 5 | |||
8673 | }; | |||
8674 | ||||
8675 | static XRayInstrumentAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
8676 | auto *A = new (Ctx) XRayInstrumentAttr(Loc, Ctx, S); | |||
8677 | A->setImplicit(true); | |||
8678 | return A; | |||
8679 | } | |||
8680 | ||||
8681 | XRayInstrumentAttr(SourceRange R, ASTContext &Ctx | |||
8682 | , unsigned SI | |||
8683 | ) | |||
8684 | : InheritableAttr(attr::XRayInstrument, R, SI, false, false) | |||
8685 | { | |||
8686 | } | |||
8687 | ||||
8688 | XRayInstrumentAttr *clone(ASTContext &C) const; | |||
8689 | void printPretty(raw_ostream &OS, | |||
8690 | const PrintingPolicy &Policy) const; | |||
8691 | const char *getSpelling() const; | |||
8692 | Spelling getSemanticSpelling() const { | |||
8693 | switch (SpellingListIndex) { | |||
8694 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 8694); | |||
8695 | case 0: return GNU_xray_always_instrument; | |||
8696 | case 1: return CXX11_clang_xray_always_instrument; | |||
8697 | case 2: return C2x_clang_xray_always_instrument; | |||
8698 | case 3: return GNU_xray_never_instrument; | |||
8699 | case 4: return CXX11_clang_xray_never_instrument; | |||
8700 | case 5: return C2x_clang_xray_never_instrument; | |||
8701 | } | |||
8702 | } | |||
8703 | bool alwaysXRayInstrument() const { return SpellingListIndex == 0 || | |||
8704 | SpellingListIndex == 1 || | |||
8705 | SpellingListIndex == 2; } | |||
8706 | bool neverXRayInstrument() const { return SpellingListIndex == 3 || | |||
8707 | SpellingListIndex == 4 || | |||
8708 | SpellingListIndex == 5; } | |||
8709 | ||||
8710 | ||||
8711 | static bool classof(const Attr *A) { return A->getKind() == attr::XRayInstrument; } | |||
8712 | }; | |||
8713 | ||||
8714 | class XRayLogArgsAttr : public InheritableAttr { | |||
8715 | unsigned argumentCount; | |||
8716 | ||||
8717 | public: | |||
8718 | static XRayLogArgsAttr *CreateImplicit(ASTContext &Ctx, unsigned ArgumentCount, SourceRange Loc = SourceRange()) { | |||
8719 | auto *A = new (Ctx) XRayLogArgsAttr(Loc, Ctx, ArgumentCount, 0); | |||
8720 | A->setImplicit(true); | |||
8721 | return A; | |||
8722 | } | |||
8723 | ||||
8724 | XRayLogArgsAttr(SourceRange R, ASTContext &Ctx | |||
8725 | , unsigned ArgumentCount | |||
8726 | , unsigned SI | |||
8727 | ) | |||
8728 | : InheritableAttr(attr::XRayLogArgs, R, SI, false, false) | |||
8729 | , argumentCount(ArgumentCount) | |||
8730 | { | |||
8731 | } | |||
8732 | ||||
8733 | XRayLogArgsAttr *clone(ASTContext &C) const; | |||
8734 | void printPretty(raw_ostream &OS, | |||
8735 | const PrintingPolicy &Policy) const; | |||
8736 | const char *getSpelling() const; | |||
8737 | unsigned getArgumentCount() const { | |||
8738 | return argumentCount; | |||
8739 | } | |||
8740 | ||||
8741 | ||||
8742 | ||||
8743 | static bool classof(const Attr *A) { return A->getKind() == attr::XRayLogArgs; } | |||
8744 | }; | |||
8745 | ||||
8746 | #endif // LLVM_CLANG_ATTR_CLASSES_INC |