File: | build-llvm/tools/clang/include/clang/AST/Attrs.inc |
Warning: | line 5605, column 5 Called C++ object pointer is null |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | //===- ASTReaderDecl.cpp - Decl Deserialization ---------------------------===// | |||
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 the ASTReader::ReadDeclRecord method, which is the | |||
11 | // entrypoint for loading a decl. | |||
12 | // | |||
13 | //===----------------------------------------------------------------------===// | |||
14 | ||||
15 | #include "ASTCommon.h" | |||
16 | #include "ASTReaderInternals.h" | |||
17 | #include "clang/AST/ASTContext.h" | |||
18 | #include "clang/AST/Attr.h" | |||
19 | #include "clang/AST/AttrIterator.h" | |||
20 | #include "clang/AST/Decl.h" | |||
21 | #include "clang/AST/DeclBase.h" | |||
22 | #include "clang/AST/DeclCXX.h" | |||
23 | #include "clang/AST/DeclFriend.h" | |||
24 | #include "clang/AST/DeclObjC.h" | |||
25 | #include "clang/AST/DeclOpenMP.h" | |||
26 | #include "clang/AST/DeclTemplate.h" | |||
27 | #include "clang/AST/DeclVisitor.h" | |||
28 | #include "clang/AST/DeclarationName.h" | |||
29 | #include "clang/AST/Expr.h" | |||
30 | #include "clang/AST/ExternalASTSource.h" | |||
31 | #include "clang/AST/LambdaCapture.h" | |||
32 | #include "clang/AST/NestedNameSpecifier.h" | |||
33 | #include "clang/AST/Redeclarable.h" | |||
34 | #include "clang/AST/Stmt.h" | |||
35 | #include "clang/AST/TemplateBase.h" | |||
36 | #include "clang/AST/Type.h" | |||
37 | #include "clang/AST/UnresolvedSet.h" | |||
38 | #include "clang/Basic/AttrKinds.h" | |||
39 | #include "clang/Basic/ExceptionSpecificationType.h" | |||
40 | #include "clang/Basic/IdentifierTable.h" | |||
41 | #include "clang/Basic/LLVM.h" | |||
42 | #include "clang/Basic/Lambda.h" | |||
43 | #include "clang/Basic/LangOptions.h" | |||
44 | #include "clang/Basic/Linkage.h" | |||
45 | #include "clang/Basic/Module.h" | |||
46 | #include "clang/Basic/PragmaKinds.h" | |||
47 | #include "clang/Basic/SourceLocation.h" | |||
48 | #include "clang/Basic/Specifiers.h" | |||
49 | #include "clang/Sema/IdentifierResolver.h" | |||
50 | #include "clang/Sema/SemaDiagnostic.h" | |||
51 | #include "clang/Serialization/ASTBitCodes.h" | |||
52 | #include "clang/Serialization/ASTReader.h" | |||
53 | #include "clang/Serialization/ContinuousRangeMap.h" | |||
54 | #include "clang/Serialization/Module.h" | |||
55 | #include "llvm/ADT/DenseMap.h" | |||
56 | #include "llvm/ADT/FoldingSet.h" | |||
57 | #include "llvm/ADT/STLExtras.h" | |||
58 | #include "llvm/ADT/SmallPtrSet.h" | |||
59 | #include "llvm/ADT/SmallVector.h" | |||
60 | #include "llvm/ADT/iterator_range.h" | |||
61 | #include "llvm/Bitcode/BitstreamReader.h" | |||
62 | #include "llvm/Support/Casting.h" | |||
63 | #include "llvm/Support/ErrorHandling.h" | |||
64 | #include "llvm/Support/SaveAndRestore.h" | |||
65 | #include <algorithm> | |||
66 | #include <cassert> | |||
67 | #include <cstdint> | |||
68 | #include <cstring> | |||
69 | #include <string> | |||
70 | #include <utility> | |||
71 | ||||
72 | using namespace clang; | |||
73 | using namespace serialization; | |||
74 | ||||
75 | //===----------------------------------------------------------------------===// | |||
76 | // Declaration deserialization | |||
77 | //===----------------------------------------------------------------------===// | |||
78 | ||||
79 | namespace clang { | |||
80 | ||||
81 | class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> { | |||
82 | ASTReader &Reader; | |||
83 | ASTRecordReader &Record; | |||
84 | ASTReader::RecordLocation Loc; | |||
85 | const DeclID ThisDeclID; | |||
86 | const SourceLocation ThisDeclLoc; | |||
87 | ||||
88 | using RecordData = ASTReader::RecordData; | |||
89 | ||||
90 | TypeID DeferredTypeID = 0; | |||
91 | unsigned AnonymousDeclNumber; | |||
92 | GlobalDeclID NamedDeclForTagDecl = 0; | |||
93 | IdentifierInfo *TypedefNameForLinkage = nullptr; | |||
94 | ||||
95 | bool HasPendingBody = false; | |||
96 | ||||
97 | ///A flag to carry the information for a decl from the entity is | |||
98 | /// used. We use it to delay the marking of the canonical decl as used until | |||
99 | /// the entire declaration is deserialized and merged. | |||
100 | bool IsDeclMarkedUsed = false; | |||
101 | ||||
102 | uint64_t GetCurrentCursorOffset(); | |||
103 | ||||
104 | uint64_t ReadLocalOffset() { | |||
105 | uint64_t LocalOffset = Record.readInt(); | |||
106 | assert(LocalOffset < Loc.Offset && "offset point after current record")(static_cast <bool> (LocalOffset < Loc.Offset && "offset point after current record") ? void (0) : __assert_fail ("LocalOffset < Loc.Offset && \"offset point after current record\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 106, __extension__ __PRETTY_FUNCTION__)); | |||
107 | return LocalOffset ? Loc.Offset - LocalOffset : 0; | |||
108 | } | |||
109 | ||||
110 | uint64_t ReadGlobalOffset() { | |||
111 | uint64_t Local = ReadLocalOffset(); | |||
112 | return Local ? Record.getGlobalBitOffset(Local) : 0; | |||
113 | } | |||
114 | ||||
115 | SourceLocation ReadSourceLocation() { | |||
116 | return Record.readSourceLocation(); | |||
117 | } | |||
118 | ||||
119 | SourceRange ReadSourceRange() { | |||
120 | return Record.readSourceRange(); | |||
121 | } | |||
122 | ||||
123 | TypeSourceInfo *GetTypeSourceInfo() { | |||
124 | return Record.getTypeSourceInfo(); | |||
125 | } | |||
126 | ||||
127 | serialization::DeclID ReadDeclID() { | |||
128 | return Record.readDeclID(); | |||
129 | } | |||
130 | ||||
131 | std::string ReadString() { | |||
132 | return Record.readString(); | |||
133 | } | |||
134 | ||||
135 | void ReadDeclIDList(SmallVectorImpl<DeclID> &IDs) { | |||
136 | for (unsigned I = 0, Size = Record.readInt(); I != Size; ++I) | |||
137 | IDs.push_back(ReadDeclID()); | |||
138 | } | |||
139 | ||||
140 | Decl *ReadDecl() { | |||
141 | return Record.readDecl(); | |||
142 | } | |||
143 | ||||
144 | template<typename T> | |||
145 | T *ReadDeclAs() { | |||
146 | return Record.readDeclAs<T>(); | |||
147 | } | |||
148 | ||||
149 | void ReadQualifierInfo(QualifierInfo &Info) { | |||
150 | Record.readQualifierInfo(Info); | |||
151 | } | |||
152 | ||||
153 | void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name) { | |||
154 | Record.readDeclarationNameLoc(DNLoc, Name); | |||
155 | } | |||
156 | ||||
157 | serialization::SubmoduleID readSubmoduleID() { | |||
158 | if (Record.getIdx() == Record.size()) | |||
159 | return 0; | |||
160 | ||||
161 | return Record.getGlobalSubmoduleID(Record.readInt()); | |||
162 | } | |||
163 | ||||
164 | Module *readModule() { | |||
165 | return Record.getSubmodule(readSubmoduleID()); | |||
166 | } | |||
167 | ||||
168 | void ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update); | |||
169 | void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data, | |||
170 | const CXXRecordDecl *D); | |||
171 | void MergeDefinitionData(CXXRecordDecl *D, | |||
172 | struct CXXRecordDecl::DefinitionData &&NewDD); | |||
173 | void ReadObjCDefinitionData(struct ObjCInterfaceDecl::DefinitionData &Data); | |||
174 | void MergeDefinitionData(ObjCInterfaceDecl *D, | |||
175 | struct ObjCInterfaceDecl::DefinitionData &&NewDD); | |||
176 | void ReadObjCDefinitionData(struct ObjCProtocolDecl::DefinitionData &Data); | |||
177 | void MergeDefinitionData(ObjCProtocolDecl *D, | |||
178 | struct ObjCProtocolDecl::DefinitionData &&NewDD); | |||
179 | ||||
180 | static DeclContext *getPrimaryDCForAnonymousDecl(DeclContext *LexicalDC); | |||
181 | ||||
182 | static NamedDecl *getAnonymousDeclForMerging(ASTReader &Reader, | |||
183 | DeclContext *DC, | |||
184 | unsigned Index); | |||
185 | static void setAnonymousDeclForMerging(ASTReader &Reader, DeclContext *DC, | |||
186 | unsigned Index, NamedDecl *D); | |||
187 | ||||
188 | /// Results from loading a RedeclarableDecl. | |||
189 | class RedeclarableResult { | |||
190 | Decl *MergeWith; | |||
191 | GlobalDeclID FirstID; | |||
192 | bool IsKeyDecl; | |||
193 | ||||
194 | public: | |||
195 | RedeclarableResult(Decl *MergeWith, GlobalDeclID FirstID, bool IsKeyDecl) | |||
196 | : MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl) {} | |||
197 | ||||
198 | /// Retrieve the first ID. | |||
199 | GlobalDeclID getFirstID() const { return FirstID; } | |||
200 | ||||
201 | /// Is this declaration a key declaration? | |||
202 | bool isKeyDecl() const { return IsKeyDecl; } | |||
203 | ||||
204 | /// Get a known declaration that this should be merged with, if | |||
205 | /// any. | |||
206 | Decl *getKnownMergeTarget() const { return MergeWith; } | |||
207 | }; | |||
208 | ||||
209 | /// Class used to capture the result of searching for an existing | |||
210 | /// declaration of a specific kind and name, along with the ability | |||
211 | /// to update the place where this result was found (the declaration | |||
212 | /// chain hanging off an identifier or the DeclContext we searched in) | |||
213 | /// if requested. | |||
214 | class FindExistingResult { | |||
215 | ASTReader &Reader; | |||
216 | NamedDecl *New = nullptr; | |||
217 | NamedDecl *Existing = nullptr; | |||
218 | bool AddResult = false; | |||
219 | unsigned AnonymousDeclNumber = 0; | |||
220 | IdentifierInfo *TypedefNameForLinkage = nullptr; | |||
221 | ||||
222 | public: | |||
223 | FindExistingResult(ASTReader &Reader) : Reader(Reader) {} | |||
224 | ||||
225 | FindExistingResult(ASTReader &Reader, NamedDecl *New, NamedDecl *Existing, | |||
226 | unsigned AnonymousDeclNumber, | |||
227 | IdentifierInfo *TypedefNameForLinkage) | |||
228 | : Reader(Reader), New(New), Existing(Existing), AddResult(true), | |||
229 | AnonymousDeclNumber(AnonymousDeclNumber), | |||
230 | TypedefNameForLinkage(TypedefNameForLinkage) {} | |||
231 | ||||
232 | FindExistingResult(FindExistingResult &&Other) | |||
233 | : Reader(Other.Reader), New(Other.New), Existing(Other.Existing), | |||
234 | AddResult(Other.AddResult), | |||
235 | AnonymousDeclNumber(Other.AnonymousDeclNumber), | |||
236 | TypedefNameForLinkage(Other.TypedefNameForLinkage) { | |||
237 | Other.AddResult = false; | |||
238 | } | |||
239 | ||||
240 | FindExistingResult &operator=(FindExistingResult &&) = delete; | |||
241 | ~FindExistingResult(); | |||
242 | ||||
243 | /// Suppress the addition of this result into the known set of | |||
244 | /// names. | |||
245 | void suppress() { AddResult = false; } | |||
246 | ||||
247 | operator NamedDecl*() const { return Existing; } | |||
248 | ||||
249 | template<typename T> | |||
250 | operator T*() const { return dyn_cast_or_null<T>(Existing); } | |||
251 | }; | |||
252 | ||||
253 | static DeclContext *getPrimaryContextForMerging(ASTReader &Reader, | |||
254 | DeclContext *DC); | |||
255 | FindExistingResult findExisting(NamedDecl *D); | |||
256 | ||||
257 | public: | |||
258 | ASTDeclReader(ASTReader &Reader, ASTRecordReader &Record, | |||
259 | ASTReader::RecordLocation Loc, | |||
260 | DeclID thisDeclID, SourceLocation ThisDeclLoc) | |||
261 | : Reader(Reader), Record(Record), Loc(Loc), ThisDeclID(thisDeclID), | |||
262 | ThisDeclLoc(ThisDeclLoc) {} | |||
263 | ||||
264 | template <typename T> static | |||
265 | void AddLazySpecializations(T *D, | |||
266 | SmallVectorImpl<serialization::DeclID>& IDs) { | |||
267 | if (IDs.empty()) | |||
268 | return; | |||
269 | ||||
270 | // FIXME: We should avoid this pattern of getting the ASTContext. | |||
271 | ASTContext &C = D->getASTContext(); | |||
272 | ||||
273 | auto *&LazySpecializations = D->getCommonPtr()->LazySpecializations; | |||
274 | ||||
275 | if (auto &Old = LazySpecializations) { | |||
276 | IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]); | |||
277 | llvm::sort(IDs.begin(), IDs.end()); | |||
278 | IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end()); | |||
279 | } | |||
280 | ||||
281 | auto *Result = new (C) serialization::DeclID[1 + IDs.size()]; | |||
282 | *Result = IDs.size(); | |||
283 | std::copy(IDs.begin(), IDs.end(), Result + 1); | |||
284 | ||||
285 | LazySpecializations = Result; | |||
286 | } | |||
287 | ||||
288 | template <typename DeclT> | |||
289 | static Decl *getMostRecentDeclImpl(Redeclarable<DeclT> *D); | |||
290 | static Decl *getMostRecentDeclImpl(...); | |||
291 | static Decl *getMostRecentDecl(Decl *D); | |||
292 | ||||
293 | template <typename DeclT> | |||
294 | static void attachPreviousDeclImpl(ASTReader &Reader, | |||
295 | Redeclarable<DeclT> *D, Decl *Previous, | |||
296 | Decl *Canon); | |||
297 | static void attachPreviousDeclImpl(ASTReader &Reader, ...); | |||
298 | static void attachPreviousDecl(ASTReader &Reader, Decl *D, Decl *Previous, | |||
299 | Decl *Canon); | |||
300 | ||||
301 | template <typename DeclT> | |||
302 | static void attachLatestDeclImpl(Redeclarable<DeclT> *D, Decl *Latest); | |||
303 | static void attachLatestDeclImpl(...); | |||
304 | static void attachLatestDecl(Decl *D, Decl *latest); | |||
305 | ||||
306 | template <typename DeclT> | |||
307 | static void markIncompleteDeclChainImpl(Redeclarable<DeclT> *D); | |||
308 | static void markIncompleteDeclChainImpl(...); | |||
309 | ||||
310 | /// Determine whether this declaration has a pending body. | |||
311 | bool hasPendingBody() const { return HasPendingBody; } | |||
312 | ||||
313 | void ReadFunctionDefinition(FunctionDecl *FD); | |||
314 | void Visit(Decl *D); | |||
315 | ||||
316 | void UpdateDecl(Decl *D, SmallVectorImpl<serialization::DeclID> &); | |||
317 | ||||
318 | static void setNextObjCCategory(ObjCCategoryDecl *Cat, | |||
319 | ObjCCategoryDecl *Next) { | |||
320 | Cat->NextClassCategory = Next; | |||
321 | } | |||
322 | ||||
323 | void VisitDecl(Decl *D); | |||
324 | void VisitPragmaCommentDecl(PragmaCommentDecl *D); | |||
325 | void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D); | |||
326 | void VisitTranslationUnitDecl(TranslationUnitDecl *TU); | |||
327 | void VisitNamedDecl(NamedDecl *ND); | |||
328 | void VisitLabelDecl(LabelDecl *LD); | |||
329 | void VisitNamespaceDecl(NamespaceDecl *D); | |||
330 | void VisitUsingDirectiveDecl(UsingDirectiveDecl *D); | |||
331 | void VisitNamespaceAliasDecl(NamespaceAliasDecl *D); | |||
332 | void VisitTypeDecl(TypeDecl *TD); | |||
333 | RedeclarableResult VisitTypedefNameDecl(TypedefNameDecl *TD); | |||
334 | void VisitTypedefDecl(TypedefDecl *TD); | |||
335 | void VisitTypeAliasDecl(TypeAliasDecl *TD); | |||
336 | void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D); | |||
337 | RedeclarableResult VisitTagDecl(TagDecl *TD); | |||
338 | void VisitEnumDecl(EnumDecl *ED); | |||
339 | RedeclarableResult VisitRecordDeclImpl(RecordDecl *RD); | |||
340 | void VisitRecordDecl(RecordDecl *RD) { VisitRecordDeclImpl(RD); } | |||
341 | RedeclarableResult VisitCXXRecordDeclImpl(CXXRecordDecl *D); | |||
342 | void VisitCXXRecordDecl(CXXRecordDecl *D) { VisitCXXRecordDeclImpl(D); } | |||
343 | RedeclarableResult VisitClassTemplateSpecializationDeclImpl( | |||
344 | ClassTemplateSpecializationDecl *D); | |||
345 | ||||
346 | void VisitClassTemplateSpecializationDecl( | |||
347 | ClassTemplateSpecializationDecl *D) { | |||
348 | VisitClassTemplateSpecializationDeclImpl(D); | |||
349 | } | |||
350 | ||||
351 | void VisitClassTemplatePartialSpecializationDecl( | |||
352 | ClassTemplatePartialSpecializationDecl *D); | |||
353 | void VisitClassScopeFunctionSpecializationDecl( | |||
354 | ClassScopeFunctionSpecializationDecl *D); | |||
355 | RedeclarableResult | |||
356 | VisitVarTemplateSpecializationDeclImpl(VarTemplateSpecializationDecl *D); | |||
357 | ||||
358 | void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D) { | |||
359 | VisitVarTemplateSpecializationDeclImpl(D); | |||
360 | } | |||
361 | ||||
362 | void VisitVarTemplatePartialSpecializationDecl( | |||
363 | VarTemplatePartialSpecializationDecl *D); | |||
364 | void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D); | |||
365 | void VisitValueDecl(ValueDecl *VD); | |||
366 | void VisitEnumConstantDecl(EnumConstantDecl *ECD); | |||
367 | void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D); | |||
368 | void VisitDeclaratorDecl(DeclaratorDecl *DD); | |||
369 | void VisitFunctionDecl(FunctionDecl *FD); | |||
370 | void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *GD); | |||
371 | void VisitCXXMethodDecl(CXXMethodDecl *D); | |||
372 | void VisitCXXConstructorDecl(CXXConstructorDecl *D); | |||
373 | void VisitCXXDestructorDecl(CXXDestructorDecl *D); | |||
374 | void VisitCXXConversionDecl(CXXConversionDecl *D); | |||
375 | void VisitFieldDecl(FieldDecl *FD); | |||
376 | void VisitMSPropertyDecl(MSPropertyDecl *FD); | |||
377 | void VisitIndirectFieldDecl(IndirectFieldDecl *FD); | |||
378 | RedeclarableResult VisitVarDeclImpl(VarDecl *D); | |||
379 | void VisitVarDecl(VarDecl *VD) { VisitVarDeclImpl(VD); } | |||
380 | void VisitImplicitParamDecl(ImplicitParamDecl *PD); | |||
381 | void VisitParmVarDecl(ParmVarDecl *PD); | |||
382 | void VisitDecompositionDecl(DecompositionDecl *DD); | |||
383 | void VisitBindingDecl(BindingDecl *BD); | |||
384 | void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); | |||
385 | DeclID VisitTemplateDecl(TemplateDecl *D); | |||
386 | RedeclarableResult VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D); | |||
387 | void VisitClassTemplateDecl(ClassTemplateDecl *D); | |||
388 | void VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D); | |||
389 | void VisitVarTemplateDecl(VarTemplateDecl *D); | |||
390 | void VisitFunctionTemplateDecl(FunctionTemplateDecl *D); | |||
391 | void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D); | |||
392 | void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D); | |||
393 | void VisitUsingDecl(UsingDecl *D); | |||
394 | void VisitUsingPackDecl(UsingPackDecl *D); | |||
395 | void VisitUsingShadowDecl(UsingShadowDecl *D); | |||
396 | void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D); | |||
397 | void VisitLinkageSpecDecl(LinkageSpecDecl *D); | |||
398 | void VisitExportDecl(ExportDecl *D); | |||
399 | void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD); | |||
400 | void VisitImportDecl(ImportDecl *D); | |||
401 | void VisitAccessSpecDecl(AccessSpecDecl *D); | |||
402 | void VisitFriendDecl(FriendDecl *D); | |||
403 | void VisitFriendTemplateDecl(FriendTemplateDecl *D); | |||
404 | void VisitStaticAssertDecl(StaticAssertDecl *D); | |||
405 | void VisitBlockDecl(BlockDecl *BD); | |||
406 | void VisitCapturedDecl(CapturedDecl *CD); | |||
407 | void VisitEmptyDecl(EmptyDecl *D); | |||
408 | ||||
409 | std::pair<uint64_t, uint64_t> VisitDeclContext(DeclContext *DC); | |||
410 | ||||
411 | template<typename T> | |||
412 | RedeclarableResult VisitRedeclarable(Redeclarable<T> *D); | |||
413 | ||||
414 | template<typename T> | |||
415 | void mergeRedeclarable(Redeclarable<T> *D, RedeclarableResult &Redecl, | |||
416 | DeclID TemplatePatternID = 0); | |||
417 | ||||
418 | template<typename T> | |||
419 | void mergeRedeclarable(Redeclarable<T> *D, T *Existing, | |||
420 | RedeclarableResult &Redecl, | |||
421 | DeclID TemplatePatternID = 0); | |||
422 | ||||
423 | template<typename T> | |||
424 | void mergeMergeable(Mergeable<T> *D); | |||
425 | ||||
426 | void mergeTemplatePattern(RedeclarableTemplateDecl *D, | |||
427 | RedeclarableTemplateDecl *Existing, | |||
428 | DeclID DsID, bool IsKeyDecl); | |||
429 | ||||
430 | ObjCTypeParamList *ReadObjCTypeParamList(); | |||
431 | ||||
432 | // FIXME: Reorder according to DeclNodes.td? | |||
433 | void VisitObjCMethodDecl(ObjCMethodDecl *D); | |||
434 | void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D); | |||
435 | void VisitObjCContainerDecl(ObjCContainerDecl *D); | |||
436 | void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D); | |||
437 | void VisitObjCIvarDecl(ObjCIvarDecl *D); | |||
438 | void VisitObjCProtocolDecl(ObjCProtocolDecl *D); | |||
439 | void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D); | |||
440 | void VisitObjCCategoryDecl(ObjCCategoryDecl *D); | |||
441 | void VisitObjCImplDecl(ObjCImplDecl *D); | |||
442 | void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D); | |||
443 | void VisitObjCImplementationDecl(ObjCImplementationDecl *D); | |||
444 | void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D); | |||
445 | void VisitObjCPropertyDecl(ObjCPropertyDecl *D); | |||
446 | void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); | |||
447 | void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D); | |||
448 | void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D); | |||
449 | void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D); | |||
450 | }; | |||
451 | ||||
452 | } // namespace clang | |||
453 | ||||
454 | namespace { | |||
455 | ||||
456 | /// Iterator over the redeclarations of a declaration that have already | |||
457 | /// been merged into the same redeclaration chain. | |||
458 | template<typename DeclT> | |||
459 | class MergedRedeclIterator { | |||
460 | DeclT *Start; | |||
461 | DeclT *Canonical = nullptr; | |||
462 | DeclT *Current = nullptr; | |||
463 | ||||
464 | public: | |||
465 | MergedRedeclIterator() = default; | |||
466 | MergedRedeclIterator(DeclT *Start) : Start(Start), Current(Start) {} | |||
467 | ||||
468 | DeclT *operator*() { return Current; } | |||
469 | ||||
470 | MergedRedeclIterator &operator++() { | |||
471 | if (Current->isFirstDecl()) { | |||
472 | Canonical = Current; | |||
473 | Current = Current->getMostRecentDecl(); | |||
474 | } else | |||
475 | Current = Current->getPreviousDecl(); | |||
476 | ||||
477 | // If we started in the merged portion, we'll reach our start position | |||
478 | // eventually. Otherwise, we'll never reach it, but the second declaration | |||
479 | // we reached was the canonical declaration, so stop when we see that one | |||
480 | // again. | |||
481 | if (Current == Start || Current == Canonical) | |||
482 | Current = nullptr; | |||
483 | return *this; | |||
484 | } | |||
485 | ||||
486 | friend bool operator!=(const MergedRedeclIterator &A, | |||
487 | const MergedRedeclIterator &B) { | |||
488 | return A.Current != B.Current; | |||
489 | } | |||
490 | }; | |||
491 | ||||
492 | } // namespace | |||
493 | ||||
494 | template <typename DeclT> | |||
495 | static llvm::iterator_range<MergedRedeclIterator<DeclT>> | |||
496 | merged_redecls(DeclT *D) { | |||
497 | return llvm::make_range(MergedRedeclIterator<DeclT>(D), | |||
498 | MergedRedeclIterator<DeclT>()); | |||
499 | } | |||
500 | ||||
501 | uint64_t ASTDeclReader::GetCurrentCursorOffset() { | |||
502 | return Loc.F->DeclsCursor.GetCurrentBitNo() + Loc.F->GlobalBitOffset; | |||
503 | } | |||
504 | ||||
505 | void ASTDeclReader::ReadFunctionDefinition(FunctionDecl *FD) { | |||
506 | if (Record.readInt()) | |||
507 | Reader.DefinitionSource[FD] = Loc.F->Kind == ModuleKind::MK_MainFile; | |||
508 | if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) { | |||
509 | CD->NumCtorInitializers = Record.readInt(); | |||
510 | if (CD->NumCtorInitializers) | |||
511 | CD->CtorInitializers = ReadGlobalOffset(); | |||
512 | } | |||
513 | // Store the offset of the body so we can lazily load it later. | |||
514 | Reader.PendingBodies[FD] = GetCurrentCursorOffset(); | |||
515 | HasPendingBody = true; | |||
516 | } | |||
517 | ||||
518 | void ASTDeclReader::Visit(Decl *D) { | |||
519 | DeclVisitor<ASTDeclReader, void>::Visit(D); | |||
520 | ||||
521 | // At this point we have deserialized and merged the decl and it is safe to | |||
522 | // update its canonical decl to signal that the entire entity is used. | |||
523 | D->getCanonicalDecl()->Used |= IsDeclMarkedUsed; | |||
524 | IsDeclMarkedUsed = false; | |||
525 | ||||
526 | if (auto *DD = dyn_cast<DeclaratorDecl>(D)) { | |||
527 | if (auto *TInfo = DD->getTypeSourceInfo()) | |||
528 | Record.readTypeLoc(TInfo->getTypeLoc()); | |||
529 | } | |||
530 | ||||
531 | if (auto *TD = dyn_cast<TypeDecl>(D)) { | |||
532 | // We have a fully initialized TypeDecl. Read its type now. | |||
533 | TD->setTypeForDecl(Reader.GetType(DeferredTypeID).getTypePtrOrNull()); | |||
534 | ||||
535 | // If this is a tag declaration with a typedef name for linkage, it's safe | |||
536 | // to load that typedef now. | |||
537 | if (NamedDeclForTagDecl) | |||
538 | cast<TagDecl>(D)->TypedefNameDeclOrQualifier = | |||
539 | cast<TypedefNameDecl>(Reader.GetDecl(NamedDeclForTagDecl)); | |||
540 | } else if (auto *ID = dyn_cast<ObjCInterfaceDecl>(D)) { | |||
541 | // if we have a fully initialized TypeDecl, we can safely read its type now. | |||
542 | ID->TypeForDecl = Reader.GetType(DeferredTypeID).getTypePtrOrNull(); | |||
543 | } else if (auto *FD = dyn_cast<FunctionDecl>(D)) { | |||
544 | if (DeferredTypeID) | |||
545 | FD->setType(Reader.GetType(DeferredTypeID)); | |||
546 | ||||
547 | // FunctionDecl's body was written last after all other Stmts/Exprs. | |||
548 | // We only read it if FD doesn't already have a body (e.g., from another | |||
549 | // module). | |||
550 | // FIXME: Can we diagnose ODR violations somehow? | |||
551 | if (Record.readInt()) | |||
552 | ReadFunctionDefinition(FD); | |||
553 | } | |||
554 | } | |||
555 | ||||
556 | void ASTDeclReader::VisitDecl(Decl *D) { | |||
557 | if (D->isTemplateParameter() || D->isTemplateParameterPack() || | |||
558 | isa<ParmVarDecl>(D)) { | |||
559 | // We don't want to deserialize the DeclContext of a template | |||
560 | // parameter or of a parameter of a function template immediately. These | |||
561 | // entities might be used in the formulation of its DeclContext (for | |||
562 | // example, a function parameter can be used in decltype() in trailing | |||
563 | // return type of the function). Use the translation unit DeclContext as a | |||
564 | // placeholder. | |||
565 | GlobalDeclID SemaDCIDForTemplateParmDecl = ReadDeclID(); | |||
566 | GlobalDeclID LexicalDCIDForTemplateParmDecl = ReadDeclID(); | |||
567 | if (!LexicalDCIDForTemplateParmDecl) | |||
568 | LexicalDCIDForTemplateParmDecl = SemaDCIDForTemplateParmDecl; | |||
569 | Reader.addPendingDeclContextInfo(D, | |||
570 | SemaDCIDForTemplateParmDecl, | |||
571 | LexicalDCIDForTemplateParmDecl); | |||
572 | D->setDeclContext(Reader.getContext().getTranslationUnitDecl()); | |||
573 | } else { | |||
574 | auto *SemaDC = ReadDeclAs<DeclContext>(); | |||
575 | auto *LexicalDC = ReadDeclAs<DeclContext>(); | |||
576 | if (!LexicalDC) | |||
577 | LexicalDC = SemaDC; | |||
578 | DeclContext *MergedSemaDC = Reader.MergedDeclContexts.lookup(SemaDC); | |||
579 | // Avoid calling setLexicalDeclContext() directly because it uses | |||
580 | // Decl::getASTContext() internally which is unsafe during derialization. | |||
581 | D->setDeclContextsImpl(MergedSemaDC ? MergedSemaDC : SemaDC, LexicalDC, | |||
582 | Reader.getContext()); | |||
583 | } | |||
584 | D->setLocation(ThisDeclLoc); | |||
585 | D->setInvalidDecl(Record.readInt()); | |||
586 | if (Record.readInt()) { // hasAttrs | |||
587 | AttrVec Attrs; | |||
588 | Record.readAttributes(Attrs); | |||
589 | // Avoid calling setAttrs() directly because it uses Decl::getASTContext() | |||
590 | // internally which is unsafe during derialization. | |||
591 | D->setAttrsImpl(Attrs, Reader.getContext()); | |||
592 | } | |||
593 | D->setImplicit(Record.readInt()); | |||
594 | D->Used = Record.readInt(); | |||
595 | IsDeclMarkedUsed |= D->Used; | |||
596 | D->setReferenced(Record.readInt()); | |||
597 | D->setTopLevelDeclInObjCContainer(Record.readInt()); | |||
598 | D->setAccess((AccessSpecifier)Record.readInt()); | |||
599 | D->FromASTFile = true; | |||
600 | bool ModulePrivate = Record.readInt(); | |||
601 | ||||
602 | // Determine whether this declaration is part of a (sub)module. If so, it | |||
603 | // may not yet be visible. | |||
604 | if (unsigned SubmoduleID = readSubmoduleID()) { | |||
605 | // Store the owning submodule ID in the declaration. | |||
606 | D->setModuleOwnershipKind( | |||
607 | ModulePrivate ? Decl::ModuleOwnershipKind::ModulePrivate | |||
608 | : Decl::ModuleOwnershipKind::VisibleWhenImported); | |||
609 | D->setOwningModuleID(SubmoduleID); | |||
610 | ||||
611 | if (ModulePrivate) { | |||
612 | // Module-private declarations are never visible, so there is no work to | |||
613 | // do. | |||
614 | } else if (Reader.getContext().getLangOpts().ModulesLocalVisibility) { | |||
615 | // If local visibility is being tracked, this declaration will become | |||
616 | // hidden and visible as the owning module does. | |||
617 | } else if (Module *Owner = Reader.getSubmodule(SubmoduleID)) { | |||
618 | // Mark the declaration as visible when its owning module becomes visible. | |||
619 | if (Owner->NameVisibility == Module::AllVisible) | |||
620 | D->setVisibleDespiteOwningModule(); | |||
621 | else | |||
622 | Reader.HiddenNamesMap[Owner].push_back(D); | |||
623 | } | |||
624 | } else if (ModulePrivate) { | |||
625 | D->setModuleOwnershipKind(Decl::ModuleOwnershipKind::ModulePrivate); | |||
626 | } | |||
627 | } | |||
628 | ||||
629 | void ASTDeclReader::VisitPragmaCommentDecl(PragmaCommentDecl *D) { | |||
630 | VisitDecl(D); | |||
631 | D->setLocation(ReadSourceLocation()); | |||
632 | D->CommentKind = (PragmaMSCommentKind)Record.readInt(); | |||
633 | std::string Arg = ReadString(); | |||
634 | memcpy(D->getTrailingObjects<char>(), Arg.data(), Arg.size()); | |||
635 | D->getTrailingObjects<char>()[Arg.size()] = '\0'; | |||
636 | } | |||
637 | ||||
638 | void ASTDeclReader::VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D) { | |||
639 | VisitDecl(D); | |||
640 | D->setLocation(ReadSourceLocation()); | |||
641 | std::string Name = ReadString(); | |||
642 | memcpy(D->getTrailingObjects<char>(), Name.data(), Name.size()); | |||
643 | D->getTrailingObjects<char>()[Name.size()] = '\0'; | |||
644 | ||||
645 | D->ValueStart = Name.size() + 1; | |||
646 | std::string Value = ReadString(); | |||
647 | memcpy(D->getTrailingObjects<char>() + D->ValueStart, Value.data(), | |||
648 | Value.size()); | |||
649 | D->getTrailingObjects<char>()[D->ValueStart + Value.size()] = '\0'; | |||
650 | } | |||
651 | ||||
652 | void ASTDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) { | |||
653 | llvm_unreachable("Translation units are not serialized")::llvm::llvm_unreachable_internal("Translation units are not serialized" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 653); | |||
654 | } | |||
655 | ||||
656 | void ASTDeclReader::VisitNamedDecl(NamedDecl *ND) { | |||
657 | VisitDecl(ND); | |||
658 | ND->setDeclName(Record.readDeclarationName()); | |||
659 | AnonymousDeclNumber = Record.readInt(); | |||
660 | } | |||
661 | ||||
662 | void ASTDeclReader::VisitTypeDecl(TypeDecl *TD) { | |||
663 | VisitNamedDecl(TD); | |||
664 | TD->setLocStart(ReadSourceLocation()); | |||
665 | // Delay type reading until after we have fully initialized the decl. | |||
666 | DeferredTypeID = Record.getGlobalTypeID(Record.readInt()); | |||
667 | } | |||
668 | ||||
669 | ASTDeclReader::RedeclarableResult | |||
670 | ASTDeclReader::VisitTypedefNameDecl(TypedefNameDecl *TD) { | |||
671 | RedeclarableResult Redecl = VisitRedeclarable(TD); | |||
672 | VisitTypeDecl(TD); | |||
673 | TypeSourceInfo *TInfo = GetTypeSourceInfo(); | |||
674 | if (Record.readInt()) { // isModed | |||
675 | QualType modedT = Record.readType(); | |||
676 | TD->setModedTypeSourceInfo(TInfo, modedT); | |||
677 | } else | |||
678 | TD->setTypeSourceInfo(TInfo); | |||
679 | // Read and discard the declaration for which this is a typedef name for | |||
680 | // linkage, if it exists. We cannot rely on our type to pull in this decl, | |||
681 | // because it might have been merged with a type from another module and | |||
682 | // thus might not refer to our version of the declaration. | |||
683 | ReadDecl(); | |||
684 | return Redecl; | |||
685 | } | |||
686 | ||||
687 | void ASTDeclReader::VisitTypedefDecl(TypedefDecl *TD) { | |||
688 | RedeclarableResult Redecl = VisitTypedefNameDecl(TD); | |||
689 | mergeRedeclarable(TD, Redecl); | |||
690 | } | |||
691 | ||||
692 | void ASTDeclReader::VisitTypeAliasDecl(TypeAliasDecl *TD) { | |||
693 | RedeclarableResult Redecl = VisitTypedefNameDecl(TD); | |||
694 | if (auto *Template = ReadDeclAs<TypeAliasTemplateDecl>()) | |||
695 | // Merged when we merge the template. | |||
696 | TD->setDescribedAliasTemplate(Template); | |||
697 | else | |||
698 | mergeRedeclarable(TD, Redecl); | |||
699 | } | |||
700 | ||||
701 | ASTDeclReader::RedeclarableResult ASTDeclReader::VisitTagDecl(TagDecl *TD) { | |||
702 | RedeclarableResult Redecl = VisitRedeclarable(TD); | |||
703 | VisitTypeDecl(TD); | |||
704 | ||||
705 | TD->IdentifierNamespace = Record.readInt(); | |||
706 | TD->setTagKind((TagDecl::TagKind)Record.readInt()); | |||
707 | if (!isa<CXXRecordDecl>(TD)) | |||
708 | TD->setCompleteDefinition(Record.readInt()); | |||
709 | TD->setEmbeddedInDeclarator(Record.readInt()); | |||
710 | TD->setFreeStanding(Record.readInt()); | |||
711 | TD->setCompleteDefinitionRequired(Record.readInt()); | |||
712 | TD->setBraceRange(ReadSourceRange()); | |||
713 | ||||
714 | switch (Record.readInt()) { | |||
715 | case 0: | |||
716 | break; | |||
717 | case 1: { // ExtInfo | |||
718 | auto *Info = new (Reader.getContext()) TagDecl::ExtInfo(); | |||
719 | ReadQualifierInfo(*Info); | |||
720 | TD->TypedefNameDeclOrQualifier = Info; | |||
721 | break; | |||
722 | } | |||
723 | case 2: // TypedefNameForAnonDecl | |||
724 | NamedDeclForTagDecl = ReadDeclID(); | |||
725 | TypedefNameForLinkage = Record.getIdentifierInfo(); | |||
726 | break; | |||
727 | default: | |||
728 | llvm_unreachable("unexpected tag info kind")::llvm::llvm_unreachable_internal("unexpected tag info kind", "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 728); | |||
729 | } | |||
730 | ||||
731 | if (!isa<CXXRecordDecl>(TD)) | |||
732 | mergeRedeclarable(TD, Redecl); | |||
733 | return Redecl; | |||
734 | } | |||
735 | ||||
736 | void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) { | |||
737 | VisitTagDecl(ED); | |||
738 | if (TypeSourceInfo *TI = GetTypeSourceInfo()) | |||
739 | ED->setIntegerTypeSourceInfo(TI); | |||
740 | else | |||
741 | ED->setIntegerType(Record.readType()); | |||
742 | ED->setPromotionType(Record.readType()); | |||
743 | ED->setNumPositiveBits(Record.readInt()); | |||
744 | ED->setNumNegativeBits(Record.readInt()); | |||
745 | ED->IsScoped = Record.readInt(); | |||
746 | ED->IsScopedUsingClassTag = Record.readInt(); | |||
747 | ED->IsFixed = Record.readInt(); | |||
748 | ||||
749 | ED->HasODRHash = true; | |||
750 | ED->ODRHash = Record.readInt(); | |||
751 | ||||
752 | // If this is a definition subject to the ODR, and we already have a | |||
753 | // definition, merge this one into it. | |||
754 | if (ED->IsCompleteDefinition && | |||
755 | Reader.getContext().getLangOpts().Modules && | |||
756 | Reader.getContext().getLangOpts().CPlusPlus) { | |||
757 | EnumDecl *&OldDef = Reader.EnumDefinitions[ED->getCanonicalDecl()]; | |||
758 | if (!OldDef) { | |||
759 | // This is the first time we've seen an imported definition. Look for a | |||
760 | // local definition before deciding that we are the first definition. | |||
761 | for (auto *D : merged_redecls(ED->getCanonicalDecl())) { | |||
762 | if (!D->isFromASTFile() && D->isCompleteDefinition()) { | |||
763 | OldDef = D; | |||
764 | break; | |||
765 | } | |||
766 | } | |||
767 | } | |||
768 | if (OldDef) { | |||
769 | Reader.MergedDeclContexts.insert(std::make_pair(ED, OldDef)); | |||
770 | ED->IsCompleteDefinition = false; | |||
771 | Reader.mergeDefinitionVisibility(OldDef, ED); | |||
772 | if (OldDef->getODRHash() != ED->getODRHash()) | |||
773 | Reader.PendingEnumOdrMergeFailures[OldDef].push_back(ED); | |||
774 | } else { | |||
775 | OldDef = ED; | |||
776 | } | |||
777 | } | |||
778 | ||||
779 | if (auto *InstED = ReadDeclAs<EnumDecl>()) { | |||
780 | auto TSK = (TemplateSpecializationKind)Record.readInt(); | |||
781 | SourceLocation POI = ReadSourceLocation(); | |||
782 | ED->setInstantiationOfMemberEnum(Reader.getContext(), InstED, TSK); | |||
783 | ED->getMemberSpecializationInfo()->setPointOfInstantiation(POI); | |||
784 | } | |||
785 | } | |||
786 | ||||
787 | ASTDeclReader::RedeclarableResult | |||
788 | ASTDeclReader::VisitRecordDeclImpl(RecordDecl *RD) { | |||
789 | RedeclarableResult Redecl = VisitTagDecl(RD); | |||
790 | RD->setHasFlexibleArrayMember(Record.readInt()); | |||
791 | RD->setAnonymousStructOrUnion(Record.readInt()); | |||
792 | RD->setHasObjectMember(Record.readInt()); | |||
793 | RD->setHasVolatileMember(Record.readInt()); | |||
794 | RD->setNonTrivialToPrimitiveDefaultInitialize(Record.readInt()); | |||
795 | RD->setNonTrivialToPrimitiveCopy(Record.readInt()); | |||
796 | RD->setNonTrivialToPrimitiveDestroy(Record.readInt()); | |||
797 | RD->setParamDestroyedInCallee(Record.readInt()); | |||
798 | RD->setArgPassingRestrictions((RecordDecl::ArgPassingKind)Record.readInt()); | |||
799 | return Redecl; | |||
800 | } | |||
801 | ||||
802 | void ASTDeclReader::VisitValueDecl(ValueDecl *VD) { | |||
803 | VisitNamedDecl(VD); | |||
804 | // For function declarations, defer reading the type in case the function has | |||
805 | // a deduced return type that references an entity declared within the | |||
806 | // function. | |||
807 | if (isa<FunctionDecl>(VD)) | |||
808 | DeferredTypeID = Record.getGlobalTypeID(Record.readInt()); | |||
809 | else | |||
810 | VD->setType(Record.readType()); | |||
811 | } | |||
812 | ||||
813 | void ASTDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) { | |||
814 | VisitValueDecl(ECD); | |||
815 | if (Record.readInt()) | |||
816 | ECD->setInitExpr(Record.readExpr()); | |||
817 | ECD->setInitVal(Record.readAPSInt()); | |||
818 | mergeMergeable(ECD); | |||
819 | } | |||
820 | ||||
821 | void ASTDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) { | |||
822 | VisitValueDecl(DD); | |||
823 | DD->setInnerLocStart(ReadSourceLocation()); | |||
824 | if (Record.readInt()) { // hasExtInfo | |||
825 | auto *Info = new (Reader.getContext()) DeclaratorDecl::ExtInfo(); | |||
826 | ReadQualifierInfo(*Info); | |||
827 | DD->DeclInfo = Info; | |||
828 | } | |||
829 | QualType TSIType = Record.readType(); | |||
830 | DD->setTypeSourceInfo( | |||
831 | TSIType.isNull() ? nullptr | |||
832 | : Reader.getContext().CreateTypeSourceInfo(TSIType)); | |||
833 | } | |||
834 | ||||
835 | void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { | |||
836 | RedeclarableResult Redecl = VisitRedeclarable(FD); | |||
837 | VisitDeclaratorDecl(FD); | |||
838 | ||||
839 | // Attach a type to this function. Use the real type if possible, but fall | |||
840 | // back to the type as written if it involves a deduced return type. | |||
841 | if (FD->getTypeSourceInfo() && | |||
842 | FD->getTypeSourceInfo()->getType()->castAs<FunctionType>() | |||
843 | ->getReturnType()->getContainedAutoType()) { | |||
844 | // We'll set up the real type in Visit, once we've finished loading the | |||
845 | // function. | |||
846 | FD->setType(FD->getTypeSourceInfo()->getType()); | |||
847 | } else { | |||
848 | FD->setType(Reader.GetType(DeferredTypeID)); | |||
849 | DeferredTypeID = 0; | |||
850 | } | |||
851 | ||||
852 | ReadDeclarationNameLoc(FD->DNLoc, FD->getDeclName()); | |||
853 | FD->IdentifierNamespace = Record.readInt(); | |||
854 | ||||
855 | // FunctionDecl's body is handled last at ASTDeclReader::Visit, | |||
856 | // after everything else is read. | |||
857 | ||||
858 | FD->SClass = (StorageClass)Record.readInt(); | |||
859 | FD->IsInline = Record.readInt(); | |||
860 | FD->IsInlineSpecified = Record.readInt(); | |||
861 | FD->IsExplicitSpecified = Record.readInt(); | |||
862 | FD->IsVirtualAsWritten = Record.readInt(); | |||
863 | FD->IsPure = Record.readInt(); | |||
864 | FD->HasInheritedPrototype = Record.readInt(); | |||
865 | FD->HasWrittenPrototype = Record.readInt(); | |||
866 | FD->IsDeleted = Record.readInt(); | |||
867 | FD->IsTrivial = Record.readInt(); | |||
868 | FD->IsTrivialForCall = Record.readInt(); | |||
869 | FD->IsDefaulted = Record.readInt(); | |||
870 | FD->IsExplicitlyDefaulted = Record.readInt(); | |||
871 | FD->HasImplicitReturnZero = Record.readInt(); | |||
872 | FD->IsConstexpr = Record.readInt(); | |||
873 | FD->UsesSEHTry = Record.readInt(); | |||
874 | FD->HasSkippedBody = Record.readInt(); | |||
875 | FD->IsMultiVersion = Record.readInt(); | |||
876 | FD->IsLateTemplateParsed = Record.readInt(); | |||
877 | FD->setCachedLinkage(Linkage(Record.readInt())); | |||
878 | FD->EndRangeLoc = ReadSourceLocation(); | |||
879 | ||||
880 | FD->ODRHash = Record.readInt(); | |||
881 | FD->HasODRHash = true; | |||
882 | ||||
883 | switch ((FunctionDecl::TemplatedKind)Record.readInt()) { | |||
884 | case FunctionDecl::TK_NonTemplate: | |||
885 | mergeRedeclarable(FD, Redecl); | |||
886 | break; | |||
887 | case FunctionDecl::TK_FunctionTemplate: | |||
888 | // Merged when we merge the template. | |||
889 | FD->setDescribedFunctionTemplate(ReadDeclAs<FunctionTemplateDecl>()); | |||
890 | break; | |||
891 | case FunctionDecl::TK_MemberSpecialization: { | |||
892 | auto *InstFD = ReadDeclAs<FunctionDecl>(); | |||
893 | auto TSK = (TemplateSpecializationKind)Record.readInt(); | |||
894 | SourceLocation POI = ReadSourceLocation(); | |||
895 | FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK); | |||
896 | FD->getMemberSpecializationInfo()->setPointOfInstantiation(POI); | |||
897 | mergeRedeclarable(FD, Redecl); | |||
898 | break; | |||
899 | } | |||
900 | case FunctionDecl::TK_FunctionTemplateSpecialization: { | |||
901 | auto *Template = ReadDeclAs<FunctionTemplateDecl>(); | |||
902 | auto TSK = (TemplateSpecializationKind)Record.readInt(); | |||
903 | ||||
904 | // Template arguments. | |||
905 | SmallVector<TemplateArgument, 8> TemplArgs; | |||
906 | Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true); | |||
907 | ||||
908 | // Template args as written. | |||
909 | SmallVector<TemplateArgumentLoc, 8> TemplArgLocs; | |||
910 | SourceLocation LAngleLoc, RAngleLoc; | |||
911 | bool HasTemplateArgumentsAsWritten = Record.readInt(); | |||
912 | if (HasTemplateArgumentsAsWritten) { | |||
913 | unsigned NumTemplateArgLocs = Record.readInt(); | |||
914 | TemplArgLocs.reserve(NumTemplateArgLocs); | |||
915 | for (unsigned i = 0; i != NumTemplateArgLocs; ++i) | |||
916 | TemplArgLocs.push_back(Record.readTemplateArgumentLoc()); | |||
917 | ||||
918 | LAngleLoc = ReadSourceLocation(); | |||
919 | RAngleLoc = ReadSourceLocation(); | |||
920 | } | |||
921 | ||||
922 | SourceLocation POI = ReadSourceLocation(); | |||
923 | ||||
924 | ASTContext &C = Reader.getContext(); | |||
925 | TemplateArgumentList *TemplArgList | |||
926 | = TemplateArgumentList::CreateCopy(C, TemplArgs); | |||
927 | TemplateArgumentListInfo TemplArgsInfo(LAngleLoc, RAngleLoc); | |||
928 | for (unsigned i = 0, e = TemplArgLocs.size(); i != e; ++i) | |||
929 | TemplArgsInfo.addArgument(TemplArgLocs[i]); | |||
930 | FunctionTemplateSpecializationInfo *FTInfo | |||
931 | = FunctionTemplateSpecializationInfo::Create(C, FD, Template, TSK, | |||
932 | TemplArgList, | |||
933 | HasTemplateArgumentsAsWritten ? &TemplArgsInfo | |||
934 | : nullptr, | |||
935 | POI); | |||
936 | FD->TemplateOrSpecialization = FTInfo; | |||
937 | ||||
938 | if (FD->isCanonicalDecl()) { // if canonical add to template's set. | |||
939 | // The template that contains the specializations set. It's not safe to | |||
940 | // use getCanonicalDecl on Template since it may still be initializing. | |||
941 | auto *CanonTemplate = ReadDeclAs<FunctionTemplateDecl>(); | |||
942 | // Get the InsertPos by FindNodeOrInsertPos() instead of calling | |||
943 | // InsertNode(FTInfo) directly to avoid the getASTContext() call in | |||
944 | // FunctionTemplateSpecializationInfo's Profile(). | |||
945 | // We avoid getASTContext because a decl in the parent hierarchy may | |||
946 | // be initializing. | |||
947 | llvm::FoldingSetNodeID ID; | |||
948 | FunctionTemplateSpecializationInfo::Profile(ID, TemplArgs, C); | |||
949 | void *InsertPos = nullptr; | |||
950 | FunctionTemplateDecl::Common *CommonPtr = CanonTemplate->getCommonPtr(); | |||
951 | FunctionTemplateSpecializationInfo *ExistingInfo = | |||
952 | CommonPtr->Specializations.FindNodeOrInsertPos(ID, InsertPos); | |||
953 | if (InsertPos) | |||
954 | CommonPtr->Specializations.InsertNode(FTInfo, InsertPos); | |||
955 | else { | |||
956 | assert(Reader.getContext().getLangOpts().Modules &&(static_cast <bool> (Reader.getContext().getLangOpts(). Modules && "already deserialized this template specialization" ) ? void (0) : __assert_fail ("Reader.getContext().getLangOpts().Modules && \"already deserialized this template specialization\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 957, __extension__ __PRETTY_FUNCTION__)) | |||
957 | "already deserialized this template specialization")(static_cast <bool> (Reader.getContext().getLangOpts(). Modules && "already deserialized this template specialization" ) ? void (0) : __assert_fail ("Reader.getContext().getLangOpts().Modules && \"already deserialized this template specialization\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 957, __extension__ __PRETTY_FUNCTION__)); | |||
958 | mergeRedeclarable(FD, ExistingInfo->Function, Redecl); | |||
959 | } | |||
960 | } | |||
961 | break; | |||
962 | } | |||
963 | case FunctionDecl::TK_DependentFunctionTemplateSpecialization: { | |||
964 | // Templates. | |||
965 | UnresolvedSet<8> TemplDecls; | |||
966 | unsigned NumTemplates = Record.readInt(); | |||
967 | while (NumTemplates--) | |||
968 | TemplDecls.addDecl(ReadDeclAs<NamedDecl>()); | |||
969 | ||||
970 | // Templates args. | |||
971 | TemplateArgumentListInfo TemplArgs; | |||
972 | unsigned NumArgs = Record.readInt(); | |||
973 | while (NumArgs--) | |||
974 | TemplArgs.addArgument(Record.readTemplateArgumentLoc()); | |||
975 | TemplArgs.setLAngleLoc(ReadSourceLocation()); | |||
976 | TemplArgs.setRAngleLoc(ReadSourceLocation()); | |||
977 | ||||
978 | FD->setDependentTemplateSpecialization(Reader.getContext(), | |||
979 | TemplDecls, TemplArgs); | |||
980 | // These are not merged; we don't need to merge redeclarations of dependent | |||
981 | // template friends. | |||
982 | break; | |||
983 | } | |||
984 | } | |||
985 | ||||
986 | // Read in the parameters. | |||
987 | unsigned NumParams = Record.readInt(); | |||
988 | SmallVector<ParmVarDecl *, 16> Params; | |||
989 | Params.reserve(NumParams); | |||
990 | for (unsigned I = 0; I != NumParams; ++I) | |||
991 | Params.push_back(ReadDeclAs<ParmVarDecl>()); | |||
992 | FD->setParams(Reader.getContext(), Params); | |||
993 | } | |||
994 | ||||
995 | void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { | |||
996 | VisitNamedDecl(MD); | |||
997 | if (Record.readInt()) { | |||
998 | // Load the body on-demand. Most clients won't care, because method | |||
999 | // definitions rarely show up in headers. | |||
1000 | Reader.PendingBodies[MD] = GetCurrentCursorOffset(); | |||
1001 | HasPendingBody = true; | |||
1002 | MD->setSelfDecl(ReadDeclAs<ImplicitParamDecl>()); | |||
1003 | MD->setCmdDecl(ReadDeclAs<ImplicitParamDecl>()); | |||
1004 | } | |||
1005 | MD->setInstanceMethod(Record.readInt()); | |||
1006 | MD->setVariadic(Record.readInt()); | |||
1007 | MD->setPropertyAccessor(Record.readInt()); | |||
1008 | MD->setDefined(Record.readInt()); | |||
1009 | MD->IsOverriding = Record.readInt(); | |||
1010 | MD->HasSkippedBody = Record.readInt(); | |||
1011 | ||||
1012 | MD->IsRedeclaration = Record.readInt(); | |||
1013 | MD->HasRedeclaration = Record.readInt(); | |||
1014 | if (MD->HasRedeclaration) | |||
1015 | Reader.getContext().setObjCMethodRedeclaration(MD, | |||
1016 | ReadDeclAs<ObjCMethodDecl>()); | |||
1017 | ||||
1018 | MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record.readInt()); | |||
1019 | MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record.readInt()); | |||
1020 | MD->SetRelatedResultType(Record.readInt()); | |||
1021 | MD->setReturnType(Record.readType()); | |||
1022 | MD->setReturnTypeSourceInfo(GetTypeSourceInfo()); | |||
1023 | MD->DeclEndLoc = ReadSourceLocation(); | |||
1024 | unsigned NumParams = Record.readInt(); | |||
1025 | SmallVector<ParmVarDecl *, 16> Params; | |||
1026 | Params.reserve(NumParams); | |||
1027 | for (unsigned I = 0; I != NumParams; ++I) | |||
1028 | Params.push_back(ReadDeclAs<ParmVarDecl>()); | |||
1029 | ||||
1030 | MD->SelLocsKind = Record.readInt(); | |||
1031 | unsigned NumStoredSelLocs = Record.readInt(); | |||
1032 | SmallVector<SourceLocation, 16> SelLocs; | |||
1033 | SelLocs.reserve(NumStoredSelLocs); | |||
1034 | for (unsigned i = 0; i != NumStoredSelLocs; ++i) | |||
1035 | SelLocs.push_back(ReadSourceLocation()); | |||
1036 | ||||
1037 | MD->setParamsAndSelLocs(Reader.getContext(), Params, SelLocs); | |||
1038 | } | |||
1039 | ||||
1040 | void ASTDeclReader::VisitObjCTypeParamDecl(ObjCTypeParamDecl *D) { | |||
1041 | VisitTypedefNameDecl(D); | |||
1042 | ||||
1043 | D->Variance = Record.readInt(); | |||
1044 | D->Index = Record.readInt(); | |||
1045 | D->VarianceLoc = ReadSourceLocation(); | |||
1046 | D->ColonLoc = ReadSourceLocation(); | |||
1047 | } | |||
1048 | ||||
1049 | void ASTDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) { | |||
1050 | VisitNamedDecl(CD); | |||
1051 | CD->setAtStartLoc(ReadSourceLocation()); | |||
1052 | CD->setAtEndRange(ReadSourceRange()); | |||
1053 | } | |||
1054 | ||||
1055 | ObjCTypeParamList *ASTDeclReader::ReadObjCTypeParamList() { | |||
1056 | unsigned numParams = Record.readInt(); | |||
1057 | if (numParams == 0) | |||
1058 | return nullptr; | |||
1059 | ||||
1060 | SmallVector<ObjCTypeParamDecl *, 4> typeParams; | |||
1061 | typeParams.reserve(numParams); | |||
1062 | for (unsigned i = 0; i != numParams; ++i) { | |||
1063 | auto *typeParam = ReadDeclAs<ObjCTypeParamDecl>(); | |||
1064 | if (!typeParam) | |||
1065 | return nullptr; | |||
1066 | ||||
1067 | typeParams.push_back(typeParam); | |||
1068 | } | |||
1069 | ||||
1070 | SourceLocation lAngleLoc = ReadSourceLocation(); | |||
1071 | SourceLocation rAngleLoc = ReadSourceLocation(); | |||
1072 | ||||
1073 | return ObjCTypeParamList::create(Reader.getContext(), lAngleLoc, | |||
1074 | typeParams, rAngleLoc); | |||
1075 | } | |||
1076 | ||||
1077 | void ASTDeclReader::ReadObjCDefinitionData( | |||
1078 | struct ObjCInterfaceDecl::DefinitionData &Data) { | |||
1079 | // Read the superclass. | |||
1080 | Data.SuperClassTInfo = GetTypeSourceInfo(); | |||
1081 | ||||
1082 | Data.EndLoc = ReadSourceLocation(); | |||
1083 | Data.HasDesignatedInitializers = Record.readInt(); | |||
1084 | ||||
1085 | // Read the directly referenced protocols and their SourceLocations. | |||
1086 | unsigned NumProtocols = Record.readInt(); | |||
1087 | SmallVector<ObjCProtocolDecl *, 16> Protocols; | |||
1088 | Protocols.reserve(NumProtocols); | |||
1089 | for (unsigned I = 0; I != NumProtocols; ++I) | |||
1090 | Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>()); | |||
1091 | SmallVector<SourceLocation, 16> ProtoLocs; | |||
1092 | ProtoLocs.reserve(NumProtocols); | |||
1093 | for (unsigned I = 0; I != NumProtocols; ++I) | |||
1094 | ProtoLocs.push_back(ReadSourceLocation()); | |||
1095 | Data.ReferencedProtocols.set(Protocols.data(), NumProtocols, ProtoLocs.data(), | |||
1096 | Reader.getContext()); | |||
1097 | ||||
1098 | // Read the transitive closure of protocols referenced by this class. | |||
1099 | NumProtocols = Record.readInt(); | |||
1100 | Protocols.clear(); | |||
1101 | Protocols.reserve(NumProtocols); | |||
1102 | for (unsigned I = 0; I != NumProtocols; ++I) | |||
1103 | Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>()); | |||
1104 | Data.AllReferencedProtocols.set(Protocols.data(), NumProtocols, | |||
1105 | Reader.getContext()); | |||
1106 | } | |||
1107 | ||||
1108 | void ASTDeclReader::MergeDefinitionData(ObjCInterfaceDecl *D, | |||
1109 | struct ObjCInterfaceDecl::DefinitionData &&NewDD) { | |||
1110 | // FIXME: odr checking? | |||
1111 | } | |||
1112 | ||||
1113 | void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { | |||
1114 | RedeclarableResult Redecl = VisitRedeclarable(ID); | |||
1115 | VisitObjCContainerDecl(ID); | |||
1116 | DeferredTypeID = Record.getGlobalTypeID(Record.readInt()); | |||
1117 | mergeRedeclarable(ID, Redecl); | |||
1118 | ||||
1119 | ID->TypeParamList = ReadObjCTypeParamList(); | |||
1120 | if (Record.readInt()) { | |||
1121 | // Read the definition. | |||
1122 | ID->allocateDefinitionData(); | |||
1123 | ||||
1124 | ReadObjCDefinitionData(ID->data()); | |||
1125 | ObjCInterfaceDecl *Canon = ID->getCanonicalDecl(); | |||
1126 | if (Canon->Data.getPointer()) { | |||
1127 | // If we already have a definition, keep the definition invariant and | |||
1128 | // merge the data. | |||
1129 | MergeDefinitionData(Canon, std::move(ID->data())); | |||
1130 | ID->Data = Canon->Data; | |||
1131 | } else { | |||
1132 | // Set the definition data of the canonical declaration, so other | |||
1133 | // redeclarations will see it. | |||
1134 | ID->getCanonicalDecl()->Data = ID->Data; | |||
1135 | ||||
1136 | // We will rebuild this list lazily. | |||
1137 | ID->setIvarList(nullptr); | |||
1138 | } | |||
1139 | ||||
1140 | // Note that we have deserialized a definition. | |||
1141 | Reader.PendingDefinitions.insert(ID); | |||
1142 | ||||
1143 | // Note that we've loaded this Objective-C class. | |||
1144 | Reader.ObjCClassesLoaded.push_back(ID); | |||
1145 | } else { | |||
1146 | ID->Data = ID->getCanonicalDecl()->Data; | |||
1147 | } | |||
1148 | } | |||
1149 | ||||
1150 | void ASTDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) { | |||
1151 | VisitFieldDecl(IVD); | |||
1152 | IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record.readInt()); | |||
1153 | // This field will be built lazily. | |||
1154 | IVD->setNextIvar(nullptr); | |||
1155 | bool synth = Record.readInt(); | |||
1156 | IVD->setSynthesize(synth); | |||
1157 | } | |||
1158 | ||||
1159 | void ASTDeclReader::ReadObjCDefinitionData( | |||
1160 | struct ObjCProtocolDecl::DefinitionData &Data) { | |||
1161 | unsigned NumProtoRefs = Record.readInt(); | |||
1162 | SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; | |||
1163 | ProtoRefs.reserve(NumProtoRefs); | |||
1164 | for (unsigned I = 0; I != NumProtoRefs; ++I) | |||
1165 | ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>()); | |||
1166 | SmallVector<SourceLocation, 16> ProtoLocs; | |||
1167 | ProtoLocs.reserve(NumProtoRefs); | |||
1168 | for (unsigned I = 0; I != NumProtoRefs; ++I) | |||
1169 | ProtoLocs.push_back(ReadSourceLocation()); | |||
1170 | Data.ReferencedProtocols.set(ProtoRefs.data(), NumProtoRefs, | |||
1171 | ProtoLocs.data(), Reader.getContext()); | |||
1172 | } | |||
1173 | ||||
1174 | void ASTDeclReader::MergeDefinitionData(ObjCProtocolDecl *D, | |||
1175 | struct ObjCProtocolDecl::DefinitionData &&NewDD) { | |||
1176 | // FIXME: odr checking? | |||
1177 | } | |||
1178 | ||||
1179 | void ASTDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) { | |||
1180 | RedeclarableResult Redecl = VisitRedeclarable(PD); | |||
1181 | VisitObjCContainerDecl(PD); | |||
1182 | mergeRedeclarable(PD, Redecl); | |||
1183 | ||||
1184 | if (Record.readInt()) { | |||
1185 | // Read the definition. | |||
1186 | PD->allocateDefinitionData(); | |||
1187 | ||||
1188 | ReadObjCDefinitionData(PD->data()); | |||
1189 | ||||
1190 | ObjCProtocolDecl *Canon = PD->getCanonicalDecl(); | |||
1191 | if (Canon->Data.getPointer()) { | |||
1192 | // If we already have a definition, keep the definition invariant and | |||
1193 | // merge the data. | |||
1194 | MergeDefinitionData(Canon, std::move(PD->data())); | |||
1195 | PD->Data = Canon->Data; | |||
1196 | } else { | |||
1197 | // Set the definition data of the canonical declaration, so other | |||
1198 | // redeclarations will see it. | |||
1199 | PD->getCanonicalDecl()->Data = PD->Data; | |||
1200 | } | |||
1201 | // Note that we have deserialized a definition. | |||
1202 | Reader.PendingDefinitions.insert(PD); | |||
1203 | } else { | |||
1204 | PD->Data = PD->getCanonicalDecl()->Data; | |||
1205 | } | |||
1206 | } | |||
1207 | ||||
1208 | void ASTDeclReader::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) { | |||
1209 | VisitFieldDecl(FD); | |||
1210 | } | |||
1211 | ||||
1212 | void ASTDeclReader::VisitObjCCategoryDecl(ObjCCategoryDecl *CD) { | |||
1213 | VisitObjCContainerDecl(CD); | |||
1214 | CD->setCategoryNameLoc(ReadSourceLocation()); | |||
1215 | CD->setIvarLBraceLoc(ReadSourceLocation()); | |||
1216 | CD->setIvarRBraceLoc(ReadSourceLocation()); | |||
1217 | ||||
1218 | // Note that this category has been deserialized. We do this before | |||
1219 | // deserializing the interface declaration, so that it will consider this | |||
1220 | /// category. | |||
1221 | Reader.CategoriesDeserialized.insert(CD); | |||
1222 | ||||
1223 | CD->ClassInterface = ReadDeclAs<ObjCInterfaceDecl>(); | |||
1224 | CD->TypeParamList = ReadObjCTypeParamList(); | |||
1225 | unsigned NumProtoRefs = Record.readInt(); | |||
1226 | SmallVector<ObjCProtocolDecl *, 16> ProtoRefs; | |||
1227 | ProtoRefs.reserve(NumProtoRefs); | |||
1228 | for (unsigned I = 0; I != NumProtoRefs; ++I) | |||
1229 | ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>()); | |||
1230 | SmallVector<SourceLocation, 16> ProtoLocs; | |||
1231 | ProtoLocs.reserve(NumProtoRefs); | |||
1232 | for (unsigned I = 0; I != NumProtoRefs; ++I) | |||
1233 | ProtoLocs.push_back(ReadSourceLocation()); | |||
1234 | CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), | |||
1235 | Reader.getContext()); | |||
1236 | ||||
1237 | // Protocols in the class extension belong to the class. | |||
1238 | if (NumProtoRefs > 0 && CD->ClassInterface && CD->IsClassExtension()) | |||
1239 | CD->ClassInterface->mergeClassExtensionProtocolList( | |||
1240 | (ObjCProtocolDecl *const *)ProtoRefs.data(), NumProtoRefs, | |||
1241 | Reader.getContext()); | |||
1242 | } | |||
1243 | ||||
1244 | void ASTDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) { | |||
1245 | VisitNamedDecl(CAD); | |||
1246 | CAD->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>()); | |||
1247 | } | |||
1248 | ||||
1249 | void ASTDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { | |||
1250 | VisitNamedDecl(D); | |||
1251 | D->setAtLoc(ReadSourceLocation()); | |||
1252 | D->setLParenLoc(ReadSourceLocation()); | |||
1253 | QualType T = Record.readType(); | |||
1254 | TypeSourceInfo *TSI = GetTypeSourceInfo(); | |||
1255 | D->setType(T, TSI); | |||
1256 | D->setPropertyAttributes( | |||
1257 | (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt()); | |||
1258 | D->setPropertyAttributesAsWritten( | |||
1259 | (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt()); | |||
1260 | D->setPropertyImplementation( | |||
1261 | (ObjCPropertyDecl::PropertyControl)Record.readInt()); | |||
1262 | DeclarationName GetterName = Record.readDeclarationName(); | |||
1263 | SourceLocation GetterLoc = ReadSourceLocation(); | |||
1264 | D->setGetterName(GetterName.getObjCSelector(), GetterLoc); | |||
1265 | DeclarationName SetterName = Record.readDeclarationName(); | |||
1266 | SourceLocation SetterLoc = ReadSourceLocation(); | |||
1267 | D->setSetterName(SetterName.getObjCSelector(), SetterLoc); | |||
1268 | D->setGetterMethodDecl(ReadDeclAs<ObjCMethodDecl>()); | |||
1269 | D->setSetterMethodDecl(ReadDeclAs<ObjCMethodDecl>()); | |||
1270 | D->setPropertyIvarDecl(ReadDeclAs<ObjCIvarDecl>()); | |||
1271 | } | |||
1272 | ||||
1273 | void ASTDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) { | |||
1274 | VisitObjCContainerDecl(D); | |||
1275 | D->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>()); | |||
1276 | } | |||
1277 | ||||
1278 | void ASTDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { | |||
1279 | VisitObjCImplDecl(D); | |||
1280 | D->CategoryNameLoc = ReadSourceLocation(); | |||
1281 | } | |||
1282 | ||||
1283 | void ASTDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { | |||
1284 | VisitObjCImplDecl(D); | |||
1285 | D->setSuperClass(ReadDeclAs<ObjCInterfaceDecl>()); | |||
1286 | D->SuperLoc = ReadSourceLocation(); | |||
1287 | D->setIvarLBraceLoc(ReadSourceLocation()); | |||
1288 | D->setIvarRBraceLoc(ReadSourceLocation()); | |||
1289 | D->setHasNonZeroConstructors(Record.readInt()); | |||
1290 | D->setHasDestructors(Record.readInt()); | |||
1291 | D->NumIvarInitializers = Record.readInt(); | |||
1292 | if (D->NumIvarInitializers) | |||
1293 | D->IvarInitializers = ReadGlobalOffset(); | |||
1294 | } | |||
1295 | ||||
1296 | void ASTDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { | |||
1297 | VisitDecl(D); | |||
1298 | D->setAtLoc(ReadSourceLocation()); | |||
1299 | D->setPropertyDecl(ReadDeclAs<ObjCPropertyDecl>()); | |||
1300 | D->PropertyIvarDecl = ReadDeclAs<ObjCIvarDecl>(); | |||
1301 | D->IvarLoc = ReadSourceLocation(); | |||
1302 | D->setGetterCXXConstructor(Record.readExpr()); | |||
1303 | D->setSetterCXXAssignment(Record.readExpr()); | |||
1304 | } | |||
1305 | ||||
1306 | void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) { | |||
1307 | VisitDeclaratorDecl(FD); | |||
1308 | FD->Mutable = Record.readInt(); | |||
1309 | ||||
1310 | if (auto ISK = static_cast<FieldDecl::InitStorageKind>(Record.readInt())) { | |||
1311 | FD->InitStorage.setInt(ISK); | |||
1312 | FD->InitStorage.setPointer(ISK == FieldDecl::ISK_CapturedVLAType | |||
1313 | ? Record.readType().getAsOpaquePtr() | |||
1314 | : Record.readExpr()); | |||
1315 | } | |||
1316 | ||||
1317 | if (auto *BW = Record.readExpr()) | |||
1318 | FD->setBitWidth(BW); | |||
1319 | ||||
1320 | if (!FD->getDeclName()) { | |||
1321 | if (auto *Tmpl = ReadDeclAs<FieldDecl>()) | |||
1322 | Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl); | |||
1323 | } | |||
1324 | mergeMergeable(FD); | |||
1325 | } | |||
1326 | ||||
1327 | void ASTDeclReader::VisitMSPropertyDecl(MSPropertyDecl *PD) { | |||
1328 | VisitDeclaratorDecl(PD); | |||
1329 | PD->GetterId = Record.getIdentifierInfo(); | |||
1330 | PD->SetterId = Record.getIdentifierInfo(); | |||
1331 | } | |||
1332 | ||||
1333 | void ASTDeclReader::VisitIndirectFieldDecl(IndirectFieldDecl *FD) { | |||
1334 | VisitValueDecl(FD); | |||
1335 | ||||
1336 | FD->ChainingSize = Record.readInt(); | |||
1337 | assert(FD->ChainingSize >= 2 && "Anonymous chaining must be >= 2")(static_cast <bool> (FD->ChainingSize >= 2 && "Anonymous chaining must be >= 2") ? void (0) : __assert_fail ("FD->ChainingSize >= 2 && \"Anonymous chaining must be >= 2\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 1337, __extension__ __PRETTY_FUNCTION__)); | |||
1338 | FD->Chaining = new (Reader.getContext())NamedDecl*[FD->ChainingSize]; | |||
1339 | ||||
1340 | for (unsigned I = 0; I != FD->ChainingSize; ++I) | |||
1341 | FD->Chaining[I] = ReadDeclAs<NamedDecl>(); | |||
1342 | ||||
1343 | mergeMergeable(FD); | |||
1344 | } | |||
1345 | ||||
1346 | ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) { | |||
1347 | RedeclarableResult Redecl = VisitRedeclarable(VD); | |||
1348 | VisitDeclaratorDecl(VD); | |||
1349 | ||||
1350 | VD->VarDeclBits.SClass = (StorageClass)Record.readInt(); | |||
1351 | VD->VarDeclBits.TSCSpec = Record.readInt(); | |||
1352 | VD->VarDeclBits.InitStyle = Record.readInt(); | |||
1353 | if (!isa<ParmVarDecl>(VD)) { | |||
1354 | VD->NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = | |||
1355 | Record.readInt(); | |||
1356 | VD->NonParmVarDeclBits.ExceptionVar = Record.readInt(); | |||
1357 | VD->NonParmVarDeclBits.NRVOVariable = Record.readInt(); | |||
1358 | VD->NonParmVarDeclBits.CXXForRangeDecl = Record.readInt(); | |||
1359 | VD->NonParmVarDeclBits.ObjCForDecl = Record.readInt(); | |||
1360 | VD->NonParmVarDeclBits.ARCPseudoStrong = Record.readInt(); | |||
1361 | VD->NonParmVarDeclBits.IsInline = Record.readInt(); | |||
1362 | VD->NonParmVarDeclBits.IsInlineSpecified = Record.readInt(); | |||
1363 | VD->NonParmVarDeclBits.IsConstexpr = Record.readInt(); | |||
1364 | VD->NonParmVarDeclBits.IsInitCapture = Record.readInt(); | |||
1365 | VD->NonParmVarDeclBits.PreviousDeclInSameBlockScope = Record.readInt(); | |||
1366 | VD->NonParmVarDeclBits.ImplicitParamKind = Record.readInt(); | |||
1367 | } | |||
1368 | auto VarLinkage = Linkage(Record.readInt()); | |||
1369 | VD->setCachedLinkage(VarLinkage); | |||
1370 | ||||
1371 | // Reconstruct the one piece of the IdentifierNamespace that we need. | |||
1372 | if (VD->getStorageClass() == SC_Extern && VarLinkage != NoLinkage && | |||
1373 | VD->getLexicalDeclContext()->isFunctionOrMethod()) | |||
1374 | VD->setLocalExternDecl(); | |||
1375 | ||||
1376 | if (uint64_t Val = Record.readInt()) { | |||
1377 | VD->setInit(Record.readExpr()); | |||
1378 | if (Val > 1) { // IsInitKnownICE = 1, IsInitNotICE = 2, IsInitICE = 3 | |||
1379 | EvaluatedStmt *Eval = VD->ensureEvaluatedStmt(); | |||
1380 | Eval->CheckedICE = true; | |||
1381 | Eval->IsICE = Val == 3; | |||
1382 | } | |||
1383 | } | |||
1384 | ||||
1385 | if (VD->getStorageDuration() == SD_Static && Record.readInt()) | |||
1386 | Reader.DefinitionSource[VD] = Loc.F->Kind == ModuleKind::MK_MainFile; | |||
1387 | ||||
1388 | enum VarKind { | |||
1389 | VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization | |||
1390 | }; | |||
1391 | switch ((VarKind)Record.readInt()) { | |||
1392 | case VarNotTemplate: | |||
1393 | // Only true variables (not parameters or implicit parameters) can be | |||
1394 | // merged; the other kinds are not really redeclarable at all. | |||
1395 | if (!isa<ParmVarDecl>(VD) && !isa<ImplicitParamDecl>(VD) && | |||
1396 | !isa<VarTemplateSpecializationDecl>(VD)) | |||
1397 | mergeRedeclarable(VD, Redecl); | |||
1398 | break; | |||
1399 | case VarTemplate: | |||
1400 | // Merged when we merge the template. | |||
1401 | VD->setDescribedVarTemplate(ReadDeclAs<VarTemplateDecl>()); | |||
1402 | break; | |||
1403 | case StaticDataMemberSpecialization: { // HasMemberSpecializationInfo. | |||
1404 | auto *Tmpl = ReadDeclAs<VarDecl>(); | |||
1405 | auto TSK = (TemplateSpecializationKind)Record.readInt(); | |||
1406 | SourceLocation POI = ReadSourceLocation(); | |||
1407 | Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI); | |||
1408 | mergeRedeclarable(VD, Redecl); | |||
1409 | break; | |||
1410 | } | |||
1411 | } | |||
1412 | ||||
1413 | return Redecl; | |||
1414 | } | |||
1415 | ||||
1416 | void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) { | |||
1417 | VisitVarDecl(PD); | |||
1418 | } | |||
1419 | ||||
1420 | void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) { | |||
1421 | VisitVarDecl(PD); | |||
1422 | unsigned isObjCMethodParam = Record.readInt(); | |||
1423 | unsigned scopeDepth = Record.readInt(); | |||
1424 | unsigned scopeIndex = Record.readInt(); | |||
1425 | unsigned declQualifier = Record.readInt(); | |||
1426 | if (isObjCMethodParam) { | |||
1427 | assert(scopeDepth == 0)(static_cast <bool> (scopeDepth == 0) ? void (0) : __assert_fail ("scopeDepth == 0", "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 1427, __extension__ __PRETTY_FUNCTION__)); | |||
1428 | PD->setObjCMethodScopeInfo(scopeIndex); | |||
1429 | PD->ParmVarDeclBits.ScopeDepthOrObjCQuals = declQualifier; | |||
1430 | } else { | |||
1431 | PD->setScopeInfo(scopeDepth, scopeIndex); | |||
1432 | } | |||
1433 | PD->ParmVarDeclBits.IsKNRPromoted = Record.readInt(); | |||
1434 | PD->ParmVarDeclBits.HasInheritedDefaultArg = Record.readInt(); | |||
1435 | if (Record.readInt()) // hasUninstantiatedDefaultArg. | |||
1436 | PD->setUninstantiatedDefaultArg(Record.readExpr()); | |||
1437 | ||||
1438 | // FIXME: If this is a redeclaration of a function from another module, handle | |||
1439 | // inheritance of default arguments. | |||
1440 | } | |||
1441 | ||||
1442 | void ASTDeclReader::VisitDecompositionDecl(DecompositionDecl *DD) { | |||
1443 | VisitVarDecl(DD); | |||
1444 | auto **BDs = DD->getTrailingObjects<BindingDecl *>(); | |||
1445 | for (unsigned I = 0; I != DD->NumBindings; ++I) | |||
1446 | BDs[I] = ReadDeclAs<BindingDecl>(); | |||
1447 | } | |||
1448 | ||||
1449 | void ASTDeclReader::VisitBindingDecl(BindingDecl *BD) { | |||
1450 | VisitValueDecl(BD); | |||
1451 | BD->Binding = Record.readExpr(); | |||
1452 | } | |||
1453 | ||||
1454 | void ASTDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) { | |||
1455 | VisitDecl(AD); | |||
1456 | AD->setAsmString(cast<StringLiteral>(Record.readExpr())); | |||
1457 | AD->setRParenLoc(ReadSourceLocation()); | |||
1458 | } | |||
1459 | ||||
1460 | void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) { | |||
1461 | VisitDecl(BD); | |||
1462 | BD->setBody(cast_or_null<CompoundStmt>(Record.readStmt())); | |||
1463 | BD->setSignatureAsWritten(GetTypeSourceInfo()); | |||
1464 | unsigned NumParams = Record.readInt(); | |||
1465 | SmallVector<ParmVarDecl *, 16> Params; | |||
1466 | Params.reserve(NumParams); | |||
1467 | for (unsigned I = 0; I != NumParams; ++I) | |||
1468 | Params.push_back(ReadDeclAs<ParmVarDecl>()); | |||
1469 | BD->setParams(Params); | |||
1470 | ||||
1471 | BD->setIsVariadic(Record.readInt()); | |||
1472 | BD->setBlockMissingReturnType(Record.readInt()); | |||
1473 | BD->setIsConversionFromLambda(Record.readInt()); | |||
1474 | ||||
1475 | bool capturesCXXThis = Record.readInt(); | |||
1476 | unsigned numCaptures = Record.readInt(); | |||
1477 | SmallVector<BlockDecl::Capture, 16> captures; | |||
1478 | captures.reserve(numCaptures); | |||
1479 | for (unsigned i = 0; i != numCaptures; ++i) { | |||
1480 | auto *decl = ReadDeclAs<VarDecl>(); | |||
1481 | unsigned flags = Record.readInt(); | |||
1482 | bool byRef = (flags & 1); | |||
1483 | bool nested = (flags & 2); | |||
1484 | Expr *copyExpr = ((flags & 4) ? Record.readExpr() : nullptr); | |||
1485 | ||||
1486 | captures.push_back(BlockDecl::Capture(decl, byRef, nested, copyExpr)); | |||
1487 | } | |||
1488 | BD->setCaptures(Reader.getContext(), captures, capturesCXXThis); | |||
1489 | } | |||
1490 | ||||
1491 | void ASTDeclReader::VisitCapturedDecl(CapturedDecl *CD) { | |||
1492 | VisitDecl(CD); | |||
1493 | unsigned ContextParamPos = Record.readInt(); | |||
1494 | CD->setNothrow(Record.readInt() != 0); | |||
1495 | // Body is set by VisitCapturedStmt. | |||
1496 | for (unsigned I = 0; I < CD->NumParams; ++I) { | |||
1497 | if (I != ContextParamPos) | |||
1498 | CD->setParam(I, ReadDeclAs<ImplicitParamDecl>()); | |||
1499 | else | |||
1500 | CD->setContextParam(I, ReadDeclAs<ImplicitParamDecl>()); | |||
1501 | } | |||
1502 | } | |||
1503 | ||||
1504 | void ASTDeclReader::VisitLinkageSpecDecl(LinkageSpecDecl *D) { | |||
1505 | VisitDecl(D); | |||
1506 | D->setLanguage((LinkageSpecDecl::LanguageIDs)Record.readInt()); | |||
1507 | D->setExternLoc(ReadSourceLocation()); | |||
1508 | D->setRBraceLoc(ReadSourceLocation()); | |||
1509 | } | |||
1510 | ||||
1511 | void ASTDeclReader::VisitExportDecl(ExportDecl *D) { | |||
1512 | VisitDecl(D); | |||
1513 | D->RBraceLoc = ReadSourceLocation(); | |||
1514 | } | |||
1515 | ||||
1516 | void ASTDeclReader::VisitLabelDecl(LabelDecl *D) { | |||
1517 | VisitNamedDecl(D); | |||
1518 | D->setLocStart(ReadSourceLocation()); | |||
1519 | } | |||
1520 | ||||
1521 | void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) { | |||
1522 | RedeclarableResult Redecl = VisitRedeclarable(D); | |||
1523 | VisitNamedDecl(D); | |||
1524 | D->setInline(Record.readInt()); | |||
1525 | D->LocStart = ReadSourceLocation(); | |||
1526 | D->RBraceLoc = ReadSourceLocation(); | |||
1527 | ||||
1528 | // Defer loading the anonymous namespace until we've finished merging | |||
1529 | // this namespace; loading it might load a later declaration of the | |||
1530 | // same namespace, and we have an invariant that older declarations | |||
1531 | // get merged before newer ones try to merge. | |||
1532 | GlobalDeclID AnonNamespace = 0; | |||
1533 | if (Redecl.getFirstID() == ThisDeclID) { | |||
1534 | AnonNamespace = ReadDeclID(); | |||
1535 | } else { | |||
1536 | // Link this namespace back to the first declaration, which has already | |||
1537 | // been deserialized. | |||
1538 | D->AnonOrFirstNamespaceAndInline.setPointer(D->getFirstDecl()); | |||
1539 | } | |||
1540 | ||||
1541 | mergeRedeclarable(D, Redecl); | |||
1542 | ||||
1543 | if (AnonNamespace) { | |||
1544 | // Each module has its own anonymous namespace, which is disjoint from | |||
1545 | // any other module's anonymous namespaces, so don't attach the anonymous | |||
1546 | // namespace at all. | |||
1547 | auto *Anon = cast<NamespaceDecl>(Reader.GetDecl(AnonNamespace)); | |||
1548 | if (!Record.isModule()) | |||
1549 | D->setAnonymousNamespace(Anon); | |||
1550 | } | |||
1551 | } | |||
1552 | ||||
1553 | void ASTDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { | |||
1554 | RedeclarableResult Redecl = VisitRedeclarable(D); | |||
1555 | VisitNamedDecl(D); | |||
1556 | D->NamespaceLoc = ReadSourceLocation(); | |||
1557 | D->IdentLoc = ReadSourceLocation(); | |||
1558 | D->QualifierLoc = Record.readNestedNameSpecifierLoc(); | |||
1559 | D->Namespace = ReadDeclAs<NamedDecl>(); | |||
1560 | mergeRedeclarable(D, Redecl); | |||
1561 | } | |||
1562 | ||||
1563 | void ASTDeclReader::VisitUsingDecl(UsingDecl *D) { | |||
1564 | VisitNamedDecl(D); | |||
1565 | D->setUsingLoc(ReadSourceLocation()); | |||
1566 | D->QualifierLoc = Record.readNestedNameSpecifierLoc(); | |||
1567 | ReadDeclarationNameLoc(D->DNLoc, D->getDeclName()); | |||
1568 | D->FirstUsingShadow.setPointer(ReadDeclAs<UsingShadowDecl>()); | |||
1569 | D->setTypename(Record.readInt()); | |||
1570 | if (auto *Pattern = ReadDeclAs<NamedDecl>()) | |||
1571 | Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern); | |||
1572 | mergeMergeable(D); | |||
1573 | } | |||
1574 | ||||
1575 | void ASTDeclReader::VisitUsingPackDecl(UsingPackDecl *D) { | |||
1576 | VisitNamedDecl(D); | |||
1577 | D->InstantiatedFrom = ReadDeclAs<NamedDecl>(); | |||
1578 | auto **Expansions = D->getTrailingObjects<NamedDecl *>(); | |||
1579 | for (unsigned I = 0; I != D->NumExpansions; ++I) | |||
1580 | Expansions[I] = ReadDeclAs<NamedDecl>(); | |||
1581 | mergeMergeable(D); | |||
1582 | } | |||
1583 | ||||
1584 | void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) { | |||
1585 | RedeclarableResult Redecl = VisitRedeclarable(D); | |||
1586 | VisitNamedDecl(D); | |||
1587 | D->Underlying = ReadDeclAs<NamedDecl>(); | |||
1588 | D->IdentifierNamespace = Record.readInt(); | |||
1589 | D->UsingOrNextShadow = ReadDeclAs<NamedDecl>(); | |||
1590 | auto *Pattern = ReadDeclAs<UsingShadowDecl>(); | |||
1591 | if (Pattern) | |||
1592 | Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern); | |||
1593 | mergeRedeclarable(D, Redecl); | |||
1594 | } | |||
1595 | ||||
1596 | void ASTDeclReader::VisitConstructorUsingShadowDecl( | |||
1597 | ConstructorUsingShadowDecl *D) { | |||
1598 | VisitUsingShadowDecl(D); | |||
1599 | D->NominatedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>(); | |||
1600 | D->ConstructedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>(); | |||
1601 | D->IsVirtual = Record.readInt(); | |||
1602 | } | |||
1603 | ||||
1604 | void ASTDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { | |||
1605 | VisitNamedDecl(D); | |||
1606 | D->UsingLoc = ReadSourceLocation(); | |||
1607 | D->NamespaceLoc = ReadSourceLocation(); | |||
1608 | D->QualifierLoc = Record.readNestedNameSpecifierLoc(); | |||
1609 | D->NominatedNamespace = ReadDeclAs<NamedDecl>(); | |||
1610 | D->CommonAncestor = ReadDeclAs<DeclContext>(); | |||
1611 | } | |||
1612 | ||||
1613 | void ASTDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { | |||
1614 | VisitValueDecl(D); | |||
1615 | D->setUsingLoc(ReadSourceLocation()); | |||
1616 | D->QualifierLoc = Record.readNestedNameSpecifierLoc(); | |||
1617 | ReadDeclarationNameLoc(D->DNLoc, D->getDeclName()); | |||
1618 | D->EllipsisLoc = ReadSourceLocation(); | |||
1619 | mergeMergeable(D); | |||
1620 | } | |||
1621 | ||||
1622 | void ASTDeclReader::VisitUnresolvedUsingTypenameDecl( | |||
1623 | UnresolvedUsingTypenameDecl *D) { | |||
1624 | VisitTypeDecl(D); | |||
1625 | D->TypenameLocation = ReadSourceLocation(); | |||
1626 | D->QualifierLoc = Record.readNestedNameSpecifierLoc(); | |||
1627 | D->EllipsisLoc = ReadSourceLocation(); | |||
1628 | mergeMergeable(D); | |||
1629 | } | |||
1630 | ||||
1631 | void ASTDeclReader::ReadCXXDefinitionData( | |||
1632 | struct CXXRecordDecl::DefinitionData &Data, const CXXRecordDecl *D) { | |||
1633 | // Note: the caller has deserialized the IsLambda bit already. | |||
1634 | Data.UserDeclaredConstructor = Record.readInt(); | |||
1635 | Data.UserDeclaredSpecialMembers = Record.readInt(); | |||
1636 | Data.Aggregate = Record.readInt(); | |||
1637 | Data.PlainOldData = Record.readInt(); | |||
1638 | Data.Empty = Record.readInt(); | |||
1639 | Data.Polymorphic = Record.readInt(); | |||
1640 | Data.Abstract = Record.readInt(); | |||
1641 | Data.IsStandardLayout = Record.readInt(); | |||
1642 | Data.IsCXX11StandardLayout = Record.readInt(); | |||
1643 | Data.HasBasesWithFields = Record.readInt(); | |||
1644 | Data.HasBasesWithNonStaticDataMembers = Record.readInt(); | |||
1645 | Data.HasPrivateFields = Record.readInt(); | |||
1646 | Data.HasProtectedFields = Record.readInt(); | |||
1647 | Data.HasPublicFields = Record.readInt(); | |||
1648 | Data.HasMutableFields = Record.readInt(); | |||
1649 | Data.HasVariantMembers = Record.readInt(); | |||
1650 | Data.HasOnlyCMembers = Record.readInt(); | |||
1651 | Data.HasInClassInitializer = Record.readInt(); | |||
1652 | Data.HasUninitializedReferenceMember = Record.readInt(); | |||
1653 | Data.HasUninitializedFields = Record.readInt(); | |||
1654 | Data.HasInheritedConstructor = Record.readInt(); | |||
1655 | Data.HasInheritedAssignment = Record.readInt(); | |||
1656 | Data.NeedOverloadResolutionForCopyConstructor = Record.readInt(); | |||
1657 | Data.NeedOverloadResolutionForMoveConstructor = Record.readInt(); | |||
1658 | Data.NeedOverloadResolutionForMoveAssignment = Record.readInt(); | |||
1659 | Data.NeedOverloadResolutionForDestructor = Record.readInt(); | |||
1660 | Data.DefaultedCopyConstructorIsDeleted = Record.readInt(); | |||
1661 | Data.DefaultedMoveConstructorIsDeleted = Record.readInt(); | |||
1662 | Data.DefaultedMoveAssignmentIsDeleted = Record.readInt(); | |||
1663 | Data.DefaultedDestructorIsDeleted = Record.readInt(); | |||
1664 | Data.HasTrivialSpecialMembers = Record.readInt(); | |||
1665 | Data.HasTrivialSpecialMembersForCall = Record.readInt(); | |||
1666 | Data.DeclaredNonTrivialSpecialMembers = Record.readInt(); | |||
1667 | Data.DeclaredNonTrivialSpecialMembersForCall = Record.readInt(); | |||
1668 | Data.HasIrrelevantDestructor = Record.readInt(); | |||
1669 | Data.HasConstexprNonCopyMoveConstructor = Record.readInt(); | |||
1670 | Data.HasDefaultedDefaultConstructor = Record.readInt(); | |||
1671 | Data.DefaultedDefaultConstructorIsConstexpr = Record.readInt(); | |||
1672 | Data.HasConstexprDefaultConstructor = Record.readInt(); | |||
1673 | Data.HasNonLiteralTypeFieldsOrBases = Record.readInt(); | |||
1674 | Data.ComputedVisibleConversions = Record.readInt(); | |||
1675 | Data.UserProvidedDefaultConstructor = Record.readInt(); | |||
1676 | Data.DeclaredSpecialMembers = Record.readInt(); | |||
1677 | Data.ImplicitCopyConstructorCanHaveConstParamForVBase = Record.readInt(); | |||
1678 | Data.ImplicitCopyConstructorCanHaveConstParamForNonVBase = Record.readInt(); | |||
1679 | Data.ImplicitCopyAssignmentHasConstParam = Record.readInt(); | |||
1680 | Data.HasDeclaredCopyConstructorWithConstParam = Record.readInt(); | |||
1681 | Data.HasDeclaredCopyAssignmentWithConstParam = Record.readInt(); | |||
1682 | Data.ODRHash = Record.readInt(); | |||
1683 | Data.HasODRHash = true; | |||
1684 | ||||
1685 | if (Record.readInt()) | |||
1686 | Reader.DefinitionSource[D] = Loc.F->Kind == ModuleKind::MK_MainFile; | |||
1687 | ||||
1688 | Data.NumBases = Record.readInt(); | |||
1689 | if (Data.NumBases) | |||
1690 | Data.Bases = ReadGlobalOffset(); | |||
1691 | Data.NumVBases = Record.readInt(); | |||
1692 | if (Data.NumVBases) | |||
1693 | Data.VBases = ReadGlobalOffset(); | |||
1694 | ||||
1695 | Record.readUnresolvedSet(Data.Conversions); | |||
1696 | Record.readUnresolvedSet(Data.VisibleConversions); | |||
1697 | assert(Data.Definition && "Data.Definition should be already set!")(static_cast <bool> (Data.Definition && "Data.Definition should be already set!" ) ? void (0) : __assert_fail ("Data.Definition && \"Data.Definition should be already set!\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 1697, __extension__ __PRETTY_FUNCTION__)); | |||
1698 | Data.FirstFriend = ReadDeclID(); | |||
1699 | ||||
1700 | if (Data.IsLambda) { | |||
1701 | using Capture = LambdaCapture; | |||
1702 | ||||
1703 | auto &Lambda = static_cast<CXXRecordDecl::LambdaDefinitionData &>(Data); | |||
1704 | Lambda.Dependent = Record.readInt(); | |||
1705 | Lambda.IsGenericLambda = Record.readInt(); | |||
1706 | Lambda.CaptureDefault = Record.readInt(); | |||
1707 | Lambda.NumCaptures = Record.readInt(); | |||
1708 | Lambda.NumExplicitCaptures = Record.readInt(); | |||
1709 | Lambda.ManglingNumber = Record.readInt(); | |||
1710 | Lambda.ContextDecl = ReadDeclID(); | |||
1711 | Lambda.Captures = (Capture *)Reader.getContext().Allocate( | |||
1712 | sizeof(Capture) * Lambda.NumCaptures); | |||
1713 | Capture *ToCapture = Lambda.Captures; | |||
1714 | Lambda.MethodTyInfo = GetTypeSourceInfo(); | |||
1715 | for (unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) { | |||
1716 | SourceLocation Loc = ReadSourceLocation(); | |||
1717 | bool IsImplicit = Record.readInt(); | |||
1718 | auto Kind = static_cast<LambdaCaptureKind>(Record.readInt()); | |||
1719 | switch (Kind) { | |||
1720 | case LCK_StarThis: | |||
1721 | case LCK_This: | |||
1722 | case LCK_VLAType: | |||
1723 | *ToCapture++ = Capture(Loc, IsImplicit, Kind, nullptr,SourceLocation()); | |||
1724 | break; | |||
1725 | case LCK_ByCopy: | |||
1726 | case LCK_ByRef: | |||
1727 | auto *Var = ReadDeclAs<VarDecl>(); | |||
1728 | SourceLocation EllipsisLoc = ReadSourceLocation(); | |||
1729 | *ToCapture++ = Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc); | |||
1730 | break; | |||
1731 | } | |||
1732 | } | |||
1733 | } | |||
1734 | } | |||
1735 | ||||
1736 | void ASTDeclReader::MergeDefinitionData( | |||
1737 | CXXRecordDecl *D, struct CXXRecordDecl::DefinitionData &&MergeDD) { | |||
1738 | assert(D->DefinitionData &&(static_cast <bool> (D->DefinitionData && "merging class definition into non-definition" ) ? void (0) : __assert_fail ("D->DefinitionData && \"merging class definition into non-definition\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 1739, __extension__ __PRETTY_FUNCTION__)) | |||
1739 | "merging class definition into non-definition")(static_cast <bool> (D->DefinitionData && "merging class definition into non-definition" ) ? void (0) : __assert_fail ("D->DefinitionData && \"merging class definition into non-definition\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 1739, __extension__ __PRETTY_FUNCTION__)); | |||
1740 | auto &DD = *D->DefinitionData; | |||
1741 | ||||
1742 | if (DD.Definition != MergeDD.Definition) { | |||
1743 | // Track that we merged the definitions. | |||
1744 | Reader.MergedDeclContexts.insert(std::make_pair(MergeDD.Definition, | |||
1745 | DD.Definition)); | |||
1746 | Reader.PendingDefinitions.erase(MergeDD.Definition); | |||
1747 | MergeDD.Definition->IsCompleteDefinition = false; | |||
1748 | Reader.mergeDefinitionVisibility(DD.Definition, MergeDD.Definition); | |||
1749 | assert(Reader.Lookups.find(MergeDD.Definition) == Reader.Lookups.end() &&(static_cast <bool> (Reader.Lookups.find(MergeDD.Definition ) == Reader.Lookups.end() && "already loaded pending lookups for merged definition" ) ? void (0) : __assert_fail ("Reader.Lookups.find(MergeDD.Definition) == Reader.Lookups.end() && \"already loaded pending lookups for merged definition\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 1750, __extension__ __PRETTY_FUNCTION__)) | |||
1750 | "already loaded pending lookups for merged definition")(static_cast <bool> (Reader.Lookups.find(MergeDD.Definition ) == Reader.Lookups.end() && "already loaded pending lookups for merged definition" ) ? void (0) : __assert_fail ("Reader.Lookups.find(MergeDD.Definition) == Reader.Lookups.end() && \"already loaded pending lookups for merged definition\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 1750, __extension__ __PRETTY_FUNCTION__)); | |||
1751 | } | |||
1752 | ||||
1753 | auto PFDI = Reader.PendingFakeDefinitionData.find(&DD); | |||
1754 | if (PFDI != Reader.PendingFakeDefinitionData.end() && | |||
1755 | PFDI->second == ASTReader::PendingFakeDefinitionKind::Fake) { | |||
1756 | // We faked up this definition data because we found a class for which we'd | |||
1757 | // not yet loaded the definition. Replace it with the real thing now. | |||
1758 | assert(!DD.IsLambda && !MergeDD.IsLambda && "faked up lambda definition?")(static_cast <bool> (!DD.IsLambda && !MergeDD.IsLambda && "faked up lambda definition?") ? void (0) : __assert_fail ("!DD.IsLambda && !MergeDD.IsLambda && \"faked up lambda definition?\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 1758, __extension__ __PRETTY_FUNCTION__)); | |||
1759 | PFDI->second = ASTReader::PendingFakeDefinitionKind::FakeLoaded; | |||
1760 | ||||
1761 | // Don't change which declaration is the definition; that is required | |||
1762 | // to be invariant once we select it. | |||
1763 | auto *Def = DD.Definition; | |||
1764 | DD = std::move(MergeDD); | |||
1765 | DD.Definition = Def; | |||
1766 | return; | |||
1767 | } | |||
1768 | ||||
1769 | // FIXME: Move this out into a .def file? | |||
1770 | bool DetectedOdrViolation = false; | |||
1771 | #define OR_FIELD(Field) DD.Field |= MergeDD.Field; | |||
1772 | #define MATCH_FIELD(Field) \ | |||
1773 | DetectedOdrViolation |= DD.Field != MergeDD.Field; \ | |||
1774 | OR_FIELD(Field) | |||
1775 | MATCH_FIELD(UserDeclaredConstructor) | |||
1776 | MATCH_FIELD(UserDeclaredSpecialMembers) | |||
1777 | MATCH_FIELD(Aggregate) | |||
1778 | MATCH_FIELD(PlainOldData) | |||
1779 | MATCH_FIELD(Empty) | |||
1780 | MATCH_FIELD(Polymorphic) | |||
1781 | MATCH_FIELD(Abstract) | |||
1782 | MATCH_FIELD(IsStandardLayout) | |||
1783 | MATCH_FIELD(IsCXX11StandardLayout) | |||
1784 | MATCH_FIELD(HasBasesWithFields) | |||
1785 | MATCH_FIELD(HasBasesWithNonStaticDataMembers) | |||
1786 | MATCH_FIELD(HasPrivateFields) | |||
1787 | MATCH_FIELD(HasProtectedFields) | |||
1788 | MATCH_FIELD(HasPublicFields) | |||
1789 | MATCH_FIELD(HasMutableFields) | |||
1790 | MATCH_FIELD(HasVariantMembers) | |||
1791 | MATCH_FIELD(HasOnlyCMembers) | |||
1792 | MATCH_FIELD(HasInClassInitializer) | |||
1793 | MATCH_FIELD(HasUninitializedReferenceMember) | |||
1794 | MATCH_FIELD(HasUninitializedFields) | |||
1795 | MATCH_FIELD(HasInheritedConstructor) | |||
1796 | MATCH_FIELD(HasInheritedAssignment) | |||
1797 | MATCH_FIELD(NeedOverloadResolutionForCopyConstructor) | |||
1798 | MATCH_FIELD(NeedOverloadResolutionForMoveConstructor) | |||
1799 | MATCH_FIELD(NeedOverloadResolutionForMoveAssignment) | |||
1800 | MATCH_FIELD(NeedOverloadResolutionForDestructor) | |||
1801 | MATCH_FIELD(DefaultedCopyConstructorIsDeleted) | |||
1802 | MATCH_FIELD(DefaultedMoveConstructorIsDeleted) | |||
1803 | MATCH_FIELD(DefaultedMoveAssignmentIsDeleted) | |||
1804 | MATCH_FIELD(DefaultedDestructorIsDeleted) | |||
1805 | OR_FIELD(HasTrivialSpecialMembers) | |||
1806 | OR_FIELD(HasTrivialSpecialMembersForCall) | |||
1807 | OR_FIELD(DeclaredNonTrivialSpecialMembers) | |||
1808 | OR_FIELD(DeclaredNonTrivialSpecialMembersForCall) | |||
1809 | MATCH_FIELD(HasIrrelevantDestructor) | |||
1810 | OR_FIELD(HasConstexprNonCopyMoveConstructor) | |||
1811 | OR_FIELD(HasDefaultedDefaultConstructor) | |||
1812 | MATCH_FIELD(DefaultedDefaultConstructorIsConstexpr) | |||
1813 | OR_FIELD(HasConstexprDefaultConstructor) | |||
1814 | MATCH_FIELD(HasNonLiteralTypeFieldsOrBases) | |||
1815 | // ComputedVisibleConversions is handled below. | |||
1816 | MATCH_FIELD(UserProvidedDefaultConstructor) | |||
1817 | OR_FIELD(DeclaredSpecialMembers) | |||
1818 | MATCH_FIELD(ImplicitCopyConstructorCanHaveConstParamForVBase) | |||
1819 | MATCH_FIELD(ImplicitCopyConstructorCanHaveConstParamForNonVBase) | |||
1820 | MATCH_FIELD(ImplicitCopyAssignmentHasConstParam) | |||
1821 | OR_FIELD(HasDeclaredCopyConstructorWithConstParam) | |||
1822 | OR_FIELD(HasDeclaredCopyAssignmentWithConstParam) | |||
1823 | MATCH_FIELD(IsLambda) | |||
1824 | #undef OR_FIELD | |||
1825 | #undef MATCH_FIELD | |||
1826 | ||||
1827 | if (DD.NumBases != MergeDD.NumBases || DD.NumVBases != MergeDD.NumVBases) | |||
1828 | DetectedOdrViolation = true; | |||
1829 | // FIXME: Issue a diagnostic if the base classes don't match when we come | |||
1830 | // to lazily load them. | |||
1831 | ||||
1832 | // FIXME: Issue a diagnostic if the list of conversion functions doesn't | |||
1833 | // match when we come to lazily load them. | |||
1834 | if (MergeDD.ComputedVisibleConversions && !DD.ComputedVisibleConversions) { | |||
1835 | DD.VisibleConversions = std::move(MergeDD.VisibleConversions); | |||
1836 | DD.ComputedVisibleConversions = true; | |||
1837 | } | |||
1838 | ||||
1839 | // FIXME: Issue a diagnostic if FirstFriend doesn't match when we come to | |||
1840 | // lazily load it. | |||
1841 | ||||
1842 | if (DD.IsLambda) { | |||
1843 | // FIXME: ODR-checking for merging lambdas (this happens, for instance, | |||
1844 | // when they occur within the body of a function template specialization). | |||
1845 | } | |||
1846 | ||||
1847 | if (D->getODRHash() != MergeDD.ODRHash) { | |||
1848 | DetectedOdrViolation = true; | |||
1849 | } | |||
1850 | ||||
1851 | if (DetectedOdrViolation) | |||
1852 | Reader.PendingOdrMergeFailures[DD.Definition].push_back( | |||
1853 | {MergeDD.Definition, &MergeDD}); | |||
1854 | } | |||
1855 | ||||
1856 | void ASTDeclReader::ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update) { | |||
1857 | struct CXXRecordDecl::DefinitionData *DD; | |||
1858 | ASTContext &C = Reader.getContext(); | |||
1859 | ||||
1860 | // Determine whether this is a lambda closure type, so that we can | |||
1861 | // allocate the appropriate DefinitionData structure. | |||
1862 | bool IsLambda = Record.readInt(); | |||
1863 | if (IsLambda) | |||
1864 | DD = new (C) CXXRecordDecl::LambdaDefinitionData(D, nullptr, false, false, | |||
1865 | LCD_None); | |||
1866 | else | |||
1867 | DD = new (C) struct CXXRecordDecl::DefinitionData(D); | |||
1868 | ||||
1869 | CXXRecordDecl *Canon = D->getCanonicalDecl(); | |||
1870 | // Set decl definition data before reading it, so that during deserialization | |||
1871 | // when we read CXXRecordDecl, it already has definition data and we don't | |||
1872 | // set fake one. | |||
1873 | if (!Canon->DefinitionData) | |||
1874 | Canon->DefinitionData = DD; | |||
1875 | D->DefinitionData = Canon->DefinitionData; | |||
1876 | ReadCXXDefinitionData(*DD, D); | |||
1877 | ||||
1878 | // We might already have a different definition for this record. This can | |||
1879 | // happen either because we're reading an update record, or because we've | |||
1880 | // already done some merging. Either way, just merge into it. | |||
1881 | if (Canon->DefinitionData != DD) { | |||
1882 | MergeDefinitionData(Canon, std::move(*DD)); | |||
1883 | return; | |||
1884 | } | |||
1885 | ||||
1886 | // Mark this declaration as being a definition. | |||
1887 | D->IsCompleteDefinition = true; | |||
1888 | ||||
1889 | // If this is not the first declaration or is an update record, we can have | |||
1890 | // other redeclarations already. Make a note that we need to propagate the | |||
1891 | // DefinitionData pointer onto them. | |||
1892 | if (Update || Canon != D) | |||
1893 | Reader.PendingDefinitions.insert(D); | |||
1894 | } | |||
1895 | ||||
1896 | ASTDeclReader::RedeclarableResult | |||
1897 | ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) { | |||
1898 | RedeclarableResult Redecl = VisitRecordDeclImpl(D); | |||
1899 | ||||
1900 | ASTContext &C = Reader.getContext(); | |||
1901 | ||||
1902 | enum CXXRecKind { | |||
1903 | CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization | |||
1904 | }; | |||
1905 | switch ((CXXRecKind)Record.readInt()) { | |||
1906 | case CXXRecNotTemplate: | |||
1907 | // Merged when we merge the folding set entry in the primary template. | |||
1908 | if (!isa<ClassTemplateSpecializationDecl>(D)) | |||
1909 | mergeRedeclarable(D, Redecl); | |||
1910 | break; | |||
1911 | case CXXRecTemplate: { | |||
1912 | // Merged when we merge the template. | |||
1913 | auto *Template = ReadDeclAs<ClassTemplateDecl>(); | |||
1914 | D->TemplateOrInstantiation = Template; | |||
1915 | if (!Template->getTemplatedDecl()) { | |||
1916 | // We've not actually loaded the ClassTemplateDecl yet, because we're | |||
1917 | // currently being loaded as its pattern. Rely on it to set up our | |||
1918 | // TypeForDecl (see VisitClassTemplateDecl). | |||
1919 | // | |||
1920 | // Beware: we do not yet know our canonical declaration, and may still | |||
1921 | // get merged once the surrounding class template has got off the ground. | |||
1922 | DeferredTypeID = 0; | |||
1923 | } | |||
1924 | break; | |||
1925 | } | |||
1926 | case CXXRecMemberSpecialization: { | |||
1927 | auto *RD = ReadDeclAs<CXXRecordDecl>(); | |||
1928 | auto TSK = (TemplateSpecializationKind)Record.readInt(); | |||
1929 | SourceLocation POI = ReadSourceLocation(); | |||
1930 | MemberSpecializationInfo *MSI = new (C) MemberSpecializationInfo(RD, TSK); | |||
1931 | MSI->setPointOfInstantiation(POI); | |||
1932 | D->TemplateOrInstantiation = MSI; | |||
1933 | mergeRedeclarable(D, Redecl); | |||
1934 | break; | |||
1935 | } | |||
1936 | } | |||
1937 | ||||
1938 | bool WasDefinition = Record.readInt(); | |||
1939 | if (WasDefinition) | |||
1940 | ReadCXXRecordDefinition(D, /*Update*/false); | |||
1941 | else | |||
1942 | // Propagate DefinitionData pointer from the canonical declaration. | |||
1943 | D->DefinitionData = D->getCanonicalDecl()->DefinitionData; | |||
1944 | ||||
1945 | // Lazily load the key function to avoid deserializing every method so we can | |||
1946 | // compute it. | |||
1947 | if (WasDefinition) { | |||
1948 | DeclID KeyFn = ReadDeclID(); | |||
1949 | if (KeyFn && D->IsCompleteDefinition) | |||
1950 | // FIXME: This is wrong for the ARM ABI, where some other module may have | |||
1951 | // made this function no longer be a key function. We need an update | |||
1952 | // record or similar for that case. | |||
1953 | C.KeyFunctions[D] = KeyFn; | |||
1954 | } | |||
1955 | ||||
1956 | return Redecl; | |||
1957 | } | |||
1958 | ||||
1959 | void ASTDeclReader::VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D) { | |||
1960 | VisitFunctionDecl(D); | |||
1961 | D->IsCopyDeductionCandidate = Record.readInt(); | |||
1962 | } | |||
1963 | ||||
1964 | void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) { | |||
1965 | VisitFunctionDecl(D); | |||
1966 | ||||
1967 | unsigned NumOverridenMethods = Record.readInt(); | |||
1968 | if (D->isCanonicalDecl()) { | |||
1969 | while (NumOverridenMethods--) { | |||
1970 | // Avoid invariant checking of CXXMethodDecl::addOverriddenMethod, | |||
1971 | // MD may be initializing. | |||
1972 | if (auto *MD = ReadDeclAs<CXXMethodDecl>()) | |||
1973 | Reader.getContext().addOverriddenMethod(D, MD->getCanonicalDecl()); | |||
1974 | } | |||
1975 | } else { | |||
1976 | // We don't care about which declarations this used to override; we get | |||
1977 | // the relevant information from the canonical declaration. | |||
1978 | Record.skipInts(NumOverridenMethods); | |||
1979 | } | |||
1980 | } | |||
1981 | ||||
1982 | void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) { | |||
1983 | // We need the inherited constructor information to merge the declaration, | |||
1984 | // so we have to read it before we call VisitCXXMethodDecl. | |||
1985 | if (D->isInheritingConstructor()) { | |||
1986 | auto *Shadow = ReadDeclAs<ConstructorUsingShadowDecl>(); | |||
1987 | auto *Ctor = ReadDeclAs<CXXConstructorDecl>(); | |||
1988 | *D->getTrailingObjects<InheritedConstructor>() = | |||
1989 | InheritedConstructor(Shadow, Ctor); | |||
1990 | } | |||
1991 | ||||
1992 | VisitCXXMethodDecl(D); | |||
1993 | } | |||
1994 | ||||
1995 | void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) { | |||
1996 | VisitCXXMethodDecl(D); | |||
1997 | ||||
1998 | if (auto *OperatorDelete = ReadDeclAs<FunctionDecl>()) { | |||
1999 | CXXDestructorDecl *Canon = D->getCanonicalDecl(); | |||
2000 | auto *ThisArg = Record.readExpr(); | |||
2001 | // FIXME: Check consistency if we have an old and new operator delete. | |||
2002 | if (!Canon->OperatorDelete) { | |||
2003 | Canon->OperatorDelete = OperatorDelete; | |||
2004 | Canon->OperatorDeleteThisArg = ThisArg; | |||
2005 | } | |||
2006 | } | |||
2007 | } | |||
2008 | ||||
2009 | void ASTDeclReader::VisitCXXConversionDecl(CXXConversionDecl *D) { | |||
2010 | VisitCXXMethodDecl(D); | |||
2011 | } | |||
2012 | ||||
2013 | void ASTDeclReader::VisitImportDecl(ImportDecl *D) { | |||
2014 | VisitDecl(D); | |||
2015 | D->ImportedAndComplete.setPointer(readModule()); | |||
2016 | D->ImportedAndComplete.setInt(Record.readInt()); | |||
2017 | auto *StoredLocs = D->getTrailingObjects<SourceLocation>(); | |||
2018 | for (unsigned I = 0, N = Record.back(); I != N; ++I) | |||
2019 | StoredLocs[I] = ReadSourceLocation(); | |||
2020 | Record.skipInts(1); // The number of stored source locations. | |||
2021 | } | |||
2022 | ||||
2023 | void ASTDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) { | |||
2024 | VisitDecl(D); | |||
2025 | D->setColonLoc(ReadSourceLocation()); | |||
2026 | } | |||
2027 | ||||
2028 | void ASTDeclReader::VisitFriendDecl(FriendDecl *D) { | |||
2029 | VisitDecl(D); | |||
2030 | if (Record.readInt()) // hasFriendDecl | |||
2031 | D->Friend = ReadDeclAs<NamedDecl>(); | |||
2032 | else | |||
2033 | D->Friend = GetTypeSourceInfo(); | |||
2034 | for (unsigned i = 0; i != D->NumTPLists; ++i) | |||
2035 | D->getTrailingObjects<TemplateParameterList *>()[i] = | |||
2036 | Record.readTemplateParameterList(); | |||
2037 | D->NextFriend = ReadDeclID(); | |||
2038 | D->UnsupportedFriend = (Record.readInt() != 0); | |||
2039 | D->FriendLoc = ReadSourceLocation(); | |||
2040 | } | |||
2041 | ||||
2042 | void ASTDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) { | |||
2043 | VisitDecl(D); | |||
2044 | unsigned NumParams = Record.readInt(); | |||
2045 | D->NumParams = NumParams; | |||
2046 | D->Params = new TemplateParameterList*[NumParams]; | |||
2047 | for (unsigned i = 0; i != NumParams; ++i) | |||
2048 | D->Params[i] = Record.readTemplateParameterList(); | |||
2049 | if (Record.readInt()) // HasFriendDecl | |||
2050 | D->Friend = ReadDeclAs<NamedDecl>(); | |||
2051 | else | |||
2052 | D->Friend = GetTypeSourceInfo(); | |||
2053 | D->FriendLoc = ReadSourceLocation(); | |||
2054 | } | |||
2055 | ||||
2056 | DeclID ASTDeclReader::VisitTemplateDecl(TemplateDecl *D) { | |||
2057 | VisitNamedDecl(D); | |||
2058 | ||||
2059 | DeclID PatternID = ReadDeclID(); | |||
2060 | auto *TemplatedDecl = cast_or_null<NamedDecl>(Reader.GetDecl(PatternID)); | |||
2061 | TemplateParameterList *TemplateParams = Record.readTemplateParameterList(); | |||
2062 | // FIXME handle associated constraints | |||
2063 | D->init(TemplatedDecl, TemplateParams); | |||
2064 | ||||
2065 | return PatternID; | |||
2066 | } | |||
2067 | ||||
2068 | ASTDeclReader::RedeclarableResult | |||
2069 | ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { | |||
2070 | RedeclarableResult Redecl = VisitRedeclarable(D); | |||
2071 | ||||
2072 | // Make sure we've allocated the Common pointer first. We do this before | |||
2073 | // VisitTemplateDecl so that getCommonPtr() can be used during initialization. | |||
2074 | RedeclarableTemplateDecl *CanonD = D->getCanonicalDecl(); | |||
2075 | if (!CanonD->Common) { | |||
2076 | CanonD->Common = CanonD->newCommon(Reader.getContext()); | |||
2077 | Reader.PendingDefinitions.insert(CanonD); | |||
2078 | } | |||
2079 | D->Common = CanonD->Common; | |||
2080 | ||||
2081 | // If this is the first declaration of the template, fill in the information | |||
2082 | // for the 'common' pointer. | |||
2083 | if (ThisDeclID == Redecl.getFirstID()) { | |||
2084 | if (auto *RTD = ReadDeclAs<RedeclarableTemplateDecl>()) { | |||
2085 | assert(RTD->getKind() == D->getKind() &&(static_cast <bool> (RTD->getKind() == D->getKind () && "InstantiatedFromMemberTemplate kind mismatch") ? void (0) : __assert_fail ("RTD->getKind() == D->getKind() && \"InstantiatedFromMemberTemplate kind mismatch\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 2086, __extension__ __PRETTY_FUNCTION__)) | |||
2086 | "InstantiatedFromMemberTemplate kind mismatch")(static_cast <bool> (RTD->getKind() == D->getKind () && "InstantiatedFromMemberTemplate kind mismatch") ? void (0) : __assert_fail ("RTD->getKind() == D->getKind() && \"InstantiatedFromMemberTemplate kind mismatch\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 2086, __extension__ __PRETTY_FUNCTION__)); | |||
2087 | D->setInstantiatedFromMemberTemplate(RTD); | |||
2088 | if (Record.readInt()) | |||
2089 | D->setMemberSpecialization(); | |||
2090 | } | |||
2091 | } | |||
2092 | ||||
2093 | DeclID PatternID = VisitTemplateDecl(D); | |||
2094 | D->IdentifierNamespace = Record.readInt(); | |||
2095 | ||||
2096 | mergeRedeclarable(D, Redecl, PatternID); | |||
2097 | ||||
2098 | // If we merged the template with a prior declaration chain, merge the common | |||
2099 | // pointer. | |||
2100 | // FIXME: Actually merge here, don't just overwrite. | |||
2101 | D->Common = D->getCanonicalDecl()->Common; | |||
2102 | ||||
2103 | return Redecl; | |||
2104 | } | |||
2105 | ||||
2106 | void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) { | |||
2107 | RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D); | |||
2108 | ||||
2109 | if (ThisDeclID == Redecl.getFirstID()) { | |||
2110 | // This ClassTemplateDecl owns a CommonPtr; read it to keep track of all of | |||
2111 | // the specializations. | |||
2112 | SmallVector<serialization::DeclID, 32> SpecIDs; | |||
2113 | ReadDeclIDList(SpecIDs); | |||
2114 | ASTDeclReader::AddLazySpecializations(D, SpecIDs); | |||
2115 | } | |||
2116 | ||||
2117 | if (D->getTemplatedDecl()->TemplateOrInstantiation) { | |||
2118 | // We were loaded before our templated declaration was. We've not set up | |||
2119 | // its corresponding type yet (see VisitCXXRecordDeclImpl), so reconstruct | |||
2120 | // it now. | |||
2121 | Reader.getContext().getInjectedClassNameType( | |||
2122 | D->getTemplatedDecl(), D->getInjectedClassNameSpecialization()); | |||
2123 | } | |||
2124 | } | |||
2125 | ||||
2126 | void ASTDeclReader::VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D) { | |||
2127 | llvm_unreachable("BuiltinTemplates are not serialized")::llvm::llvm_unreachable_internal("BuiltinTemplates are not serialized" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 2127); | |||
2128 | } | |||
2129 | ||||
2130 | /// TODO: Unify with ClassTemplateDecl version? | |||
2131 | /// May require unifying ClassTemplateDecl and | |||
2132 | /// VarTemplateDecl beyond TemplateDecl... | |||
2133 | void ASTDeclReader::VisitVarTemplateDecl(VarTemplateDecl *D) { | |||
2134 | RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D); | |||
2135 | ||||
2136 | if (ThisDeclID == Redecl.getFirstID()) { | |||
2137 | // This VarTemplateDecl owns a CommonPtr; read it to keep track of all of | |||
2138 | // the specializations. | |||
2139 | SmallVector<serialization::DeclID, 32> SpecIDs; | |||
2140 | ReadDeclIDList(SpecIDs); | |||
2141 | ASTDeclReader::AddLazySpecializations(D, SpecIDs); | |||
2142 | } | |||
2143 | } | |||
2144 | ||||
2145 | ASTDeclReader::RedeclarableResult | |||
2146 | ASTDeclReader::VisitClassTemplateSpecializationDeclImpl( | |||
2147 | ClassTemplateSpecializationDecl *D) { | |||
2148 | RedeclarableResult Redecl = VisitCXXRecordDeclImpl(D); | |||
2149 | ||||
2150 | ASTContext &C = Reader.getContext(); | |||
2151 | if (Decl *InstD = ReadDecl()) { | |||
2152 | if (auto *CTD = dyn_cast<ClassTemplateDecl>(InstD)) { | |||
2153 | D->SpecializedTemplate = CTD; | |||
2154 | } else { | |||
2155 | SmallVector<TemplateArgument, 8> TemplArgs; | |||
2156 | Record.readTemplateArgumentList(TemplArgs); | |||
2157 | TemplateArgumentList *ArgList | |||
2158 | = TemplateArgumentList::CreateCopy(C, TemplArgs); | |||
2159 | auto *PS = | |||
2160 | new (C) ClassTemplateSpecializationDecl:: | |||
2161 | SpecializedPartialSpecialization(); | |||
2162 | PS->PartialSpecialization | |||
2163 | = cast<ClassTemplatePartialSpecializationDecl>(InstD); | |||
2164 | PS->TemplateArgs = ArgList; | |||
2165 | D->SpecializedTemplate = PS; | |||
2166 | } | |||
2167 | } | |||
2168 | ||||
2169 | SmallVector<TemplateArgument, 8> TemplArgs; | |||
2170 | Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true); | |||
2171 | D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs); | |||
2172 | D->PointOfInstantiation = ReadSourceLocation(); | |||
2173 | D->SpecializationKind = (TemplateSpecializationKind)Record.readInt(); | |||
2174 | ||||
2175 | bool writtenAsCanonicalDecl = Record.readInt(); | |||
2176 | if (writtenAsCanonicalDecl) { | |||
2177 | auto *CanonPattern = ReadDeclAs<ClassTemplateDecl>(); | |||
2178 | if (D->isCanonicalDecl()) { // It's kept in the folding set. | |||
2179 | // Set this as, or find, the canonical declaration for this specialization | |||
2180 | ClassTemplateSpecializationDecl *CanonSpec; | |||
2181 | if (auto *Partial = dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) { | |||
2182 | CanonSpec = CanonPattern->getCommonPtr()->PartialSpecializations | |||
2183 | .GetOrInsertNode(Partial); | |||
2184 | } else { | |||
2185 | CanonSpec = | |||
2186 | CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D); | |||
2187 | } | |||
2188 | // If there was already a canonical specialization, merge into it. | |||
2189 | if (CanonSpec != D) { | |||
2190 | mergeRedeclarable<TagDecl>(D, CanonSpec, Redecl); | |||
2191 | ||||
2192 | // This declaration might be a definition. Merge with any existing | |||
2193 | // definition. | |||
2194 | if (auto *DDD = D->DefinitionData) { | |||
2195 | if (CanonSpec->DefinitionData) | |||
2196 | MergeDefinitionData(CanonSpec, std::move(*DDD)); | |||
2197 | else | |||
2198 | CanonSpec->DefinitionData = D->DefinitionData; | |||
2199 | } | |||
2200 | D->DefinitionData = CanonSpec->DefinitionData; | |||
2201 | } | |||
2202 | } | |||
2203 | } | |||
2204 | ||||
2205 | // Explicit info. | |||
2206 | if (TypeSourceInfo *TyInfo = GetTypeSourceInfo()) { | |||
2207 | auto *ExplicitInfo = | |||
2208 | new (C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo; | |||
2209 | ExplicitInfo->TypeAsWritten = TyInfo; | |||
2210 | ExplicitInfo->ExternLoc = ReadSourceLocation(); | |||
2211 | ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(); | |||
2212 | D->ExplicitInfo = ExplicitInfo; | |||
2213 | } | |||
2214 | ||||
2215 | return Redecl; | |||
2216 | } | |||
2217 | ||||
2218 | void ASTDeclReader::VisitClassTemplatePartialSpecializationDecl( | |||
2219 | ClassTemplatePartialSpecializationDecl *D) { | |||
2220 | RedeclarableResult Redecl = VisitClassTemplateSpecializationDeclImpl(D); | |||
2221 | ||||
2222 | D->TemplateParams = Record.readTemplateParameterList(); | |||
2223 | D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo(); | |||
2224 | ||||
2225 | // These are read/set from/to the first declaration. | |||
2226 | if (ThisDeclID == Redecl.getFirstID()) { | |||
2227 | D->InstantiatedFromMember.setPointer( | |||
2228 | ReadDeclAs<ClassTemplatePartialSpecializationDecl>()); | |||
2229 | D->InstantiatedFromMember.setInt(Record.readInt()); | |||
2230 | } | |||
2231 | } | |||
2232 | ||||
2233 | void ASTDeclReader::VisitClassScopeFunctionSpecializationDecl( | |||
2234 | ClassScopeFunctionSpecializationDecl *D) { | |||
2235 | VisitDecl(D); | |||
2236 | D->Specialization = ReadDeclAs<CXXMethodDecl>(); | |||
2237 | } | |||
2238 | ||||
2239 | void ASTDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { | |||
2240 | RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D); | |||
2241 | ||||
2242 | if (ThisDeclID == Redecl.getFirstID()) { | |||
2243 | // This FunctionTemplateDecl owns a CommonPtr; read it. | |||
2244 | SmallVector<serialization::DeclID, 32> SpecIDs; | |||
2245 | ReadDeclIDList(SpecIDs); | |||
2246 | ASTDeclReader::AddLazySpecializations(D, SpecIDs); | |||
2247 | } | |||
2248 | } | |||
2249 | ||||
2250 | /// TODO: Unify with ClassTemplateSpecializationDecl version? | |||
2251 | /// May require unifying ClassTemplate(Partial)SpecializationDecl and | |||
2252 | /// VarTemplate(Partial)SpecializationDecl with a new data | |||
2253 | /// structure Template(Partial)SpecializationDecl, and | |||
2254 | /// using Template(Partial)SpecializationDecl as input type. | |||
2255 | ASTDeclReader::RedeclarableResult | |||
2256 | ASTDeclReader::VisitVarTemplateSpecializationDeclImpl( | |||
2257 | VarTemplateSpecializationDecl *D) { | |||
2258 | RedeclarableResult Redecl = VisitVarDeclImpl(D); | |||
2259 | ||||
2260 | ASTContext &C = Reader.getContext(); | |||
2261 | if (Decl *InstD = ReadDecl()) { | |||
2262 | if (auto *VTD = dyn_cast<VarTemplateDecl>(InstD)) { | |||
2263 | D->SpecializedTemplate = VTD; | |||
2264 | } else { | |||
2265 | SmallVector<TemplateArgument, 8> TemplArgs; | |||
2266 | Record.readTemplateArgumentList(TemplArgs); | |||
2267 | TemplateArgumentList *ArgList = TemplateArgumentList::CreateCopy( | |||
2268 | C, TemplArgs); | |||
2269 | auto *PS = | |||
2270 | new (C) | |||
2271 | VarTemplateSpecializationDecl::SpecializedPartialSpecialization(); | |||
2272 | PS->PartialSpecialization = | |||
2273 | cast<VarTemplatePartialSpecializationDecl>(InstD); | |||
2274 | PS->TemplateArgs = ArgList; | |||
2275 | D->SpecializedTemplate = PS; | |||
2276 | } | |||
2277 | } | |||
2278 | ||||
2279 | // Explicit info. | |||
2280 | if (TypeSourceInfo *TyInfo = GetTypeSourceInfo()) { | |||
2281 | auto *ExplicitInfo = | |||
2282 | new (C) VarTemplateSpecializationDecl::ExplicitSpecializationInfo; | |||
2283 | ExplicitInfo->TypeAsWritten = TyInfo; | |||
2284 | ExplicitInfo->ExternLoc = ReadSourceLocation(); | |||
2285 | ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(); | |||
2286 | D->ExplicitInfo = ExplicitInfo; | |||
2287 | } | |||
2288 | ||||
2289 | SmallVector<TemplateArgument, 8> TemplArgs; | |||
2290 | Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true); | |||
2291 | D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs); | |||
2292 | D->PointOfInstantiation = ReadSourceLocation(); | |||
2293 | D->SpecializationKind = (TemplateSpecializationKind)Record.readInt(); | |||
2294 | D->IsCompleteDefinition = Record.readInt(); | |||
2295 | ||||
2296 | bool writtenAsCanonicalDecl = Record.readInt(); | |||
2297 | if (writtenAsCanonicalDecl) { | |||
2298 | auto *CanonPattern = ReadDeclAs<VarTemplateDecl>(); | |||
2299 | if (D->isCanonicalDecl()) { // It's kept in the folding set. | |||
2300 | // FIXME: If it's already present, merge it. | |||
2301 | if (auto *Partial = dyn_cast<VarTemplatePartialSpecializationDecl>(D)) { | |||
2302 | CanonPattern->getCommonPtr()->PartialSpecializations | |||
2303 | .GetOrInsertNode(Partial); | |||
2304 | } else { | |||
2305 | CanonPattern->getCommonPtr()->Specializations.GetOrInsertNode(D); | |||
2306 | } | |||
2307 | } | |||
2308 | } | |||
2309 | ||||
2310 | return Redecl; | |||
2311 | } | |||
2312 | ||||
2313 | /// TODO: Unify with ClassTemplatePartialSpecializationDecl version? | |||
2314 | /// May require unifying ClassTemplate(Partial)SpecializationDecl and | |||
2315 | /// VarTemplate(Partial)SpecializationDecl with a new data | |||
2316 | /// structure Template(Partial)SpecializationDecl, and | |||
2317 | /// using Template(Partial)SpecializationDecl as input type. | |||
2318 | void ASTDeclReader::VisitVarTemplatePartialSpecializationDecl( | |||
2319 | VarTemplatePartialSpecializationDecl *D) { | |||
2320 | RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D); | |||
2321 | ||||
2322 | D->TemplateParams = Record.readTemplateParameterList(); | |||
2323 | D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo(); | |||
2324 | ||||
2325 | // These are read/set from/to the first declaration. | |||
2326 | if (ThisDeclID == Redecl.getFirstID()) { | |||
2327 | D->InstantiatedFromMember.setPointer( | |||
2328 | ReadDeclAs<VarTemplatePartialSpecializationDecl>()); | |||
2329 | D->InstantiatedFromMember.setInt(Record.readInt()); | |||
2330 | } | |||
2331 | } | |||
2332 | ||||
2333 | void ASTDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { | |||
2334 | VisitTypeDecl(D); | |||
2335 | ||||
2336 | D->setDeclaredWithTypename(Record.readInt()); | |||
2337 | ||||
2338 | if (Record.readInt()) | |||
2339 | D->setDefaultArgument(GetTypeSourceInfo()); | |||
2340 | } | |||
2341 | ||||
2342 | void ASTDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { | |||
2343 | VisitDeclaratorDecl(D); | |||
2344 | // TemplateParmPosition. | |||
2345 | D->setDepth(Record.readInt()); | |||
2346 | D->setPosition(Record.readInt()); | |||
2347 | if (D->isExpandedParameterPack()) { | |||
2348 | auto TypesAndInfos = | |||
2349 | D->getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>(); | |||
2350 | for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) { | |||
2351 | new (&TypesAndInfos[I].first) QualType(Record.readType()); | |||
2352 | TypesAndInfos[I].second = GetTypeSourceInfo(); | |||
2353 | } | |||
2354 | } else { | |||
2355 | // Rest of NonTypeTemplateParmDecl. | |||
2356 | D->ParameterPack = Record.readInt(); | |||
2357 | if (Record.readInt()) | |||
2358 | D->setDefaultArgument(Record.readExpr()); | |||
2359 | } | |||
2360 | } | |||
2361 | ||||
2362 | void ASTDeclReader::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { | |||
2363 | VisitTemplateDecl(D); | |||
2364 | // TemplateParmPosition. | |||
2365 | D->setDepth(Record.readInt()); | |||
2366 | D->setPosition(Record.readInt()); | |||
2367 | if (D->isExpandedParameterPack()) { | |||
2368 | auto **Data = D->getTrailingObjects<TemplateParameterList *>(); | |||
2369 | for (unsigned I = 0, N = D->getNumExpansionTemplateParameters(); | |||
2370 | I != N; ++I) | |||
2371 | Data[I] = Record.readTemplateParameterList(); | |||
2372 | } else { | |||
2373 | // Rest of TemplateTemplateParmDecl. | |||
2374 | D->ParameterPack = Record.readInt(); | |||
2375 | if (Record.readInt()) | |||
2376 | D->setDefaultArgument(Reader.getContext(), | |||
2377 | Record.readTemplateArgumentLoc()); | |||
2378 | } | |||
2379 | } | |||
2380 | ||||
2381 | void ASTDeclReader::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { | |||
2382 | VisitRedeclarableTemplateDecl(D); | |||
2383 | } | |||
2384 | ||||
2385 | void ASTDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) { | |||
2386 | VisitDecl(D); | |||
2387 | D->AssertExprAndFailed.setPointer(Record.readExpr()); | |||
2388 | D->AssertExprAndFailed.setInt(Record.readInt()); | |||
2389 | D->Message = cast_or_null<StringLiteral>(Record.readExpr()); | |||
2390 | D->RParenLoc = ReadSourceLocation(); | |||
2391 | } | |||
2392 | ||||
2393 | void ASTDeclReader::VisitEmptyDecl(EmptyDecl *D) { | |||
2394 | VisitDecl(D); | |||
2395 | } | |||
2396 | ||||
2397 | std::pair<uint64_t, uint64_t> | |||
2398 | ASTDeclReader::VisitDeclContext(DeclContext *DC) { | |||
2399 | uint64_t LexicalOffset = ReadLocalOffset(); | |||
2400 | uint64_t VisibleOffset = ReadLocalOffset(); | |||
2401 | return std::make_pair(LexicalOffset, VisibleOffset); | |||
2402 | } | |||
2403 | ||||
2404 | template <typename T> | |||
2405 | ASTDeclReader::RedeclarableResult | |||
2406 | ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) { | |||
2407 | DeclID FirstDeclID = ReadDeclID(); | |||
2408 | Decl *MergeWith = nullptr; | |||
2409 | ||||
2410 | bool IsKeyDecl = ThisDeclID == FirstDeclID; | |||
2411 | bool IsFirstLocalDecl = false; | |||
2412 | ||||
2413 | uint64_t RedeclOffset = 0; | |||
2414 | ||||
2415 | // 0 indicates that this declaration was the only declaration of its entity, | |||
2416 | // and is used for space optimization. | |||
2417 | if (FirstDeclID == 0) { | |||
2418 | FirstDeclID = ThisDeclID; | |||
2419 | IsKeyDecl = true; | |||
2420 | IsFirstLocalDecl = true; | |||
2421 | } else if (unsigned N = Record.readInt()) { | |||
2422 | // This declaration was the first local declaration, but may have imported | |||
2423 | // other declarations. | |||
2424 | IsKeyDecl = N == 1; | |||
2425 | IsFirstLocalDecl = true; | |||
2426 | ||||
2427 | // We have some declarations that must be before us in our redeclaration | |||
2428 | // chain. Read them now, and remember that we ought to merge with one of | |||
2429 | // them. | |||
2430 | // FIXME: Provide a known merge target to the second and subsequent such | |||
2431 | // declaration. | |||
2432 | for (unsigned I = 0; I != N - 1; ++I) | |||
2433 | MergeWith = ReadDecl(); | |||
2434 | ||||
2435 | RedeclOffset = ReadLocalOffset(); | |||
2436 | } else { | |||
2437 | // This declaration was not the first local declaration. Read the first | |||
2438 | // local declaration now, to trigger the import of other redeclarations. | |||
2439 | (void)ReadDecl(); | |||
2440 | } | |||
2441 | ||||
2442 | auto *FirstDecl = cast_or_null<T>(Reader.GetDecl(FirstDeclID)); | |||
2443 | if (FirstDecl != D) { | |||
2444 | // We delay loading of the redeclaration chain to avoid deeply nested calls. | |||
2445 | // We temporarily set the first (canonical) declaration as the previous one | |||
2446 | // which is the one that matters and mark the real previous DeclID to be | |||
2447 | // loaded & attached later on. | |||
2448 | D->RedeclLink = Redeclarable<T>::PreviousDeclLink(FirstDecl); | |||
2449 | D->First = FirstDecl->getCanonicalDecl(); | |||
2450 | } | |||
2451 | ||||
2452 | auto *DAsT = static_cast<T *>(D); | |||
2453 | ||||
2454 | // Note that we need to load local redeclarations of this decl and build a | |||
2455 | // decl chain for them. This must happen *after* we perform the preloading | |||
2456 | // above; this ensures that the redeclaration chain is built in the correct | |||
2457 | // order. | |||
2458 | if (IsFirstLocalDecl) | |||
2459 | Reader.PendingDeclChains.push_back(std::make_pair(DAsT, RedeclOffset)); | |||
2460 | ||||
2461 | return RedeclarableResult(MergeWith, FirstDeclID, IsKeyDecl); | |||
2462 | } | |||
2463 | ||||
2464 | /// Attempts to merge the given declaration (D) with another declaration | |||
2465 | /// of the same entity. | |||
2466 | template<typename T> | |||
2467 | void ASTDeclReader::mergeRedeclarable(Redeclarable<T> *DBase, | |||
2468 | RedeclarableResult &Redecl, | |||
2469 | DeclID TemplatePatternID) { | |||
2470 | // If modules are not available, there is no reason to perform this merge. | |||
2471 | if (!Reader.getContext().getLangOpts().Modules) | |||
2472 | return; | |||
2473 | ||||
2474 | // If we're not the canonical declaration, we don't need to merge. | |||
2475 | if (!DBase->isFirstDecl()) | |||
2476 | return; | |||
2477 | ||||
2478 | auto *D = static_cast<T *>(DBase); | |||
2479 | ||||
2480 | if (auto *Existing = Redecl.getKnownMergeTarget()) | |||
2481 | // We already know of an existing declaration we should merge with. | |||
2482 | mergeRedeclarable(D, cast<T>(Existing), Redecl, TemplatePatternID); | |||
2483 | else if (FindExistingResult ExistingRes = findExisting(D)) | |||
2484 | if (T *Existing = ExistingRes) | |||
2485 | mergeRedeclarable(D, Existing, Redecl, TemplatePatternID); | |||
2486 | } | |||
2487 | ||||
2488 | /// "Cast" to type T, asserting if we don't have an implicit conversion. | |||
2489 | /// We use this to put code in a template that will only be valid for certain | |||
2490 | /// instantiations. | |||
2491 | template<typename T> static T assert_cast(T t) { return t; } | |||
2492 | template<typename T> static T assert_cast(...) { | |||
2493 | llvm_unreachable("bad assert_cast")::llvm::llvm_unreachable_internal("bad assert_cast", "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 2493); | |||
2494 | } | |||
2495 | ||||
2496 | /// Merge together the pattern declarations from two template | |||
2497 | /// declarations. | |||
2498 | void ASTDeclReader::mergeTemplatePattern(RedeclarableTemplateDecl *D, | |||
2499 | RedeclarableTemplateDecl *Existing, | |||
2500 | DeclID DsID, bool IsKeyDecl) { | |||
2501 | auto *DPattern = D->getTemplatedDecl(); | |||
2502 | auto *ExistingPattern = Existing->getTemplatedDecl(); | |||
2503 | RedeclarableResult Result(/*MergeWith*/ ExistingPattern, | |||
2504 | DPattern->getCanonicalDecl()->getGlobalID(), | |||
2505 | IsKeyDecl); | |||
2506 | ||||
2507 | if (auto *DClass = dyn_cast<CXXRecordDecl>(DPattern)) { | |||
2508 | // Merge with any existing definition. | |||
2509 | // FIXME: This is duplicated in several places. Refactor. | |||
2510 | auto *ExistingClass = | |||
2511 | cast<CXXRecordDecl>(ExistingPattern)->getCanonicalDecl(); | |||
2512 | if (auto *DDD = DClass->DefinitionData) { | |||
2513 | if (ExistingClass->DefinitionData) { | |||
2514 | MergeDefinitionData(ExistingClass, std::move(*DDD)); | |||
2515 | } else { | |||
2516 | ExistingClass->DefinitionData = DClass->DefinitionData; | |||
2517 | // We may have skipped this before because we thought that DClass | |||
2518 | // was the canonical declaration. | |||
2519 | Reader.PendingDefinitions.insert(DClass); | |||
2520 | } | |||
2521 | } | |||
2522 | DClass->DefinitionData = ExistingClass->DefinitionData; | |||
2523 | ||||
2524 | return mergeRedeclarable(DClass, cast<TagDecl>(ExistingPattern), | |||
2525 | Result); | |||
2526 | } | |||
2527 | if (auto *DFunction = dyn_cast<FunctionDecl>(DPattern)) | |||
2528 | return mergeRedeclarable(DFunction, cast<FunctionDecl>(ExistingPattern), | |||
2529 | Result); | |||
2530 | if (auto *DVar = dyn_cast<VarDecl>(DPattern)) | |||
2531 | return mergeRedeclarable(DVar, cast<VarDecl>(ExistingPattern), Result); | |||
2532 | if (auto *DAlias = dyn_cast<TypeAliasDecl>(DPattern)) | |||
2533 | return mergeRedeclarable(DAlias, cast<TypedefNameDecl>(ExistingPattern), | |||
2534 | Result); | |||
2535 | llvm_unreachable("merged an unknown kind of redeclarable template")::llvm::llvm_unreachable_internal("merged an unknown kind of redeclarable template" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 2535); | |||
2536 | } | |||
2537 | ||||
2538 | /// Attempts to merge the given declaration (D) with another declaration | |||
2539 | /// of the same entity. | |||
2540 | template<typename T> | |||
2541 | void ASTDeclReader::mergeRedeclarable(Redeclarable<T> *DBase, T *Existing, | |||
2542 | RedeclarableResult &Redecl, | |||
2543 | DeclID TemplatePatternID) { | |||
2544 | auto *D = static_cast<T *>(DBase); | |||
2545 | T *ExistingCanon = Existing->getCanonicalDecl(); | |||
2546 | T *DCanon = D->getCanonicalDecl(); | |||
2547 | if (ExistingCanon != DCanon) { | |||
2548 | assert(DCanon->getGlobalID() == Redecl.getFirstID() &&(static_cast <bool> (DCanon->getGlobalID() == Redecl .getFirstID() && "already merged this declaration") ? void (0) : __assert_fail ("DCanon->getGlobalID() == Redecl.getFirstID() && \"already merged this declaration\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 2549, __extension__ __PRETTY_FUNCTION__)) | |||
2549 | "already merged this declaration")(static_cast <bool> (DCanon->getGlobalID() == Redecl .getFirstID() && "already merged this declaration") ? void (0) : __assert_fail ("DCanon->getGlobalID() == Redecl.getFirstID() && \"already merged this declaration\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 2549, __extension__ __PRETTY_FUNCTION__)); | |||
2550 | ||||
2551 | // Have our redeclaration link point back at the canonical declaration | |||
2552 | // of the existing declaration, so that this declaration has the | |||
2553 | // appropriate canonical declaration. | |||
2554 | D->RedeclLink = Redeclarable<T>::PreviousDeclLink(ExistingCanon); | |||
2555 | D->First = ExistingCanon; | |||
2556 | ExistingCanon->Used |= D->Used; | |||
2557 | D->Used = false; | |||
2558 | ||||
2559 | // When we merge a namespace, update its pointer to the first namespace. | |||
2560 | // We cannot have loaded any redeclarations of this declaration yet, so | |||
2561 | // there's nothing else that needs to be updated. | |||
2562 | if (auto *Namespace = dyn_cast<NamespaceDecl>(D)) | |||
2563 | Namespace->AnonOrFirstNamespaceAndInline.setPointer( | |||
2564 | assert_cast<NamespaceDecl*>(ExistingCanon)); | |||
2565 | ||||
2566 | // When we merge a template, merge its pattern. | |||
2567 | if (auto *DTemplate = dyn_cast<RedeclarableTemplateDecl>(D)) | |||
2568 | mergeTemplatePattern( | |||
2569 | DTemplate, assert_cast<RedeclarableTemplateDecl*>(ExistingCanon), | |||
2570 | TemplatePatternID, Redecl.isKeyDecl()); | |||
2571 | ||||
2572 | // If this declaration is a key declaration, make a note of that. | |||
2573 | if (Redecl.isKeyDecl()) | |||
2574 | Reader.KeyDecls[ExistingCanon].push_back(Redecl.getFirstID()); | |||
2575 | } | |||
2576 | } | |||
2577 | ||||
2578 | /// ODR-like semantics for C/ObjC allow us to merge tag types and a structural | |||
2579 | /// check in Sema guarantees the types can be merged (see C11 6.2.7/1 or C89 | |||
2580 | /// 6.1.2.6/1). Although most merging is done in Sema, we need to guarantee | |||
2581 | /// that some types are mergeable during deserialization, otherwise name | |||
2582 | /// lookup fails. This is the case for EnumConstantDecl. | |||
2583 | static bool allowODRLikeMergeInC(NamedDecl *ND) { | |||
2584 | if (!ND) | |||
2585 | return false; | |||
2586 | // TODO: implement merge for other necessary decls. | |||
2587 | if (isa<EnumConstantDecl>(ND)) | |||
2588 | return true; | |||
2589 | return false; | |||
2590 | } | |||
2591 | ||||
2592 | /// Attempts to merge the given declaration (D) with another declaration | |||
2593 | /// of the same entity, for the case where the entity is not actually | |||
2594 | /// redeclarable. This happens, for instance, when merging the fields of | |||
2595 | /// identical class definitions from two different modules. | |||
2596 | template<typename T> | |||
2597 | void ASTDeclReader::mergeMergeable(Mergeable<T> *D) { | |||
2598 | // If modules are not available, there is no reason to perform this merge. | |||
2599 | if (!Reader.getContext().getLangOpts().Modules) | |||
2600 | return; | |||
2601 | ||||
2602 | // ODR-based merging is performed in C++ and in some cases (tag types) in C. | |||
2603 | // Note that C identically-named things in different translation units are | |||
2604 | // not redeclarations, but may still have compatible types, where ODR-like | |||
2605 | // semantics may apply. | |||
2606 | if (!Reader.getContext().getLangOpts().CPlusPlus && | |||
2607 | !allowODRLikeMergeInC(dyn_cast<NamedDecl>(static_cast<T*>(D)))) | |||
2608 | return; | |||
2609 | ||||
2610 | if (FindExistingResult ExistingRes = findExisting(static_cast<T*>(D))) | |||
2611 | if (T *Existing = ExistingRes) | |||
2612 | Reader.getContext().setPrimaryMergedDecl(static_cast<T *>(D), | |||
2613 | Existing->getCanonicalDecl()); | |||
2614 | } | |||
2615 | ||||
2616 | void ASTDeclReader::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) { | |||
2617 | VisitDecl(D); | |||
2618 | unsigned NumVars = D->varlist_size(); | |||
2619 | SmallVector<Expr *, 16> Vars; | |||
2620 | Vars.reserve(NumVars); | |||
2621 | for (unsigned i = 0; i != NumVars; ++i) { | |||
2622 | Vars.push_back(Record.readExpr()); | |||
2623 | } | |||
2624 | D->setVars(Vars); | |||
2625 | } | |||
2626 | ||||
2627 | void ASTDeclReader::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) { | |||
2628 | VisitValueDecl(D); | |||
2629 | D->setLocation(ReadSourceLocation()); | |||
2630 | D->setCombiner(Record.readExpr()); | |||
2631 | D->setInitializer( | |||
2632 | Record.readExpr(), | |||
2633 | static_cast<OMPDeclareReductionDecl::InitKind>(Record.readInt())); | |||
2634 | D->PrevDeclInScope = ReadDeclID(); | |||
2635 | } | |||
2636 | ||||
2637 | void ASTDeclReader::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) { | |||
2638 | VisitVarDecl(D); | |||
2639 | } | |||
2640 | ||||
2641 | //===----------------------------------------------------------------------===// | |||
2642 | // Attribute Reading | |||
2643 | //===----------------------------------------------------------------------===// | |||
2644 | ||||
2645 | /// Reads attributes from the current stream position. | |||
2646 | void ASTReader::ReadAttributes(ASTRecordReader &Record, AttrVec &Attrs) { | |||
2647 | for (unsigned i = 0, e = Record.readInt(); i != e; ++i) { | |||
2648 | Attr *New = nullptr; | |||
2649 | auto Kind = (attr::Kind)Record.readInt(); | |||
2650 | SourceRange Range = Record.readSourceRange(); | |||
2651 | ASTContext &Context = getContext(); | |||
2652 | ||||
2653 | #include "clang/Serialization/AttrPCHRead.inc" | |||
2654 | ||||
2655 | assert(New && "Unable to decode attribute?")(static_cast <bool> (New && "Unable to decode attribute?" ) ? void (0) : __assert_fail ("New && \"Unable to decode attribute?\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 2655, __extension__ __PRETTY_FUNCTION__)); | |||
2656 | Attrs.push_back(New); | |||
2657 | } | |||
2658 | } | |||
2659 | ||||
2660 | //===----------------------------------------------------------------------===// | |||
2661 | // ASTReader Implementation | |||
2662 | //===----------------------------------------------------------------------===// | |||
2663 | ||||
2664 | /// Note that we have loaded the declaration with the given | |||
2665 | /// Index. | |||
2666 | /// | |||
2667 | /// This routine notes that this declaration has already been loaded, | |||
2668 | /// so that future GetDecl calls will return this declaration rather | |||
2669 | /// than trying to load a new declaration. | |||
2670 | inline void ASTReader::LoadedDecl(unsigned Index, Decl *D) { | |||
2671 | assert(!DeclsLoaded[Index] && "Decl loaded twice?")(static_cast <bool> (!DeclsLoaded[Index] && "Decl loaded twice?" ) ? void (0) : __assert_fail ("!DeclsLoaded[Index] && \"Decl loaded twice?\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 2671, __extension__ __PRETTY_FUNCTION__)); | |||
2672 | DeclsLoaded[Index] = D; | |||
2673 | } | |||
2674 | ||||
2675 | /// Determine whether the consumer will be interested in seeing | |||
2676 | /// this declaration (via HandleTopLevelDecl). | |||
2677 | /// | |||
2678 | /// This routine should return true for anything that might affect | |||
2679 | /// code generation, e.g., inline function definitions, Objective-C | |||
2680 | /// declarations with metadata, etc. | |||
2681 | static bool isConsumerInterestedIn(ASTContext &Ctx, Decl *D, bool HasBody) { | |||
2682 | // An ObjCMethodDecl is never considered as "interesting" because its | |||
2683 | // implementation container always is. | |||
2684 | ||||
2685 | // An ImportDecl or VarDecl imported from a module map module will get | |||
2686 | // emitted when we import the relevant module. | |||
2687 | if (isa<ImportDecl>(D) || isa<VarDecl>(D)) { | |||
2688 | auto *M = D->getImportedOwningModule(); | |||
2689 | if (M && M->Kind == Module::ModuleMapModule && | |||
2690 | Ctx.DeclMustBeEmitted(D)) | |||
2691 | return false; | |||
2692 | } | |||
2693 | ||||
2694 | if (isa<FileScopeAsmDecl>(D) || | |||
2695 | isa<ObjCProtocolDecl>(D) || | |||
2696 | isa<ObjCImplDecl>(D) || | |||
2697 | isa<ImportDecl>(D) || | |||
2698 | isa<PragmaCommentDecl>(D) || | |||
2699 | isa<PragmaDetectMismatchDecl>(D)) | |||
2700 | return true; | |||
2701 | if (isa<OMPThreadPrivateDecl>(D) || isa<OMPDeclareReductionDecl>(D)) | |||
2702 | return !D->getDeclContext()->isFunctionOrMethod(); | |||
2703 | if (const auto *Var = dyn_cast<VarDecl>(D)) | |||
2704 | return Var->isFileVarDecl() && | |||
2705 | Var->isThisDeclarationADefinition() == VarDecl::Definition; | |||
2706 | if (const auto *Func = dyn_cast<FunctionDecl>(D)) | |||
2707 | return Func->doesThisDeclarationHaveABody() || HasBody; | |||
2708 | ||||
2709 | if (auto *ES = D->getASTContext().getExternalSource()) | |||
2710 | if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never) | |||
2711 | return true; | |||
2712 | ||||
2713 | return false; | |||
2714 | } | |||
2715 | ||||
2716 | /// Get the correct cursor and offset for loading a declaration. | |||
2717 | ASTReader::RecordLocation | |||
2718 | ASTReader::DeclCursorForID(DeclID ID, SourceLocation &Loc) { | |||
2719 | GlobalDeclMapType::iterator I = GlobalDeclMap.find(ID); | |||
2720 | assert(I != GlobalDeclMap.end() && "Corrupted global declaration map")(static_cast <bool> (I != GlobalDeclMap.end() && "Corrupted global declaration map") ? void (0) : __assert_fail ("I != GlobalDeclMap.end() && \"Corrupted global declaration map\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 2720, __extension__ __PRETTY_FUNCTION__)); | |||
2721 | ModuleFile *M = I->second; | |||
2722 | const DeclOffset &DOffs = | |||
2723 | M->DeclOffsets[ID - M->BaseDeclID - NUM_PREDEF_DECL_IDS]; | |||
2724 | Loc = TranslateSourceLocation(*M, DOffs.getLocation()); | |||
2725 | return RecordLocation(M, DOffs.BitOffset); | |||
2726 | } | |||
2727 | ||||
2728 | ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) { | |||
2729 | auto I = GlobalBitOffsetsMap.find(GlobalOffset); | |||
2730 | ||||
2731 | assert(I != GlobalBitOffsetsMap.end() && "Corrupted global bit offsets map")(static_cast <bool> (I != GlobalBitOffsetsMap.end() && "Corrupted global bit offsets map") ? void (0) : __assert_fail ("I != GlobalBitOffsetsMap.end() && \"Corrupted global bit offsets map\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 2731, __extension__ __PRETTY_FUNCTION__)); | |||
2732 | return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset); | |||
2733 | } | |||
2734 | ||||
2735 | uint64_t ASTReader::getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset) { | |||
2736 | return LocalOffset + M.GlobalBitOffset; | |||
2737 | } | |||
2738 | ||||
2739 | static bool isSameTemplateParameterList(const TemplateParameterList *X, | |||
2740 | const TemplateParameterList *Y); | |||
2741 | ||||
2742 | /// Determine whether two template parameters are similar enough | |||
2743 | /// that they may be used in declarations of the same template. | |||
2744 | static bool isSameTemplateParameter(const NamedDecl *X, | |||
2745 | const NamedDecl *Y) { | |||
2746 | if (X->getKind() != Y->getKind()) | |||
2747 | return false; | |||
2748 | ||||
2749 | if (const auto *TX = dyn_cast<TemplateTypeParmDecl>(X)) { | |||
2750 | const auto *TY = cast<TemplateTypeParmDecl>(Y); | |||
2751 | return TX->isParameterPack() == TY->isParameterPack(); | |||
2752 | } | |||
2753 | ||||
2754 | if (const auto *TX = dyn_cast<NonTypeTemplateParmDecl>(X)) { | |||
2755 | const auto *TY = cast<NonTypeTemplateParmDecl>(Y); | |||
2756 | return TX->isParameterPack() == TY->isParameterPack() && | |||
2757 | TX->getASTContext().hasSameType(TX->getType(), TY->getType()); | |||
2758 | } | |||
2759 | ||||
2760 | const auto *TX = cast<TemplateTemplateParmDecl>(X); | |||
2761 | const auto *TY = cast<TemplateTemplateParmDecl>(Y); | |||
2762 | return TX->isParameterPack() == TY->isParameterPack() && | |||
2763 | isSameTemplateParameterList(TX->getTemplateParameters(), | |||
2764 | TY->getTemplateParameters()); | |||
2765 | } | |||
2766 | ||||
2767 | static NamespaceDecl *getNamespace(const NestedNameSpecifier *X) { | |||
2768 | if (auto *NS = X->getAsNamespace()) | |||
2769 | return NS; | |||
2770 | if (auto *NAS = X->getAsNamespaceAlias()) | |||
2771 | return NAS->getNamespace(); | |||
2772 | return nullptr; | |||
2773 | } | |||
2774 | ||||
2775 | static bool isSameQualifier(const NestedNameSpecifier *X, | |||
2776 | const NestedNameSpecifier *Y) { | |||
2777 | if (auto *NSX = getNamespace(X)) { | |||
2778 | auto *NSY = getNamespace(Y); | |||
2779 | if (!NSY || NSX->getCanonicalDecl() != NSY->getCanonicalDecl()) | |||
2780 | return false; | |||
2781 | } else if (X->getKind() != Y->getKind()) | |||
2782 | return false; | |||
2783 | ||||
2784 | // FIXME: For namespaces and types, we're permitted to check that the entity | |||
2785 | // is named via the same tokens. We should probably do so. | |||
2786 | switch (X->getKind()) { | |||
2787 | case NestedNameSpecifier::Identifier: | |||
2788 | if (X->getAsIdentifier() != Y->getAsIdentifier()) | |||
2789 | return false; | |||
2790 | break; | |||
2791 | case NestedNameSpecifier::Namespace: | |||
2792 | case NestedNameSpecifier::NamespaceAlias: | |||
2793 | // We've already checked that we named the same namespace. | |||
2794 | break; | |||
2795 | case NestedNameSpecifier::TypeSpec: | |||
2796 | case NestedNameSpecifier::TypeSpecWithTemplate: | |||
2797 | if (X->getAsType()->getCanonicalTypeInternal() != | |||
2798 | Y->getAsType()->getCanonicalTypeInternal()) | |||
2799 | return false; | |||
2800 | break; | |||
2801 | case NestedNameSpecifier::Global: | |||
2802 | case NestedNameSpecifier::Super: | |||
2803 | return true; | |||
2804 | } | |||
2805 | ||||
2806 | // Recurse into earlier portion of NNS, if any. | |||
2807 | auto *PX = X->getPrefix(); | |||
2808 | auto *PY = Y->getPrefix(); | |||
2809 | if (PX && PY) | |||
2810 | return isSameQualifier(PX, PY); | |||
2811 | return !PX && !PY; | |||
2812 | } | |||
2813 | ||||
2814 | /// Determine whether two template parameter lists are similar enough | |||
2815 | /// that they may be used in declarations of the same template. | |||
2816 | static bool isSameTemplateParameterList(const TemplateParameterList *X, | |||
2817 | const TemplateParameterList *Y) { | |||
2818 | if (X->size() != Y->size()) | |||
2819 | return false; | |||
2820 | ||||
2821 | for (unsigned I = 0, N = X->size(); I != N; ++I) | |||
2822 | if (!isSameTemplateParameter(X->getParam(I), Y->getParam(I))) | |||
2823 | return false; | |||
2824 | ||||
2825 | return true; | |||
2826 | } | |||
2827 | ||||
2828 | /// Determine whether the attributes we can overload on are identical for A and | |||
2829 | /// B. Will ignore any overloadable attrs represented in the type of A and B. | |||
2830 | static bool hasSameOverloadableAttrs(const FunctionDecl *A, | |||
2831 | const FunctionDecl *B) { | |||
2832 | // Note that pass_object_size attributes are represented in the function's | |||
2833 | // ExtParameterInfo, so we don't need to check them here. | |||
2834 | ||||
2835 | SmallVector<const EnableIfAttr *, 4> AEnableIfs; | |||
2836 | // Since this is an equality check, we can ignore that enable_if attrs show up | |||
2837 | // in reverse order. | |||
2838 | for (const auto *EIA : A->specific_attrs<EnableIfAttr>()) | |||
2839 | AEnableIfs.push_back(EIA); | |||
2840 | ||||
2841 | SmallVector<const EnableIfAttr *, 4> BEnableIfs; | |||
2842 | for (const auto *EIA : B->specific_attrs<EnableIfAttr>()) | |||
2843 | BEnableIfs.push_back(EIA); | |||
2844 | ||||
2845 | // Two very common cases: either we have 0 enable_if attrs, or we have an | |||
2846 | // unequal number of enable_if attrs. | |||
2847 | if (AEnableIfs.empty() && BEnableIfs.empty()) | |||
2848 | return true; | |||
2849 | ||||
2850 | if (AEnableIfs.size() != BEnableIfs.size()) | |||
2851 | return false; | |||
2852 | ||||
2853 | llvm::FoldingSetNodeID Cand1ID, Cand2ID; | |||
2854 | for (unsigned I = 0, E = AEnableIfs.size(); I != E; ++I) { | |||
2855 | Cand1ID.clear(); | |||
2856 | Cand2ID.clear(); | |||
2857 | ||||
2858 | AEnableIfs[I]->getCond()->Profile(Cand1ID, A->getASTContext(), true); | |||
2859 | BEnableIfs[I]->getCond()->Profile(Cand2ID, B->getASTContext(), true); | |||
2860 | if (Cand1ID != Cand2ID) | |||
2861 | return false; | |||
2862 | } | |||
2863 | ||||
2864 | return true; | |||
2865 | } | |||
2866 | ||||
2867 | /// Determine whether the two declarations refer to the same entity. | |||
2868 | static bool isSameEntity(NamedDecl *X, NamedDecl *Y) { | |||
2869 | assert(X->getDeclName() == Y->getDeclName() && "Declaration name mismatch!")(static_cast <bool> (X->getDeclName() == Y->getDeclName () && "Declaration name mismatch!") ? void (0) : __assert_fail ("X->getDeclName() == Y->getDeclName() && \"Declaration name mismatch!\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 2869, __extension__ __PRETTY_FUNCTION__)); | |||
2870 | ||||
2871 | if (X == Y) | |||
2872 | return true; | |||
2873 | ||||
2874 | // Must be in the same context. | |||
2875 | // | |||
2876 | // Note that we can't use DeclContext::Equals here, because the DeclContexts | |||
2877 | // could be two different declarations of the same function. (We will fix the | |||
2878 | // semantic DC to refer to the primary definition after merging.) | |||
2879 | if (!declaresSameEntity(cast<Decl>(X->getDeclContext()->getRedeclContext()), | |||
2880 | cast<Decl>(Y->getDeclContext()->getRedeclContext()))) | |||
2881 | return false; | |||
2882 | ||||
2883 | // Two typedefs refer to the same entity if they have the same underlying | |||
2884 | // type. | |||
2885 | if (const auto *TypedefX = dyn_cast<TypedefNameDecl>(X)) | |||
2886 | if (const auto *TypedefY = dyn_cast<TypedefNameDecl>(Y)) | |||
2887 | return X->getASTContext().hasSameType(TypedefX->getUnderlyingType(), | |||
2888 | TypedefY->getUnderlyingType()); | |||
2889 | ||||
2890 | // Must have the same kind. | |||
2891 | if (X->getKind() != Y->getKind()) | |||
2892 | return false; | |||
2893 | ||||
2894 | // Objective-C classes and protocols with the same name always match. | |||
2895 | if (isa<ObjCInterfaceDecl>(X) || isa<ObjCProtocolDecl>(X)) | |||
2896 | return true; | |||
2897 | ||||
2898 | if (isa<ClassTemplateSpecializationDecl>(X)) { | |||
2899 | // No need to handle these here: we merge them when adding them to the | |||
2900 | // template. | |||
2901 | return false; | |||
2902 | } | |||
2903 | ||||
2904 | // Compatible tags match. | |||
2905 | if (const auto *TagX = dyn_cast<TagDecl>(X)) { | |||
2906 | const auto *TagY = cast<TagDecl>(Y); | |||
2907 | return (TagX->getTagKind() == TagY->getTagKind()) || | |||
2908 | ((TagX->getTagKind() == TTK_Struct || TagX->getTagKind() == TTK_Class || | |||
2909 | TagX->getTagKind() == TTK_Interface) && | |||
2910 | (TagY->getTagKind() == TTK_Struct || TagY->getTagKind() == TTK_Class || | |||
2911 | TagY->getTagKind() == TTK_Interface)); | |||
2912 | } | |||
2913 | ||||
2914 | // Functions with the same type and linkage match. | |||
2915 | // FIXME: This needs to cope with merging of prototyped/non-prototyped | |||
2916 | // functions, etc. | |||
2917 | if (const auto *FuncX = dyn_cast<FunctionDecl>(X)) { | |||
2918 | const auto *FuncY = cast<FunctionDecl>(Y); | |||
2919 | if (const auto *CtorX = dyn_cast<CXXConstructorDecl>(X)) { | |||
2920 | const auto *CtorY = cast<CXXConstructorDecl>(Y); | |||
2921 | if (CtorX->getInheritedConstructor() && | |||
2922 | !isSameEntity(CtorX->getInheritedConstructor().getConstructor(), | |||
2923 | CtorY->getInheritedConstructor().getConstructor())) | |||
2924 | return false; | |||
2925 | } | |||
2926 | ||||
2927 | if (FuncX->isMultiVersion() != FuncY->isMultiVersion()) | |||
2928 | return false; | |||
2929 | ||||
2930 | // Multiversioned functions with different feature strings are represented | |||
2931 | // as separate declarations. | |||
2932 | if (FuncX->isMultiVersion()) { | |||
2933 | const auto *TAX = FuncX->getAttr<TargetAttr>(); | |||
2934 | const auto *TAY = FuncY->getAttr<TargetAttr>(); | |||
2935 | assert(TAX && TAY && "Multiversion Function without target attribute")(static_cast <bool> (TAX && TAY && "Multiversion Function without target attribute" ) ? void (0) : __assert_fail ("TAX && TAY && \"Multiversion Function without target attribute\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 2935, __extension__ __PRETTY_FUNCTION__)); | |||
2936 | ||||
2937 | if (TAX->getFeaturesStr() != TAY->getFeaturesStr()) | |||
2938 | return false; | |||
2939 | } | |||
2940 | ||||
2941 | ASTContext &C = FuncX->getASTContext(); | |||
2942 | auto GetTypeAsWritten = [](const FunctionDecl *FD) { | |||
2943 | // Map to the first declaration that we've already merged into this one. | |||
2944 | // The TSI of redeclarations might not match (due to calling conventions | |||
2945 | // being inherited onto the type but not the TSI), but the TSI type of | |||
2946 | // the first declaration of the function should match across modules. | |||
2947 | FD = FD->getCanonicalDecl(); | |||
2948 | return FD->getTypeSourceInfo() ? FD->getTypeSourceInfo()->getType() | |||
2949 | : FD->getType(); | |||
2950 | }; | |||
2951 | QualType XT = GetTypeAsWritten(FuncX), YT = GetTypeAsWritten(FuncY); | |||
2952 | if (!C.hasSameType(XT, YT)) { | |||
2953 | // We can get functions with different types on the redecl chain in C++17 | |||
2954 | // if they have differing exception specifications and at least one of | |||
2955 | // the excpetion specs is unresolved. | |||
2956 | auto *XFPT = XT->getAs<FunctionProtoType>(); | |||
2957 | auto *YFPT = YT->getAs<FunctionProtoType>(); | |||
2958 | if (C.getLangOpts().CPlusPlus17 && XFPT && YFPT && | |||
2959 | (isUnresolvedExceptionSpec(XFPT->getExceptionSpecType()) || | |||
2960 | isUnresolvedExceptionSpec(YFPT->getExceptionSpecType())) && | |||
2961 | C.hasSameFunctionTypeIgnoringExceptionSpec(XT, YT)) | |||
2962 | return true; | |||
2963 | return false; | |||
2964 | } | |||
2965 | return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() && | |||
2966 | hasSameOverloadableAttrs(FuncX, FuncY); | |||
2967 | } | |||
2968 | ||||
2969 | // Variables with the same type and linkage match. | |||
2970 | if (const auto *VarX = dyn_cast<VarDecl>(X)) { | |||
2971 | const auto *VarY = cast<VarDecl>(Y); | |||
2972 | if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) { | |||
2973 | ASTContext &C = VarX->getASTContext(); | |||
2974 | if (C.hasSameType(VarX->getType(), VarY->getType())) | |||
2975 | return true; | |||
2976 | ||||
2977 | // We can get decls with different types on the redecl chain. Eg. | |||
2978 | // template <typename T> struct S { static T Var[]; }; // #1 | |||
2979 | // template <typename T> T S<T>::Var[sizeof(T)]; // #2 | |||
2980 | // Only? happens when completing an incomplete array type. In this case | |||
2981 | // when comparing #1 and #2 we should go through their element type. | |||
2982 | const ArrayType *VarXTy = C.getAsArrayType(VarX->getType()); | |||
2983 | const ArrayType *VarYTy = C.getAsArrayType(VarY->getType()); | |||
2984 | if (!VarXTy || !VarYTy) | |||
2985 | return false; | |||
2986 | if (VarXTy->isIncompleteArrayType() || VarYTy->isIncompleteArrayType()) | |||
2987 | return C.hasSameType(VarXTy->getElementType(), VarYTy->getElementType()); | |||
2988 | } | |||
2989 | return false; | |||
2990 | } | |||
2991 | ||||
2992 | // Namespaces with the same name and inlinedness match. | |||
2993 | if (const auto *NamespaceX = dyn_cast<NamespaceDecl>(X)) { | |||
2994 | const auto *NamespaceY = cast<NamespaceDecl>(Y); | |||
2995 | return NamespaceX->isInline() == NamespaceY->isInline(); | |||
2996 | } | |||
2997 | ||||
2998 | // Identical template names and kinds match if their template parameter lists | |||
2999 | // and patterns match. | |||
3000 | if (const auto *TemplateX = dyn_cast<TemplateDecl>(X)) { | |||
3001 | const auto *TemplateY = cast<TemplateDecl>(Y); | |||
3002 | return isSameEntity(TemplateX->getTemplatedDecl(), | |||
3003 | TemplateY->getTemplatedDecl()) && | |||
3004 | isSameTemplateParameterList(TemplateX->getTemplateParameters(), | |||
3005 | TemplateY->getTemplateParameters()); | |||
3006 | } | |||
3007 | ||||
3008 | // Fields with the same name and the same type match. | |||
3009 | if (const auto *FDX = dyn_cast<FieldDecl>(X)) { | |||
3010 | const auto *FDY = cast<FieldDecl>(Y); | |||
3011 | // FIXME: Also check the bitwidth is odr-equivalent, if any. | |||
3012 | return X->getASTContext().hasSameType(FDX->getType(), FDY->getType()); | |||
3013 | } | |||
3014 | ||||
3015 | // Indirect fields with the same target field match. | |||
3016 | if (const auto *IFDX = dyn_cast<IndirectFieldDecl>(X)) { | |||
3017 | const auto *IFDY = cast<IndirectFieldDecl>(Y); | |||
3018 | return IFDX->getAnonField()->getCanonicalDecl() == | |||
3019 | IFDY->getAnonField()->getCanonicalDecl(); | |||
3020 | } | |||
3021 | ||||
3022 | // Enumerators with the same name match. | |||
3023 | if (isa<EnumConstantDecl>(X)) | |||
3024 | // FIXME: Also check the value is odr-equivalent. | |||
3025 | return true; | |||
3026 | ||||
3027 | // Using shadow declarations with the same target match. | |||
3028 | if (const auto *USX = dyn_cast<UsingShadowDecl>(X)) { | |||
3029 | const auto *USY = cast<UsingShadowDecl>(Y); | |||
3030 | return USX->getTargetDecl() == USY->getTargetDecl(); | |||
3031 | } | |||
3032 | ||||
3033 | // Using declarations with the same qualifier match. (We already know that | |||
3034 | // the name matches.) | |||
3035 | if (const auto *UX = dyn_cast<UsingDecl>(X)) { | |||
3036 | const auto *UY = cast<UsingDecl>(Y); | |||
3037 | return isSameQualifier(UX->getQualifier(), UY->getQualifier()) && | |||
3038 | UX->hasTypename() == UY->hasTypename() && | |||
3039 | UX->isAccessDeclaration() == UY->isAccessDeclaration(); | |||
3040 | } | |||
3041 | if (const auto *UX = dyn_cast<UnresolvedUsingValueDecl>(X)) { | |||
3042 | const auto *UY = cast<UnresolvedUsingValueDecl>(Y); | |||
3043 | return isSameQualifier(UX->getQualifier(), UY->getQualifier()) && | |||
3044 | UX->isAccessDeclaration() == UY->isAccessDeclaration(); | |||
3045 | } | |||
3046 | if (const auto *UX = dyn_cast<UnresolvedUsingTypenameDecl>(X)) | |||
3047 | return isSameQualifier( | |||
3048 | UX->getQualifier(), | |||
3049 | cast<UnresolvedUsingTypenameDecl>(Y)->getQualifier()); | |||
3050 | ||||
3051 | // Namespace alias definitions with the same target match. | |||
3052 | if (const auto *NAX = dyn_cast<NamespaceAliasDecl>(X)) { | |||
3053 | const auto *NAY = cast<NamespaceAliasDecl>(Y); | |||
3054 | return NAX->getNamespace()->Equals(NAY->getNamespace()); | |||
3055 | } | |||
3056 | ||||
3057 | return false; | |||
3058 | } | |||
3059 | ||||
3060 | /// Find the context in which we should search for previous declarations when | |||
3061 | /// looking for declarations to merge. | |||
3062 | DeclContext *ASTDeclReader::getPrimaryContextForMerging(ASTReader &Reader, | |||
3063 | DeclContext *DC) { | |||
3064 | if (auto *ND = dyn_cast<NamespaceDecl>(DC)) | |||
3065 | return ND->getOriginalNamespace(); | |||
3066 | ||||
3067 | if (auto *RD = dyn_cast<CXXRecordDecl>(DC)) { | |||
3068 | // Try to dig out the definition. | |||
3069 | auto *DD = RD->DefinitionData; | |||
3070 | if (!DD) | |||
3071 | DD = RD->getCanonicalDecl()->DefinitionData; | |||
3072 | ||||
3073 | // If there's no definition yet, then DC's definition is added by an update | |||
3074 | // record, but we've not yet loaded that update record. In this case, we | |||
3075 | // commit to DC being the canonical definition now, and will fix this when | |||
3076 | // we load the update record. | |||
3077 | if (!DD) { | |||
3078 | DD = new (Reader.getContext()) struct CXXRecordDecl::DefinitionData(RD); | |||
3079 | RD->IsCompleteDefinition = true; | |||
3080 | RD->DefinitionData = DD; | |||
3081 | RD->getCanonicalDecl()->DefinitionData = DD; | |||
3082 | ||||
3083 | // Track that we did this horrible thing so that we can fix it later. | |||
3084 | Reader.PendingFakeDefinitionData.insert( | |||
3085 | std::make_pair(DD, ASTReader::PendingFakeDefinitionKind::Fake)); | |||
3086 | } | |||
3087 | ||||
3088 | return DD->Definition; | |||
3089 | } | |||
3090 | ||||
3091 | if (auto *ED = dyn_cast<EnumDecl>(DC)) | |||
3092 | return ED->getASTContext().getLangOpts().CPlusPlus? ED->getDefinition() | |||
3093 | : nullptr; | |||
3094 | ||||
3095 | // We can see the TU here only if we have no Sema object. In that case, | |||
3096 | // there's no TU scope to look in, so using the DC alone is sufficient. | |||
3097 | if (auto *TU = dyn_cast<TranslationUnitDecl>(DC)) | |||
3098 | return TU; | |||
3099 | ||||
3100 | return nullptr; | |||
3101 | } | |||
3102 | ||||
3103 | ASTDeclReader::FindExistingResult::~FindExistingResult() { | |||
3104 | // Record that we had a typedef name for linkage whether or not we merge | |||
3105 | // with that declaration. | |||
3106 | if (TypedefNameForLinkage) { | |||
3107 | DeclContext *DC = New->getDeclContext()->getRedeclContext(); | |||
3108 | Reader.ImportedTypedefNamesForLinkage.insert( | |||
3109 | std::make_pair(std::make_pair(DC, TypedefNameForLinkage), New)); | |||
3110 | return; | |||
3111 | } | |||
3112 | ||||
3113 | if (!AddResult || Existing) | |||
3114 | return; | |||
3115 | ||||
3116 | DeclarationName Name = New->getDeclName(); | |||
3117 | DeclContext *DC = New->getDeclContext()->getRedeclContext(); | |||
3118 | if (needsAnonymousDeclarationNumber(New)) { | |||
3119 | setAnonymousDeclForMerging(Reader, New->getLexicalDeclContext(), | |||
3120 | AnonymousDeclNumber, New); | |||
3121 | } else if (DC->isTranslationUnit() && | |||
3122 | !Reader.getContext().getLangOpts().CPlusPlus) { | |||
3123 | if (Reader.getIdResolver().tryAddTopLevelDecl(New, Name)) | |||
3124 | Reader.PendingFakeLookupResults[Name.getAsIdentifierInfo()] | |||
3125 | .push_back(New); | |||
3126 | } else if (DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) { | |||
3127 | // Add the declaration to its redeclaration context so later merging | |||
3128 | // lookups will find it. | |||
3129 | MergeDC->makeDeclVisibleInContextImpl(New, /*Internal*/true); | |||
3130 | } | |||
3131 | } | |||
3132 | ||||
3133 | /// Find the declaration that should be merged into, given the declaration found | |||
3134 | /// by name lookup. If we're merging an anonymous declaration within a typedef, | |||
3135 | /// we need a matching typedef, and we merge with the type inside it. | |||
3136 | static NamedDecl *getDeclForMerging(NamedDecl *Found, | |||
3137 | bool IsTypedefNameForLinkage) { | |||
3138 | if (!IsTypedefNameForLinkage) | |||
3139 | return Found; | |||
3140 | ||||
3141 | // If we found a typedef declaration that gives a name to some other | |||
3142 | // declaration, then we want that inner declaration. Declarations from | |||
3143 | // AST files are handled via ImportedTypedefNamesForLinkage. | |||
3144 | if (Found->isFromASTFile()) | |||
3145 | return nullptr; | |||
3146 | ||||
3147 | if (auto *TND = dyn_cast<TypedefNameDecl>(Found)) | |||
3148 | return TND->getAnonDeclWithTypedefName(/*AnyRedecl*/true); | |||
3149 | ||||
3150 | return nullptr; | |||
3151 | } | |||
3152 | ||||
3153 | /// Find the declaration to use to populate the anonymous declaration table | |||
3154 | /// for the given lexical DeclContext. We only care about finding local | |||
3155 | /// definitions of the context; we'll merge imported ones as we go. | |||
3156 | DeclContext * | |||
3157 | ASTDeclReader::getPrimaryDCForAnonymousDecl(DeclContext *LexicalDC) { | |||
3158 | // For classes, we track the definition as we merge. | |||
3159 | if (auto *RD = dyn_cast<CXXRecordDecl>(LexicalDC)) { | |||
3160 | auto *DD = RD->getCanonicalDecl()->DefinitionData; | |||
3161 | return DD ? DD->Definition : nullptr; | |||
3162 | } | |||
3163 | ||||
3164 | // For anything else, walk its merged redeclarations looking for a definition. | |||
3165 | // Note that we can't just call getDefinition here because the redeclaration | |||
3166 | // chain isn't wired up. | |||
3167 | for (auto *D : merged_redecls(cast<Decl>(LexicalDC))) { | |||
3168 | if (auto *FD = dyn_cast<FunctionDecl>(D)) | |||
3169 | if (FD->isThisDeclarationADefinition()) | |||
3170 | return FD; | |||
3171 | if (auto *MD = dyn_cast<ObjCMethodDecl>(D)) | |||
3172 | if (MD->isThisDeclarationADefinition()) | |||
3173 | return MD; | |||
3174 | } | |||
3175 | ||||
3176 | // No merged definition yet. | |||
3177 | return nullptr; | |||
3178 | } | |||
3179 | ||||
3180 | NamedDecl *ASTDeclReader::getAnonymousDeclForMerging(ASTReader &Reader, | |||
3181 | DeclContext *DC, | |||
3182 | unsigned Index) { | |||
3183 | // If the lexical context has been merged, look into the now-canonical | |||
3184 | // definition. | |||
3185 | auto *CanonDC = cast<Decl>(DC)->getCanonicalDecl(); | |||
3186 | ||||
3187 | // If we've seen this before, return the canonical declaration. | |||
3188 | auto &Previous = Reader.AnonymousDeclarationsForMerging[CanonDC]; | |||
3189 | if (Index < Previous.size() && Previous[Index]) | |||
3190 | return Previous[Index]; | |||
3191 | ||||
3192 | // If this is the first time, but we have parsed a declaration of the context, | |||
3193 | // build the anonymous declaration list from the parsed declaration. | |||
3194 | auto *PrimaryDC = getPrimaryDCForAnonymousDecl(DC); | |||
3195 | if (PrimaryDC && !cast<Decl>(PrimaryDC)->isFromASTFile()) { | |||
3196 | numberAnonymousDeclsWithin(PrimaryDC, [&](NamedDecl *ND, unsigned Number) { | |||
3197 | if (Previous.size() == Number) | |||
3198 | Previous.push_back(cast<NamedDecl>(ND->getCanonicalDecl())); | |||
3199 | else | |||
3200 | Previous[Number] = cast<NamedDecl>(ND->getCanonicalDecl()); | |||
3201 | }); | |||
3202 | } | |||
3203 | ||||
3204 | return Index < Previous.size() ? Previous[Index] : nullptr; | |||
3205 | } | |||
3206 | ||||
3207 | void ASTDeclReader::setAnonymousDeclForMerging(ASTReader &Reader, | |||
3208 | DeclContext *DC, unsigned Index, | |||
3209 | NamedDecl *D) { | |||
3210 | auto *CanonDC = cast<Decl>(DC)->getCanonicalDecl(); | |||
3211 | ||||
3212 | auto &Previous = Reader.AnonymousDeclarationsForMerging[CanonDC]; | |||
3213 | if (Index >= Previous.size()) | |||
3214 | Previous.resize(Index + 1); | |||
3215 | if (!Previous[Index]) | |||
3216 | Previous[Index] = D; | |||
3217 | } | |||
3218 | ||||
3219 | ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(NamedDecl *D) { | |||
3220 | DeclarationName Name = TypedefNameForLinkage ? TypedefNameForLinkage | |||
3221 | : D->getDeclName(); | |||
3222 | ||||
3223 | if (!Name && !needsAnonymousDeclarationNumber(D)) { | |||
3224 | // Don't bother trying to find unnamed declarations that are in | |||
3225 | // unmergeable contexts. | |||
3226 | FindExistingResult Result(Reader, D, /*Existing=*/nullptr, | |||
3227 | AnonymousDeclNumber, TypedefNameForLinkage); | |||
3228 | Result.suppress(); | |||
3229 | return Result; | |||
3230 | } | |||
3231 | ||||
3232 | DeclContext *DC = D->getDeclContext()->getRedeclContext(); | |||
3233 | if (TypedefNameForLinkage) { | |||
3234 | auto It = Reader.ImportedTypedefNamesForLinkage.find( | |||
3235 | std::make_pair(DC, TypedefNameForLinkage)); | |||
3236 | if (It != Reader.ImportedTypedefNamesForLinkage.end()) | |||
3237 | if (isSameEntity(It->second, D)) | |||
3238 | return FindExistingResult(Reader, D, It->second, AnonymousDeclNumber, | |||
3239 | TypedefNameForLinkage); | |||
3240 | // Go on to check in other places in case an existing typedef name | |||
3241 | // was not imported. | |||
3242 | } | |||
3243 | ||||
3244 | if (needsAnonymousDeclarationNumber(D)) { | |||
3245 | // This is an anonymous declaration that we may need to merge. Look it up | |||
3246 | // in its context by number. | |||
3247 | if (auto *Existing = getAnonymousDeclForMerging( | |||
3248 | Reader, D->getLexicalDeclContext(), AnonymousDeclNumber)) | |||
3249 | if (isSameEntity(Existing, D)) | |||
3250 | return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber, | |||
3251 | TypedefNameForLinkage); | |||
3252 | } else if (DC->isTranslationUnit() && | |||
3253 | !Reader.getContext().getLangOpts().CPlusPlus) { | |||
3254 | IdentifierResolver &IdResolver = Reader.getIdResolver(); | |||
3255 | ||||
3256 | // Temporarily consider the identifier to be up-to-date. We don't want to | |||
3257 | // cause additional lookups here. | |||
3258 | class UpToDateIdentifierRAII { | |||
3259 | IdentifierInfo *II; | |||
3260 | bool WasOutToDate = false; | |||
3261 | ||||
3262 | public: | |||
3263 | explicit UpToDateIdentifierRAII(IdentifierInfo *II) : II(II) { | |||
3264 | if (II) { | |||
3265 | WasOutToDate = II->isOutOfDate(); | |||
3266 | if (WasOutToDate) | |||
3267 | II->setOutOfDate(false); | |||
3268 | } | |||
3269 | } | |||
3270 | ||||
3271 | ~UpToDateIdentifierRAII() { | |||
3272 | if (WasOutToDate) | |||
3273 | II->setOutOfDate(true); | |||
3274 | } | |||
3275 | } UpToDate(Name.getAsIdentifierInfo()); | |||
3276 | ||||
3277 | for (IdentifierResolver::iterator I = IdResolver.begin(Name), | |||
3278 | IEnd = IdResolver.end(); | |||
3279 | I != IEnd; ++I) { | |||
3280 | if (NamedDecl *Existing = getDeclForMerging(*I, TypedefNameForLinkage)) | |||
3281 | if (isSameEntity(Existing, D)) | |||
3282 | return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber, | |||
3283 | TypedefNameForLinkage); | |||
3284 | } | |||
3285 | } else if (DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) { | |||
3286 | DeclContext::lookup_result R = MergeDC->noload_lookup(Name); | |||
3287 | for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E; ++I) { | |||
3288 | if (NamedDecl *Existing = getDeclForMerging(*I, TypedefNameForLinkage)) | |||
3289 | if (isSameEntity(Existing, D)) | |||
3290 | return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber, | |||
3291 | TypedefNameForLinkage); | |||
3292 | } | |||
3293 | } else { | |||
3294 | // Not in a mergeable context. | |||
3295 | return FindExistingResult(Reader); | |||
3296 | } | |||
3297 | ||||
3298 | // If this declaration is from a merged context, make a note that we need to | |||
3299 | // check that the canonical definition of that context contains the decl. | |||
3300 | // | |||
3301 | // FIXME: We should do something similar if we merge two definitions of the | |||
3302 | // same template specialization into the same CXXRecordDecl. | |||
3303 | auto MergedDCIt = Reader.MergedDeclContexts.find(D->getLexicalDeclContext()); | |||
3304 | if (MergedDCIt != Reader.MergedDeclContexts.end() && | |||
3305 | MergedDCIt->second == D->getDeclContext()) | |||
3306 | Reader.PendingOdrMergeChecks.push_back(D); | |||
3307 | ||||
3308 | return FindExistingResult(Reader, D, /*Existing=*/nullptr, | |||
3309 | AnonymousDeclNumber, TypedefNameForLinkage); | |||
3310 | } | |||
3311 | ||||
3312 | template<typename DeclT> | |||
3313 | Decl *ASTDeclReader::getMostRecentDeclImpl(Redeclarable<DeclT> *D) { | |||
3314 | return D->RedeclLink.getLatestNotUpdated(); | |||
3315 | } | |||
3316 | ||||
3317 | Decl *ASTDeclReader::getMostRecentDeclImpl(...) { | |||
3318 | llvm_unreachable("getMostRecentDecl on non-redeclarable declaration")::llvm::llvm_unreachable_internal("getMostRecentDecl on non-redeclarable declaration" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3318); | |||
3319 | } | |||
3320 | ||||
3321 | Decl *ASTDeclReader::getMostRecentDecl(Decl *D) { | |||
3322 | assert(D)(static_cast <bool> (D) ? void (0) : __assert_fail ("D" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3322, __extension__ __PRETTY_FUNCTION__)); | |||
3323 | ||||
3324 | switch (D->getKind()) { | |||
3325 | #define ABSTRACT_DECL(TYPE) | |||
3326 | #define DECL(TYPE, BASE) \ | |||
3327 | case Decl::TYPE: \ | |||
3328 | return getMostRecentDeclImpl(cast<TYPE##Decl>(D)); | |||
3329 | #include "clang/AST/DeclNodes.inc" | |||
3330 | } | |||
3331 | llvm_unreachable("unknown decl kind")::llvm::llvm_unreachable_internal("unknown decl kind", "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3331); | |||
3332 | } | |||
3333 | ||||
3334 | Decl *ASTReader::getMostRecentExistingDecl(Decl *D) { | |||
3335 | return ASTDeclReader::getMostRecentDecl(D->getCanonicalDecl()); | |||
3336 | } | |||
3337 | ||||
3338 | template<typename DeclT> | |||
3339 | void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader, | |||
3340 | Redeclarable<DeclT> *D, | |||
3341 | Decl *Previous, Decl *Canon) { | |||
3342 | D->RedeclLink.setPrevious(cast<DeclT>(Previous)); | |||
3343 | D->First = cast<DeclT>(Previous)->First; | |||
3344 | } | |||
3345 | ||||
3346 | namespace clang { | |||
3347 | ||||
3348 | template<> | |||
3349 | void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader, | |||
3350 | Redeclarable<VarDecl> *D, | |||
3351 | Decl *Previous, Decl *Canon) { | |||
3352 | auto *VD = static_cast<VarDecl *>(D); | |||
3353 | auto *PrevVD = cast<VarDecl>(Previous); | |||
3354 | D->RedeclLink.setPrevious(PrevVD); | |||
3355 | D->First = PrevVD->First; | |||
3356 | ||||
3357 | // We should keep at most one definition on the chain. | |||
3358 | // FIXME: Cache the definition once we've found it. Building a chain with | |||
3359 | // N definitions currently takes O(N^2) time here. | |||
3360 | if (VD->isThisDeclarationADefinition() == VarDecl::Definition) { | |||
3361 | for (VarDecl *CurD = PrevVD; CurD; CurD = CurD->getPreviousDecl()) { | |||
3362 | if (CurD->isThisDeclarationADefinition() == VarDecl::Definition) { | |||
3363 | Reader.mergeDefinitionVisibility(CurD, VD); | |||
3364 | VD->demoteThisDefinitionToDeclaration(); | |||
3365 | break; | |||
3366 | } | |||
3367 | } | |||
3368 | } | |||
3369 | } | |||
3370 | ||||
3371 | template<> | |||
3372 | void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader, | |||
3373 | Redeclarable<FunctionDecl> *D, | |||
3374 | Decl *Previous, Decl *Canon) { | |||
3375 | auto *FD = static_cast<FunctionDecl *>(D); | |||
3376 | auto *PrevFD = cast<FunctionDecl>(Previous); | |||
3377 | ||||
3378 | FD->RedeclLink.setPrevious(PrevFD); | |||
3379 | FD->First = PrevFD->First; | |||
3380 | ||||
3381 | // If the previous declaration is an inline function declaration, then this | |||
3382 | // declaration is too. | |||
3383 | if (PrevFD->IsInline != FD->IsInline) { | |||
3384 | // FIXME: [dcl.fct.spec]p4: | |||
3385 | // If a function with external linkage is declared inline in one | |||
3386 | // translation unit, it shall be declared inline in all translation | |||
3387 | // units in which it appears. | |||
3388 | // | |||
3389 | // Be careful of this case: | |||
3390 | // | |||
3391 | // module A: | |||
3392 | // template<typename T> struct X { void f(); }; | |||
3393 | // template<typename T> inline void X<T>::f() {} | |||
3394 | // | |||
3395 | // module B instantiates the declaration of X<int>::f | |||
3396 | // module C instantiates the definition of X<int>::f | |||
3397 | // | |||
3398 | // If module B and C are merged, we do not have a violation of this rule. | |||
3399 | FD->IsInline = true; | |||
3400 | } | |||
3401 | ||||
3402 | // If we need to propagate an exception specification along the redecl | |||
3403 | // chain, make a note of that so that we can do so later. | |||
3404 | auto *FPT = FD->getType()->getAs<FunctionProtoType>(); | |||
3405 | auto *PrevFPT = PrevFD->getType()->getAs<FunctionProtoType>(); | |||
3406 | if (FPT && PrevFPT) { | |||
3407 | bool IsUnresolved = isUnresolvedExceptionSpec(FPT->getExceptionSpecType()); | |||
3408 | bool WasUnresolved = | |||
3409 | isUnresolvedExceptionSpec(PrevFPT->getExceptionSpecType()); | |||
3410 | if (IsUnresolved != WasUnresolved) | |||
3411 | Reader.PendingExceptionSpecUpdates.insert( | |||
3412 | std::make_pair(Canon, IsUnresolved ? PrevFD : FD)); | |||
3413 | } | |||
3414 | } | |||
3415 | ||||
3416 | } // namespace clang | |||
3417 | ||||
3418 | void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader, ...) { | |||
3419 | llvm_unreachable("attachPreviousDecl on non-redeclarable declaration")::llvm::llvm_unreachable_internal("attachPreviousDecl on non-redeclarable declaration" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3419); | |||
3420 | } | |||
3421 | ||||
3422 | /// Inherit the default template argument from \p From to \p To. Returns | |||
3423 | /// \c false if there is no default template for \p From. | |||
3424 | template <typename ParmDecl> | |||
3425 | static bool inheritDefaultTemplateArgument(ASTContext &Context, ParmDecl *From, | |||
3426 | Decl *ToD) { | |||
3427 | auto *To = cast<ParmDecl>(ToD); | |||
3428 | if (!From->hasDefaultArgument()) | |||
3429 | return false; | |||
3430 | To->setInheritedDefaultArgument(Context, From); | |||
3431 | return true; | |||
3432 | } | |||
3433 | ||||
3434 | static void inheritDefaultTemplateArguments(ASTContext &Context, | |||
3435 | TemplateDecl *From, | |||
3436 | TemplateDecl *To) { | |||
3437 | auto *FromTP = From->getTemplateParameters(); | |||
3438 | auto *ToTP = To->getTemplateParameters(); | |||
3439 | assert(FromTP->size() == ToTP->size() && "merged mismatched templates?")(static_cast <bool> (FromTP->size() == ToTP->size () && "merged mismatched templates?") ? void (0) : __assert_fail ("FromTP->size() == ToTP->size() && \"merged mismatched templates?\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3439, __extension__ __PRETTY_FUNCTION__)); | |||
3440 | ||||
3441 | for (unsigned I = 0, N = FromTP->size(); I != N; ++I) { | |||
3442 | NamedDecl *FromParam = FromTP->getParam(N - I - 1); | |||
3443 | if (FromParam->isParameterPack()) | |||
3444 | continue; | |||
3445 | NamedDecl *ToParam = ToTP->getParam(N - I - 1); | |||
3446 | ||||
3447 | if (auto *FTTP = dyn_cast<TemplateTypeParmDecl>(FromParam)) { | |||
3448 | if (!inheritDefaultTemplateArgument(Context, FTTP, ToParam)) | |||
3449 | break; | |||
3450 | } else if (auto *FNTTP = dyn_cast<NonTypeTemplateParmDecl>(FromParam)) { | |||
3451 | if (!inheritDefaultTemplateArgument(Context, FNTTP, ToParam)) | |||
3452 | break; | |||
3453 | } else { | |||
3454 | if (!inheritDefaultTemplateArgument( | |||
3455 | Context, cast<TemplateTemplateParmDecl>(FromParam), ToParam)) | |||
3456 | break; | |||
3457 | } | |||
3458 | } | |||
3459 | } | |||
3460 | ||||
3461 | void ASTDeclReader::attachPreviousDecl(ASTReader &Reader, Decl *D, | |||
3462 | Decl *Previous, Decl *Canon) { | |||
3463 | assert(D && Previous)(static_cast <bool> (D && Previous) ? void (0) : __assert_fail ("D && Previous", "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3463, __extension__ __PRETTY_FUNCTION__)); | |||
3464 | ||||
3465 | switch (D->getKind()) { | |||
3466 | #define ABSTRACT_DECL(TYPE) | |||
3467 | #define DECL(TYPE, BASE) \ | |||
3468 | case Decl::TYPE: \ | |||
3469 | attachPreviousDeclImpl(Reader, cast<TYPE##Decl>(D), Previous, Canon); \ | |||
3470 | break; | |||
3471 | #include "clang/AST/DeclNodes.inc" | |||
3472 | } | |||
3473 | ||||
3474 | // If the declaration was visible in one module, a redeclaration of it in | |||
3475 | // another module remains visible even if it wouldn't be visible by itself. | |||
3476 | // | |||
3477 | // FIXME: In this case, the declaration should only be visible if a module | |||
3478 | // that makes it visible has been imported. | |||
3479 | D->IdentifierNamespace |= | |||
3480 | Previous->IdentifierNamespace & | |||
3481 | (Decl::IDNS_Ordinary | Decl::IDNS_Tag | Decl::IDNS_Type); | |||
3482 | ||||
3483 | // If the declaration declares a template, it may inherit default arguments | |||
3484 | // from the previous declaration. | |||
3485 | if (auto *TD = dyn_cast<TemplateDecl>(D)) | |||
3486 | inheritDefaultTemplateArguments(Reader.getContext(), | |||
3487 | cast<TemplateDecl>(Previous), TD); | |||
3488 | } | |||
3489 | ||||
3490 | template<typename DeclT> | |||
3491 | void ASTDeclReader::attachLatestDeclImpl(Redeclarable<DeclT> *D, Decl *Latest) { | |||
3492 | D->RedeclLink.setLatest(cast<DeclT>(Latest)); | |||
3493 | } | |||
3494 | ||||
3495 | void ASTDeclReader::attachLatestDeclImpl(...) { | |||
3496 | llvm_unreachable("attachLatestDecl on non-redeclarable declaration")::llvm::llvm_unreachable_internal("attachLatestDecl on non-redeclarable declaration" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3496); | |||
3497 | } | |||
3498 | ||||
3499 | void ASTDeclReader::attachLatestDecl(Decl *D, Decl *Latest) { | |||
3500 | assert(D && Latest)(static_cast <bool> (D && Latest) ? void (0) : __assert_fail ("D && Latest", "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3500, __extension__ __PRETTY_FUNCTION__)); | |||
3501 | ||||
3502 | switch (D->getKind()) { | |||
3503 | #define ABSTRACT_DECL(TYPE) | |||
3504 | #define DECL(TYPE, BASE) \ | |||
3505 | case Decl::TYPE: \ | |||
3506 | attachLatestDeclImpl(cast<TYPE##Decl>(D), Latest); \ | |||
3507 | break; | |||
3508 | #include "clang/AST/DeclNodes.inc" | |||
3509 | } | |||
3510 | } | |||
3511 | ||||
3512 | template<typename DeclT> | |||
3513 | void ASTDeclReader::markIncompleteDeclChainImpl(Redeclarable<DeclT> *D) { | |||
3514 | D->RedeclLink.markIncomplete(); | |||
3515 | } | |||
3516 | ||||
3517 | void ASTDeclReader::markIncompleteDeclChainImpl(...) { | |||
3518 | llvm_unreachable("markIncompleteDeclChain on non-redeclarable declaration")::llvm::llvm_unreachable_internal("markIncompleteDeclChain on non-redeclarable declaration" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3518); | |||
3519 | } | |||
3520 | ||||
3521 | void ASTReader::markIncompleteDeclChain(Decl *D) { | |||
3522 | switch (D->getKind()) { | |||
3523 | #define ABSTRACT_DECL(TYPE) | |||
3524 | #define DECL(TYPE, BASE) \ | |||
3525 | case Decl::TYPE: \ | |||
3526 | ASTDeclReader::markIncompleteDeclChainImpl(cast<TYPE##Decl>(D)); \ | |||
3527 | break; | |||
3528 | #include "clang/AST/DeclNodes.inc" | |||
3529 | } | |||
3530 | } | |||
3531 | ||||
3532 | /// Read the declaration at the given offset from the AST file. | |||
3533 | Decl *ASTReader::ReadDeclRecord(DeclID ID) { | |||
3534 | unsigned Index = ID - NUM_PREDEF_DECL_IDS; | |||
3535 | SourceLocation DeclLoc; | |||
3536 | RecordLocation Loc = DeclCursorForID(ID, DeclLoc); | |||
3537 | llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor; | |||
3538 | // Keep track of where we are in the stream, then jump back there | |||
3539 | // after reading this declaration. | |||
3540 | SavedStreamPosition SavedPosition(DeclsCursor); | |||
3541 | ||||
3542 | ReadingKindTracker ReadingKind(Read_Decl, *this); | |||
3543 | ||||
3544 | // Note that we are loading a declaration record. | |||
3545 | Deserializing ADecl(this); | |||
3546 | ||||
3547 | DeclsCursor.JumpToBit(Loc.Offset); | |||
3548 | ASTRecordReader Record(*this, *Loc.F); | |||
3549 | ASTDeclReader Reader(*this, Record, Loc, ID, DeclLoc); | |||
3550 | unsigned Code = DeclsCursor.ReadCode(); | |||
3551 | ||||
3552 | ASTContext &Context = getContext(); | |||
3553 | Decl *D = nullptr; | |||
3554 | switch ((DeclCode)Record.readRecord(DeclsCursor, Code)) { | |||
3555 | case DECL_CONTEXT_LEXICAL: | |||
3556 | case DECL_CONTEXT_VISIBLE: | |||
3557 | llvm_unreachable("Record cannot be de-serialized with ReadDeclRecord")::llvm::llvm_unreachable_internal("Record cannot be de-serialized with ReadDeclRecord" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3557); | |||
3558 | case DECL_TYPEDEF: | |||
3559 | D = TypedefDecl::CreateDeserialized(Context, ID); | |||
3560 | break; | |||
3561 | case DECL_TYPEALIAS: | |||
3562 | D = TypeAliasDecl::CreateDeserialized(Context, ID); | |||
3563 | break; | |||
3564 | case DECL_ENUM: | |||
3565 | D = EnumDecl::CreateDeserialized(Context, ID); | |||
3566 | break; | |||
3567 | case DECL_RECORD: | |||
3568 | D = RecordDecl::CreateDeserialized(Context, ID); | |||
3569 | break; | |||
3570 | case DECL_ENUM_CONSTANT: | |||
3571 | D = EnumConstantDecl::CreateDeserialized(Context, ID); | |||
3572 | break; | |||
3573 | case DECL_FUNCTION: | |||
3574 | D = FunctionDecl::CreateDeserialized(Context, ID); | |||
3575 | break; | |||
3576 | case DECL_LINKAGE_SPEC: | |||
3577 | D = LinkageSpecDecl::CreateDeserialized(Context, ID); | |||
3578 | break; | |||
3579 | case DECL_EXPORT: | |||
3580 | D = ExportDecl::CreateDeserialized(Context, ID); | |||
3581 | break; | |||
3582 | case DECL_LABEL: | |||
3583 | D = LabelDecl::CreateDeserialized(Context, ID); | |||
3584 | break; | |||
3585 | case DECL_NAMESPACE: | |||
3586 | D = NamespaceDecl::CreateDeserialized(Context, ID); | |||
3587 | break; | |||
3588 | case DECL_NAMESPACE_ALIAS: | |||
3589 | D = NamespaceAliasDecl::CreateDeserialized(Context, ID); | |||
3590 | break; | |||
3591 | case DECL_USING: | |||
3592 | D = UsingDecl::CreateDeserialized(Context, ID); | |||
3593 | break; | |||
3594 | case DECL_USING_PACK: | |||
3595 | D = UsingPackDecl::CreateDeserialized(Context, ID, Record.readInt()); | |||
3596 | break; | |||
3597 | case DECL_USING_SHADOW: | |||
3598 | D = UsingShadowDecl::CreateDeserialized(Context, ID); | |||
3599 | break; | |||
3600 | case DECL_CONSTRUCTOR_USING_SHADOW: | |||
3601 | D = ConstructorUsingShadowDecl::CreateDeserialized(Context, ID); | |||
3602 | break; | |||
3603 | case DECL_USING_DIRECTIVE: | |||
3604 | D = UsingDirectiveDecl::CreateDeserialized(Context, ID); | |||
3605 | break; | |||
3606 | case DECL_UNRESOLVED_USING_VALUE: | |||
3607 | D = UnresolvedUsingValueDecl::CreateDeserialized(Context, ID); | |||
3608 | break; | |||
3609 | case DECL_UNRESOLVED_USING_TYPENAME: | |||
3610 | D = UnresolvedUsingTypenameDecl::CreateDeserialized(Context, ID); | |||
3611 | break; | |||
3612 | case DECL_CXX_RECORD: | |||
3613 | D = CXXRecordDecl::CreateDeserialized(Context, ID); | |||
3614 | break; | |||
3615 | case DECL_CXX_DEDUCTION_GUIDE: | |||
3616 | D = CXXDeductionGuideDecl::CreateDeserialized(Context, ID); | |||
3617 | break; | |||
3618 | case DECL_CXX_METHOD: | |||
3619 | D = CXXMethodDecl::CreateDeserialized(Context, ID); | |||
3620 | break; | |||
3621 | case DECL_CXX_CONSTRUCTOR: | |||
3622 | D = CXXConstructorDecl::CreateDeserialized(Context, ID, false); | |||
3623 | break; | |||
3624 | case DECL_CXX_INHERITED_CONSTRUCTOR: | |||
3625 | D = CXXConstructorDecl::CreateDeserialized(Context, ID, true); | |||
3626 | break; | |||
3627 | case DECL_CXX_DESTRUCTOR: | |||
3628 | D = CXXDestructorDecl::CreateDeserialized(Context, ID); | |||
3629 | break; | |||
3630 | case DECL_CXX_CONVERSION: | |||
3631 | D = CXXConversionDecl::CreateDeserialized(Context, ID); | |||
3632 | break; | |||
3633 | case DECL_ACCESS_SPEC: | |||
3634 | D = AccessSpecDecl::CreateDeserialized(Context, ID); | |||
3635 | break; | |||
3636 | case DECL_FRIEND: | |||
3637 | D = FriendDecl::CreateDeserialized(Context, ID, Record.readInt()); | |||
3638 | break; | |||
3639 | case DECL_FRIEND_TEMPLATE: | |||
3640 | D = FriendTemplateDecl::CreateDeserialized(Context, ID); | |||
3641 | break; | |||
3642 | case DECL_CLASS_TEMPLATE: | |||
3643 | D = ClassTemplateDecl::CreateDeserialized(Context, ID); | |||
3644 | break; | |||
3645 | case DECL_CLASS_TEMPLATE_SPECIALIZATION: | |||
3646 | D = ClassTemplateSpecializationDecl::CreateDeserialized(Context, ID); | |||
3647 | break; | |||
3648 | case DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION: | |||
3649 | D = ClassTemplatePartialSpecializationDecl::CreateDeserialized(Context, ID); | |||
3650 | break; | |||
3651 | case DECL_VAR_TEMPLATE: | |||
3652 | D = VarTemplateDecl::CreateDeserialized(Context, ID); | |||
3653 | break; | |||
3654 | case DECL_VAR_TEMPLATE_SPECIALIZATION: | |||
3655 | D = VarTemplateSpecializationDecl::CreateDeserialized(Context, ID); | |||
3656 | break; | |||
3657 | case DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION: | |||
3658 | D = VarTemplatePartialSpecializationDecl::CreateDeserialized(Context, ID); | |||
3659 | break; | |||
3660 | case DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION: | |||
3661 | D = ClassScopeFunctionSpecializationDecl::CreateDeserialized(Context, ID); | |||
3662 | break; | |||
3663 | case DECL_FUNCTION_TEMPLATE: | |||
3664 | D = FunctionTemplateDecl::CreateDeserialized(Context, ID); | |||
3665 | break; | |||
3666 | case DECL_TEMPLATE_TYPE_PARM: | |||
3667 | D = TemplateTypeParmDecl::CreateDeserialized(Context, ID); | |||
3668 | break; | |||
3669 | case DECL_NON_TYPE_TEMPLATE_PARM: | |||
3670 | D = NonTypeTemplateParmDecl::CreateDeserialized(Context, ID); | |||
3671 | break; | |||
3672 | case DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK: | |||
3673 | D = NonTypeTemplateParmDecl::CreateDeserialized(Context, ID, | |||
3674 | Record.readInt()); | |||
3675 | break; | |||
3676 | case DECL_TEMPLATE_TEMPLATE_PARM: | |||
3677 | D = TemplateTemplateParmDecl::CreateDeserialized(Context, ID); | |||
3678 | break; | |||
3679 | case DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK: | |||
3680 | D = TemplateTemplateParmDecl::CreateDeserialized(Context, ID, | |||
3681 | Record.readInt()); | |||
3682 | break; | |||
3683 | case DECL_TYPE_ALIAS_TEMPLATE: | |||
3684 | D = TypeAliasTemplateDecl::CreateDeserialized(Context, ID); | |||
3685 | break; | |||
3686 | case DECL_STATIC_ASSERT: | |||
3687 | D = StaticAssertDecl::CreateDeserialized(Context, ID); | |||
3688 | break; | |||
3689 | case DECL_OBJC_METHOD: | |||
3690 | D = ObjCMethodDecl::CreateDeserialized(Context, ID); | |||
3691 | break; | |||
3692 | case DECL_OBJC_INTERFACE: | |||
3693 | D = ObjCInterfaceDecl::CreateDeserialized(Context, ID); | |||
3694 | break; | |||
3695 | case DECL_OBJC_IVAR: | |||
3696 | D = ObjCIvarDecl::CreateDeserialized(Context, ID); | |||
3697 | break; | |||
3698 | case DECL_OBJC_PROTOCOL: | |||
3699 | D = ObjCProtocolDecl::CreateDeserialized(Context, ID); | |||
3700 | break; | |||
3701 | case DECL_OBJC_AT_DEFS_FIELD: | |||
3702 | D = ObjCAtDefsFieldDecl::CreateDeserialized(Context, ID); | |||
3703 | break; | |||
3704 | case DECL_OBJC_CATEGORY: | |||
3705 | D = ObjCCategoryDecl::CreateDeserialized(Context, ID); | |||
3706 | break; | |||
3707 | case DECL_OBJC_CATEGORY_IMPL: | |||
3708 | D = ObjCCategoryImplDecl::CreateDeserialized(Context, ID); | |||
3709 | break; | |||
3710 | case DECL_OBJC_IMPLEMENTATION: | |||
3711 | D = ObjCImplementationDecl::CreateDeserialized(Context, ID); | |||
3712 | break; | |||
3713 | case DECL_OBJC_COMPATIBLE_ALIAS: | |||
3714 | D = ObjCCompatibleAliasDecl::CreateDeserialized(Context, ID); | |||
3715 | break; | |||
3716 | case DECL_OBJC_PROPERTY: | |||
3717 | D = ObjCPropertyDecl::CreateDeserialized(Context, ID); | |||
3718 | break; | |||
3719 | case DECL_OBJC_PROPERTY_IMPL: | |||
3720 | D = ObjCPropertyImplDecl::CreateDeserialized(Context, ID); | |||
3721 | break; | |||
3722 | case DECL_FIELD: | |||
3723 | D = FieldDecl::CreateDeserialized(Context, ID); | |||
3724 | break; | |||
3725 | case DECL_INDIRECTFIELD: | |||
3726 | D = IndirectFieldDecl::CreateDeserialized(Context, ID); | |||
3727 | break; | |||
3728 | case DECL_VAR: | |||
3729 | D = VarDecl::CreateDeserialized(Context, ID); | |||
3730 | break; | |||
3731 | case DECL_IMPLICIT_PARAM: | |||
3732 | D = ImplicitParamDecl::CreateDeserialized(Context, ID); | |||
3733 | break; | |||
3734 | case DECL_PARM_VAR: | |||
3735 | D = ParmVarDecl::CreateDeserialized(Context, ID); | |||
3736 | break; | |||
3737 | case DECL_DECOMPOSITION: | |||
3738 | D = DecompositionDecl::CreateDeserialized(Context, ID, Record.readInt()); | |||
3739 | break; | |||
3740 | case DECL_BINDING: | |||
3741 | D = BindingDecl::CreateDeserialized(Context, ID); | |||
3742 | break; | |||
3743 | case DECL_FILE_SCOPE_ASM: | |||
3744 | D = FileScopeAsmDecl::CreateDeserialized(Context, ID); | |||
3745 | break; | |||
3746 | case DECL_BLOCK: | |||
3747 | D = BlockDecl::CreateDeserialized(Context, ID); | |||
3748 | break; | |||
3749 | case DECL_MS_PROPERTY: | |||
3750 | D = MSPropertyDecl::CreateDeserialized(Context, ID); | |||
3751 | break; | |||
3752 | case DECL_CAPTURED: | |||
3753 | D = CapturedDecl::CreateDeserialized(Context, ID, Record.readInt()); | |||
3754 | break; | |||
3755 | case DECL_CXX_BASE_SPECIFIERS: | |||
3756 | Error("attempt to read a C++ base-specifier record as a declaration"); | |||
3757 | return nullptr; | |||
3758 | case DECL_CXX_CTOR_INITIALIZERS: | |||
3759 | Error("attempt to read a C++ ctor initializer record as a declaration"); | |||
3760 | return nullptr; | |||
3761 | case DECL_IMPORT: | |||
3762 | // Note: last entry of the ImportDecl record is the number of stored source | |||
3763 | // locations. | |||
3764 | D = ImportDecl::CreateDeserialized(Context, ID, Record.back()); | |||
3765 | break; | |||
3766 | case DECL_OMP_THREADPRIVATE: | |||
3767 | D = OMPThreadPrivateDecl::CreateDeserialized(Context, ID, Record.readInt()); | |||
3768 | break; | |||
3769 | case DECL_OMP_DECLARE_REDUCTION: | |||
3770 | D = OMPDeclareReductionDecl::CreateDeserialized(Context, ID); | |||
3771 | break; | |||
3772 | case DECL_OMP_CAPTUREDEXPR: | |||
3773 | D = OMPCapturedExprDecl::CreateDeserialized(Context, ID); | |||
3774 | break; | |||
3775 | case DECL_PRAGMA_COMMENT: | |||
3776 | D = PragmaCommentDecl::CreateDeserialized(Context, ID, Record.readInt()); | |||
3777 | break; | |||
3778 | case DECL_PRAGMA_DETECT_MISMATCH: | |||
3779 | D = PragmaDetectMismatchDecl::CreateDeserialized(Context, ID, | |||
3780 | Record.readInt()); | |||
3781 | break; | |||
3782 | case DECL_EMPTY: | |||
3783 | D = EmptyDecl::CreateDeserialized(Context, ID); | |||
3784 | break; | |||
3785 | case DECL_OBJC_TYPE_PARAM: | |||
3786 | D = ObjCTypeParamDecl::CreateDeserialized(Context, ID); | |||
3787 | break; | |||
3788 | } | |||
3789 | ||||
3790 | assert(D && "Unknown declaration reading AST file")(static_cast <bool> (D && "Unknown declaration reading AST file" ) ? void (0) : __assert_fail ("D && \"Unknown declaration reading AST file\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3790, __extension__ __PRETTY_FUNCTION__)); | |||
3791 | LoadedDecl(Index, D); | |||
3792 | // Set the DeclContext before doing any deserialization, to make sure internal | |||
3793 | // calls to Decl::getASTContext() by Decl's methods will find the | |||
3794 | // TranslationUnitDecl without crashing. | |||
3795 | D->setDeclContext(Context.getTranslationUnitDecl()); | |||
3796 | Reader.Visit(D); | |||
3797 | ||||
3798 | // If this declaration is also a declaration context, get the | |||
3799 | // offsets for its tables of lexical and visible declarations. | |||
3800 | if (auto *DC = dyn_cast<DeclContext>(D)) { | |||
3801 | std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC); | |||
3802 | if (Offsets.first && | |||
3803 | ReadLexicalDeclContextStorage(*Loc.F, DeclsCursor, Offsets.first, DC)) | |||
3804 | return nullptr; | |||
3805 | if (Offsets.second && | |||
3806 | ReadVisibleDeclContextStorage(*Loc.F, DeclsCursor, Offsets.second, ID)) | |||
3807 | return nullptr; | |||
3808 | } | |||
3809 | assert(Record.getIdx() == Record.size())(static_cast <bool> (Record.getIdx() == Record.size()) ? void (0) : __assert_fail ("Record.getIdx() == Record.size()" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3809, __extension__ __PRETTY_FUNCTION__)); | |||
3810 | ||||
3811 | // Load any relevant update records. | |||
3812 | PendingUpdateRecords.push_back( | |||
3813 | PendingUpdateRecord(ID, D, /*JustLoaded=*/true)); | |||
3814 | ||||
3815 | // Load the categories after recursive loading is finished. | |||
3816 | if (auto *Class = dyn_cast<ObjCInterfaceDecl>(D)) | |||
3817 | // If we already have a definition when deserializing the ObjCInterfaceDecl, | |||
3818 | // we put the Decl in PendingDefinitions so we can pull the categories here. | |||
3819 | if (Class->isThisDeclarationADefinition() || | |||
3820 | PendingDefinitions.count(Class)) | |||
3821 | loadObjCCategories(ID, Class); | |||
3822 | ||||
3823 | // If we have deserialized a declaration that has a definition the | |||
3824 | // AST consumer might need to know about, queue it. | |||
3825 | // We don't pass it to the consumer immediately because we may be in recursive | |||
3826 | // loading, and some declarations may still be initializing. | |||
3827 | PotentiallyInterestingDecls.push_back( | |||
3828 | InterestingDecl(D, Reader.hasPendingBody())); | |||
3829 | ||||
3830 | return D; | |||
3831 | } | |||
3832 | ||||
3833 | void ASTReader::PassInterestingDeclsToConsumer() { | |||
3834 | assert(Consumer)(static_cast <bool> (Consumer) ? void (0) : __assert_fail ("Consumer", "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3834, __extension__ __PRETTY_FUNCTION__)); | |||
3835 | ||||
3836 | if (PassingDeclsToConsumer) | |||
3837 | return; | |||
3838 | ||||
3839 | // Guard variable to avoid recursively redoing the process of passing | |||
3840 | // decls to consumer. | |||
3841 | SaveAndRestore<bool> GuardPassingDeclsToConsumer(PassingDeclsToConsumer, | |||
3842 | true); | |||
3843 | ||||
3844 | // Ensure that we've loaded all potentially-interesting declarations | |||
3845 | // that need to be eagerly loaded. | |||
3846 | for (auto ID : EagerlyDeserializedDecls) | |||
3847 | GetDecl(ID); | |||
3848 | EagerlyDeserializedDecls.clear(); | |||
3849 | ||||
3850 | while (!PotentiallyInterestingDecls.empty()) { | |||
3851 | InterestingDecl D = PotentiallyInterestingDecls.front(); | |||
3852 | PotentiallyInterestingDecls.pop_front(); | |||
3853 | if (isConsumerInterestedIn(getContext(), D.getDecl(), D.hasPendingBody())) | |||
3854 | PassInterestingDeclToConsumer(D.getDecl()); | |||
3855 | } | |||
3856 | } | |||
3857 | ||||
3858 | void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) { | |||
3859 | // The declaration may have been modified by files later in the chain. | |||
3860 | // If this is the case, read the record containing the updates from each file | |||
3861 | // and pass it to ASTDeclReader to make the modifications. | |||
3862 | serialization::GlobalDeclID ID = Record.ID; | |||
3863 | Decl *D = Record.D; | |||
3864 | ProcessingUpdatesRAIIObj ProcessingUpdates(*this); | |||
3865 | DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID); | |||
3866 | ||||
3867 | SmallVector<serialization::DeclID, 8> PendingLazySpecializationIDs; | |||
3868 | ||||
3869 | if (UpdI != DeclUpdateOffsets.end()) { | |||
| ||||
3870 | auto UpdateOffsets = std::move(UpdI->second); | |||
3871 | DeclUpdateOffsets.erase(UpdI); | |||
3872 | ||||
3873 | // Check if this decl was interesting to the consumer. If we just loaded | |||
3874 | // the declaration, then we know it was interesting and we skip the call | |||
3875 | // to isConsumerInterestedIn because it is unsafe to call in the | |||
3876 | // current ASTReader state. | |||
3877 | bool WasInteresting = | |||
3878 | Record.JustLoaded || isConsumerInterestedIn(getContext(), D, false); | |||
3879 | for (auto &FileAndOffset : UpdateOffsets) { | |||
3880 | ModuleFile *F = FileAndOffset.first; | |||
3881 | uint64_t Offset = FileAndOffset.second; | |||
3882 | llvm::BitstreamCursor &Cursor = F->DeclsCursor; | |||
3883 | SavedStreamPosition SavedPosition(Cursor); | |||
3884 | Cursor.JumpToBit(Offset); | |||
3885 | unsigned Code = Cursor.ReadCode(); | |||
3886 | ASTRecordReader Record(*this, *F); | |||
3887 | unsigned RecCode = Record.readRecord(Cursor, Code); | |||
3888 | (void)RecCode; | |||
3889 | assert(RecCode == DECL_UPDATES && "Expected DECL_UPDATES record!")(static_cast <bool> (RecCode == DECL_UPDATES && "Expected DECL_UPDATES record!") ? void (0) : __assert_fail ( "RecCode == DECL_UPDATES && \"Expected DECL_UPDATES record!\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3889, __extension__ __PRETTY_FUNCTION__)); | |||
3890 | ||||
3891 | ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID, | |||
3892 | SourceLocation()); | |||
3893 | Reader.UpdateDecl(D, PendingLazySpecializationIDs); | |||
3894 | ||||
3895 | // We might have made this declaration interesting. If so, remember that | |||
3896 | // we need to hand it off to the consumer. | |||
3897 | if (!WasInteresting && | |||
3898 | isConsumerInterestedIn(getContext(), D, Reader.hasPendingBody())) { | |||
3899 | PotentiallyInterestingDecls.push_back( | |||
3900 | InterestingDecl(D, Reader.hasPendingBody())); | |||
3901 | WasInteresting = true; | |||
3902 | } | |||
3903 | } | |||
3904 | } | |||
3905 | // Add the lazy specializations to the template. | |||
3906 | assert((PendingLazySpecializationIDs.empty() || isa<ClassTemplateDecl>(D) ||(static_cast <bool> ((PendingLazySpecializationIDs.empty () || isa<ClassTemplateDecl>(D) || isa<FunctionTemplateDecl >(D) || isa<VarTemplateDecl>(D)) && "Must not have pending specializations" ) ? void (0) : __assert_fail ("(PendingLazySpecializationIDs.empty() || isa<ClassTemplateDecl>(D) || isa<FunctionTemplateDecl>(D) || isa<VarTemplateDecl>(D)) && \"Must not have pending specializations\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3908, __extension__ __PRETTY_FUNCTION__)) | |||
3907 | isa<FunctionTemplateDecl>(D) || isa<VarTemplateDecl>(D)) &&(static_cast <bool> ((PendingLazySpecializationIDs.empty () || isa<ClassTemplateDecl>(D) || isa<FunctionTemplateDecl >(D) || isa<VarTemplateDecl>(D)) && "Must not have pending specializations" ) ? void (0) : __assert_fail ("(PendingLazySpecializationIDs.empty() || isa<ClassTemplateDecl>(D) || isa<FunctionTemplateDecl>(D) || isa<VarTemplateDecl>(D)) && \"Must not have pending specializations\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3908, __extension__ __PRETTY_FUNCTION__)) | |||
3908 | "Must not have pending specializations")(static_cast <bool> ((PendingLazySpecializationIDs.empty () || isa<ClassTemplateDecl>(D) || isa<FunctionTemplateDecl >(D) || isa<VarTemplateDecl>(D)) && "Must not have pending specializations" ) ? void (0) : __assert_fail ("(PendingLazySpecializationIDs.empty() || isa<ClassTemplateDecl>(D) || isa<FunctionTemplateDecl>(D) || isa<VarTemplateDecl>(D)) && \"Must not have pending specializations\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3908, __extension__ __PRETTY_FUNCTION__)); | |||
3909 | if (auto *CTD = dyn_cast<ClassTemplateDecl>(D)) | |||
3910 | ASTDeclReader::AddLazySpecializations(CTD, PendingLazySpecializationIDs); | |||
3911 | else if (auto *FTD = dyn_cast<FunctionTemplateDecl>(D)) | |||
3912 | ASTDeclReader::AddLazySpecializations(FTD, PendingLazySpecializationIDs); | |||
3913 | else if (auto *VTD = dyn_cast<VarTemplateDecl>(D)) | |||
3914 | ASTDeclReader::AddLazySpecializations(VTD, PendingLazySpecializationIDs); | |||
3915 | PendingLazySpecializationIDs.clear(); | |||
3916 | ||||
3917 | // Load the pending visible updates for this decl context, if it has any. | |||
3918 | auto I = PendingVisibleUpdates.find(ID); | |||
3919 | if (I != PendingVisibleUpdates.end()) { | |||
3920 | auto VisibleUpdates = std::move(I->second); | |||
3921 | PendingVisibleUpdates.erase(I); | |||
3922 | ||||
3923 | auto *DC = cast<DeclContext>(D)->getPrimaryContext(); | |||
3924 | for (const auto &Update : VisibleUpdates) | |||
3925 | Lookups[DC].Table.add( | |||
3926 | Update.Mod, Update.Data, | |||
3927 | reader::ASTDeclContextNameLookupTrait(*this, *Update.Mod)); | |||
3928 | DC->setHasExternalVisibleStorage(true); | |||
3929 | } | |||
3930 | } | |||
3931 | ||||
3932 | void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) { | |||
3933 | // Attach FirstLocal to the end of the decl chain. | |||
3934 | Decl *CanonDecl = FirstLocal->getCanonicalDecl(); | |||
3935 | if (FirstLocal != CanonDecl) { | |||
3936 | Decl *PrevMostRecent = ASTDeclReader::getMostRecentDecl(CanonDecl); | |||
3937 | ASTDeclReader::attachPreviousDecl( | |||
3938 | *this, FirstLocal, PrevMostRecent ? PrevMostRecent : CanonDecl, | |||
3939 | CanonDecl); | |||
3940 | } | |||
3941 | ||||
3942 | if (!LocalOffset) { | |||
3943 | ASTDeclReader::attachLatestDecl(CanonDecl, FirstLocal); | |||
3944 | return; | |||
3945 | } | |||
3946 | ||||
3947 | // Load the list of other redeclarations from this module file. | |||
3948 | ModuleFile *M = getOwningModuleFile(FirstLocal); | |||
3949 | assert(M && "imported decl from no module file")(static_cast <bool> (M && "imported decl from no module file" ) ? void (0) : __assert_fail ("M && \"imported decl from no module file\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3949, __extension__ __PRETTY_FUNCTION__)); | |||
3950 | ||||
3951 | llvm::BitstreamCursor &Cursor = M->DeclsCursor; | |||
3952 | SavedStreamPosition SavedPosition(Cursor); | |||
3953 | Cursor.JumpToBit(LocalOffset); | |||
3954 | ||||
3955 | RecordData Record; | |||
3956 | unsigned Code = Cursor.ReadCode(); | |||
3957 | unsigned RecCode = Cursor.readRecord(Code, Record); | |||
3958 | (void)RecCode; | |||
3959 | assert(RecCode == LOCAL_REDECLARATIONS && "expected LOCAL_REDECLARATIONS record!")(static_cast <bool> (RecCode == LOCAL_REDECLARATIONS && "expected LOCAL_REDECLARATIONS record!") ? void (0) : __assert_fail ("RecCode == LOCAL_REDECLARATIONS && \"expected LOCAL_REDECLARATIONS record!\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 3959, __extension__ __PRETTY_FUNCTION__)); | |||
3960 | ||||
3961 | // FIXME: We have several different dispatches on decl kind here; maybe | |||
3962 | // we should instead generate one loop per kind and dispatch up-front? | |||
3963 | Decl *MostRecent = FirstLocal; | |||
3964 | for (unsigned I = 0, N = Record.size(); I != N; ++I) { | |||
3965 | auto *D = GetLocalDecl(*M, Record[N - I - 1]); | |||
3966 | ASTDeclReader::attachPreviousDecl(*this, D, MostRecent, CanonDecl); | |||
3967 | MostRecent = D; | |||
3968 | } | |||
3969 | ASTDeclReader::attachLatestDecl(CanonDecl, MostRecent); | |||
3970 | } | |||
3971 | ||||
3972 | namespace { | |||
3973 | ||||
3974 | /// Given an ObjC interface, goes through the modules and links to the | |||
3975 | /// interface all the categories for it. | |||
3976 | class ObjCCategoriesVisitor { | |||
3977 | ASTReader &Reader; | |||
3978 | ObjCInterfaceDecl *Interface; | |||
3979 | llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized; | |||
3980 | ObjCCategoryDecl *Tail = nullptr; | |||
3981 | llvm::DenseMap<DeclarationName, ObjCCategoryDecl *> NameCategoryMap; | |||
3982 | serialization::GlobalDeclID InterfaceID; | |||
3983 | unsigned PreviousGeneration; | |||
3984 | ||||
3985 | void add(ObjCCategoryDecl *Cat) { | |||
3986 | // Only process each category once. | |||
3987 | if (!Deserialized.erase(Cat)) | |||
3988 | return; | |||
3989 | ||||
3990 | // Check for duplicate categories. | |||
3991 | if (Cat->getDeclName()) { | |||
3992 | ObjCCategoryDecl *&Existing = NameCategoryMap[Cat->getDeclName()]; | |||
3993 | if (Existing && | |||
3994 | Reader.getOwningModuleFile(Existing) | |||
3995 | != Reader.getOwningModuleFile(Cat)) { | |||
3996 | // FIXME: We should not warn for duplicates in diamond: | |||
3997 | // | |||
3998 | // MT // | |||
3999 | // / \ // | |||
4000 | // ML MR // | |||
4001 | // \ / // | |||
4002 | // MB // | |||
4003 | // | |||
4004 | // If there are duplicates in ML/MR, there will be warning when | |||
4005 | // creating MB *and* when importing MB. We should not warn when | |||
4006 | // importing. | |||
4007 | Reader.Diag(Cat->getLocation(), diag::warn_dup_category_def) | |||
4008 | << Interface->getDeclName() << Cat->getDeclName(); | |||
4009 | Reader.Diag(Existing->getLocation(), diag::note_previous_definition); | |||
4010 | } else if (!Existing) { | |||
4011 | // Record this category. | |||
4012 | Existing = Cat; | |||
4013 | } | |||
4014 | } | |||
4015 | ||||
4016 | // Add this category to the end of the chain. | |||
4017 | if (Tail) | |||
4018 | ASTDeclReader::setNextObjCCategory(Tail, Cat); | |||
4019 | else | |||
4020 | Interface->setCategoryListRaw(Cat); | |||
4021 | Tail = Cat; | |||
4022 | } | |||
4023 | ||||
4024 | public: | |||
4025 | ObjCCategoriesVisitor(ASTReader &Reader, | |||
4026 | ObjCInterfaceDecl *Interface, | |||
4027 | llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized, | |||
4028 | serialization::GlobalDeclID InterfaceID, | |||
4029 | unsigned PreviousGeneration) | |||
4030 | : Reader(Reader), Interface(Interface), Deserialized(Deserialized), | |||
4031 | InterfaceID(InterfaceID), PreviousGeneration(PreviousGeneration) { | |||
4032 | // Populate the name -> category map with the set of known categories. | |||
4033 | for (auto *Cat : Interface->known_categories()) { | |||
4034 | if (Cat->getDeclName()) | |||
4035 | NameCategoryMap[Cat->getDeclName()] = Cat; | |||
4036 | ||||
4037 | // Keep track of the tail of the category list. | |||
4038 | Tail = Cat; | |||
4039 | } | |||
4040 | } | |||
4041 | ||||
4042 | bool operator()(ModuleFile &M) { | |||
4043 | // If we've loaded all of the category information we care about from | |||
4044 | // this module file, we're done. | |||
4045 | if (M.Generation <= PreviousGeneration) | |||
4046 | return true; | |||
4047 | ||||
4048 | // Map global ID of the definition down to the local ID used in this | |||
4049 | // module file. If there is no such mapping, we'll find nothing here | |||
4050 | // (or in any module it imports). | |||
4051 | DeclID LocalID = Reader.mapGlobalIDToModuleFileGlobalID(M, InterfaceID); | |||
4052 | if (!LocalID) | |||
4053 | return true; | |||
4054 | ||||
4055 | // Perform a binary search to find the local redeclarations for this | |||
4056 | // declaration (if any). | |||
4057 | const ObjCCategoriesInfo Compare = { LocalID, 0 }; | |||
4058 | const ObjCCategoriesInfo *Result | |||
4059 | = std::lower_bound(M.ObjCCategoriesMap, | |||
4060 | M.ObjCCategoriesMap + M.LocalNumObjCCategoriesInMap, | |||
4061 | Compare); | |||
4062 | if (Result == M.ObjCCategoriesMap + M.LocalNumObjCCategoriesInMap || | |||
4063 | Result->DefinitionID != LocalID) { | |||
4064 | // We didn't find anything. If the class definition is in this module | |||
4065 | // file, then the module files it depends on cannot have any categories, | |||
4066 | // so suppress further lookup. | |||
4067 | return Reader.isDeclIDFromModule(InterfaceID, M); | |||
4068 | } | |||
4069 | ||||
4070 | // We found something. Dig out all of the categories. | |||
4071 | unsigned Offset = Result->Offset; | |||
4072 | unsigned N = M.ObjCCategories[Offset]; | |||
4073 | M.ObjCCategories[Offset++] = 0; // Don't try to deserialize again | |||
4074 | for (unsigned I = 0; I != N; ++I) | |||
4075 | add(cast_or_null<ObjCCategoryDecl>( | |||
4076 | Reader.GetLocalDecl(M, M.ObjCCategories[Offset++]))); | |||
4077 | return true; | |||
4078 | } | |||
4079 | }; | |||
4080 | ||||
4081 | } // namespace | |||
4082 | ||||
4083 | void ASTReader::loadObjCCategories(serialization::GlobalDeclID ID, | |||
4084 | ObjCInterfaceDecl *D, | |||
4085 | unsigned PreviousGeneration) { | |||
4086 | ObjCCategoriesVisitor Visitor(*this, D, CategoriesDeserialized, ID, | |||
4087 | PreviousGeneration); | |||
4088 | ModuleMgr.visit(Visitor); | |||
4089 | } | |||
4090 | ||||
4091 | template<typename DeclT, typename Fn> | |||
4092 | static void forAllLaterRedecls(DeclT *D, Fn F) { | |||
4093 | F(D); | |||
4094 | ||||
4095 | // Check whether we've already merged D into its redeclaration chain. | |||
4096 | // MostRecent may or may not be nullptr if D has not been merged. If | |||
4097 | // not, walk the merged redecl chain and see if it's there. | |||
4098 | auto *MostRecent = D->getMostRecentDecl(); | |||
4099 | bool Found = false; | |||
4100 | for (auto *Redecl = MostRecent; Redecl && !Found; | |||
4101 | Redecl = Redecl->getPreviousDecl()) | |||
4102 | Found = (Redecl == D); | |||
4103 | ||||
4104 | // If this declaration is merged, apply the functor to all later decls. | |||
4105 | if (Found) { | |||
4106 | for (auto *Redecl = MostRecent; Redecl != D; | |||
4107 | Redecl = Redecl->getPreviousDecl()) | |||
4108 | F(Redecl); | |||
4109 | } | |||
4110 | } | |||
4111 | ||||
4112 | void ASTDeclReader::UpdateDecl(Decl *D, | |||
4113 | llvm::SmallVectorImpl<serialization::DeclID> &PendingLazySpecializationIDs) { | |||
4114 | while (Record.getIdx() < Record.size()) { | |||
4115 | switch ((DeclUpdateKind)Record.readInt()) { | |||
4116 | case UPD_CXX_ADDED_IMPLICIT_MEMBER: { | |||
4117 | auto *RD = cast<CXXRecordDecl>(D); | |||
4118 | // FIXME: If we also have an update record for instantiating the | |||
4119 | // definition of D, we need that to happen before we get here. | |||
4120 | Decl *MD = Record.readDecl(); | |||
4121 | assert(MD && "couldn't read decl from update record")(static_cast <bool> (MD && "couldn't read decl from update record" ) ? void (0) : __assert_fail ("MD && \"couldn't read decl from update record\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 4121, __extension__ __PRETTY_FUNCTION__)); | |||
4122 | // FIXME: We should call addHiddenDecl instead, to add the member | |||
4123 | // to its DeclContext. | |||
4124 | RD->addedMember(MD); | |||
4125 | break; | |||
4126 | } | |||
4127 | ||||
4128 | case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: | |||
4129 | // It will be added to the template's lazy specialization set. | |||
4130 | PendingLazySpecializationIDs.push_back(ReadDeclID()); | |||
4131 | break; | |||
4132 | ||||
4133 | case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: { | |||
4134 | auto *Anon = ReadDeclAs<NamespaceDecl>(); | |||
4135 | ||||
4136 | // Each module has its own anonymous namespace, which is disjoint from | |||
4137 | // any other module's anonymous namespaces, so don't attach the anonymous | |||
4138 | // namespace at all. | |||
4139 | if (!Record.isModule()) { | |||
4140 | if (auto *TU = dyn_cast<TranslationUnitDecl>(D)) | |||
4141 | TU->setAnonymousNamespace(Anon); | |||
4142 | else | |||
4143 | cast<NamespaceDecl>(D)->setAnonymousNamespace(Anon); | |||
4144 | } | |||
4145 | break; | |||
4146 | } | |||
4147 | ||||
4148 | case UPD_CXX_ADDED_VAR_DEFINITION: { | |||
4149 | auto *VD = cast<VarDecl>(D); | |||
4150 | VD->NonParmVarDeclBits.IsInline = Record.readInt(); | |||
4151 | VD->NonParmVarDeclBits.IsInlineSpecified = Record.readInt(); | |||
4152 | uint64_t Val = Record.readInt(); | |||
4153 | if (Val && !VD->getInit()) { | |||
4154 | VD->setInit(Record.readExpr()); | |||
4155 | if (Val > 1) { // IsInitKnownICE = 1, IsInitNotICE = 2, IsInitICE = 3 | |||
4156 | EvaluatedStmt *Eval = VD->ensureEvaluatedStmt(); | |||
4157 | Eval->CheckedICE = true; | |||
4158 | Eval->IsICE = Val == 3; | |||
4159 | } | |||
4160 | } | |||
4161 | break; | |||
4162 | } | |||
4163 | ||||
4164 | case UPD_CXX_POINT_OF_INSTANTIATION: { | |||
4165 | SourceLocation POI = Record.readSourceLocation(); | |||
4166 | if (auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D)) { | |||
4167 | VTSD->setPointOfInstantiation(POI); | |||
4168 | } else if (auto *VD = dyn_cast<VarDecl>(D)) { | |||
4169 | VD->getMemberSpecializationInfo()->setPointOfInstantiation(POI); | |||
4170 | } else { | |||
4171 | auto *FD = cast<FunctionDecl>(D); | |||
4172 | if (auto *FTSInfo = FD->TemplateOrSpecialization | |||
4173 | .dyn_cast<FunctionTemplateSpecializationInfo *>()) | |||
4174 | FTSInfo->setPointOfInstantiation(POI); | |||
4175 | else | |||
4176 | FD->TemplateOrSpecialization.get<MemberSpecializationInfo *>() | |||
4177 | ->setPointOfInstantiation(POI); | |||
4178 | } | |||
4179 | break; | |||
4180 | } | |||
4181 | ||||
4182 | case UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT: { | |||
4183 | auto *Param = cast<ParmVarDecl>(D); | |||
4184 | ||||
4185 | // We have to read the default argument regardless of whether we use it | |||
4186 | // so that hypothetical further update records aren't messed up. | |||
4187 | // TODO: Add a function to skip over the next expr record. | |||
4188 | auto *DefaultArg = Record.readExpr(); | |||
4189 | ||||
4190 | // Only apply the update if the parameter still has an uninstantiated | |||
4191 | // default argument. | |||
4192 | if (Param->hasUninstantiatedDefaultArg()) | |||
4193 | Param->setDefaultArg(DefaultArg); | |||
4194 | break; | |||
4195 | } | |||
4196 | ||||
4197 | case UPD_CXX_INSTANTIATED_DEFAULT_MEMBER_INITIALIZER: { | |||
4198 | auto *FD = cast<FieldDecl>(D); | |||
4199 | auto *DefaultInit = Record.readExpr(); | |||
4200 | ||||
4201 | // Only apply the update if the field still has an uninstantiated | |||
4202 | // default member initializer. | |||
4203 | if (FD->hasInClassInitializer() && !FD->getInClassInitializer()) { | |||
4204 | if (DefaultInit) | |||
4205 | FD->setInClassInitializer(DefaultInit); | |||
4206 | else | |||
4207 | // Instantiation failed. We can get here if we serialized an AST for | |||
4208 | // an invalid program. | |||
4209 | FD->removeInClassInitializer(); | |||
4210 | } | |||
4211 | break; | |||
4212 | } | |||
4213 | ||||
4214 | case UPD_CXX_ADDED_FUNCTION_DEFINITION: { | |||
4215 | auto *FD = cast<FunctionDecl>(D); | |||
4216 | if (Reader.PendingBodies[FD]) { | |||
4217 | // FIXME: Maybe check for ODR violations. | |||
4218 | // It's safe to stop now because this update record is always last. | |||
4219 | return; | |||
4220 | } | |||
4221 | ||||
4222 | if (Record.readInt()) { | |||
4223 | // Maintain AST consistency: any later redeclarations of this function | |||
4224 | // are inline if this one is. (We might have merged another declaration | |||
4225 | // into this one.) | |||
4226 | forAllLaterRedecls(FD, [](FunctionDecl *FD) { | |||
4227 | FD->setImplicitlyInline(); | |||
4228 | }); | |||
4229 | } | |||
4230 | FD->setInnerLocStart(ReadSourceLocation()); | |||
4231 | ReadFunctionDefinition(FD); | |||
4232 | assert(Record.getIdx() == Record.size() && "lazy body must be last")(static_cast <bool> (Record.getIdx() == Record.size() && "lazy body must be last") ? void (0) : __assert_fail ("Record.getIdx() == Record.size() && \"lazy body must be last\"" , "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 4232, __extension__ __PRETTY_FUNCTION__)); | |||
4233 | break; | |||
4234 | } | |||
4235 | ||||
4236 | case UPD_CXX_INSTANTIATED_CLASS_DEFINITION: { | |||
4237 | auto *RD = cast<CXXRecordDecl>(D); | |||
4238 | auto *OldDD = RD->getCanonicalDecl()->DefinitionData; | |||
4239 | bool HadRealDefinition = | |||
4240 | OldDD && (OldDD->Definition != RD || | |||
4241 | !Reader.PendingFakeDefinitionData.count(OldDD)); | |||
4242 | RD->setParamDestroyedInCallee(Record.readInt()); | |||
4243 | RD->setArgPassingRestrictions( | |||
4244 | (RecordDecl::ArgPassingKind)Record.readInt()); | |||
4245 | ReadCXXRecordDefinition(RD, /*Update*/true); | |||
4246 | ||||
4247 | // Visible update is handled separately. | |||
4248 | uint64_t LexicalOffset = ReadLocalOffset(); | |||
4249 | if (!HadRealDefinition && LexicalOffset) { | |||
4250 | Record.readLexicalDeclContextStorage(LexicalOffset, RD); | |||
4251 | Reader.PendingFakeDefinitionData.erase(OldDD); | |||
4252 | } | |||
4253 | ||||
4254 | auto TSK = (TemplateSpecializationKind)Record.readInt(); | |||
4255 | SourceLocation POI = ReadSourceLocation(); | |||
4256 | if (MemberSpecializationInfo *MSInfo = | |||
4257 | RD->getMemberSpecializationInfo()) { | |||
4258 | MSInfo->setTemplateSpecializationKind(TSK); | |||
4259 | MSInfo->setPointOfInstantiation(POI); | |||
4260 | } else { | |||
4261 | auto *Spec = cast<ClassTemplateSpecializationDecl>(RD); | |||
4262 | Spec->setTemplateSpecializationKind(TSK); | |||
4263 | Spec->setPointOfInstantiation(POI); | |||
4264 | ||||
4265 | if (Record.readInt()) { | |||
4266 | auto *PartialSpec = | |||
4267 | ReadDeclAs<ClassTemplatePartialSpecializationDecl>(); | |||
4268 | SmallVector<TemplateArgument, 8> TemplArgs; | |||
4269 | Record.readTemplateArgumentList(TemplArgs); | |||
4270 | auto *TemplArgList = TemplateArgumentList::CreateCopy( | |||
4271 | Reader.getContext(), TemplArgs); | |||
4272 | ||||
4273 | // FIXME: If we already have a partial specialization set, | |||
4274 | // check that it matches. | |||
4275 | if (!Spec->getSpecializedTemplateOrPartial() | |||
4276 | .is<ClassTemplatePartialSpecializationDecl *>()) | |||
4277 | Spec->setInstantiationOf(PartialSpec, TemplArgList); | |||
4278 | } | |||
4279 | } | |||
4280 | ||||
4281 | RD->setTagKind((TagTypeKind)Record.readInt()); | |||
4282 | RD->setLocation(ReadSourceLocation()); | |||
4283 | RD->setLocStart(ReadSourceLocation()); | |||
4284 | RD->setBraceRange(ReadSourceRange()); | |||
4285 | ||||
4286 | if (Record.readInt()) { | |||
4287 | AttrVec Attrs; | |||
4288 | Record.readAttributes(Attrs); | |||
4289 | // If the declaration already has attributes, we assume that some other | |||
4290 | // AST file already loaded them. | |||
4291 | if (!D->hasAttrs()) | |||
4292 | D->setAttrsImpl(Attrs, Reader.getContext()); | |||
4293 | } | |||
4294 | break; | |||
4295 | } | |||
4296 | ||||
4297 | case UPD_CXX_RESOLVED_DTOR_DELETE: { | |||
4298 | // Set the 'operator delete' directly to avoid emitting another update | |||
4299 | // record. | |||
4300 | auto *Del = ReadDeclAs<FunctionDecl>(); | |||
4301 | auto *First = cast<CXXDestructorDecl>(D->getCanonicalDecl()); | |||
4302 | auto *ThisArg = Record.readExpr(); | |||
4303 | // FIXME: Check consistency if we have an old and new operator delete. | |||
4304 | if (!First->OperatorDelete) { | |||
4305 | First->OperatorDelete = Del; | |||
4306 | First->OperatorDeleteThisArg = ThisArg; | |||
4307 | } | |||
4308 | break; | |||
4309 | } | |||
4310 | ||||
4311 | case UPD_CXX_RESOLVED_EXCEPTION_SPEC: { | |||
4312 | FunctionProtoType::ExceptionSpecInfo ESI; | |||
4313 | SmallVector<QualType, 8> ExceptionStorage; | |||
4314 | Record.readExceptionSpec(ExceptionStorage, ESI); | |||
4315 | ||||
4316 | // Update this declaration's exception specification, if needed. | |||
4317 | auto *FD = cast<FunctionDecl>(D); | |||
4318 | auto *FPT = FD->getType()->castAs<FunctionProtoType>(); | |||
4319 | // FIXME: If the exception specification is already present, check that it | |||
4320 | // matches. | |||
4321 | if (isUnresolvedExceptionSpec(FPT->getExceptionSpecType())) { | |||
4322 | FD->setType(Reader.getContext().getFunctionType( | |||
4323 | FPT->getReturnType(), FPT->getParamTypes(), | |||
4324 | FPT->getExtProtoInfo().withExceptionSpec(ESI))); | |||
4325 | ||||
4326 | // When we get to the end of deserializing, see if there are other decls | |||
4327 | // that we need to propagate this exception specification onto. | |||
4328 | Reader.PendingExceptionSpecUpdates.insert( | |||
4329 | std::make_pair(FD->getCanonicalDecl(), FD)); | |||
4330 | } | |||
4331 | break; | |||
4332 | } | |||
4333 | ||||
4334 | case UPD_CXX_DEDUCED_RETURN_TYPE: { | |||
4335 | // FIXME: Also do this when merging redecls. | |||
4336 | QualType DeducedResultType = Record.readType(); | |||
4337 | for (auto *Redecl : merged_redecls(D)) { | |||
4338 | // FIXME: If the return type is already deduced, check that it matches. | |||
4339 | auto *FD = cast<FunctionDecl>(Redecl); | |||
4340 | Reader.getContext().adjustDeducedFunctionResultType(FD, | |||
4341 | DeducedResultType); | |||
4342 | } | |||
4343 | break; | |||
4344 | } | |||
4345 | ||||
4346 | case UPD_DECL_MARKED_USED: | |||
4347 | // Maintain AST consistency: any later redeclarations are used too. | |||
4348 | D->markUsed(Reader.getContext()); | |||
4349 | break; | |||
4350 | ||||
4351 | case UPD_MANGLING_NUMBER: | |||
4352 | Reader.getContext().setManglingNumber(cast<NamedDecl>(D), | |||
4353 | Record.readInt()); | |||
4354 | break; | |||
4355 | ||||
4356 | case UPD_STATIC_LOCAL_NUMBER: | |||
4357 | Reader.getContext().setStaticLocalNumber(cast<VarDecl>(D), | |||
4358 | Record.readInt()); | |||
4359 | break; | |||
4360 | ||||
4361 | case UPD_DECL_MARKED_OPENMP_THREADPRIVATE: | |||
4362 | D->addAttr(OMPThreadPrivateDeclAttr::CreateImplicit(Reader.getContext(), | |||
4363 | ReadSourceRange())); | |||
4364 | break; | |||
4365 | ||||
4366 | case UPD_DECL_EXPORTED: { | |||
4367 | unsigned SubmoduleID = readSubmoduleID(); | |||
4368 | auto *Exported = cast<NamedDecl>(D); | |||
4369 | if (auto *TD = dyn_cast<TagDecl>(Exported)) | |||
4370 | Exported = TD->getDefinition(); | |||
4371 | Module *Owner = SubmoduleID ? Reader.getSubmodule(SubmoduleID) : nullptr; | |||
4372 | if (Reader.getContext().getLangOpts().ModulesLocalVisibility) { | |||
4373 | Reader.getContext().mergeDefinitionIntoModule(cast<NamedDecl>(Exported), | |||
4374 | Owner); | |||
4375 | Reader.PendingMergedDefinitionsToDeduplicate.insert( | |||
4376 | cast<NamedDecl>(Exported)); | |||
4377 | } else if (Owner && Owner->NameVisibility != Module::AllVisible) { | |||
4378 | // If Owner is made visible at some later point, make this declaration | |||
4379 | // visible too. | |||
4380 | Reader.HiddenNamesMap[Owner].push_back(Exported); | |||
4381 | } else { | |||
4382 | // The declaration is now visible. | |||
4383 | Exported->setVisibleDespiteOwningModule(); | |||
4384 | } | |||
4385 | break; | |||
4386 | } | |||
4387 | ||||
4388 | case UPD_DECL_MARKED_OPENMP_DECLARETARGET: | |||
4389 | case UPD_ADDED_ATTR_TO_RECORD: | |||
4390 | AttrVec Attrs; | |||
4391 | Record.readAttributes(Attrs); | |||
4392 | assert(Attrs.size() == 1)(static_cast <bool> (Attrs.size() == 1) ? void (0) : __assert_fail ("Attrs.size() == 1", "/build/llvm-toolchain-snapshot-7~svn338205/tools/clang/lib/Serialization/ASTReaderDecl.cpp" , 4392, __extension__ __PRETTY_FUNCTION__)); | |||
4393 | D->addAttr(Attrs[0]); | |||
4394 | break; | |||
4395 | } | |||
4396 | } | |||
4397 | } |
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~svn338205/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~svn338205/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~svn338205/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~svn338205/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~svn338205/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 | ParamIdx paramIndex; | |||
686 | ||||
687 | public: | |||
688 | static AllocAlignAttr *CreateImplicit(ASTContext &Ctx, ParamIdx 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 | , ParamIdx 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 | ParamIdx 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 | ParamIdx elemSizeParam; | |||
718 | ||||
719 | ParamIdx numElemsParam; | |||
720 | ||||
721 | public: | |||
722 | static AllocSizeAttr *CreateImplicit(ASTContext &Ctx, ParamIdx ElemSizeParam, ParamIdx 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 | , ParamIdx ElemSizeParam | |||
730 | , ParamIdx 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 | , ParamIdx 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 | ParamIdx getElemSizeParam() const { | |||
754 | return elemSizeParam; | |||
755 | } | |||
756 | ||||
757 | ParamIdx 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~svn338205/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 AnyX86NoCfCheckAttr : public InheritableAttr { | |||
921 | public: | |||
922 | static AnyX86NoCfCheckAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
923 | auto *A = new (Ctx) AnyX86NoCfCheckAttr(Loc, Ctx, 0); | |||
924 | A->setImplicit(true); | |||
925 | return A; | |||
926 | } | |||
927 | ||||
928 | AnyX86NoCfCheckAttr(SourceRange R, ASTContext &Ctx | |||
929 | , unsigned SI | |||
930 | ) | |||
931 | : InheritableAttr(attr::AnyX86NoCfCheck, R, SI, false, false) | |||
932 | { | |||
933 | } | |||
934 | ||||
935 | AnyX86NoCfCheckAttr *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::AnyX86NoCfCheck; } | |||
942 | }; | |||
943 | ||||
944 | class ArcWeakrefUnavailableAttr : public InheritableAttr { | |||
945 | public: | |||
946 | static ArcWeakrefUnavailableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
947 | auto *A = new (Ctx) ArcWeakrefUnavailableAttr(Loc, Ctx, 0); | |||
948 | A->setImplicit(true); | |||
949 | return A; | |||
950 | } | |||
951 | ||||
952 | ArcWeakrefUnavailableAttr(SourceRange R, ASTContext &Ctx | |||
953 | , unsigned SI | |||
954 | ) | |||
955 | : InheritableAttr(attr::ArcWeakrefUnavailable, R, SI, false, false) | |||
956 | { | |||
957 | } | |||
958 | ||||
959 | ArcWeakrefUnavailableAttr *clone(ASTContext &C) const; | |||
960 | void printPretty(raw_ostream &OS, | |||
961 | const PrintingPolicy &Policy) const; | |||
962 | const char *getSpelling() const; | |||
963 | ||||
964 | ||||
965 | static bool classof(const Attr *A) { return A->getKind() == attr::ArcWeakrefUnavailable; } | |||
966 | }; | |||
967 | ||||
968 | class ArgumentWithTypeTagAttr : public InheritableAttr { | |||
969 | IdentifierInfo * argumentKind; | |||
970 | ||||
971 | ParamIdx argumentIdx; | |||
972 | ||||
973 | ParamIdx typeTagIdx; | |||
974 | ||||
975 | bool isPointer; | |||
976 | ||||
977 | public: | |||
978 | enum Spelling { | |||
979 | GNU_argument_with_type_tag = 0, | |||
980 | CXX11_clang_argument_with_type_tag = 1, | |||
981 | C2x_clang_argument_with_type_tag = 2, | |||
982 | GNU_pointer_with_type_tag = 3, | |||
983 | CXX11_clang_pointer_with_type_tag = 4, | |||
984 | C2x_clang_pointer_with_type_tag = 5 | |||
985 | }; | |||
986 | ||||
987 | static ArgumentWithTypeTagAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * ArgumentKind, ParamIdx ArgumentIdx, ParamIdx TypeTagIdx, bool IsPointer, SourceRange Loc = SourceRange()) { | |||
988 | auto *A = new (Ctx) ArgumentWithTypeTagAttr(Loc, Ctx, ArgumentKind, ArgumentIdx, TypeTagIdx, IsPointer, S); | |||
989 | A->setImplicit(true); | |||
990 | return A; | |||
991 | } | |||
992 | ||||
993 | static ArgumentWithTypeTagAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * ArgumentKind, ParamIdx ArgumentIdx, ParamIdx TypeTagIdx, SourceRange Loc = SourceRange()) { | |||
994 | auto *A = new (Ctx) ArgumentWithTypeTagAttr(Loc, Ctx, ArgumentKind, ArgumentIdx, TypeTagIdx, S); | |||
995 | A->setImplicit(true); | |||
996 | return A; | |||
997 | } | |||
998 | ||||
999 | ArgumentWithTypeTagAttr(SourceRange R, ASTContext &Ctx | |||
1000 | , IdentifierInfo * ArgumentKind | |||
1001 | , ParamIdx ArgumentIdx | |||
1002 | , ParamIdx TypeTagIdx | |||
1003 | , bool IsPointer | |||
1004 | , unsigned SI | |||
1005 | ) | |||
1006 | : InheritableAttr(attr::ArgumentWithTypeTag, R, SI, false, false) | |||
1007 | , argumentKind(ArgumentKind) | |||
1008 | , argumentIdx(ArgumentIdx) | |||
1009 | , typeTagIdx(TypeTagIdx) | |||
1010 | , isPointer(IsPointer) | |||
1011 | { | |||
1012 | } | |||
1013 | ||||
1014 | ArgumentWithTypeTagAttr(SourceRange R, ASTContext &Ctx | |||
1015 | , IdentifierInfo * ArgumentKind | |||
1016 | , ParamIdx ArgumentIdx | |||
1017 | , ParamIdx TypeTagIdx | |||
1018 | , unsigned SI | |||
1019 | ) | |||
1020 | : InheritableAttr(attr::ArgumentWithTypeTag, R, SI, false, false) | |||
1021 | , argumentKind(ArgumentKind) | |||
1022 | , argumentIdx(ArgumentIdx) | |||
1023 | , typeTagIdx(TypeTagIdx) | |||
1024 | , isPointer() | |||
1025 | { | |||
1026 | } | |||
1027 | ||||
1028 | ArgumentWithTypeTagAttr *clone(ASTContext &C) const; | |||
1029 | void printPretty(raw_ostream &OS, | |||
1030 | const PrintingPolicy &Policy) const; | |||
1031 | const char *getSpelling() const; | |||
1032 | Spelling getSemanticSpelling() const { | |||
1033 | switch (SpellingListIndex) { | |||
1034 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 1034); | |||
1035 | case 0: return GNU_argument_with_type_tag; | |||
1036 | case 1: return CXX11_clang_argument_with_type_tag; | |||
1037 | case 2: return C2x_clang_argument_with_type_tag; | |||
1038 | case 3: return GNU_pointer_with_type_tag; | |||
1039 | case 4: return CXX11_clang_pointer_with_type_tag; | |||
1040 | case 5: return C2x_clang_pointer_with_type_tag; | |||
1041 | } | |||
1042 | } | |||
1043 | IdentifierInfo * getArgumentKind() const { | |||
1044 | return argumentKind; | |||
1045 | } | |||
1046 | ||||
1047 | ParamIdx getArgumentIdx() const { | |||
1048 | return argumentIdx; | |||
1049 | } | |||
1050 | ||||
1051 | ParamIdx getTypeTagIdx() const { | |||
1052 | return typeTagIdx; | |||
1053 | } | |||
1054 | ||||
1055 | bool getIsPointer() const { | |||
1056 | return isPointer; | |||
1057 | } | |||
1058 | ||||
1059 | ||||
1060 | ||||
1061 | static bool classof(const Attr *A) { return A->getKind() == attr::ArgumentWithTypeTag; } | |||
1062 | }; | |||
1063 | ||||
1064 | class ArtificialAttr : public InheritableAttr { | |||
1065 | public: | |||
1066 | static ArtificialAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1067 | auto *A = new (Ctx) ArtificialAttr(Loc, Ctx, 0); | |||
1068 | A->setImplicit(true); | |||
1069 | return A; | |||
1070 | } | |||
1071 | ||||
1072 | ArtificialAttr(SourceRange R, ASTContext &Ctx | |||
1073 | , unsigned SI | |||
1074 | ) | |||
1075 | : InheritableAttr(attr::Artificial, R, SI, false, false) | |||
1076 | { | |||
1077 | } | |||
1078 | ||||
1079 | ArtificialAttr *clone(ASTContext &C) const; | |||
1080 | void printPretty(raw_ostream &OS, | |||
1081 | const PrintingPolicy &Policy) const; | |||
1082 | const char *getSpelling() const; | |||
1083 | ||||
1084 | ||||
1085 | static bool classof(const Attr *A) { return A->getKind() == attr::Artificial; } | |||
1086 | }; | |||
1087 | ||||
1088 | class AsmLabelAttr : public InheritableAttr { | |||
1089 | unsigned labelLength; | |||
1090 | char *label; | |||
1091 | ||||
1092 | public: | |||
1093 | static AsmLabelAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Label, SourceRange Loc = SourceRange()) { | |||
1094 | auto *A = new (Ctx) AsmLabelAttr(Loc, Ctx, Label, 0); | |||
1095 | A->setImplicit(true); | |||
1096 | return A; | |||
1097 | } | |||
1098 | ||||
1099 | AsmLabelAttr(SourceRange R, ASTContext &Ctx | |||
1100 | , llvm::StringRef Label | |||
1101 | , unsigned SI | |||
1102 | ) | |||
1103 | : InheritableAttr(attr::AsmLabel, R, SI, false, false) | |||
1104 | , labelLength(Label.size()),label(new (Ctx, 1) char[labelLength]) | |||
1105 | { | |||
1106 | if (!Label.empty()) | |||
1107 | std::memcpy(label, Label.data(), labelLength); | |||
1108 | } | |||
1109 | ||||
1110 | AsmLabelAttr *clone(ASTContext &C) const; | |||
1111 | void printPretty(raw_ostream &OS, | |||
1112 | const PrintingPolicy &Policy) const; | |||
1113 | const char *getSpelling() const; | |||
1114 | llvm::StringRef getLabel() const { | |||
1115 | return llvm::StringRef(label, labelLength); | |||
1116 | } | |||
1117 | unsigned getLabelLength() const { | |||
1118 | return labelLength; | |||
1119 | } | |||
1120 | void setLabel(ASTContext &C, llvm::StringRef S) { | |||
1121 | labelLength = S.size(); | |||
1122 | this->label = new (C, 1) char [labelLength]; | |||
1123 | if (!S.empty()) | |||
1124 | std::memcpy(this->label, S.data(), labelLength); | |||
1125 | } | |||
1126 | ||||
1127 | ||||
1128 | ||||
1129 | static bool classof(const Attr *A) { return A->getKind() == attr::AsmLabel; } | |||
1130 | }; | |||
1131 | ||||
1132 | class AssertCapabilityAttr : public InheritableAttr { | |||
1133 | unsigned args_Size; | |||
1134 | Expr * *args_; | |||
1135 | ||||
1136 | public: | |||
1137 | enum Spelling { | |||
1138 | GNU_assert_capability = 0, | |||
1139 | CXX11_clang_assert_capability = 1, | |||
1140 | GNU_assert_shared_capability = 2, | |||
1141 | CXX11_clang_assert_shared_capability = 3 | |||
1142 | }; | |||
1143 | ||||
1144 | static AssertCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
1145 | auto *A = new (Ctx) AssertCapabilityAttr(Loc, Ctx, Args, ArgsSize, S); | |||
1146 | A->setImplicit(true); | |||
1147 | return A; | |||
1148 | } | |||
1149 | ||||
1150 | AssertCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
1151 | , Expr * *Args, unsigned ArgsSize | |||
1152 | , unsigned SI | |||
1153 | ) | |||
1154 | : InheritableAttr(attr::AssertCapability, R, SI, true, true) | |||
1155 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
1156 | { | |||
1157 | std::copy(Args, Args + args_Size, args_); | |||
1158 | } | |||
1159 | ||||
1160 | AssertCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
1161 | , unsigned SI | |||
1162 | ) | |||
1163 | : InheritableAttr(attr::AssertCapability, R, SI, true, true) | |||
1164 | , args_Size(0), args_(nullptr) | |||
1165 | { | |||
1166 | } | |||
1167 | ||||
1168 | AssertCapabilityAttr *clone(ASTContext &C) const; | |||
1169 | void printPretty(raw_ostream &OS, | |||
1170 | const PrintingPolicy &Policy) const; | |||
1171 | const char *getSpelling() const; | |||
1172 | Spelling getSemanticSpelling() const { | |||
1173 | switch (SpellingListIndex) { | |||
1174 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 1174); | |||
1175 | case 0: return GNU_assert_capability; | |||
1176 | case 1: return CXX11_clang_assert_capability; | |||
1177 | case 2: return GNU_assert_shared_capability; | |||
1178 | case 3: return CXX11_clang_assert_shared_capability; | |||
1179 | } | |||
1180 | } | |||
1181 | bool isShared() const { return SpellingListIndex == 2 || | |||
1182 | SpellingListIndex == 3; } | |||
1183 | typedef Expr ** args_iterator; | |||
1184 | args_iterator args_begin() const { return args_; } | |||
1185 | args_iterator args_end() const { return args_ + args_Size; } | |||
1186 | unsigned args_size() const { return args_Size; } | |||
1187 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
1188 | ||||
1189 | ||||
1190 | ||||
1191 | ||||
1192 | static bool classof(const Attr *A) { return A->getKind() == attr::AssertCapability; } | |||
1193 | }; | |||
1194 | ||||
1195 | class AssertExclusiveLockAttr : public InheritableAttr { | |||
1196 | unsigned args_Size; | |||
1197 | Expr * *args_; | |||
1198 | ||||
1199 | public: | |||
1200 | static AssertExclusiveLockAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
1201 | auto *A = new (Ctx) AssertExclusiveLockAttr(Loc, Ctx, Args, ArgsSize, 0); | |||
1202 | A->setImplicit(true); | |||
1203 | return A; | |||
1204 | } | |||
1205 | ||||
1206 | AssertExclusiveLockAttr(SourceRange R, ASTContext &Ctx | |||
1207 | , Expr * *Args, unsigned ArgsSize | |||
1208 | , unsigned SI | |||
1209 | ) | |||
1210 | : InheritableAttr(attr::AssertExclusiveLock, R, SI, true, true) | |||
1211 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
1212 | { | |||
1213 | std::copy(Args, Args + args_Size, args_); | |||
1214 | } | |||
1215 | ||||
1216 | AssertExclusiveLockAttr(SourceRange R, ASTContext &Ctx | |||
1217 | , unsigned SI | |||
1218 | ) | |||
1219 | : InheritableAttr(attr::AssertExclusiveLock, R, SI, true, true) | |||
1220 | , args_Size(0), args_(nullptr) | |||
1221 | { | |||
1222 | } | |||
1223 | ||||
1224 | AssertExclusiveLockAttr *clone(ASTContext &C) const; | |||
1225 | void printPretty(raw_ostream &OS, | |||
1226 | const PrintingPolicy &Policy) const; | |||
1227 | const char *getSpelling() const; | |||
1228 | typedef Expr ** args_iterator; | |||
1229 | args_iterator args_begin() const { return args_; } | |||
1230 | args_iterator args_end() const { return args_ + args_Size; } | |||
1231 | unsigned args_size() const { return args_Size; } | |||
1232 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
1233 | ||||
1234 | ||||
1235 | ||||
1236 | ||||
1237 | static bool classof(const Attr *A) { return A->getKind() == attr::AssertExclusiveLock; } | |||
1238 | }; | |||
1239 | ||||
1240 | class AssertSharedLockAttr : public InheritableAttr { | |||
1241 | unsigned args_Size; | |||
1242 | Expr * *args_; | |||
1243 | ||||
1244 | public: | |||
1245 | static AssertSharedLockAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
1246 | auto *A = new (Ctx) AssertSharedLockAttr(Loc, Ctx, Args, ArgsSize, 0); | |||
1247 | A->setImplicit(true); | |||
1248 | return A; | |||
1249 | } | |||
1250 | ||||
1251 | AssertSharedLockAttr(SourceRange R, ASTContext &Ctx | |||
1252 | , Expr * *Args, unsigned ArgsSize | |||
1253 | , unsigned SI | |||
1254 | ) | |||
1255 | : InheritableAttr(attr::AssertSharedLock, R, SI, true, true) | |||
1256 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
1257 | { | |||
1258 | std::copy(Args, Args + args_Size, args_); | |||
1259 | } | |||
1260 | ||||
1261 | AssertSharedLockAttr(SourceRange R, ASTContext &Ctx | |||
1262 | , unsigned SI | |||
1263 | ) | |||
1264 | : InheritableAttr(attr::AssertSharedLock, R, SI, true, true) | |||
1265 | , args_Size(0), args_(nullptr) | |||
1266 | { | |||
1267 | } | |||
1268 | ||||
1269 | AssertSharedLockAttr *clone(ASTContext &C) const; | |||
1270 | void printPretty(raw_ostream &OS, | |||
1271 | const PrintingPolicy &Policy) const; | |||
1272 | const char *getSpelling() const; | |||
1273 | typedef Expr ** args_iterator; | |||
1274 | args_iterator args_begin() const { return args_; } | |||
1275 | args_iterator args_end() const { return args_ + args_Size; } | |||
1276 | unsigned args_size() const { return args_Size; } | |||
1277 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
1278 | ||||
1279 | ||||
1280 | ||||
1281 | ||||
1282 | static bool classof(const Attr *A) { return A->getKind() == attr::AssertSharedLock; } | |||
1283 | }; | |||
1284 | ||||
1285 | class AssumeAlignedAttr : public InheritableAttr { | |||
1286 | Expr * alignment; | |||
1287 | ||||
1288 | Expr * offset; | |||
1289 | ||||
1290 | public: | |||
1291 | static AssumeAlignedAttr *CreateImplicit(ASTContext &Ctx, Expr * Alignment, Expr * Offset, SourceRange Loc = SourceRange()) { | |||
1292 | auto *A = new (Ctx) AssumeAlignedAttr(Loc, Ctx, Alignment, Offset, 0); | |||
1293 | A->setImplicit(true); | |||
1294 | return A; | |||
1295 | } | |||
1296 | ||||
1297 | AssumeAlignedAttr(SourceRange R, ASTContext &Ctx | |||
1298 | , Expr * Alignment | |||
1299 | , Expr * Offset | |||
1300 | , unsigned SI | |||
1301 | ) | |||
1302 | : InheritableAttr(attr::AssumeAligned, R, SI, false, false) | |||
1303 | , alignment(Alignment) | |||
1304 | , offset(Offset) | |||
1305 | { | |||
1306 | } | |||
1307 | ||||
1308 | AssumeAlignedAttr(SourceRange R, ASTContext &Ctx | |||
1309 | , Expr * Alignment | |||
1310 | , unsigned SI | |||
1311 | ) | |||
1312 | : InheritableAttr(attr::AssumeAligned, R, SI, false, false) | |||
1313 | , alignment(Alignment) | |||
1314 | , offset() | |||
1315 | { | |||
1316 | } | |||
1317 | ||||
1318 | AssumeAlignedAttr *clone(ASTContext &C) const; | |||
1319 | void printPretty(raw_ostream &OS, | |||
1320 | const PrintingPolicy &Policy) const; | |||
1321 | const char *getSpelling() const; | |||
1322 | Expr * getAlignment() const { | |||
1323 | return alignment; | |||
1324 | } | |||
1325 | ||||
1326 | Expr * getOffset() const { | |||
1327 | return offset; | |||
1328 | } | |||
1329 | ||||
1330 | ||||
1331 | ||||
1332 | static bool classof(const Attr *A) { return A->getKind() == attr::AssumeAligned; } | |||
1333 | }; | |||
1334 | ||||
1335 | class AvailabilityAttr : public InheritableAttr { | |||
1336 | IdentifierInfo * platform; | |||
1337 | ||||
1338 | VersionTuple introduced; | |||
1339 | ||||
1340 | ||||
1341 | VersionTuple deprecated; | |||
1342 | ||||
1343 | ||||
1344 | VersionTuple obsoleted; | |||
1345 | ||||
1346 | ||||
1347 | bool unavailable; | |||
1348 | ||||
1349 | unsigned messageLength; | |||
1350 | char *message; | |||
1351 | ||||
1352 | bool strict; | |||
1353 | ||||
1354 | unsigned replacementLength; | |||
1355 | char *replacement; | |||
1356 | ||||
1357 | public: | |||
1358 | 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()) { | |||
1359 | auto *A = new (Ctx) AvailabilityAttr(Loc, Ctx, Platform, Introduced, Deprecated, Obsoleted, Unavailable, Message, Strict, Replacement, 0); | |||
1360 | A->setImplicit(true); | |||
1361 | return A; | |||
1362 | } | |||
1363 | ||||
1364 | AvailabilityAttr(SourceRange R, ASTContext &Ctx | |||
1365 | , IdentifierInfo * Platform | |||
1366 | , VersionTuple Introduced | |||
1367 | , VersionTuple Deprecated | |||
1368 | , VersionTuple Obsoleted | |||
1369 | , bool Unavailable | |||
1370 | , llvm::StringRef Message | |||
1371 | , bool Strict | |||
1372 | , llvm::StringRef Replacement | |||
1373 | , unsigned SI | |||
1374 | ) | |||
1375 | : InheritableAttr(attr::Availability, R, SI, false, true) | |||
1376 | , platform(Platform) | |||
1377 | , introduced(Introduced) | |||
1378 | , deprecated(Deprecated) | |||
1379 | , obsoleted(Obsoleted) | |||
1380 | , unavailable(Unavailable) | |||
1381 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
1382 | , strict(Strict) | |||
1383 | , replacementLength(Replacement.size()),replacement(new (Ctx, 1) char[replacementLength]) | |||
1384 | { | |||
1385 | if (!Message.empty()) | |||
1386 | std::memcpy(message, Message.data(), messageLength); | |||
1387 | if (!Replacement.empty()) | |||
1388 | std::memcpy(replacement, Replacement.data(), replacementLength); | |||
1389 | } | |||
1390 | ||||
1391 | AvailabilityAttr *clone(ASTContext &C) const; | |||
1392 | void printPretty(raw_ostream &OS, | |||
1393 | const PrintingPolicy &Policy) const; | |||
1394 | const char *getSpelling() const; | |||
1395 | IdentifierInfo * getPlatform() const { | |||
1396 | return platform; | |||
1397 | } | |||
1398 | ||||
1399 | VersionTuple getIntroduced() const { | |||
1400 | return introduced; | |||
1401 | } | |||
1402 | void setIntroduced(ASTContext &C, VersionTuple V) { | |||
1403 | introduced = V; | |||
1404 | } | |||
1405 | ||||
1406 | VersionTuple getDeprecated() const { | |||
1407 | return deprecated; | |||
1408 | } | |||
1409 | void setDeprecated(ASTContext &C, VersionTuple V) { | |||
1410 | deprecated = V; | |||
1411 | } | |||
1412 | ||||
1413 | VersionTuple getObsoleted() const { | |||
1414 | return obsoleted; | |||
1415 | } | |||
1416 | void setObsoleted(ASTContext &C, VersionTuple V) { | |||
1417 | obsoleted = V; | |||
1418 | } | |||
1419 | ||||
1420 | bool getUnavailable() const { | |||
1421 | return unavailable; | |||
1422 | } | |||
1423 | ||||
1424 | llvm::StringRef getMessage() const { | |||
1425 | return llvm::StringRef(message, messageLength); | |||
1426 | } | |||
1427 | unsigned getMessageLength() const { | |||
1428 | return messageLength; | |||
1429 | } | |||
1430 | void setMessage(ASTContext &C, llvm::StringRef S) { | |||
1431 | messageLength = S.size(); | |||
1432 | this->message = new (C, 1) char [messageLength]; | |||
1433 | if (!S.empty()) | |||
1434 | std::memcpy(this->message, S.data(), messageLength); | |||
1435 | } | |||
1436 | ||||
1437 | bool getStrict() const { | |||
1438 | return strict; | |||
1439 | } | |||
1440 | ||||
1441 | llvm::StringRef getReplacement() const { | |||
1442 | return llvm::StringRef(replacement, replacementLength); | |||
1443 | } | |||
1444 | unsigned getReplacementLength() const { | |||
1445 | return replacementLength; | |||
1446 | } | |||
1447 | void setReplacement(ASTContext &C, llvm::StringRef S) { | |||
1448 | replacementLength = S.size(); | |||
1449 | this->replacement = new (C, 1) char [replacementLength]; | |||
1450 | if (!S.empty()) | |||
1451 | std::memcpy(this->replacement, S.data(), replacementLength); | |||
1452 | } | |||
1453 | ||||
1454 | static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) { | |||
1455 | return llvm::StringSwitch<llvm::StringRef>(Platform) | |||
1456 | .Case("android", "Android") | |||
1457 | .Case("ios", "iOS") | |||
1458 | .Case("macos", "macOS") | |||
1459 | .Case("tvos", "tvOS") | |||
1460 | .Case("watchos", "watchOS") | |||
1461 | .Case("ios_app_extension", "iOS (App Extension)") | |||
1462 | .Case("macos_app_extension", "macOS (App Extension)") | |||
1463 | .Case("tvos_app_extension", "tvOS (App Extension)") | |||
1464 | .Case("watchos_app_extension", "watchOS (App Extension)") | |||
1465 | .Default(llvm::StringRef()); | |||
1466 | } | |||
1467 | static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) { | |||
1468 | return llvm::StringSwitch<llvm::StringRef>(Platform) | |||
1469 | .Case("ios", "iOS") | |||
1470 | .Case("macos", "macOS") | |||
1471 | .Case("tvos", "tvOS") | |||
1472 | .Case("watchos", "watchOS") | |||
1473 | .Case("ios_app_extension", "iOSApplicationExtension") | |||
1474 | .Case("macos_app_extension", "macOSApplicationExtension") | |||
1475 | .Case("tvos_app_extension", "tvOSApplicationExtension") | |||
1476 | .Case("watchos_app_extension", "watchOSApplicationExtension") | |||
1477 | .Default(Platform); | |||
1478 | } | |||
1479 | static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) { | |||
1480 | return llvm::StringSwitch<llvm::StringRef>(Platform) | |||
1481 | .Case("iOS", "ios") | |||
1482 | .Case("macOS", "macos") | |||
1483 | .Case("tvOS", "tvos") | |||
1484 | .Case("watchOS", "watchos") | |||
1485 | .Case("iOSApplicationExtension", "ios_app_extension") | |||
1486 | .Case("macOSApplicationExtension", "macos_app_extension") | |||
1487 | .Case("tvOSApplicationExtension", "tvos_app_extension") | |||
1488 | .Case("watchOSApplicationExtension", "watchos_app_extension") | |||
1489 | .Default(Platform); | |||
1490 | } | |||
1491 | ||||
1492 | static bool classof(const Attr *A) { return A->getKind() == attr::Availability; } | |||
1493 | }; | |||
1494 | ||||
1495 | class BlocksAttr : public InheritableAttr { | |||
1496 | public: | |||
1497 | enum BlockType { | |||
1498 | ByRef | |||
1499 | }; | |||
1500 | private: | |||
1501 | BlockType type; | |||
1502 | ||||
1503 | public: | |||
1504 | static BlocksAttr *CreateImplicit(ASTContext &Ctx, BlockType Type, SourceRange Loc = SourceRange()) { | |||
1505 | auto *A = new (Ctx) BlocksAttr(Loc, Ctx, Type, 0); | |||
1506 | A->setImplicit(true); | |||
1507 | return A; | |||
1508 | } | |||
1509 | ||||
1510 | BlocksAttr(SourceRange R, ASTContext &Ctx | |||
1511 | , BlockType Type | |||
1512 | , unsigned SI | |||
1513 | ) | |||
1514 | : InheritableAttr(attr::Blocks, R, SI, false, false) | |||
1515 | , type(Type) | |||
1516 | { | |||
1517 | } | |||
1518 | ||||
1519 | BlocksAttr *clone(ASTContext &C) const; | |||
1520 | void printPretty(raw_ostream &OS, | |||
1521 | const PrintingPolicy &Policy) const; | |||
1522 | const char *getSpelling() const; | |||
1523 | BlockType getType() const { | |||
1524 | return type; | |||
1525 | } | |||
1526 | ||||
1527 | static bool ConvertStrToBlockType(StringRef Val, BlockType &Out) { | |||
1528 | Optional<BlockType> R = llvm::StringSwitch<Optional<BlockType>>(Val) | |||
1529 | .Case("byref", BlocksAttr::ByRef) | |||
1530 | .Default(Optional<BlockType>()); | |||
1531 | if (R) { | |||
1532 | Out = *R; | |||
1533 | return true; | |||
1534 | } | |||
1535 | return false; | |||
1536 | } | |||
1537 | ||||
1538 | static const char *ConvertBlockTypeToStr(BlockType Val) { | |||
1539 | switch(Val) { | |||
1540 | case BlocksAttr::ByRef: return "byref"; | |||
1541 | } | |||
1542 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 1542); | |||
1543 | } | |||
1544 | ||||
1545 | ||||
1546 | static bool classof(const Attr *A) { return A->getKind() == attr::Blocks; } | |||
1547 | }; | |||
1548 | ||||
1549 | class C11NoReturnAttr : public InheritableAttr { | |||
1550 | public: | |||
1551 | static C11NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1552 | auto *A = new (Ctx) C11NoReturnAttr(Loc, Ctx, 0); | |||
1553 | A->setImplicit(true); | |||
1554 | return A; | |||
1555 | } | |||
1556 | ||||
1557 | C11NoReturnAttr(SourceRange R, ASTContext &Ctx | |||
1558 | , unsigned SI | |||
1559 | ) | |||
1560 | : InheritableAttr(attr::C11NoReturn, R, SI, false, false) | |||
1561 | { | |||
1562 | } | |||
1563 | ||||
1564 | C11NoReturnAttr *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::C11NoReturn; } | |||
1571 | }; | |||
1572 | ||||
1573 | class CDeclAttr : public InheritableAttr { | |||
1574 | public: | |||
1575 | static CDeclAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1576 | auto *A = new (Ctx) CDeclAttr(Loc, Ctx, 0); | |||
1577 | A->setImplicit(true); | |||
1578 | return A; | |||
1579 | } | |||
1580 | ||||
1581 | CDeclAttr(SourceRange R, ASTContext &Ctx | |||
1582 | , unsigned SI | |||
1583 | ) | |||
1584 | : InheritableAttr(attr::CDecl, R, SI, false, false) | |||
1585 | { | |||
1586 | } | |||
1587 | ||||
1588 | CDeclAttr *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::CDecl; } | |||
1595 | }; | |||
1596 | ||||
1597 | class CFAuditedTransferAttr : public InheritableAttr { | |||
1598 | public: | |||
1599 | static CFAuditedTransferAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1600 | auto *A = new (Ctx) CFAuditedTransferAttr(Loc, Ctx, 0); | |||
1601 | A->setImplicit(true); | |||
1602 | return A; | |||
1603 | } | |||
1604 | ||||
1605 | CFAuditedTransferAttr(SourceRange R, ASTContext &Ctx | |||
1606 | , unsigned SI | |||
1607 | ) | |||
1608 | : InheritableAttr(attr::CFAuditedTransfer, R, SI, false, false) | |||
1609 | { | |||
1610 | } | |||
1611 | ||||
1612 | CFAuditedTransferAttr *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::CFAuditedTransfer; } | |||
1619 | }; | |||
1620 | ||||
1621 | class CFConsumedAttr : public InheritableParamAttr { | |||
1622 | public: | |||
1623 | static CFConsumedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1624 | auto *A = new (Ctx) CFConsumedAttr(Loc, Ctx, 0); | |||
1625 | A->setImplicit(true); | |||
1626 | return A; | |||
1627 | } | |||
1628 | ||||
1629 | CFConsumedAttr(SourceRange R, ASTContext &Ctx | |||
1630 | , unsigned SI | |||
1631 | ) | |||
1632 | : InheritableParamAttr(attr::CFConsumed, R, SI, false, false) | |||
1633 | { | |||
1634 | } | |||
1635 | ||||
1636 | CFConsumedAttr *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::CFConsumed; } | |||
1643 | }; | |||
1644 | ||||
1645 | class CFReturnsNotRetainedAttr : public InheritableAttr { | |||
1646 | public: | |||
1647 | static CFReturnsNotRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1648 | auto *A = new (Ctx) CFReturnsNotRetainedAttr(Loc, Ctx, 0); | |||
1649 | A->setImplicit(true); | |||
1650 | return A; | |||
1651 | } | |||
1652 | ||||
1653 | CFReturnsNotRetainedAttr(SourceRange R, ASTContext &Ctx | |||
1654 | , unsigned SI | |||
1655 | ) | |||
1656 | : InheritableAttr(attr::CFReturnsNotRetained, R, SI, false, false) | |||
1657 | { | |||
1658 | } | |||
1659 | ||||
1660 | CFReturnsNotRetainedAttr *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::CFReturnsNotRetained; } | |||
1667 | }; | |||
1668 | ||||
1669 | class CFReturnsRetainedAttr : public InheritableAttr { | |||
1670 | public: | |||
1671 | static CFReturnsRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1672 | auto *A = new (Ctx) CFReturnsRetainedAttr(Loc, Ctx, 0); | |||
1673 | A->setImplicit(true); | |||
1674 | return A; | |||
1675 | } | |||
1676 | ||||
1677 | CFReturnsRetainedAttr(SourceRange R, ASTContext &Ctx | |||
1678 | , unsigned SI | |||
1679 | ) | |||
1680 | : InheritableAttr(attr::CFReturnsRetained, R, SI, false, false) | |||
1681 | { | |||
1682 | } | |||
1683 | ||||
1684 | CFReturnsRetainedAttr *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::CFReturnsRetained; } | |||
1691 | }; | |||
1692 | ||||
1693 | class CFUnknownTransferAttr : public InheritableAttr { | |||
1694 | public: | |||
1695 | static CFUnknownTransferAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1696 | auto *A = new (Ctx) CFUnknownTransferAttr(Loc, Ctx, 0); | |||
1697 | A->setImplicit(true); | |||
1698 | return A; | |||
1699 | } | |||
1700 | ||||
1701 | CFUnknownTransferAttr(SourceRange R, ASTContext &Ctx | |||
1702 | , unsigned SI | |||
1703 | ) | |||
1704 | : InheritableAttr(attr::CFUnknownTransfer, R, SI, false, false) | |||
1705 | { | |||
1706 | } | |||
1707 | ||||
1708 | CFUnknownTransferAttr *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::CFUnknownTransfer; } | |||
1715 | }; | |||
1716 | ||||
1717 | class CPUDispatchAttr : public InheritableAttr { | |||
1718 | unsigned cpus_Size; | |||
1719 | IdentifierInfo * *cpus_; | |||
1720 | ||||
1721 | public: | |||
1722 | static CPUDispatchAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * *Cpus, unsigned CpusSize, SourceRange Loc = SourceRange()) { | |||
1723 | auto *A = new (Ctx) CPUDispatchAttr(Loc, Ctx, Cpus, CpusSize, 0); | |||
1724 | A->setImplicit(true); | |||
1725 | return A; | |||
1726 | } | |||
1727 | ||||
1728 | CPUDispatchAttr(SourceRange R, ASTContext &Ctx | |||
1729 | , IdentifierInfo * *Cpus, unsigned CpusSize | |||
1730 | , unsigned SI | |||
1731 | ) | |||
1732 | : InheritableAttr(attr::CPUDispatch, R, SI, false, false) | |||
1733 | , cpus_Size(CpusSize), cpus_(new (Ctx, 16) IdentifierInfo *[cpus_Size]) | |||
1734 | { | |||
1735 | std::copy(Cpus, Cpus + cpus_Size, cpus_); | |||
1736 | } | |||
1737 | ||||
1738 | CPUDispatchAttr(SourceRange R, ASTContext &Ctx | |||
1739 | , unsigned SI | |||
1740 | ) | |||
1741 | : InheritableAttr(attr::CPUDispatch, R, SI, false, false) | |||
1742 | , cpus_Size(0), cpus_(nullptr) | |||
1743 | { | |||
1744 | } | |||
1745 | ||||
1746 | CPUDispatchAttr *clone(ASTContext &C) const; | |||
1747 | void printPretty(raw_ostream &OS, | |||
1748 | const PrintingPolicy &Policy) const; | |||
1749 | const char *getSpelling() const; | |||
1750 | typedef IdentifierInfo ** cpus_iterator; | |||
1751 | cpus_iterator cpus_begin() const { return cpus_; } | |||
1752 | cpus_iterator cpus_end() const { return cpus_ + cpus_Size; } | |||
1753 | unsigned cpus_size() const { return cpus_Size; } | |||
1754 | llvm::iterator_range<cpus_iterator> cpus() const { return llvm::make_range(cpus_begin(), cpus_end()); } | |||
1755 | ||||
1756 | ||||
1757 | ||||
1758 | ||||
1759 | static bool classof(const Attr *A) { return A->getKind() == attr::CPUDispatch; } | |||
1760 | }; | |||
1761 | ||||
1762 | class CPUSpecificAttr : public InheritableAttr { | |||
1763 | unsigned cpus_Size; | |||
1764 | IdentifierInfo * *cpus_; | |||
1765 | ||||
1766 | public: | |||
1767 | static CPUSpecificAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * *Cpus, unsigned CpusSize, SourceRange Loc = SourceRange()) { | |||
1768 | auto *A = new (Ctx) CPUSpecificAttr(Loc, Ctx, Cpus, CpusSize, 0); | |||
1769 | A->setImplicit(true); | |||
1770 | return A; | |||
1771 | } | |||
1772 | ||||
1773 | CPUSpecificAttr(SourceRange R, ASTContext &Ctx | |||
1774 | , IdentifierInfo * *Cpus, unsigned CpusSize | |||
1775 | , unsigned SI | |||
1776 | ) | |||
1777 | : InheritableAttr(attr::CPUSpecific, R, SI, false, false) | |||
1778 | , cpus_Size(CpusSize), cpus_(new (Ctx, 16) IdentifierInfo *[cpus_Size]) | |||
1779 | { | |||
1780 | std::copy(Cpus, Cpus + cpus_Size, cpus_); | |||
1781 | } | |||
1782 | ||||
1783 | CPUSpecificAttr(SourceRange R, ASTContext &Ctx | |||
1784 | , unsigned SI | |||
1785 | ) | |||
1786 | : InheritableAttr(attr::CPUSpecific, R, SI, false, false) | |||
1787 | , cpus_Size(0), cpus_(nullptr) | |||
1788 | { | |||
1789 | } | |||
1790 | ||||
1791 | CPUSpecificAttr *clone(ASTContext &C) const; | |||
1792 | void printPretty(raw_ostream &OS, | |||
1793 | const PrintingPolicy &Policy) const; | |||
1794 | const char *getSpelling() const; | |||
1795 | typedef IdentifierInfo ** cpus_iterator; | |||
1796 | cpus_iterator cpus_begin() const { return cpus_; } | |||
1797 | cpus_iterator cpus_end() const { return cpus_ + cpus_Size; } | |||
1798 | unsigned cpus_size() const { return cpus_Size; } | |||
1799 | llvm::iterator_range<cpus_iterator> cpus() const { return llvm::make_range(cpus_begin(), cpus_end()); } | |||
1800 | ||||
1801 | ||||
1802 | ||||
1803 | unsigned ActiveArgIndex = 0; | |||
1804 | ||||
1805 | IdentifierInfo *getCurCPUName() const { | |||
1806 | return *(cpus_begin() + ActiveArgIndex); | |||
1807 | } | |||
1808 | ||||
1809 | ||||
1810 | static bool classof(const Attr *A) { return A->getKind() == attr::CPUSpecific; } | |||
1811 | }; | |||
1812 | ||||
1813 | class CUDAConstantAttr : public InheritableAttr { | |||
1814 | public: | |||
1815 | static CUDAConstantAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1816 | auto *A = new (Ctx) CUDAConstantAttr(Loc, Ctx, 0); | |||
1817 | A->setImplicit(true); | |||
1818 | return A; | |||
1819 | } | |||
1820 | ||||
1821 | CUDAConstantAttr(SourceRange R, ASTContext &Ctx | |||
1822 | , unsigned SI | |||
1823 | ) | |||
1824 | : InheritableAttr(attr::CUDAConstant, R, SI, false, false) | |||
1825 | { | |||
1826 | } | |||
1827 | ||||
1828 | CUDAConstantAttr *clone(ASTContext &C) const; | |||
1829 | void printPretty(raw_ostream &OS, | |||
1830 | const PrintingPolicy &Policy) const; | |||
1831 | const char *getSpelling() const; | |||
1832 | ||||
1833 | ||||
1834 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDAConstant; } | |||
1835 | }; | |||
1836 | ||||
1837 | class CUDADeviceAttr : public InheritableAttr { | |||
1838 | public: | |||
1839 | static CUDADeviceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1840 | auto *A = new (Ctx) CUDADeviceAttr(Loc, Ctx, 0); | |||
1841 | A->setImplicit(true); | |||
1842 | return A; | |||
1843 | } | |||
1844 | ||||
1845 | CUDADeviceAttr(SourceRange R, ASTContext &Ctx | |||
1846 | , unsigned SI | |||
1847 | ) | |||
1848 | : InheritableAttr(attr::CUDADevice, R, SI, false, false) | |||
1849 | { | |||
1850 | } | |||
1851 | ||||
1852 | CUDADeviceAttr *clone(ASTContext &C) const; | |||
1853 | void printPretty(raw_ostream &OS, | |||
1854 | const PrintingPolicy &Policy) const; | |||
1855 | const char *getSpelling() const; | |||
1856 | ||||
1857 | ||||
1858 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDADevice; } | |||
1859 | }; | |||
1860 | ||||
1861 | class CUDAGlobalAttr : public InheritableAttr { | |||
1862 | public: | |||
1863 | static CUDAGlobalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1864 | auto *A = new (Ctx) CUDAGlobalAttr(Loc, Ctx, 0); | |||
1865 | A->setImplicit(true); | |||
1866 | return A; | |||
1867 | } | |||
1868 | ||||
1869 | CUDAGlobalAttr(SourceRange R, ASTContext &Ctx | |||
1870 | , unsigned SI | |||
1871 | ) | |||
1872 | : InheritableAttr(attr::CUDAGlobal, R, SI, false, false) | |||
1873 | { | |||
1874 | } | |||
1875 | ||||
1876 | CUDAGlobalAttr *clone(ASTContext &C) const; | |||
1877 | void printPretty(raw_ostream &OS, | |||
1878 | const PrintingPolicy &Policy) const; | |||
1879 | const char *getSpelling() const; | |||
1880 | ||||
1881 | ||||
1882 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDAGlobal; } | |||
1883 | }; | |||
1884 | ||||
1885 | class CUDAHostAttr : public InheritableAttr { | |||
1886 | public: | |||
1887 | static CUDAHostAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1888 | auto *A = new (Ctx) CUDAHostAttr(Loc, Ctx, 0); | |||
1889 | A->setImplicit(true); | |||
1890 | return A; | |||
1891 | } | |||
1892 | ||||
1893 | CUDAHostAttr(SourceRange R, ASTContext &Ctx | |||
1894 | , unsigned SI | |||
1895 | ) | |||
1896 | : InheritableAttr(attr::CUDAHost, R, SI, false, false) | |||
1897 | { | |||
1898 | } | |||
1899 | ||||
1900 | CUDAHostAttr *clone(ASTContext &C) const; | |||
1901 | void printPretty(raw_ostream &OS, | |||
1902 | const PrintingPolicy &Policy) const; | |||
1903 | const char *getSpelling() const; | |||
1904 | ||||
1905 | ||||
1906 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDAHost; } | |||
1907 | }; | |||
1908 | ||||
1909 | class CUDAInvalidTargetAttr : public InheritableAttr { | |||
1910 | public: | |||
1911 | static CUDAInvalidTargetAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1912 | auto *A = new (Ctx) CUDAInvalidTargetAttr(Loc, Ctx, 0); | |||
1913 | A->setImplicit(true); | |||
1914 | return A; | |||
1915 | } | |||
1916 | ||||
1917 | CUDAInvalidTargetAttr(SourceRange R, ASTContext &Ctx | |||
1918 | , unsigned SI | |||
1919 | ) | |||
1920 | : InheritableAttr(attr::CUDAInvalidTarget, R, SI, false, false) | |||
1921 | { | |||
1922 | } | |||
1923 | ||||
1924 | CUDAInvalidTargetAttr *clone(ASTContext &C) const; | |||
1925 | void printPretty(raw_ostream &OS, | |||
1926 | const PrintingPolicy &Policy) const; | |||
1927 | const char *getSpelling() const; | |||
1928 | ||||
1929 | ||||
1930 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDAInvalidTarget; } | |||
1931 | }; | |||
1932 | ||||
1933 | class CUDALaunchBoundsAttr : public InheritableAttr { | |||
1934 | Expr * maxThreads; | |||
1935 | ||||
1936 | Expr * minBlocks; | |||
1937 | ||||
1938 | public: | |||
1939 | static CUDALaunchBoundsAttr *CreateImplicit(ASTContext &Ctx, Expr * MaxThreads, Expr * MinBlocks, SourceRange Loc = SourceRange()) { | |||
1940 | auto *A = new (Ctx) CUDALaunchBoundsAttr(Loc, Ctx, MaxThreads, MinBlocks, 0); | |||
1941 | A->setImplicit(true); | |||
1942 | return A; | |||
1943 | } | |||
1944 | ||||
1945 | CUDALaunchBoundsAttr(SourceRange R, ASTContext &Ctx | |||
1946 | , Expr * MaxThreads | |||
1947 | , Expr * MinBlocks | |||
1948 | , unsigned SI | |||
1949 | ) | |||
1950 | : InheritableAttr(attr::CUDALaunchBounds, R, SI, false, false) | |||
1951 | , maxThreads(MaxThreads) | |||
1952 | , minBlocks(MinBlocks) | |||
1953 | { | |||
1954 | } | |||
1955 | ||||
1956 | CUDALaunchBoundsAttr(SourceRange R, ASTContext &Ctx | |||
1957 | , Expr * MaxThreads | |||
1958 | , unsigned SI | |||
1959 | ) | |||
1960 | : InheritableAttr(attr::CUDALaunchBounds, R, SI, false, false) | |||
1961 | , maxThreads(MaxThreads) | |||
1962 | , minBlocks() | |||
1963 | { | |||
1964 | } | |||
1965 | ||||
1966 | CUDALaunchBoundsAttr *clone(ASTContext &C) const; | |||
1967 | void printPretty(raw_ostream &OS, | |||
1968 | const PrintingPolicy &Policy) const; | |||
1969 | const char *getSpelling() const; | |||
1970 | Expr * getMaxThreads() const { | |||
1971 | return maxThreads; | |||
1972 | } | |||
1973 | ||||
1974 | Expr * getMinBlocks() const { | |||
1975 | return minBlocks; | |||
1976 | } | |||
1977 | ||||
1978 | ||||
1979 | ||||
1980 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDALaunchBounds; } | |||
1981 | }; | |||
1982 | ||||
1983 | class CUDASharedAttr : public InheritableAttr { | |||
1984 | public: | |||
1985 | static CUDASharedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
1986 | auto *A = new (Ctx) CUDASharedAttr(Loc, Ctx, 0); | |||
1987 | A->setImplicit(true); | |||
1988 | return A; | |||
1989 | } | |||
1990 | ||||
1991 | CUDASharedAttr(SourceRange R, ASTContext &Ctx | |||
1992 | , unsigned SI | |||
1993 | ) | |||
1994 | : InheritableAttr(attr::CUDAShared, R, SI, false, false) | |||
1995 | { | |||
1996 | } | |||
1997 | ||||
1998 | CUDASharedAttr *clone(ASTContext &C) const; | |||
1999 | void printPretty(raw_ostream &OS, | |||
2000 | const PrintingPolicy &Policy) const; | |||
2001 | const char *getSpelling() const; | |||
2002 | ||||
2003 | ||||
2004 | static bool classof(const Attr *A) { return A->getKind() == attr::CUDAShared; } | |||
2005 | }; | |||
2006 | ||||
2007 | class CXX11NoReturnAttr : public InheritableAttr { | |||
2008 | public: | |||
2009 | static CXX11NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2010 | auto *A = new (Ctx) CXX11NoReturnAttr(Loc, Ctx, 0); | |||
2011 | A->setImplicit(true); | |||
2012 | return A; | |||
2013 | } | |||
2014 | ||||
2015 | CXX11NoReturnAttr(SourceRange R, ASTContext &Ctx | |||
2016 | , unsigned SI | |||
2017 | ) | |||
2018 | : InheritableAttr(attr::CXX11NoReturn, R, SI, false, false) | |||
2019 | { | |||
2020 | } | |||
2021 | ||||
2022 | CXX11NoReturnAttr *clone(ASTContext &C) const; | |||
2023 | void printPretty(raw_ostream &OS, | |||
2024 | const PrintingPolicy &Policy) const; | |||
2025 | const char *getSpelling() const; | |||
2026 | ||||
2027 | ||||
2028 | static bool classof(const Attr *A) { return A->getKind() == attr::CXX11NoReturn; } | |||
2029 | }; | |||
2030 | ||||
2031 | class CallableWhenAttr : public InheritableAttr { | |||
2032 | public: | |||
2033 | enum ConsumedState { | |||
2034 | Unknown, | |||
2035 | Consumed, | |||
2036 | Unconsumed | |||
2037 | }; | |||
2038 | private: | |||
2039 | unsigned callableStates_Size; | |||
2040 | ConsumedState *callableStates_; | |||
2041 | ||||
2042 | public: | |||
2043 | static CallableWhenAttr *CreateImplicit(ASTContext &Ctx, ConsumedState *CallableStates, unsigned CallableStatesSize, SourceRange Loc = SourceRange()) { | |||
2044 | auto *A = new (Ctx) CallableWhenAttr(Loc, Ctx, CallableStates, CallableStatesSize, 0); | |||
2045 | A->setImplicit(true); | |||
2046 | return A; | |||
2047 | } | |||
2048 | ||||
2049 | CallableWhenAttr(SourceRange R, ASTContext &Ctx | |||
2050 | , ConsumedState *CallableStates, unsigned CallableStatesSize | |||
2051 | , unsigned SI | |||
2052 | ) | |||
2053 | : InheritableAttr(attr::CallableWhen, R, SI, false, false) | |||
2054 | , callableStates_Size(CallableStatesSize), callableStates_(new (Ctx, 16) ConsumedState[callableStates_Size]) | |||
2055 | { | |||
2056 | std::copy(CallableStates, CallableStates + callableStates_Size, callableStates_); | |||
2057 | } | |||
2058 | ||||
2059 | CallableWhenAttr(SourceRange R, ASTContext &Ctx | |||
2060 | , unsigned SI | |||
2061 | ) | |||
2062 | : InheritableAttr(attr::CallableWhen, R, SI, false, false) | |||
2063 | , callableStates_Size(0), callableStates_(nullptr) | |||
2064 | { | |||
2065 | } | |||
2066 | ||||
2067 | CallableWhenAttr *clone(ASTContext &C) const; | |||
2068 | void printPretty(raw_ostream &OS, | |||
2069 | const PrintingPolicy &Policy) const; | |||
2070 | const char *getSpelling() const; | |||
2071 | typedef ConsumedState* callableStates_iterator; | |||
2072 | callableStates_iterator callableStates_begin() const { return callableStates_; } | |||
2073 | callableStates_iterator callableStates_end() const { return callableStates_ + callableStates_Size; } | |||
2074 | unsigned callableStates_size() const { return callableStates_Size; } | |||
2075 | llvm::iterator_range<callableStates_iterator> callableStates() const { return llvm::make_range(callableStates_begin(), callableStates_end()); } | |||
2076 | ||||
2077 | ||||
2078 | static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) { | |||
2079 | Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val) | |||
2080 | .Case("unknown", CallableWhenAttr::Unknown) | |||
2081 | .Case("consumed", CallableWhenAttr::Consumed) | |||
2082 | .Case("unconsumed", CallableWhenAttr::Unconsumed) | |||
2083 | .Default(Optional<ConsumedState>()); | |||
2084 | if (R) { | |||
2085 | Out = *R; | |||
2086 | return true; | |||
2087 | } | |||
2088 | return false; | |||
2089 | } | |||
2090 | ||||
2091 | static const char *ConvertConsumedStateToStr(ConsumedState Val) { | |||
2092 | switch(Val) { | |||
2093 | case CallableWhenAttr::Unknown: return "unknown"; | |||
2094 | case CallableWhenAttr::Consumed: return "consumed"; | |||
2095 | case CallableWhenAttr::Unconsumed: return "unconsumed"; | |||
2096 | } | |||
2097 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 2097); | |||
2098 | } | |||
2099 | ||||
2100 | ||||
2101 | static bool classof(const Attr *A) { return A->getKind() == attr::CallableWhen; } | |||
2102 | }; | |||
2103 | ||||
2104 | class CapabilityAttr : public InheritableAttr { | |||
2105 | unsigned nameLength; | |||
2106 | char *name; | |||
2107 | ||||
2108 | public: | |||
2109 | enum Spelling { | |||
2110 | GNU_capability = 0, | |||
2111 | CXX11_clang_capability = 1, | |||
2112 | GNU_shared_capability = 2, | |||
2113 | CXX11_clang_shared_capability = 3 | |||
2114 | }; | |||
2115 | ||||
2116 | static CapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, llvm::StringRef Name, SourceRange Loc = SourceRange()) { | |||
2117 | auto *A = new (Ctx) CapabilityAttr(Loc, Ctx, Name, S); | |||
2118 | A->setImplicit(true); | |||
2119 | return A; | |||
2120 | } | |||
2121 | ||||
2122 | CapabilityAttr(SourceRange R, ASTContext &Ctx | |||
2123 | , llvm::StringRef Name | |||
2124 | , unsigned SI | |||
2125 | ) | |||
2126 | : InheritableAttr(attr::Capability, R, SI, false, false) | |||
2127 | , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength]) | |||
2128 | { | |||
2129 | if (!Name.empty()) | |||
2130 | std::memcpy(name, Name.data(), nameLength); | |||
2131 | } | |||
2132 | ||||
2133 | CapabilityAttr *clone(ASTContext &C) const; | |||
2134 | void printPretty(raw_ostream &OS, | |||
2135 | const PrintingPolicy &Policy) const; | |||
2136 | const char *getSpelling() const; | |||
2137 | Spelling getSemanticSpelling() const { | |||
2138 | switch (SpellingListIndex) { | |||
2139 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 2139); | |||
2140 | case 0: return GNU_capability; | |||
2141 | case 1: return CXX11_clang_capability; | |||
2142 | case 2: return GNU_shared_capability; | |||
2143 | case 3: return CXX11_clang_shared_capability; | |||
2144 | } | |||
2145 | } | |||
2146 | bool isShared() const { return SpellingListIndex == 2 || | |||
2147 | SpellingListIndex == 3; } | |||
2148 | llvm::StringRef getName() const { | |||
2149 | return llvm::StringRef(name, nameLength); | |||
2150 | } | |||
2151 | unsigned getNameLength() const { | |||
2152 | return nameLength; | |||
2153 | } | |||
2154 | void setName(ASTContext &C, llvm::StringRef S) { | |||
2155 | nameLength = S.size(); | |||
2156 | this->name = new (C, 1) char [nameLength]; | |||
2157 | if (!S.empty()) | |||
2158 | std::memcpy(this->name, S.data(), nameLength); | |||
2159 | } | |||
2160 | ||||
2161 | ||||
2162 | bool isMutex() const { return getName().equals_lower("mutex"); } | |||
2163 | bool isRole() const { return getName().equals_lower("role"); } | |||
2164 | ||||
2165 | ||||
2166 | static bool classof(const Attr *A) { return A->getKind() == attr::Capability; } | |||
2167 | }; | |||
2168 | ||||
2169 | class CapturedRecordAttr : public InheritableAttr { | |||
2170 | public: | |||
2171 | static CapturedRecordAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2172 | auto *A = new (Ctx) CapturedRecordAttr(Loc, Ctx, 0); | |||
2173 | A->setImplicit(true); | |||
2174 | return A; | |||
2175 | } | |||
2176 | ||||
2177 | CapturedRecordAttr(SourceRange R, ASTContext &Ctx | |||
2178 | , unsigned SI | |||
2179 | ) | |||
2180 | : InheritableAttr(attr::CapturedRecord, R, SI, false, false) | |||
2181 | { | |||
2182 | } | |||
2183 | ||||
2184 | CapturedRecordAttr *clone(ASTContext &C) const; | |||
2185 | void printPretty(raw_ostream &OS, | |||
2186 | const PrintingPolicy &Policy) const; | |||
2187 | const char *getSpelling() const; | |||
2188 | ||||
2189 | ||||
2190 | static bool classof(const Attr *A) { return A->getKind() == attr::CapturedRecord; } | |||
2191 | }; | |||
2192 | ||||
2193 | class CarriesDependencyAttr : public InheritableParamAttr { | |||
2194 | public: | |||
2195 | static CarriesDependencyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2196 | auto *A = new (Ctx) CarriesDependencyAttr(Loc, Ctx, 0); | |||
2197 | A->setImplicit(true); | |||
2198 | return A; | |||
2199 | } | |||
2200 | ||||
2201 | CarriesDependencyAttr(SourceRange R, ASTContext &Ctx | |||
2202 | , unsigned SI | |||
2203 | ) | |||
2204 | : InheritableParamAttr(attr::CarriesDependency, R, SI, false, false) | |||
2205 | { | |||
2206 | } | |||
2207 | ||||
2208 | CarriesDependencyAttr *clone(ASTContext &C) const; | |||
2209 | void printPretty(raw_ostream &OS, | |||
2210 | const PrintingPolicy &Policy) const; | |||
2211 | const char *getSpelling() const; | |||
2212 | ||||
2213 | ||||
2214 | static bool classof(const Attr *A) { return A->getKind() == attr::CarriesDependency; } | |||
2215 | }; | |||
2216 | ||||
2217 | class CleanupAttr : public InheritableAttr { | |||
2218 | FunctionDecl * functionDecl; | |||
2219 | ||||
2220 | public: | |||
2221 | static CleanupAttr *CreateImplicit(ASTContext &Ctx, FunctionDecl * FunctionDecl, SourceRange Loc = SourceRange()) { | |||
2222 | auto *A = new (Ctx) CleanupAttr(Loc, Ctx, FunctionDecl, 0); | |||
2223 | A->setImplicit(true); | |||
2224 | return A; | |||
2225 | } | |||
2226 | ||||
2227 | CleanupAttr(SourceRange R, ASTContext &Ctx | |||
2228 | , FunctionDecl * FunctionDecl | |||
2229 | , unsigned SI | |||
2230 | ) | |||
2231 | : InheritableAttr(attr::Cleanup, R, SI, false, false) | |||
2232 | , functionDecl(FunctionDecl) | |||
2233 | { | |||
2234 | } | |||
2235 | ||||
2236 | CleanupAttr *clone(ASTContext &C) const; | |||
2237 | void printPretty(raw_ostream &OS, | |||
2238 | const PrintingPolicy &Policy) const; | |||
2239 | const char *getSpelling() const; | |||
2240 | FunctionDecl * getFunctionDecl() const { | |||
2241 | return functionDecl; | |||
2242 | } | |||
2243 | ||||
2244 | ||||
2245 | ||||
2246 | static bool classof(const Attr *A) { return A->getKind() == attr::Cleanup; } | |||
2247 | }; | |||
2248 | ||||
2249 | class CodeSegAttr : public InheritableAttr { | |||
2250 | unsigned nameLength; | |||
2251 | char *name; | |||
2252 | ||||
2253 | public: | |||
2254 | static CodeSegAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) { | |||
2255 | auto *A = new (Ctx) CodeSegAttr(Loc, Ctx, Name, 0); | |||
2256 | A->setImplicit(true); | |||
2257 | return A; | |||
2258 | } | |||
2259 | ||||
2260 | CodeSegAttr(SourceRange R, ASTContext &Ctx | |||
2261 | , llvm::StringRef Name | |||
2262 | , unsigned SI | |||
2263 | ) | |||
2264 | : InheritableAttr(attr::CodeSeg, R, SI, false, false) | |||
2265 | , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength]) | |||
2266 | { | |||
2267 | if (!Name.empty()) | |||
2268 | std::memcpy(name, Name.data(), nameLength); | |||
2269 | } | |||
2270 | ||||
2271 | CodeSegAttr *clone(ASTContext &C) const; | |||
2272 | void printPretty(raw_ostream &OS, | |||
2273 | const PrintingPolicy &Policy) const; | |||
2274 | const char *getSpelling() const; | |||
2275 | llvm::StringRef getName() const { | |||
2276 | return llvm::StringRef(name, nameLength); | |||
2277 | } | |||
2278 | unsigned getNameLength() const { | |||
2279 | return nameLength; | |||
2280 | } | |||
2281 | void setName(ASTContext &C, llvm::StringRef S) { | |||
2282 | nameLength = S.size(); | |||
2283 | this->name = new (C, 1) char [nameLength]; | |||
2284 | if (!S.empty()) | |||
2285 | std::memcpy(this->name, S.data(), nameLength); | |||
2286 | } | |||
2287 | ||||
2288 | ||||
2289 | ||||
2290 | static bool classof(const Attr *A) { return A->getKind() == attr::CodeSeg; } | |||
2291 | }; | |||
2292 | ||||
2293 | class ColdAttr : public InheritableAttr { | |||
2294 | public: | |||
2295 | static ColdAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2296 | auto *A = new (Ctx) ColdAttr(Loc, Ctx, 0); | |||
2297 | A->setImplicit(true); | |||
2298 | return A; | |||
2299 | } | |||
2300 | ||||
2301 | ColdAttr(SourceRange R, ASTContext &Ctx | |||
2302 | , unsigned SI | |||
2303 | ) | |||
2304 | : InheritableAttr(attr::Cold, R, SI, false, false) | |||
2305 | { | |||
2306 | } | |||
2307 | ||||
2308 | ColdAttr *clone(ASTContext &C) const; | |||
2309 | void printPretty(raw_ostream &OS, | |||
2310 | const PrintingPolicy &Policy) const; | |||
2311 | const char *getSpelling() const; | |||
2312 | ||||
2313 | ||||
2314 | static bool classof(const Attr *A) { return A->getKind() == attr::Cold; } | |||
2315 | }; | |||
2316 | ||||
2317 | class CommonAttr : public InheritableAttr { | |||
2318 | public: | |||
2319 | static CommonAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2320 | auto *A = new (Ctx) CommonAttr(Loc, Ctx, 0); | |||
2321 | A->setImplicit(true); | |||
2322 | return A; | |||
2323 | } | |||
2324 | ||||
2325 | CommonAttr(SourceRange R, ASTContext &Ctx | |||
2326 | , unsigned SI | |||
2327 | ) | |||
2328 | : InheritableAttr(attr::Common, R, SI, false, false) | |||
2329 | { | |||
2330 | } | |||
2331 | ||||
2332 | CommonAttr *clone(ASTContext &C) const; | |||
2333 | void printPretty(raw_ostream &OS, | |||
2334 | const PrintingPolicy &Policy) const; | |||
2335 | const char *getSpelling() const; | |||
2336 | ||||
2337 | ||||
2338 | static bool classof(const Attr *A) { return A->getKind() == attr::Common; } | |||
2339 | }; | |||
2340 | ||||
2341 | class ConstAttr : public InheritableAttr { | |||
2342 | public: | |||
2343 | static ConstAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2344 | auto *A = new (Ctx) ConstAttr(Loc, Ctx, 0); | |||
2345 | A->setImplicit(true); | |||
2346 | return A; | |||
2347 | } | |||
2348 | ||||
2349 | ConstAttr(SourceRange R, ASTContext &Ctx | |||
2350 | , unsigned SI | |||
2351 | ) | |||
2352 | : InheritableAttr(attr::Const, R, SI, false, false) | |||
2353 | { | |||
2354 | } | |||
2355 | ||||
2356 | ConstAttr *clone(ASTContext &C) const; | |||
2357 | void printPretty(raw_ostream &OS, | |||
2358 | const PrintingPolicy &Policy) const; | |||
2359 | const char *getSpelling() const; | |||
2360 | ||||
2361 | ||||
2362 | static bool classof(const Attr *A) { return A->getKind() == attr::Const; } | |||
2363 | }; | |||
2364 | ||||
2365 | class ConstructorAttr : public InheritableAttr { | |||
2366 | int priority; | |||
2367 | ||||
2368 | public: | |||
2369 | static ConstructorAttr *CreateImplicit(ASTContext &Ctx, int Priority, SourceRange Loc = SourceRange()) { | |||
2370 | auto *A = new (Ctx) ConstructorAttr(Loc, Ctx, Priority, 0); | |||
2371 | A->setImplicit(true); | |||
2372 | return A; | |||
2373 | } | |||
2374 | ||||
2375 | ConstructorAttr(SourceRange R, ASTContext &Ctx | |||
2376 | , int Priority | |||
2377 | , unsigned SI | |||
2378 | ) | |||
2379 | : InheritableAttr(attr::Constructor, R, SI, false, false) | |||
2380 | , priority(Priority) | |||
2381 | { | |||
2382 | } | |||
2383 | ||||
2384 | ConstructorAttr(SourceRange R, ASTContext &Ctx | |||
2385 | , unsigned SI | |||
2386 | ) | |||
2387 | : InheritableAttr(attr::Constructor, R, SI, false, false) | |||
2388 | , priority() | |||
2389 | { | |||
2390 | } | |||
2391 | ||||
2392 | ConstructorAttr *clone(ASTContext &C) const; | |||
2393 | void printPretty(raw_ostream &OS, | |||
2394 | const PrintingPolicy &Policy) const; | |||
2395 | const char *getSpelling() const; | |||
2396 | int getPriority() const { | |||
2397 | return priority; | |||
2398 | } | |||
2399 | ||||
2400 | static const int DefaultPriority = 65535; | |||
2401 | ||||
2402 | ||||
2403 | ||||
2404 | static bool classof(const Attr *A) { return A->getKind() == attr::Constructor; } | |||
2405 | }; | |||
2406 | ||||
2407 | class ConsumableAttr : public InheritableAttr { | |||
2408 | public: | |||
2409 | enum ConsumedState { | |||
2410 | Unknown, | |||
2411 | Consumed, | |||
2412 | Unconsumed | |||
2413 | }; | |||
2414 | private: | |||
2415 | ConsumedState defaultState; | |||
2416 | ||||
2417 | public: | |||
2418 | static ConsumableAttr *CreateImplicit(ASTContext &Ctx, ConsumedState DefaultState, SourceRange Loc = SourceRange()) { | |||
2419 | auto *A = new (Ctx) ConsumableAttr(Loc, Ctx, DefaultState, 0); | |||
2420 | A->setImplicit(true); | |||
2421 | return A; | |||
2422 | } | |||
2423 | ||||
2424 | ConsumableAttr(SourceRange R, ASTContext &Ctx | |||
2425 | , ConsumedState DefaultState | |||
2426 | , unsigned SI | |||
2427 | ) | |||
2428 | : InheritableAttr(attr::Consumable, R, SI, false, false) | |||
2429 | , defaultState(DefaultState) | |||
2430 | { | |||
2431 | } | |||
2432 | ||||
2433 | ConsumableAttr *clone(ASTContext &C) const; | |||
2434 | void printPretty(raw_ostream &OS, | |||
2435 | const PrintingPolicy &Policy) const; | |||
2436 | const char *getSpelling() const; | |||
2437 | ConsumedState getDefaultState() const { | |||
2438 | return defaultState; | |||
2439 | } | |||
2440 | ||||
2441 | static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) { | |||
2442 | Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val) | |||
2443 | .Case("unknown", ConsumableAttr::Unknown) | |||
2444 | .Case("consumed", ConsumableAttr::Consumed) | |||
2445 | .Case("unconsumed", ConsumableAttr::Unconsumed) | |||
2446 | .Default(Optional<ConsumedState>()); | |||
2447 | if (R) { | |||
2448 | Out = *R; | |||
2449 | return true; | |||
2450 | } | |||
2451 | return false; | |||
2452 | } | |||
2453 | ||||
2454 | static const char *ConvertConsumedStateToStr(ConsumedState Val) { | |||
2455 | switch(Val) { | |||
2456 | case ConsumableAttr::Unknown: return "unknown"; | |||
2457 | case ConsumableAttr::Consumed: return "consumed"; | |||
2458 | case ConsumableAttr::Unconsumed: return "unconsumed"; | |||
2459 | } | |||
2460 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 2460); | |||
2461 | } | |||
2462 | ||||
2463 | ||||
2464 | static bool classof(const Attr *A) { return A->getKind() == attr::Consumable; } | |||
2465 | }; | |||
2466 | ||||
2467 | class ConsumableAutoCastAttr : public InheritableAttr { | |||
2468 | public: | |||
2469 | static ConsumableAutoCastAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2470 | auto *A = new (Ctx) ConsumableAutoCastAttr(Loc, Ctx, 0); | |||
2471 | A->setImplicit(true); | |||
2472 | return A; | |||
2473 | } | |||
2474 | ||||
2475 | ConsumableAutoCastAttr(SourceRange R, ASTContext &Ctx | |||
2476 | , unsigned SI | |||
2477 | ) | |||
2478 | : InheritableAttr(attr::ConsumableAutoCast, R, SI, false, false) | |||
2479 | { | |||
2480 | } | |||
2481 | ||||
2482 | ConsumableAutoCastAttr *clone(ASTContext &C) const; | |||
2483 | void printPretty(raw_ostream &OS, | |||
2484 | const PrintingPolicy &Policy) const; | |||
2485 | const char *getSpelling() const; | |||
2486 | ||||
2487 | ||||
2488 | static bool classof(const Attr *A) { return A->getKind() == attr::ConsumableAutoCast; } | |||
2489 | }; | |||
2490 | ||||
2491 | class ConsumableSetOnReadAttr : public InheritableAttr { | |||
2492 | public: | |||
2493 | static ConsumableSetOnReadAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2494 | auto *A = new (Ctx) ConsumableSetOnReadAttr(Loc, Ctx, 0); | |||
2495 | A->setImplicit(true); | |||
2496 | return A; | |||
2497 | } | |||
2498 | ||||
2499 | ConsumableSetOnReadAttr(SourceRange R, ASTContext &Ctx | |||
2500 | , unsigned SI | |||
2501 | ) | |||
2502 | : InheritableAttr(attr::ConsumableSetOnRead, R, SI, false, false) | |||
2503 | { | |||
2504 | } | |||
2505 | ||||
2506 | ConsumableSetOnReadAttr *clone(ASTContext &C) const; | |||
2507 | void printPretty(raw_ostream &OS, | |||
2508 | const PrintingPolicy &Policy) const; | |||
2509 | const char *getSpelling() const; | |||
2510 | ||||
2511 | ||||
2512 | static bool classof(const Attr *A) { return A->getKind() == attr::ConsumableSetOnRead; } | |||
2513 | }; | |||
2514 | ||||
2515 | class ConvergentAttr : public InheritableAttr { | |||
2516 | public: | |||
2517 | static ConvergentAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2518 | auto *A = new (Ctx) ConvergentAttr(Loc, Ctx, 0); | |||
2519 | A->setImplicit(true); | |||
2520 | return A; | |||
2521 | } | |||
2522 | ||||
2523 | ConvergentAttr(SourceRange R, ASTContext &Ctx | |||
2524 | , unsigned SI | |||
2525 | ) | |||
2526 | : InheritableAttr(attr::Convergent, R, SI, false, false) | |||
2527 | { | |||
2528 | } | |||
2529 | ||||
2530 | ConvergentAttr *clone(ASTContext &C) const; | |||
2531 | void printPretty(raw_ostream &OS, | |||
2532 | const PrintingPolicy &Policy) const; | |||
2533 | const char *getSpelling() const; | |||
2534 | ||||
2535 | ||||
2536 | static bool classof(const Attr *A) { return A->getKind() == attr::Convergent; } | |||
2537 | }; | |||
2538 | ||||
2539 | class DLLExportAttr : public InheritableAttr { | |||
2540 | public: | |||
2541 | static DLLExportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2542 | auto *A = new (Ctx) DLLExportAttr(Loc, Ctx, 0); | |||
2543 | A->setImplicit(true); | |||
2544 | return A; | |||
2545 | } | |||
2546 | ||||
2547 | DLLExportAttr(SourceRange R, ASTContext &Ctx | |||
2548 | , unsigned SI | |||
2549 | ) | |||
2550 | : InheritableAttr(attr::DLLExport, R, SI, false, false) | |||
2551 | { | |||
2552 | } | |||
2553 | ||||
2554 | DLLExportAttr *clone(ASTContext &C) const; | |||
2555 | void printPretty(raw_ostream &OS, | |||
2556 | const PrintingPolicy &Policy) const; | |||
2557 | const char *getSpelling() const; | |||
2558 | ||||
2559 | ||||
2560 | static bool classof(const Attr *A) { return A->getKind() == attr::DLLExport; } | |||
2561 | }; | |||
2562 | ||||
2563 | class DLLImportAttr : public InheritableAttr { | |||
2564 | public: | |||
2565 | static DLLImportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2566 | auto *A = new (Ctx) DLLImportAttr(Loc, Ctx, 0); | |||
2567 | A->setImplicit(true); | |||
2568 | return A; | |||
2569 | } | |||
2570 | ||||
2571 | DLLImportAttr(SourceRange R, ASTContext &Ctx | |||
2572 | , unsigned SI | |||
2573 | ) | |||
2574 | : InheritableAttr(attr::DLLImport, R, SI, false, false) | |||
2575 | { | |||
2576 | } | |||
2577 | ||||
2578 | DLLImportAttr *clone(ASTContext &C) const; | |||
2579 | void printPretty(raw_ostream &OS, | |||
2580 | const PrintingPolicy &Policy) const; | |||
2581 | const char *getSpelling() const; | |||
2582 | ||||
2583 | private: | |||
2584 | bool PropagatedToBaseTemplate = false; | |||
2585 | ||||
2586 | public: | |||
2587 | void setPropagatedToBaseTemplate() { PropagatedToBaseTemplate = true; } | |||
2588 | bool wasPropagatedToBaseTemplate() { return PropagatedToBaseTemplate; } | |||
2589 | ||||
2590 | ||||
2591 | static bool classof(const Attr *A) { return A->getKind() == attr::DLLImport; } | |||
2592 | }; | |||
2593 | ||||
2594 | class DeprecatedAttr : public InheritableAttr { | |||
2595 | unsigned messageLength; | |||
2596 | char *message; | |||
2597 | ||||
2598 | unsigned replacementLength; | |||
2599 | char *replacement; | |||
2600 | ||||
2601 | public: | |||
2602 | static DeprecatedAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Message, llvm::StringRef Replacement, SourceRange Loc = SourceRange()) { | |||
2603 | auto *A = new (Ctx) DeprecatedAttr(Loc, Ctx, Message, Replacement, 0); | |||
2604 | A->setImplicit(true); | |||
2605 | return A; | |||
2606 | } | |||
2607 | ||||
2608 | DeprecatedAttr(SourceRange R, ASTContext &Ctx | |||
2609 | , llvm::StringRef Message | |||
2610 | , llvm::StringRef Replacement | |||
2611 | , unsigned SI | |||
2612 | ) | |||
2613 | : InheritableAttr(attr::Deprecated, R, SI, false, false) | |||
2614 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
2615 | , replacementLength(Replacement.size()),replacement(new (Ctx, 1) char[replacementLength]) | |||
2616 | { | |||
2617 | if (!Message.empty()) | |||
2618 | std::memcpy(message, Message.data(), messageLength); | |||
2619 | if (!Replacement.empty()) | |||
2620 | std::memcpy(replacement, Replacement.data(), replacementLength); | |||
2621 | } | |||
2622 | ||||
2623 | DeprecatedAttr(SourceRange R, ASTContext &Ctx | |||
2624 | , unsigned SI | |||
2625 | ) | |||
2626 | : InheritableAttr(attr::Deprecated, R, SI, false, false) | |||
2627 | , messageLength(0),message(nullptr) | |||
2628 | , replacementLength(0),replacement(nullptr) | |||
2629 | { | |||
2630 | } | |||
2631 | ||||
2632 | DeprecatedAttr *clone(ASTContext &C) const; | |||
2633 | void printPretty(raw_ostream &OS, | |||
2634 | const PrintingPolicy &Policy) const; | |||
2635 | const char *getSpelling() const; | |||
2636 | llvm::StringRef getMessage() const { | |||
2637 | return llvm::StringRef(message, messageLength); | |||
2638 | } | |||
2639 | unsigned getMessageLength() const { | |||
2640 | return messageLength; | |||
2641 | } | |||
2642 | void setMessage(ASTContext &C, llvm::StringRef S) { | |||
2643 | messageLength = S.size(); | |||
2644 | this->message = new (C, 1) char [messageLength]; | |||
2645 | if (!S.empty()) | |||
2646 | std::memcpy(this->message, S.data(), messageLength); | |||
2647 | } | |||
2648 | ||||
2649 | llvm::StringRef getReplacement() const { | |||
2650 | return llvm::StringRef(replacement, replacementLength); | |||
2651 | } | |||
2652 | unsigned getReplacementLength() const { | |||
2653 | return replacementLength; | |||
2654 | } | |||
2655 | void setReplacement(ASTContext &C, llvm::StringRef S) { | |||
2656 | replacementLength = S.size(); | |||
2657 | this->replacement = new (C, 1) char [replacementLength]; | |||
2658 | if (!S.empty()) | |||
2659 | std::memcpy(this->replacement, S.data(), replacementLength); | |||
2660 | } | |||
2661 | ||||
2662 | ||||
2663 | ||||
2664 | static bool classof(const Attr *A) { return A->getKind() == attr::Deprecated; } | |||
2665 | }; | |||
2666 | ||||
2667 | class DestructorAttr : public InheritableAttr { | |||
2668 | int priority; | |||
2669 | ||||
2670 | public: | |||
2671 | static DestructorAttr *CreateImplicit(ASTContext &Ctx, int Priority, SourceRange Loc = SourceRange()) { | |||
2672 | auto *A = new (Ctx) DestructorAttr(Loc, Ctx, Priority, 0); | |||
2673 | A->setImplicit(true); | |||
2674 | return A; | |||
2675 | } | |||
2676 | ||||
2677 | DestructorAttr(SourceRange R, ASTContext &Ctx | |||
2678 | , int Priority | |||
2679 | , unsigned SI | |||
2680 | ) | |||
2681 | : InheritableAttr(attr::Destructor, R, SI, false, false) | |||
2682 | , priority(Priority) | |||
2683 | { | |||
2684 | } | |||
2685 | ||||
2686 | DestructorAttr(SourceRange R, ASTContext &Ctx | |||
2687 | , unsigned SI | |||
2688 | ) | |||
2689 | : InheritableAttr(attr::Destructor, R, SI, false, false) | |||
2690 | , priority() | |||
2691 | { | |||
2692 | } | |||
2693 | ||||
2694 | DestructorAttr *clone(ASTContext &C) const; | |||
2695 | void printPretty(raw_ostream &OS, | |||
2696 | const PrintingPolicy &Policy) const; | |||
2697 | const char *getSpelling() const; | |||
2698 | int getPriority() const { | |||
2699 | return priority; | |||
2700 | } | |||
2701 | ||||
2702 | static const int DefaultPriority = 65535; | |||
2703 | ||||
2704 | ||||
2705 | ||||
2706 | static bool classof(const Attr *A) { return A->getKind() == attr::Destructor; } | |||
2707 | }; | |||
2708 | ||||
2709 | class DiagnoseIfAttr : public InheritableAttr { | |||
2710 | Expr * cond; | |||
2711 | ||||
2712 | unsigned messageLength; | |||
2713 | char *message; | |||
2714 | ||||
2715 | public: | |||
2716 | enum DiagnosticType { | |||
2717 | DT_Error, | |||
2718 | DT_Warning | |||
2719 | }; | |||
2720 | private: | |||
2721 | DiagnosticType diagnosticType; | |||
2722 | ||||
2723 | bool argDependent; | |||
2724 | ||||
2725 | NamedDecl * parent; | |||
2726 | ||||
2727 | public: | |||
2728 | static DiagnoseIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, DiagnosticType DiagnosticType, bool ArgDependent, NamedDecl * Parent, SourceRange Loc = SourceRange()) { | |||
2729 | auto *A = new (Ctx) DiagnoseIfAttr(Loc, Ctx, Cond, Message, DiagnosticType, ArgDependent, Parent, 0); | |||
2730 | A->setImplicit(true); | |||
2731 | return A; | |||
2732 | } | |||
2733 | ||||
2734 | static DiagnoseIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, DiagnosticType DiagnosticType, SourceRange Loc = SourceRange()) { | |||
2735 | auto *A = new (Ctx) DiagnoseIfAttr(Loc, Ctx, Cond, Message, DiagnosticType, 0); | |||
2736 | A->setImplicit(true); | |||
2737 | return A; | |||
2738 | } | |||
2739 | ||||
2740 | DiagnoseIfAttr(SourceRange R, ASTContext &Ctx | |||
2741 | , Expr * Cond | |||
2742 | , llvm::StringRef Message | |||
2743 | , DiagnosticType DiagnosticType | |||
2744 | , bool ArgDependent | |||
2745 | , NamedDecl * Parent | |||
2746 | , unsigned SI | |||
2747 | ) | |||
2748 | : InheritableAttr(attr::DiagnoseIf, R, SI, true, true) | |||
2749 | , cond(Cond) | |||
2750 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
2751 | , diagnosticType(DiagnosticType) | |||
2752 | , argDependent(ArgDependent) | |||
2753 | , parent(Parent) | |||
2754 | { | |||
2755 | if (!Message.empty()) | |||
2756 | std::memcpy(message, Message.data(), messageLength); | |||
2757 | } | |||
2758 | ||||
2759 | DiagnoseIfAttr(SourceRange R, ASTContext &Ctx | |||
2760 | , Expr * Cond | |||
2761 | , llvm::StringRef Message | |||
2762 | , DiagnosticType DiagnosticType | |||
2763 | , unsigned SI | |||
2764 | ) | |||
2765 | : InheritableAttr(attr::DiagnoseIf, R, SI, true, true) | |||
2766 | , cond(Cond) | |||
2767 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
2768 | , diagnosticType(DiagnosticType) | |||
2769 | , argDependent() | |||
2770 | , parent() | |||
2771 | { | |||
2772 | if (!Message.empty()) | |||
2773 | std::memcpy(message, Message.data(), messageLength); | |||
2774 | } | |||
2775 | ||||
2776 | DiagnoseIfAttr *clone(ASTContext &C) const; | |||
2777 | void printPretty(raw_ostream &OS, | |||
2778 | const PrintingPolicy &Policy) const; | |||
2779 | const char *getSpelling() const; | |||
2780 | Expr * getCond() const { | |||
2781 | return cond; | |||
2782 | } | |||
2783 | ||||
2784 | llvm::StringRef getMessage() const { | |||
2785 | return llvm::StringRef(message, messageLength); | |||
2786 | } | |||
2787 | unsigned getMessageLength() const { | |||
2788 | return messageLength; | |||
2789 | } | |||
2790 | void setMessage(ASTContext &C, llvm::StringRef S) { | |||
2791 | messageLength = S.size(); | |||
2792 | this->message = new (C, 1) char [messageLength]; | |||
2793 | if (!S.empty()) | |||
2794 | std::memcpy(this->message, S.data(), messageLength); | |||
2795 | } | |||
2796 | ||||
2797 | DiagnosticType getDiagnosticType() const { | |||
2798 | return diagnosticType; | |||
2799 | } | |||
2800 | ||||
2801 | static bool ConvertStrToDiagnosticType(StringRef Val, DiagnosticType &Out) { | |||
2802 | Optional<DiagnosticType> R = llvm::StringSwitch<Optional<DiagnosticType>>(Val) | |||
2803 | .Case("error", DiagnoseIfAttr::DT_Error) | |||
2804 | .Case("warning", DiagnoseIfAttr::DT_Warning) | |||
2805 | .Default(Optional<DiagnosticType>()); | |||
2806 | if (R) { | |||
2807 | Out = *R; | |||
2808 | return true; | |||
2809 | } | |||
2810 | return false; | |||
2811 | } | |||
2812 | ||||
2813 | static const char *ConvertDiagnosticTypeToStr(DiagnosticType Val) { | |||
2814 | switch(Val) { | |||
2815 | case DiagnoseIfAttr::DT_Error: return "error"; | |||
2816 | case DiagnoseIfAttr::DT_Warning: return "warning"; | |||
2817 | } | |||
2818 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 2818); | |||
2819 | } | |||
2820 | bool getArgDependent() const { | |||
2821 | return argDependent; | |||
2822 | } | |||
2823 | ||||
2824 | NamedDecl * getParent() const { | |||
2825 | return parent; | |||
2826 | } | |||
2827 | ||||
2828 | ||||
2829 | bool isError() const { return diagnosticType == DT_Error; } | |||
2830 | bool isWarning() const { return diagnosticType == DT_Warning; } | |||
2831 | ||||
2832 | ||||
2833 | static bool classof(const Attr *A) { return A->getKind() == attr::DiagnoseIf; } | |||
2834 | }; | |||
2835 | ||||
2836 | class DisableTailCallsAttr : public InheritableAttr { | |||
2837 | public: | |||
2838 | static DisableTailCallsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2839 | auto *A = new (Ctx) DisableTailCallsAttr(Loc, Ctx, 0); | |||
2840 | A->setImplicit(true); | |||
2841 | return A; | |||
2842 | } | |||
2843 | ||||
2844 | DisableTailCallsAttr(SourceRange R, ASTContext &Ctx | |||
2845 | , unsigned SI | |||
2846 | ) | |||
2847 | : InheritableAttr(attr::DisableTailCalls, R, SI, false, false) | |||
2848 | { | |||
2849 | } | |||
2850 | ||||
2851 | DisableTailCallsAttr *clone(ASTContext &C) const; | |||
2852 | void printPretty(raw_ostream &OS, | |||
2853 | const PrintingPolicy &Policy) const; | |||
2854 | const char *getSpelling() const; | |||
2855 | ||||
2856 | ||||
2857 | static bool classof(const Attr *A) { return A->getKind() == attr::DisableTailCalls; } | |||
2858 | }; | |||
2859 | ||||
2860 | class EmptyBasesAttr : public InheritableAttr { | |||
2861 | public: | |||
2862 | static EmptyBasesAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
2863 | auto *A = new (Ctx) EmptyBasesAttr(Loc, Ctx, 0); | |||
2864 | A->setImplicit(true); | |||
2865 | return A; | |||
2866 | } | |||
2867 | ||||
2868 | EmptyBasesAttr(SourceRange R, ASTContext &Ctx | |||
2869 | , unsigned SI | |||
2870 | ) | |||
2871 | : InheritableAttr(attr::EmptyBases, R, SI, false, false) | |||
2872 | { | |||
2873 | } | |||
2874 | ||||
2875 | EmptyBasesAttr *clone(ASTContext &C) const; | |||
2876 | void printPretty(raw_ostream &OS, | |||
2877 | const PrintingPolicy &Policy) const; | |||
2878 | const char *getSpelling() const; | |||
2879 | ||||
2880 | ||||
2881 | static bool classof(const Attr *A) { return A->getKind() == attr::EmptyBases; } | |||
2882 | }; | |||
2883 | ||||
2884 | class EnableIfAttr : public InheritableAttr { | |||
2885 | Expr * cond; | |||
2886 | ||||
2887 | unsigned messageLength; | |||
2888 | char *message; | |||
2889 | ||||
2890 | public: | |||
2891 | static EnableIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, SourceRange Loc = SourceRange()) { | |||
2892 | auto *A = new (Ctx) EnableIfAttr(Loc, Ctx, Cond, Message, 0); | |||
2893 | A->setImplicit(true); | |||
2894 | return A; | |||
2895 | } | |||
2896 | ||||
2897 | EnableIfAttr(SourceRange R, ASTContext &Ctx | |||
2898 | , Expr * Cond | |||
2899 | , llvm::StringRef Message | |||
2900 | , unsigned SI | |||
2901 | ) | |||
2902 | : InheritableAttr(attr::EnableIf, R, SI, false, false) | |||
2903 | , cond(Cond) | |||
2904 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
2905 | { | |||
2906 | if (!Message.empty()) | |||
2907 | std::memcpy(message, Message.data(), messageLength); | |||
2908 | } | |||
2909 | ||||
2910 | EnableIfAttr *clone(ASTContext &C) const; | |||
2911 | void printPretty(raw_ostream &OS, | |||
2912 | const PrintingPolicy &Policy) const; | |||
2913 | const char *getSpelling() const; | |||
2914 | Expr * getCond() const { | |||
2915 | return cond; | |||
2916 | } | |||
2917 | ||||
2918 | llvm::StringRef getMessage() const { | |||
2919 | return llvm::StringRef(message, messageLength); | |||
2920 | } | |||
2921 | unsigned getMessageLength() const { | |||
2922 | return messageLength; | |||
2923 | } | |||
2924 | void setMessage(ASTContext &C, llvm::StringRef S) { | |||
2925 | messageLength = S.size(); | |||
2926 | this->message = new (C, 1) char [messageLength]; | |||
2927 | if (!S.empty()) | |||
2928 | std::memcpy(this->message, S.data(), messageLength); | |||
2929 | } | |||
2930 | ||||
2931 | ||||
2932 | ||||
2933 | static bool classof(const Attr *A) { return A->getKind() == attr::EnableIf; } | |||
2934 | }; | |||
2935 | ||||
2936 | class EnumExtensibilityAttr : public InheritableAttr { | |||
2937 | public: | |||
2938 | enum Kind { | |||
2939 | Closed, | |||
2940 | Open | |||
2941 | }; | |||
2942 | private: | |||
2943 | Kind extensibility; | |||
2944 | ||||
2945 | public: | |||
2946 | static EnumExtensibilityAttr *CreateImplicit(ASTContext &Ctx, Kind Extensibility, SourceRange Loc = SourceRange()) { | |||
2947 | auto *A = new (Ctx) EnumExtensibilityAttr(Loc, Ctx, Extensibility, 0); | |||
2948 | A->setImplicit(true); | |||
2949 | return A; | |||
2950 | } | |||
2951 | ||||
2952 | EnumExtensibilityAttr(SourceRange R, ASTContext &Ctx | |||
2953 | , Kind Extensibility | |||
2954 | , unsigned SI | |||
2955 | ) | |||
2956 | : InheritableAttr(attr::EnumExtensibility, R, SI, false, false) | |||
2957 | , extensibility(Extensibility) | |||
2958 | { | |||
2959 | } | |||
2960 | ||||
2961 | EnumExtensibilityAttr *clone(ASTContext &C) const; | |||
2962 | void printPretty(raw_ostream &OS, | |||
2963 | const PrintingPolicy &Policy) const; | |||
2964 | const char *getSpelling() const; | |||
2965 | Kind getExtensibility() const { | |||
2966 | return extensibility; | |||
2967 | } | |||
2968 | ||||
2969 | static bool ConvertStrToKind(StringRef Val, Kind &Out) { | |||
2970 | Optional<Kind> R = llvm::StringSwitch<Optional<Kind>>(Val) | |||
2971 | .Case("closed", EnumExtensibilityAttr::Closed) | |||
2972 | .Case("open", EnumExtensibilityAttr::Open) | |||
2973 | .Default(Optional<Kind>()); | |||
2974 | if (R) { | |||
2975 | Out = *R; | |||
2976 | return true; | |||
2977 | } | |||
2978 | return false; | |||
2979 | } | |||
2980 | ||||
2981 | static const char *ConvertKindToStr(Kind Val) { | |||
2982 | switch(Val) { | |||
2983 | case EnumExtensibilityAttr::Closed: return "closed"; | |||
2984 | case EnumExtensibilityAttr::Open: return "open"; | |||
2985 | } | |||
2986 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 2986); | |||
2987 | } | |||
2988 | ||||
2989 | ||||
2990 | static bool classof(const Attr *A) { return A->getKind() == attr::EnumExtensibility; } | |||
2991 | }; | |||
2992 | ||||
2993 | class ExclusiveTrylockFunctionAttr : public InheritableAttr { | |||
2994 | Expr * successValue; | |||
2995 | ||||
2996 | unsigned args_Size; | |||
2997 | Expr * *args_; | |||
2998 | ||||
2999 | public: | |||
3000 | static ExclusiveTrylockFunctionAttr *CreateImplicit(ASTContext &Ctx, Expr * SuccessValue, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
3001 | auto *A = new (Ctx) ExclusiveTrylockFunctionAttr(Loc, Ctx, SuccessValue, Args, ArgsSize, 0); | |||
3002 | A->setImplicit(true); | |||
3003 | return A; | |||
3004 | } | |||
3005 | ||||
3006 | ExclusiveTrylockFunctionAttr(SourceRange R, ASTContext &Ctx | |||
3007 | , Expr * SuccessValue | |||
3008 | , Expr * *Args, unsigned ArgsSize | |||
3009 | , unsigned SI | |||
3010 | ) | |||
3011 | : InheritableAttr(attr::ExclusiveTrylockFunction, R, SI, true, true) | |||
3012 | , successValue(SuccessValue) | |||
3013 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
3014 | { | |||
3015 | std::copy(Args, Args + args_Size, args_); | |||
3016 | } | |||
3017 | ||||
3018 | ExclusiveTrylockFunctionAttr(SourceRange R, ASTContext &Ctx | |||
3019 | , Expr * SuccessValue | |||
3020 | , unsigned SI | |||
3021 | ) | |||
3022 | : InheritableAttr(attr::ExclusiveTrylockFunction, R, SI, true, true) | |||
3023 | , successValue(SuccessValue) | |||
3024 | , args_Size(0), args_(nullptr) | |||
3025 | { | |||
3026 | } | |||
3027 | ||||
3028 | ExclusiveTrylockFunctionAttr *clone(ASTContext &C) const; | |||
3029 | void printPretty(raw_ostream &OS, | |||
3030 | const PrintingPolicy &Policy) const; | |||
3031 | const char *getSpelling() const; | |||
3032 | Expr * getSuccessValue() const { | |||
3033 | return successValue; | |||
3034 | } | |||
3035 | ||||
3036 | typedef Expr ** args_iterator; | |||
3037 | args_iterator args_begin() const { return args_; } | |||
3038 | args_iterator args_end() const { return args_ + args_Size; } | |||
3039 | unsigned args_size() const { return args_Size; } | |||
3040 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
3041 | ||||
3042 | ||||
3043 | ||||
3044 | ||||
3045 | static bool classof(const Attr *A) { return A->getKind() == attr::ExclusiveTrylockFunction; } | |||
3046 | }; | |||
3047 | ||||
3048 | class ExternalSourceSymbolAttr : public InheritableAttr { | |||
3049 | unsigned languageLength; | |||
3050 | char *language; | |||
3051 | ||||
3052 | unsigned definedInLength; | |||
3053 | char *definedIn; | |||
3054 | ||||
3055 | bool generatedDeclaration; | |||
3056 | ||||
3057 | public: | |||
3058 | static ExternalSourceSymbolAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Language, llvm::StringRef DefinedIn, bool GeneratedDeclaration, SourceRange Loc = SourceRange()) { | |||
3059 | auto *A = new (Ctx) ExternalSourceSymbolAttr(Loc, Ctx, Language, DefinedIn, GeneratedDeclaration, 0); | |||
3060 | A->setImplicit(true); | |||
3061 | return A; | |||
3062 | } | |||
3063 | ||||
3064 | ExternalSourceSymbolAttr(SourceRange R, ASTContext &Ctx | |||
3065 | , llvm::StringRef Language | |||
3066 | , llvm::StringRef DefinedIn | |||
3067 | , bool GeneratedDeclaration | |||
3068 | , unsigned SI | |||
3069 | ) | |||
3070 | : InheritableAttr(attr::ExternalSourceSymbol, R, SI, false, false) | |||
3071 | , languageLength(Language.size()),language(new (Ctx, 1) char[languageLength]) | |||
3072 | , definedInLength(DefinedIn.size()),definedIn(new (Ctx, 1) char[definedInLength]) | |||
3073 | , generatedDeclaration(GeneratedDeclaration) | |||
3074 | { | |||
3075 | if (!Language.empty()) | |||
3076 | std::memcpy(language, Language.data(), languageLength); | |||
3077 | if (!DefinedIn.empty()) | |||
3078 | std::memcpy(definedIn, DefinedIn.data(), definedInLength); | |||
3079 | } | |||
3080 | ||||
3081 | ExternalSourceSymbolAttr(SourceRange R, ASTContext &Ctx | |||
3082 | , unsigned SI | |||
3083 | ) | |||
3084 | : InheritableAttr(attr::ExternalSourceSymbol, R, SI, false, false) | |||
3085 | , languageLength(0),language(nullptr) | |||
3086 | , definedInLength(0),definedIn(nullptr) | |||
3087 | , generatedDeclaration() | |||
3088 | { | |||
3089 | } | |||
3090 | ||||
3091 | ExternalSourceSymbolAttr *clone(ASTContext &C) const; | |||
3092 | void printPretty(raw_ostream &OS, | |||
3093 | const PrintingPolicy &Policy) const; | |||
3094 | const char *getSpelling() const; | |||
3095 | llvm::StringRef getLanguage() const { | |||
3096 | return llvm::StringRef(language, languageLength); | |||
3097 | } | |||
3098 | unsigned getLanguageLength() const { | |||
3099 | return languageLength; | |||
3100 | } | |||
3101 | void setLanguage(ASTContext &C, llvm::StringRef S) { | |||
3102 | languageLength = S.size(); | |||
3103 | this->language = new (C, 1) char [languageLength]; | |||
3104 | if (!S.empty()) | |||
3105 | std::memcpy(this->language, S.data(), languageLength); | |||
3106 | } | |||
3107 | ||||
3108 | llvm::StringRef getDefinedIn() const { | |||
3109 | return llvm::StringRef(definedIn, definedInLength); | |||
3110 | } | |||
3111 | unsigned getDefinedInLength() const { | |||
3112 | return definedInLength; | |||
3113 | } | |||
3114 | void setDefinedIn(ASTContext &C, llvm::StringRef S) { | |||
3115 | definedInLength = S.size(); | |||
3116 | this->definedIn = new (C, 1) char [definedInLength]; | |||
3117 | if (!S.empty()) | |||
3118 | std::memcpy(this->definedIn, S.data(), definedInLength); | |||
3119 | } | |||
3120 | ||||
3121 | bool getGeneratedDeclaration() const { | |||
3122 | return generatedDeclaration; | |||
3123 | } | |||
3124 | ||||
3125 | ||||
3126 | ||||
3127 | static bool classof(const Attr *A) { return A->getKind() == attr::ExternalSourceSymbol; } | |||
3128 | }; | |||
3129 | ||||
3130 | class FallThroughAttr : public StmtAttr { | |||
3131 | public: | |||
3132 | static FallThroughAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3133 | auto *A = new (Ctx) FallThroughAttr(Loc, Ctx, 0); | |||
3134 | A->setImplicit(true); | |||
3135 | return A; | |||
3136 | } | |||
3137 | ||||
3138 | FallThroughAttr(SourceRange R, ASTContext &Ctx | |||
3139 | , unsigned SI | |||
3140 | ) | |||
3141 | : StmtAttr(attr::FallThrough, R, SI, false) | |||
3142 | { | |||
3143 | } | |||
3144 | ||||
3145 | FallThroughAttr *clone(ASTContext &C) const; | |||
3146 | void printPretty(raw_ostream &OS, | |||
3147 | const PrintingPolicy &Policy) const; | |||
3148 | const char *getSpelling() const; | |||
3149 | ||||
3150 | ||||
3151 | static bool classof(const Attr *A) { return A->getKind() == attr::FallThrough; } | |||
3152 | }; | |||
3153 | ||||
3154 | class FastCallAttr : public InheritableAttr { | |||
3155 | public: | |||
3156 | static FastCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3157 | auto *A = new (Ctx) FastCallAttr(Loc, Ctx, 0); | |||
3158 | A->setImplicit(true); | |||
3159 | return A; | |||
3160 | } | |||
3161 | ||||
3162 | FastCallAttr(SourceRange R, ASTContext &Ctx | |||
3163 | , unsigned SI | |||
3164 | ) | |||
3165 | : InheritableAttr(attr::FastCall, R, SI, false, false) | |||
3166 | { | |||
3167 | } | |||
3168 | ||||
3169 | FastCallAttr *clone(ASTContext &C) const; | |||
3170 | void printPretty(raw_ostream &OS, | |||
3171 | const PrintingPolicy &Policy) const; | |||
3172 | const char *getSpelling() const; | |||
3173 | ||||
3174 | ||||
3175 | static bool classof(const Attr *A) { return A->getKind() == attr::FastCall; } | |||
3176 | }; | |||
3177 | ||||
3178 | class FinalAttr : public InheritableAttr { | |||
3179 | public: | |||
3180 | enum Spelling { | |||
3181 | Keyword_final = 0, | |||
3182 | Keyword_sealed = 1 | |||
3183 | }; | |||
3184 | ||||
3185 | static FinalAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
3186 | auto *A = new (Ctx) FinalAttr(Loc, Ctx, S); | |||
3187 | A->setImplicit(true); | |||
3188 | return A; | |||
3189 | } | |||
3190 | ||||
3191 | FinalAttr(SourceRange R, ASTContext &Ctx | |||
3192 | , unsigned SI | |||
3193 | ) | |||
3194 | : InheritableAttr(attr::Final, R, SI, false, false) | |||
3195 | { | |||
3196 | } | |||
3197 | ||||
3198 | FinalAttr *clone(ASTContext &C) const; | |||
3199 | void printPretty(raw_ostream &OS, | |||
3200 | const PrintingPolicy &Policy) const; | |||
3201 | const char *getSpelling() const; | |||
3202 | Spelling getSemanticSpelling() const { | |||
3203 | switch (SpellingListIndex) { | |||
3204 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3204); | |||
3205 | case 0: return Keyword_final; | |||
3206 | case 1: return Keyword_sealed; | |||
3207 | } | |||
3208 | } | |||
3209 | bool isSpelledAsSealed() const { return SpellingListIndex == 1; } | |||
3210 | ||||
3211 | ||||
3212 | static bool classof(const Attr *A) { return A->getKind() == attr::Final; } | |||
3213 | }; | |||
3214 | ||||
3215 | class FlagEnumAttr : public InheritableAttr { | |||
3216 | public: | |||
3217 | static FlagEnumAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3218 | auto *A = new (Ctx) FlagEnumAttr(Loc, Ctx, 0); | |||
3219 | A->setImplicit(true); | |||
3220 | return A; | |||
3221 | } | |||
3222 | ||||
3223 | FlagEnumAttr(SourceRange R, ASTContext &Ctx | |||
3224 | , unsigned SI | |||
3225 | ) | |||
3226 | : InheritableAttr(attr::FlagEnum, R, SI, false, false) | |||
3227 | { | |||
3228 | } | |||
3229 | ||||
3230 | FlagEnumAttr *clone(ASTContext &C) const; | |||
3231 | void printPretty(raw_ostream &OS, | |||
3232 | const PrintingPolicy &Policy) const; | |||
3233 | const char *getSpelling() const; | |||
3234 | ||||
3235 | ||||
3236 | static bool classof(const Attr *A) { return A->getKind() == attr::FlagEnum; } | |||
3237 | }; | |||
3238 | ||||
3239 | class FlattenAttr : public InheritableAttr { | |||
3240 | public: | |||
3241 | static FlattenAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3242 | auto *A = new (Ctx) FlattenAttr(Loc, Ctx, 0); | |||
3243 | A->setImplicit(true); | |||
3244 | return A; | |||
3245 | } | |||
3246 | ||||
3247 | FlattenAttr(SourceRange R, ASTContext &Ctx | |||
3248 | , unsigned SI | |||
3249 | ) | |||
3250 | : InheritableAttr(attr::Flatten, R, SI, false, false) | |||
3251 | { | |||
3252 | } | |||
3253 | ||||
3254 | FlattenAttr *clone(ASTContext &C) const; | |||
3255 | void printPretty(raw_ostream &OS, | |||
3256 | const PrintingPolicy &Policy) const; | |||
3257 | const char *getSpelling() const; | |||
3258 | ||||
3259 | ||||
3260 | static bool classof(const Attr *A) { return A->getKind() == attr::Flatten; } | |||
3261 | }; | |||
3262 | ||||
3263 | class FormatAttr : public InheritableAttr { | |||
3264 | IdentifierInfo * type; | |||
3265 | ||||
3266 | int formatIdx; | |||
3267 | ||||
3268 | int firstArg; | |||
3269 | ||||
3270 | public: | |||
3271 | static FormatAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Type, int FormatIdx, int FirstArg, SourceRange Loc = SourceRange()) { | |||
3272 | auto *A = new (Ctx) FormatAttr(Loc, Ctx, Type, FormatIdx, FirstArg, 0); | |||
3273 | A->setImplicit(true); | |||
3274 | return A; | |||
3275 | } | |||
3276 | ||||
3277 | FormatAttr(SourceRange R, ASTContext &Ctx | |||
3278 | , IdentifierInfo * Type | |||
3279 | , int FormatIdx | |||
3280 | , int FirstArg | |||
3281 | , unsigned SI | |||
3282 | ) | |||
3283 | : InheritableAttr(attr::Format, R, SI, false, false) | |||
3284 | , type(Type) | |||
3285 | , formatIdx(FormatIdx) | |||
3286 | , firstArg(FirstArg) | |||
3287 | { | |||
3288 | } | |||
3289 | ||||
3290 | FormatAttr *clone(ASTContext &C) const; | |||
3291 | void printPretty(raw_ostream &OS, | |||
3292 | const PrintingPolicy &Policy) const; | |||
3293 | const char *getSpelling() const; | |||
3294 | IdentifierInfo * getType() const { | |||
3295 | return type; | |||
3296 | } | |||
3297 | ||||
3298 | int getFormatIdx() const { | |||
3299 | return formatIdx; | |||
3300 | } | |||
3301 | ||||
3302 | int getFirstArg() const { | |||
3303 | return firstArg; | |||
3304 | } | |||
3305 | ||||
3306 | ||||
3307 | ||||
3308 | static bool classof(const Attr *A) { return A->getKind() == attr::Format; } | |||
3309 | }; | |||
3310 | ||||
3311 | class FormatArgAttr : public InheritableAttr { | |||
3312 | ParamIdx formatIdx; | |||
3313 | ||||
3314 | public: | |||
3315 | static FormatArgAttr *CreateImplicit(ASTContext &Ctx, ParamIdx FormatIdx, SourceRange Loc = SourceRange()) { | |||
3316 | auto *A = new (Ctx) FormatArgAttr(Loc, Ctx, FormatIdx, 0); | |||
3317 | A->setImplicit(true); | |||
3318 | return A; | |||
3319 | } | |||
3320 | ||||
3321 | FormatArgAttr(SourceRange R, ASTContext &Ctx | |||
3322 | , ParamIdx FormatIdx | |||
3323 | , unsigned SI | |||
3324 | ) | |||
3325 | : InheritableAttr(attr::FormatArg, R, SI, false, false) | |||
3326 | , formatIdx(FormatIdx) | |||
3327 | { | |||
3328 | } | |||
3329 | ||||
3330 | FormatArgAttr *clone(ASTContext &C) const; | |||
3331 | void printPretty(raw_ostream &OS, | |||
3332 | const PrintingPolicy &Policy) const; | |||
3333 | const char *getSpelling() const; | |||
3334 | ParamIdx getFormatIdx() const { | |||
3335 | return formatIdx; | |||
3336 | } | |||
3337 | ||||
3338 | ||||
3339 | ||||
3340 | static bool classof(const Attr *A) { return A->getKind() == attr::FormatArg; } | |||
3341 | }; | |||
3342 | ||||
3343 | class GNUInlineAttr : public InheritableAttr { | |||
3344 | public: | |||
3345 | static GNUInlineAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3346 | auto *A = new (Ctx) GNUInlineAttr(Loc, Ctx, 0); | |||
3347 | A->setImplicit(true); | |||
3348 | return A; | |||
3349 | } | |||
3350 | ||||
3351 | GNUInlineAttr(SourceRange R, ASTContext &Ctx | |||
3352 | , unsigned SI | |||
3353 | ) | |||
3354 | : InheritableAttr(attr::GNUInline, R, SI, false, false) | |||
3355 | { | |||
3356 | } | |||
3357 | ||||
3358 | GNUInlineAttr *clone(ASTContext &C) const; | |||
3359 | void printPretty(raw_ostream &OS, | |||
3360 | const PrintingPolicy &Policy) const; | |||
3361 | const char *getSpelling() const; | |||
3362 | ||||
3363 | ||||
3364 | static bool classof(const Attr *A) { return A->getKind() == attr::GNUInline; } | |||
3365 | }; | |||
3366 | ||||
3367 | class GuardedByAttr : public InheritableAttr { | |||
3368 | Expr * arg; | |||
3369 | ||||
3370 | public: | |||
3371 | static GuardedByAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) { | |||
3372 | auto *A = new (Ctx) GuardedByAttr(Loc, Ctx, Arg, 0); | |||
3373 | A->setImplicit(true); | |||
3374 | return A; | |||
3375 | } | |||
3376 | ||||
3377 | GuardedByAttr(SourceRange R, ASTContext &Ctx | |||
3378 | , Expr * Arg | |||
3379 | , unsigned SI | |||
3380 | ) | |||
3381 | : InheritableAttr(attr::GuardedBy, R, SI, true, true) | |||
3382 | , arg(Arg) | |||
3383 | { | |||
3384 | } | |||
3385 | ||||
3386 | GuardedByAttr *clone(ASTContext &C) const; | |||
3387 | void printPretty(raw_ostream &OS, | |||
3388 | const PrintingPolicy &Policy) const; | |||
3389 | const char *getSpelling() const; | |||
3390 | Expr * getArg() const { | |||
3391 | return arg; | |||
3392 | } | |||
3393 | ||||
3394 | ||||
3395 | ||||
3396 | static bool classof(const Attr *A) { return A->getKind() == attr::GuardedBy; } | |||
3397 | }; | |||
3398 | ||||
3399 | class GuardedVarAttr : public InheritableAttr { | |||
3400 | public: | |||
3401 | static GuardedVarAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3402 | auto *A = new (Ctx) GuardedVarAttr(Loc, Ctx, 0); | |||
3403 | A->setImplicit(true); | |||
3404 | return A; | |||
3405 | } | |||
3406 | ||||
3407 | GuardedVarAttr(SourceRange R, ASTContext &Ctx | |||
3408 | , unsigned SI | |||
3409 | ) | |||
3410 | : InheritableAttr(attr::GuardedVar, R, SI, false, false) | |||
3411 | { | |||
3412 | } | |||
3413 | ||||
3414 | GuardedVarAttr *clone(ASTContext &C) const; | |||
3415 | void printPretty(raw_ostream &OS, | |||
3416 | const PrintingPolicy &Policy) const; | |||
3417 | const char *getSpelling() const; | |||
3418 | ||||
3419 | ||||
3420 | static bool classof(const Attr *A) { return A->getKind() == attr::GuardedVar; } | |||
3421 | }; | |||
3422 | ||||
3423 | class HotAttr : public InheritableAttr { | |||
3424 | public: | |||
3425 | static HotAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3426 | auto *A = new (Ctx) HotAttr(Loc, Ctx, 0); | |||
3427 | A->setImplicit(true); | |||
3428 | return A; | |||
3429 | } | |||
3430 | ||||
3431 | HotAttr(SourceRange R, ASTContext &Ctx | |||
3432 | , unsigned SI | |||
3433 | ) | |||
3434 | : InheritableAttr(attr::Hot, R, SI, false, false) | |||
3435 | { | |||
3436 | } | |||
3437 | ||||
3438 | HotAttr *clone(ASTContext &C) const; | |||
3439 | void printPretty(raw_ostream &OS, | |||
3440 | const PrintingPolicy &Policy) const; | |||
3441 | const char *getSpelling() const; | |||
3442 | ||||
3443 | ||||
3444 | static bool classof(const Attr *A) { return A->getKind() == attr::Hot; } | |||
3445 | }; | |||
3446 | ||||
3447 | class IBActionAttr : public InheritableAttr { | |||
3448 | public: | |||
3449 | static IBActionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3450 | auto *A = new (Ctx) IBActionAttr(Loc, Ctx, 0); | |||
3451 | A->setImplicit(true); | |||
3452 | return A; | |||
3453 | } | |||
3454 | ||||
3455 | IBActionAttr(SourceRange R, ASTContext &Ctx | |||
3456 | , unsigned SI | |||
3457 | ) | |||
3458 | : InheritableAttr(attr::IBAction, R, SI, false, false) | |||
3459 | { | |||
3460 | } | |||
3461 | ||||
3462 | IBActionAttr *clone(ASTContext &C) const; | |||
3463 | void printPretty(raw_ostream &OS, | |||
3464 | const PrintingPolicy &Policy) const; | |||
3465 | const char *getSpelling() const; | |||
3466 | ||||
3467 | ||||
3468 | static bool classof(const Attr *A) { return A->getKind() == attr::IBAction; } | |||
3469 | }; | |||
3470 | ||||
3471 | class IBOutletAttr : public InheritableAttr { | |||
3472 | public: | |||
3473 | static IBOutletAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3474 | auto *A = new (Ctx) IBOutletAttr(Loc, Ctx, 0); | |||
3475 | A->setImplicit(true); | |||
3476 | return A; | |||
3477 | } | |||
3478 | ||||
3479 | IBOutletAttr(SourceRange R, ASTContext &Ctx | |||
3480 | , unsigned SI | |||
3481 | ) | |||
3482 | : InheritableAttr(attr::IBOutlet, R, SI, false, false) | |||
3483 | { | |||
3484 | } | |||
3485 | ||||
3486 | IBOutletAttr *clone(ASTContext &C) const; | |||
3487 | void printPretty(raw_ostream &OS, | |||
3488 | const PrintingPolicy &Policy) const; | |||
3489 | const char *getSpelling() const; | |||
3490 | ||||
3491 | ||||
3492 | static bool classof(const Attr *A) { return A->getKind() == attr::IBOutlet; } | |||
3493 | }; | |||
3494 | ||||
3495 | class IBOutletCollectionAttr : public InheritableAttr { | |||
3496 | TypeSourceInfo * interface_; | |||
3497 | ||||
3498 | public: | |||
3499 | static IBOutletCollectionAttr *CreateImplicit(ASTContext &Ctx, TypeSourceInfo * Interface, SourceRange Loc = SourceRange()) { | |||
3500 | auto *A = new (Ctx) IBOutletCollectionAttr(Loc, Ctx, Interface, 0); | |||
3501 | A->setImplicit(true); | |||
3502 | return A; | |||
3503 | } | |||
3504 | ||||
3505 | IBOutletCollectionAttr(SourceRange R, ASTContext &Ctx | |||
3506 | , TypeSourceInfo * Interface | |||
3507 | , unsigned SI | |||
3508 | ) | |||
3509 | : InheritableAttr(attr::IBOutletCollection, R, SI, false, false) | |||
3510 | , interface_(Interface) | |||
3511 | { | |||
3512 | } | |||
3513 | ||||
3514 | IBOutletCollectionAttr(SourceRange R, ASTContext &Ctx | |||
3515 | , unsigned SI | |||
3516 | ) | |||
3517 | : InheritableAttr(attr::IBOutletCollection, R, SI, false, false) | |||
3518 | , interface_() | |||
3519 | { | |||
3520 | } | |||
3521 | ||||
3522 | IBOutletCollectionAttr *clone(ASTContext &C) const; | |||
3523 | void printPretty(raw_ostream &OS, | |||
3524 | const PrintingPolicy &Policy) const; | |||
3525 | const char *getSpelling() const; | |||
3526 | QualType getInterface() const { | |||
3527 | return interface_->getType(); | |||
3528 | } TypeSourceInfo * getInterfaceLoc() const { | |||
3529 | return interface_; | |||
3530 | } | |||
3531 | ||||
3532 | ||||
3533 | ||||
3534 | static bool classof(const Attr *A) { return A->getKind() == attr::IBOutletCollection; } | |||
3535 | }; | |||
3536 | ||||
3537 | class IFuncAttr : public Attr { | |||
3538 | unsigned resolverLength; | |||
3539 | char *resolver; | |||
3540 | ||||
3541 | public: | |||
3542 | static IFuncAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Resolver, SourceRange Loc = SourceRange()) { | |||
3543 | auto *A = new (Ctx) IFuncAttr(Loc, Ctx, Resolver, 0); | |||
3544 | A->setImplicit(true); | |||
3545 | return A; | |||
3546 | } | |||
3547 | ||||
3548 | IFuncAttr(SourceRange R, ASTContext &Ctx | |||
3549 | , llvm::StringRef Resolver | |||
3550 | , unsigned SI | |||
3551 | ) | |||
3552 | : Attr(attr::IFunc, R, SI, false) | |||
3553 | , resolverLength(Resolver.size()),resolver(new (Ctx, 1) char[resolverLength]) | |||
3554 | { | |||
3555 | if (!Resolver.empty()) | |||
3556 | std::memcpy(resolver, Resolver.data(), resolverLength); | |||
3557 | } | |||
3558 | ||||
3559 | IFuncAttr *clone(ASTContext &C) const; | |||
3560 | void printPretty(raw_ostream &OS, | |||
3561 | const PrintingPolicy &Policy) const; | |||
3562 | const char *getSpelling() const; | |||
3563 | llvm::StringRef getResolver() const { | |||
3564 | return llvm::StringRef(resolver, resolverLength); | |||
3565 | } | |||
3566 | unsigned getResolverLength() const { | |||
3567 | return resolverLength; | |||
3568 | } | |||
3569 | void setResolver(ASTContext &C, llvm::StringRef S) { | |||
3570 | resolverLength = S.size(); | |||
3571 | this->resolver = new (C, 1) char [resolverLength]; | |||
3572 | if (!S.empty()) | |||
3573 | std::memcpy(this->resolver, S.data(), resolverLength); | |||
3574 | } | |||
3575 | ||||
3576 | ||||
3577 | ||||
3578 | static bool classof(const Attr *A) { return A->getKind() == attr::IFunc; } | |||
3579 | }; | |||
3580 | ||||
3581 | class InitPriorityAttr : public InheritableAttr { | |||
3582 | unsigned priority; | |||
3583 | ||||
3584 | public: | |||
3585 | static InitPriorityAttr *CreateImplicit(ASTContext &Ctx, unsigned Priority, SourceRange Loc = SourceRange()) { | |||
3586 | auto *A = new (Ctx) InitPriorityAttr(Loc, Ctx, Priority, 0); | |||
3587 | A->setImplicit(true); | |||
3588 | return A; | |||
3589 | } | |||
3590 | ||||
3591 | InitPriorityAttr(SourceRange R, ASTContext &Ctx | |||
3592 | , unsigned Priority | |||
3593 | , unsigned SI | |||
3594 | ) | |||
3595 | : InheritableAttr(attr::InitPriority, R, SI, false, false) | |||
3596 | , priority(Priority) | |||
3597 | { | |||
3598 | } | |||
3599 | ||||
3600 | InitPriorityAttr *clone(ASTContext &C) const; | |||
3601 | void printPretty(raw_ostream &OS, | |||
3602 | const PrintingPolicy &Policy) const; | |||
3603 | const char *getSpelling() const; | |||
3604 | unsigned getPriority() const { | |||
3605 | return priority; | |||
3606 | } | |||
3607 | ||||
3608 | ||||
3609 | ||||
3610 | static bool classof(const Attr *A) { return A->getKind() == attr::InitPriority; } | |||
3611 | }; | |||
3612 | ||||
3613 | class InitSegAttr : public Attr { | |||
3614 | unsigned sectionLength; | |||
3615 | char *section; | |||
3616 | ||||
3617 | public: | |||
3618 | static InitSegAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Section, SourceRange Loc = SourceRange()) { | |||
3619 | auto *A = new (Ctx) InitSegAttr(Loc, Ctx, Section, 0); | |||
3620 | A->setImplicit(true); | |||
3621 | return A; | |||
3622 | } | |||
3623 | ||||
3624 | InitSegAttr(SourceRange R, ASTContext &Ctx | |||
3625 | , llvm::StringRef Section | |||
3626 | , unsigned SI | |||
3627 | ) | |||
3628 | : Attr(attr::InitSeg, R, SI, false) | |||
3629 | , sectionLength(Section.size()),section(new (Ctx, 1) char[sectionLength]) | |||
3630 | { | |||
3631 | if (!Section.empty()) | |||
3632 | std::memcpy(section, Section.data(), sectionLength); | |||
3633 | } | |||
3634 | ||||
3635 | InitSegAttr *clone(ASTContext &C) const; | |||
3636 | void printPretty(raw_ostream &OS, | |||
3637 | const PrintingPolicy &Policy) const; | |||
3638 | const char *getSpelling() const; | |||
3639 | llvm::StringRef getSection() const { | |||
3640 | return llvm::StringRef(section, sectionLength); | |||
3641 | } | |||
3642 | unsigned getSectionLength() const { | |||
3643 | return sectionLength; | |||
3644 | } | |||
3645 | void setSection(ASTContext &C, llvm::StringRef S) { | |||
3646 | sectionLength = S.size(); | |||
3647 | this->section = new (C, 1) char [sectionLength]; | |||
3648 | if (!S.empty()) | |||
3649 | std::memcpy(this->section, S.data(), sectionLength); | |||
3650 | } | |||
3651 | ||||
3652 | ||||
3653 | void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const { | |||
3654 | OS << " (" << getSection() << ')'; | |||
3655 | } | |||
3656 | ||||
3657 | ||||
3658 | static bool classof(const Attr *A) { return A->getKind() == attr::InitSeg; } | |||
3659 | }; | |||
3660 | ||||
3661 | class IntelOclBiccAttr : public InheritableAttr { | |||
3662 | public: | |||
3663 | static IntelOclBiccAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3664 | auto *A = new (Ctx) IntelOclBiccAttr(Loc, Ctx, 0); | |||
3665 | A->setImplicit(true); | |||
3666 | return A; | |||
3667 | } | |||
3668 | ||||
3669 | IntelOclBiccAttr(SourceRange R, ASTContext &Ctx | |||
3670 | , unsigned SI | |||
3671 | ) | |||
3672 | : InheritableAttr(attr::IntelOclBicc, R, SI, false, false) | |||
3673 | { | |||
3674 | } | |||
3675 | ||||
3676 | IntelOclBiccAttr *clone(ASTContext &C) const; | |||
3677 | void printPretty(raw_ostream &OS, | |||
3678 | const PrintingPolicy &Policy) const; | |||
3679 | const char *getSpelling() const; | |||
3680 | ||||
3681 | ||||
3682 | static bool classof(const Attr *A) { return A->getKind() == attr::IntelOclBicc; } | |||
3683 | }; | |||
3684 | ||||
3685 | class InternalLinkageAttr : public InheritableAttr { | |||
3686 | public: | |||
3687 | static InternalLinkageAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3688 | auto *A = new (Ctx) InternalLinkageAttr(Loc, Ctx, 0); | |||
3689 | A->setImplicit(true); | |||
3690 | return A; | |||
3691 | } | |||
3692 | ||||
3693 | InternalLinkageAttr(SourceRange R, ASTContext &Ctx | |||
3694 | , unsigned SI | |||
3695 | ) | |||
3696 | : InheritableAttr(attr::InternalLinkage, R, SI, false, false) | |||
3697 | { | |||
3698 | } | |||
3699 | ||||
3700 | InternalLinkageAttr *clone(ASTContext &C) const; | |||
3701 | void printPretty(raw_ostream &OS, | |||
3702 | const PrintingPolicy &Policy) const; | |||
3703 | const char *getSpelling() const; | |||
3704 | ||||
3705 | ||||
3706 | static bool classof(const Attr *A) { return A->getKind() == attr::InternalLinkage; } | |||
3707 | }; | |||
3708 | ||||
3709 | class LTOVisibilityPublicAttr : public InheritableAttr { | |||
3710 | public: | |||
3711 | static LTOVisibilityPublicAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
3712 | auto *A = new (Ctx) LTOVisibilityPublicAttr(Loc, Ctx, 0); | |||
3713 | A->setImplicit(true); | |||
3714 | return A; | |||
3715 | } | |||
3716 | ||||
3717 | LTOVisibilityPublicAttr(SourceRange R, ASTContext &Ctx | |||
3718 | , unsigned SI | |||
3719 | ) | |||
3720 | : InheritableAttr(attr::LTOVisibilityPublic, R, SI, false, false) | |||
3721 | { | |||
3722 | } | |||
3723 | ||||
3724 | LTOVisibilityPublicAttr *clone(ASTContext &C) const; | |||
3725 | void printPretty(raw_ostream &OS, | |||
3726 | const PrintingPolicy &Policy) const; | |||
3727 | const char *getSpelling() const; | |||
3728 | ||||
3729 | ||||
3730 | static bool classof(const Attr *A) { return A->getKind() == attr::LTOVisibilityPublic; } | |||
3731 | }; | |||
3732 | ||||
3733 | class LayoutVersionAttr : public InheritableAttr { | |||
3734 | unsigned version; | |||
3735 | ||||
3736 | public: | |||
3737 | static LayoutVersionAttr *CreateImplicit(ASTContext &Ctx, unsigned Version, SourceRange Loc = SourceRange()) { | |||
3738 | auto *A = new (Ctx) LayoutVersionAttr(Loc, Ctx, Version, 0); | |||
3739 | A->setImplicit(true); | |||
3740 | return A; | |||
3741 | } | |||
3742 | ||||
3743 | LayoutVersionAttr(SourceRange R, ASTContext &Ctx | |||
3744 | , unsigned Version | |||
3745 | , unsigned SI | |||
3746 | ) | |||
3747 | : InheritableAttr(attr::LayoutVersion, R, SI, false, false) | |||
3748 | , version(Version) | |||
3749 | { | |||
3750 | } | |||
3751 | ||||
3752 | LayoutVersionAttr *clone(ASTContext &C) const; | |||
3753 | void printPretty(raw_ostream &OS, | |||
3754 | const PrintingPolicy &Policy) const; | |||
3755 | const char *getSpelling() const; | |||
3756 | unsigned getVersion() const { | |||
3757 | return version; | |||
3758 | } | |||
3759 | ||||
3760 | ||||
3761 | ||||
3762 | static bool classof(const Attr *A) { return A->getKind() == attr::LayoutVersion; } | |||
3763 | }; | |||
3764 | ||||
3765 | class LockReturnedAttr : public InheritableAttr { | |||
3766 | Expr * arg; | |||
3767 | ||||
3768 | public: | |||
3769 | static LockReturnedAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) { | |||
3770 | auto *A = new (Ctx) LockReturnedAttr(Loc, Ctx, Arg, 0); | |||
3771 | A->setImplicit(true); | |||
3772 | return A; | |||
3773 | } | |||
3774 | ||||
3775 | LockReturnedAttr(SourceRange R, ASTContext &Ctx | |||
3776 | , Expr * Arg | |||
3777 | , unsigned SI | |||
3778 | ) | |||
3779 | : InheritableAttr(attr::LockReturned, R, SI, true, false) | |||
3780 | , arg(Arg) | |||
3781 | { | |||
3782 | } | |||
3783 | ||||
3784 | LockReturnedAttr *clone(ASTContext &C) const; | |||
3785 | void printPretty(raw_ostream &OS, | |||
3786 | const PrintingPolicy &Policy) const; | |||
3787 | const char *getSpelling() const; | |||
3788 | Expr * getArg() const { | |||
3789 | return arg; | |||
3790 | } | |||
3791 | ||||
3792 | ||||
3793 | ||||
3794 | static bool classof(const Attr *A) { return A->getKind() == attr::LockReturned; } | |||
3795 | }; | |||
3796 | ||||
3797 | class LocksExcludedAttr : public InheritableAttr { | |||
3798 | unsigned args_Size; | |||
3799 | Expr * *args_; | |||
3800 | ||||
3801 | public: | |||
3802 | static LocksExcludedAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
3803 | auto *A = new (Ctx) LocksExcludedAttr(Loc, Ctx, Args, ArgsSize, 0); | |||
3804 | A->setImplicit(true); | |||
3805 | return A; | |||
3806 | } | |||
3807 | ||||
3808 | LocksExcludedAttr(SourceRange R, ASTContext &Ctx | |||
3809 | , Expr * *Args, unsigned ArgsSize | |||
3810 | , unsigned SI | |||
3811 | ) | |||
3812 | : InheritableAttr(attr::LocksExcluded, R, SI, true, true) | |||
3813 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
3814 | { | |||
3815 | std::copy(Args, Args + args_Size, args_); | |||
3816 | } | |||
3817 | ||||
3818 | LocksExcludedAttr(SourceRange R, ASTContext &Ctx | |||
3819 | , unsigned SI | |||
3820 | ) | |||
3821 | : InheritableAttr(attr::LocksExcluded, R, SI, true, true) | |||
3822 | , args_Size(0), args_(nullptr) | |||
3823 | { | |||
3824 | } | |||
3825 | ||||
3826 | LocksExcludedAttr *clone(ASTContext &C) const; | |||
3827 | void printPretty(raw_ostream &OS, | |||
3828 | const PrintingPolicy &Policy) const; | |||
3829 | const char *getSpelling() const; | |||
3830 | typedef Expr ** args_iterator; | |||
3831 | args_iterator args_begin() const { return args_; } | |||
3832 | args_iterator args_end() const { return args_ + args_Size; } | |||
3833 | unsigned args_size() const { return args_Size; } | |||
3834 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
3835 | ||||
3836 | ||||
3837 | ||||
3838 | ||||
3839 | static bool classof(const Attr *A) { return A->getKind() == attr::LocksExcluded; } | |||
3840 | }; | |||
3841 | ||||
3842 | class LoopHintAttr : public Attr { | |||
3843 | public: | |||
3844 | enum OptionType { | |||
3845 | Vectorize, | |||
3846 | VectorizeWidth, | |||
3847 | Interleave, | |||
3848 | InterleaveCount, | |||
3849 | Unroll, | |||
3850 | UnrollCount, | |||
3851 | Distribute | |||
3852 | }; | |||
3853 | private: | |||
3854 | OptionType option; | |||
3855 | ||||
3856 | public: | |||
3857 | enum LoopHintState { | |||
3858 | Enable, | |||
3859 | Disable, | |||
3860 | Numeric, | |||
3861 | AssumeSafety, | |||
3862 | Full | |||
3863 | }; | |||
3864 | private: | |||
3865 | LoopHintState state; | |||
3866 | ||||
3867 | Expr * value; | |||
3868 | ||||
3869 | public: | |||
3870 | enum Spelling { | |||
3871 | Pragma_clang_loop = 0, | |||
3872 | Pragma_unroll = 1, | |||
3873 | Pragma_nounroll = 2 | |||
3874 | }; | |||
3875 | ||||
3876 | static LoopHintAttr *CreateImplicit(ASTContext &Ctx, Spelling S, OptionType Option, LoopHintState State, Expr * Value, SourceRange Loc = SourceRange()) { | |||
3877 | auto *A = new (Ctx) LoopHintAttr(Loc, Ctx, Option, State, Value, S); | |||
3878 | A->setImplicit(true); | |||
3879 | return A; | |||
3880 | } | |||
3881 | ||||
3882 | LoopHintAttr(SourceRange R, ASTContext &Ctx | |||
3883 | , OptionType Option | |||
3884 | , LoopHintState State | |||
3885 | , Expr * Value | |||
3886 | , unsigned SI | |||
3887 | ) | |||
3888 | : Attr(attr::LoopHint, R, SI, false) | |||
3889 | , option(Option) | |||
3890 | , state(State) | |||
3891 | , value(Value) | |||
3892 | { | |||
3893 | } | |||
3894 | ||||
3895 | LoopHintAttr *clone(ASTContext &C) const; | |||
3896 | void printPretty(raw_ostream &OS, | |||
3897 | const PrintingPolicy &Policy) const; | |||
3898 | const char *getSpelling() const; | |||
3899 | Spelling getSemanticSpelling() const { | |||
3900 | switch (SpellingListIndex) { | |||
3901 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3901); | |||
3902 | case 0: return Pragma_clang_loop; | |||
3903 | case 1: return Pragma_unroll; | |||
3904 | case 2: return Pragma_nounroll; | |||
3905 | } | |||
3906 | } | |||
3907 | OptionType getOption() const { | |||
3908 | return option; | |||
3909 | } | |||
3910 | ||||
3911 | static bool ConvertStrToOptionType(StringRef Val, OptionType &Out) { | |||
3912 | Optional<OptionType> R = llvm::StringSwitch<Optional<OptionType>>(Val) | |||
3913 | .Case("vectorize", LoopHintAttr::Vectorize) | |||
3914 | .Case("vectorize_width", LoopHintAttr::VectorizeWidth) | |||
3915 | .Case("interleave", LoopHintAttr::Interleave) | |||
3916 | .Case("interleave_count", LoopHintAttr::InterleaveCount) | |||
3917 | .Case("unroll", LoopHintAttr::Unroll) | |||
3918 | .Case("unroll_count", LoopHintAttr::UnrollCount) | |||
3919 | .Case("distribute", LoopHintAttr::Distribute) | |||
3920 | .Default(Optional<OptionType>()); | |||
3921 | if (R) { | |||
3922 | Out = *R; | |||
3923 | return true; | |||
3924 | } | |||
3925 | return false; | |||
3926 | } | |||
3927 | ||||
3928 | static const char *ConvertOptionTypeToStr(OptionType Val) { | |||
3929 | switch(Val) { | |||
3930 | case LoopHintAttr::Vectorize: return "vectorize"; | |||
3931 | case LoopHintAttr::VectorizeWidth: return "vectorize_width"; | |||
3932 | case LoopHintAttr::Interleave: return "interleave"; | |||
3933 | case LoopHintAttr::InterleaveCount: return "interleave_count"; | |||
3934 | case LoopHintAttr::Unroll: return "unroll"; | |||
3935 | case LoopHintAttr::UnrollCount: return "unroll_count"; | |||
3936 | case LoopHintAttr::Distribute: return "distribute"; | |||
3937 | } | |||
3938 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3938); | |||
3939 | } | |||
3940 | LoopHintState getState() const { | |||
3941 | return state; | |||
3942 | } | |||
3943 | ||||
3944 | static bool ConvertStrToLoopHintState(StringRef Val, LoopHintState &Out) { | |||
3945 | Optional<LoopHintState> R = llvm::StringSwitch<Optional<LoopHintState>>(Val) | |||
3946 | .Case("enable", LoopHintAttr::Enable) | |||
3947 | .Case("disable", LoopHintAttr::Disable) | |||
3948 | .Case("numeric", LoopHintAttr::Numeric) | |||
3949 | .Case("assume_safety", LoopHintAttr::AssumeSafety) | |||
3950 | .Case("full", LoopHintAttr::Full) | |||
3951 | .Default(Optional<LoopHintState>()); | |||
3952 | if (R) { | |||
3953 | Out = *R; | |||
3954 | return true; | |||
3955 | } | |||
3956 | return false; | |||
3957 | } | |||
3958 | ||||
3959 | static const char *ConvertLoopHintStateToStr(LoopHintState Val) { | |||
3960 | switch(Val) { | |||
3961 | case LoopHintAttr::Enable: return "enable"; | |||
3962 | case LoopHintAttr::Disable: return "disable"; | |||
3963 | case LoopHintAttr::Numeric: return "numeric"; | |||
3964 | case LoopHintAttr::AssumeSafety: return "assume_safety"; | |||
3965 | case LoopHintAttr::Full: return "full"; | |||
3966 | } | |||
3967 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3967); | |||
3968 | } | |||
3969 | Expr * getValue() const { | |||
3970 | return value; | |||
3971 | } | |||
3972 | ||||
3973 | ||||
3974 | static const char *getOptionName(int Option) { | |||
3975 | switch(Option) { | |||
3976 | case Vectorize: return "vectorize"; | |||
3977 | case VectorizeWidth: return "vectorize_width"; | |||
3978 | case Interleave: return "interleave"; | |||
3979 | case InterleaveCount: return "interleave_count"; | |||
3980 | case Unroll: return "unroll"; | |||
3981 | case UnrollCount: return "unroll_count"; | |||
3982 | case Distribute: return "distribute"; | |||
3983 | } | |||
3984 | llvm_unreachable("Unhandled LoopHint option.")::llvm::llvm_unreachable_internal("Unhandled LoopHint option." , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3984); | |||
3985 | } | |||
3986 | ||||
3987 | void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const { | |||
3988 | unsigned SpellingIndex = getSpellingListIndex(); | |||
3989 | // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or | |||
3990 | // "nounroll" is already emitted as the pragma name. | |||
3991 | if (SpellingIndex == Pragma_nounroll) | |||
3992 | return; | |||
3993 | else if (SpellingIndex == Pragma_unroll) { | |||
3994 | OS << ' ' << getValueString(Policy); | |||
3995 | return; | |||
3996 | } | |||
3997 | ||||
3998 | 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~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 3998, __extension__ __PRETTY_FUNCTION__)); | |||
3999 | OS << ' ' << getOptionName(option) << getValueString(Policy); | |||
4000 | } | |||
4001 | ||||
4002 | // Return a string containing the loop hint argument including the | |||
4003 | // enclosing parentheses. | |||
4004 | std::string getValueString(const PrintingPolicy &Policy) const { | |||
4005 | std::string ValueName; | |||
4006 | llvm::raw_string_ostream OS(ValueName); | |||
4007 | OS << "("; | |||
4008 | if (state == Numeric) | |||
4009 | value->printPretty(OS, nullptr, Policy); | |||
4010 | else if (state == Enable) | |||
4011 | OS << "enable"; | |||
4012 | else if (state == Full) | |||
4013 | OS << "full"; | |||
4014 | else if (state == AssumeSafety) | |||
4015 | OS << "assume_safety"; | |||
4016 | else | |||
4017 | OS << "disable"; | |||
4018 | OS << ")"; | |||
4019 | return OS.str(); | |||
4020 | } | |||
4021 | ||||
4022 | // Return a string suitable for identifying this attribute in diagnostics. | |||
4023 | std::string getDiagnosticName(const PrintingPolicy &Policy) const { | |||
4024 | unsigned SpellingIndex = getSpellingListIndex(); | |||
4025 | if (SpellingIndex == Pragma_nounroll) | |||
4026 | return "#pragma nounroll"; | |||
4027 | else if (SpellingIndex == Pragma_unroll) | |||
4028 | return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : ""); | |||
4029 | ||||
4030 | 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~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 4030, __extension__ __PRETTY_FUNCTION__)); | |||
4031 | return getOptionName(option) + getValueString(Policy); | |||
4032 | } | |||
4033 | ||||
4034 | ||||
4035 | static bool classof(const Attr *A) { return A->getKind() == attr::LoopHint; } | |||
4036 | }; | |||
4037 | ||||
4038 | class MSABIAttr : public InheritableAttr { | |||
4039 | public: | |||
4040 | static MSABIAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4041 | auto *A = new (Ctx) MSABIAttr(Loc, Ctx, 0); | |||
4042 | A->setImplicit(true); | |||
4043 | return A; | |||
4044 | } | |||
4045 | ||||
4046 | MSABIAttr(SourceRange R, ASTContext &Ctx | |||
4047 | , unsigned SI | |||
4048 | ) | |||
4049 | : InheritableAttr(attr::MSABI, R, SI, false, false) | |||
4050 | { | |||
4051 | } | |||
4052 | ||||
4053 | MSABIAttr *clone(ASTContext &C) const; | |||
4054 | void printPretty(raw_ostream &OS, | |||
4055 | const PrintingPolicy &Policy) const; | |||
4056 | const char *getSpelling() const; | |||
4057 | ||||
4058 | ||||
4059 | static bool classof(const Attr *A) { return A->getKind() == attr::MSABI; } | |||
4060 | }; | |||
4061 | ||||
4062 | class MSInheritanceAttr : public InheritableAttr { | |||
4063 | bool bestCase; | |||
4064 | ||||
4065 | public: | |||
4066 | enum Spelling { | |||
4067 | Keyword_single_inheritance = 0, | |||
4068 | Keyword_multiple_inheritance = 1, | |||
4069 | Keyword_virtual_inheritance = 2, | |||
4070 | Keyword_unspecified_inheritance = 3 | |||
4071 | }; | |||
4072 | ||||
4073 | static MSInheritanceAttr *CreateImplicit(ASTContext &Ctx, Spelling S, bool BestCase, SourceRange Loc = SourceRange()) { | |||
4074 | auto *A = new (Ctx) MSInheritanceAttr(Loc, Ctx, BestCase, S); | |||
4075 | A->setImplicit(true); | |||
4076 | return A; | |||
4077 | } | |||
4078 | ||||
4079 | static MSInheritanceAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
4080 | auto *A = new (Ctx) MSInheritanceAttr(Loc, Ctx, S); | |||
4081 | A->setImplicit(true); | |||
4082 | return A; | |||
4083 | } | |||
4084 | ||||
4085 | MSInheritanceAttr(SourceRange R, ASTContext &Ctx | |||
4086 | , bool BestCase | |||
4087 | , unsigned SI | |||
4088 | ) | |||
4089 | : InheritableAttr(attr::MSInheritance, R, SI, false, false) | |||
4090 | , bestCase(BestCase) | |||
4091 | { | |||
4092 | } | |||
4093 | ||||
4094 | MSInheritanceAttr(SourceRange R, ASTContext &Ctx | |||
4095 | , unsigned SI | |||
4096 | ) | |||
4097 | : InheritableAttr(attr::MSInheritance, R, SI, false, false) | |||
4098 | , bestCase() | |||
4099 | { | |||
4100 | } | |||
4101 | ||||
4102 | MSInheritanceAttr *clone(ASTContext &C) const; | |||
4103 | void printPretty(raw_ostream &OS, | |||
4104 | const PrintingPolicy &Policy) const; | |||
4105 | const char *getSpelling() const; | |||
4106 | Spelling getSemanticSpelling() const { | |||
4107 | switch (SpellingListIndex) { | |||
4108 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 4108); | |||
4109 | case 0: return Keyword_single_inheritance; | |||
4110 | case 1: return Keyword_multiple_inheritance; | |||
4111 | case 2: return Keyword_virtual_inheritance; | |||
4112 | case 3: return Keyword_unspecified_inheritance; | |||
4113 | } | |||
4114 | } | |||
4115 | bool getBestCase() const { | |||
4116 | return bestCase; | |||
4117 | } | |||
4118 | ||||
4119 | static const bool DefaultBestCase = true; | |||
4120 | ||||
4121 | ||||
4122 | static bool hasVBPtrOffsetField(Spelling Inheritance) { | |||
4123 | return Inheritance == Keyword_unspecified_inheritance; | |||
4124 | } | |||
4125 | ||||
4126 | // Only member pointers to functions need a this adjustment, since it can be | |||
4127 | // combined with the field offset for data pointers. | |||
4128 | static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) { | |||
4129 | return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance; | |||
4130 | } | |||
4131 | ||||
4132 | static bool hasVBTableOffsetField(Spelling Inheritance) { | |||
4133 | return Inheritance >= Keyword_virtual_inheritance; | |||
4134 | } | |||
4135 | ||||
4136 | static bool hasOnlyOneField(bool IsMemberFunction, | |||
4137 | Spelling Inheritance) { | |||
4138 | if (IsMemberFunction) | |||
4139 | return Inheritance <= Keyword_single_inheritance; | |||
4140 | return Inheritance <= Keyword_multiple_inheritance; | |||
4141 | } | |||
4142 | ||||
4143 | ||||
4144 | static bool classof(const Attr *A) { return A->getKind() == attr::MSInheritance; } | |||
4145 | }; | |||
4146 | ||||
4147 | class MSNoVTableAttr : public InheritableAttr { | |||
4148 | public: | |||
4149 | static MSNoVTableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4150 | auto *A = new (Ctx) MSNoVTableAttr(Loc, Ctx, 0); | |||
4151 | A->setImplicit(true); | |||
4152 | return A; | |||
4153 | } | |||
4154 | ||||
4155 | MSNoVTableAttr(SourceRange R, ASTContext &Ctx | |||
4156 | , unsigned SI | |||
4157 | ) | |||
4158 | : InheritableAttr(attr::MSNoVTable, R, SI, false, false) | |||
4159 | { | |||
4160 | } | |||
4161 | ||||
4162 | MSNoVTableAttr *clone(ASTContext &C) const; | |||
4163 | void printPretty(raw_ostream &OS, | |||
4164 | const PrintingPolicy &Policy) const; | |||
4165 | const char *getSpelling() const; | |||
4166 | ||||
4167 | ||||
4168 | static bool classof(const Attr *A) { return A->getKind() == attr::MSNoVTable; } | |||
4169 | }; | |||
4170 | ||||
4171 | class MSP430InterruptAttr : public InheritableAttr { | |||
4172 | unsigned number; | |||
4173 | ||||
4174 | public: | |||
4175 | static MSP430InterruptAttr *CreateImplicit(ASTContext &Ctx, unsigned Number, SourceRange Loc = SourceRange()) { | |||
4176 | auto *A = new (Ctx) MSP430InterruptAttr(Loc, Ctx, Number, 0); | |||
4177 | A->setImplicit(true); | |||
4178 | return A; | |||
4179 | } | |||
4180 | ||||
4181 | MSP430InterruptAttr(SourceRange R, ASTContext &Ctx | |||
4182 | , unsigned Number | |||
4183 | , unsigned SI | |||
4184 | ) | |||
4185 | : InheritableAttr(attr::MSP430Interrupt, R, SI, false, false) | |||
4186 | , number(Number) | |||
4187 | { | |||
4188 | } | |||
4189 | ||||
4190 | MSP430InterruptAttr *clone(ASTContext &C) const; | |||
4191 | void printPretty(raw_ostream &OS, | |||
4192 | const PrintingPolicy &Policy) const; | |||
4193 | const char *getSpelling() const; | |||
4194 | unsigned getNumber() const { | |||
4195 | return number; | |||
4196 | } | |||
4197 | ||||
4198 | ||||
4199 | ||||
4200 | static bool classof(const Attr *A) { return A->getKind() == attr::MSP430Interrupt; } | |||
4201 | }; | |||
4202 | ||||
4203 | class MSStructAttr : public InheritableAttr { | |||
4204 | public: | |||
4205 | static MSStructAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4206 | auto *A = new (Ctx) MSStructAttr(Loc, Ctx, 0); | |||
4207 | A->setImplicit(true); | |||
4208 | return A; | |||
4209 | } | |||
4210 | ||||
4211 | MSStructAttr(SourceRange R, ASTContext &Ctx | |||
4212 | , unsigned SI | |||
4213 | ) | |||
4214 | : InheritableAttr(attr::MSStruct, R, SI, false, false) | |||
4215 | { | |||
4216 | } | |||
4217 | ||||
4218 | MSStructAttr *clone(ASTContext &C) const; | |||
4219 | void printPretty(raw_ostream &OS, | |||
4220 | const PrintingPolicy &Policy) const; | |||
4221 | const char *getSpelling() const; | |||
4222 | ||||
4223 | ||||
4224 | static bool classof(const Attr *A) { return A->getKind() == attr::MSStruct; } | |||
4225 | }; | |||
4226 | ||||
4227 | class MSVtorDispAttr : public InheritableAttr { | |||
4228 | unsigned vdm; | |||
4229 | ||||
4230 | public: | |||
4231 | static MSVtorDispAttr *CreateImplicit(ASTContext &Ctx, unsigned Vdm, SourceRange Loc = SourceRange()) { | |||
4232 | auto *A = new (Ctx) MSVtorDispAttr(Loc, Ctx, Vdm, 0); | |||
4233 | A->setImplicit(true); | |||
4234 | return A; | |||
4235 | } | |||
4236 | ||||
4237 | MSVtorDispAttr(SourceRange R, ASTContext &Ctx | |||
4238 | , unsigned Vdm | |||
4239 | , unsigned SI | |||
4240 | ) | |||
4241 | : InheritableAttr(attr::MSVtorDisp, R, SI, false, false) | |||
4242 | , vdm(Vdm) | |||
4243 | { | |||
4244 | } | |||
4245 | ||||
4246 | MSVtorDispAttr *clone(ASTContext &C) const; | |||
4247 | void printPretty(raw_ostream &OS, | |||
4248 | const PrintingPolicy &Policy) const; | |||
4249 | const char *getSpelling() const; | |||
4250 | unsigned getVdm() const { | |||
4251 | return vdm; | |||
4252 | } | |||
4253 | ||||
4254 | ||||
4255 | enum Mode { | |||
4256 | Never, | |||
4257 | ForVBaseOverride, | |||
4258 | ForVFTable | |||
4259 | }; | |||
4260 | ||||
4261 | Mode getVtorDispMode() const { return Mode(vdm); } | |||
4262 | ||||
4263 | ||||
4264 | static bool classof(const Attr *A) { return A->getKind() == attr::MSVtorDisp; } | |||
4265 | }; | |||
4266 | ||||
4267 | class MaxFieldAlignmentAttr : public InheritableAttr { | |||
4268 | unsigned alignment; | |||
4269 | ||||
4270 | public: | |||
4271 | static MaxFieldAlignmentAttr *CreateImplicit(ASTContext &Ctx, unsigned Alignment, SourceRange Loc = SourceRange()) { | |||
4272 | auto *A = new (Ctx) MaxFieldAlignmentAttr(Loc, Ctx, Alignment, 0); | |||
4273 | A->setImplicit(true); | |||
4274 | return A; | |||
4275 | } | |||
4276 | ||||
4277 | MaxFieldAlignmentAttr(SourceRange R, ASTContext &Ctx | |||
4278 | , unsigned Alignment | |||
4279 | , unsigned SI | |||
4280 | ) | |||
4281 | : InheritableAttr(attr::MaxFieldAlignment, R, SI, false, false) | |||
4282 | , alignment(Alignment) | |||
4283 | { | |||
4284 | } | |||
4285 | ||||
4286 | MaxFieldAlignmentAttr *clone(ASTContext &C) const; | |||
4287 | void printPretty(raw_ostream &OS, | |||
4288 | const PrintingPolicy &Policy) const; | |||
4289 | const char *getSpelling() const; | |||
4290 | unsigned getAlignment() const { | |||
4291 | return alignment; | |||
4292 | } | |||
4293 | ||||
4294 | ||||
4295 | ||||
4296 | static bool classof(const Attr *A) { return A->getKind() == attr::MaxFieldAlignment; } | |||
4297 | }; | |||
4298 | ||||
4299 | class MayAliasAttr : public InheritableAttr { | |||
4300 | public: | |||
4301 | static MayAliasAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4302 | auto *A = new (Ctx) MayAliasAttr(Loc, Ctx, 0); | |||
4303 | A->setImplicit(true); | |||
4304 | return A; | |||
4305 | } | |||
4306 | ||||
4307 | MayAliasAttr(SourceRange R, ASTContext &Ctx | |||
4308 | , unsigned SI | |||
4309 | ) | |||
4310 | : InheritableAttr(attr::MayAlias, R, SI, false, false) | |||
4311 | { | |||
4312 | } | |||
4313 | ||||
4314 | MayAliasAttr *clone(ASTContext &C) const; | |||
4315 | void printPretty(raw_ostream &OS, | |||
4316 | const PrintingPolicy &Policy) const; | |||
4317 | const char *getSpelling() const; | |||
4318 | ||||
4319 | ||||
4320 | static bool classof(const Attr *A) { return A->getKind() == attr::MayAlias; } | |||
4321 | }; | |||
4322 | ||||
4323 | class MicroMipsAttr : public InheritableAttr { | |||
4324 | public: | |||
4325 | static MicroMipsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4326 | auto *A = new (Ctx) MicroMipsAttr(Loc, Ctx, 0); | |||
4327 | A->setImplicit(true); | |||
4328 | return A; | |||
4329 | } | |||
4330 | ||||
4331 | MicroMipsAttr(SourceRange R, ASTContext &Ctx | |||
4332 | , unsigned SI | |||
4333 | ) | |||
4334 | : InheritableAttr(attr::MicroMips, R, SI, false, false) | |||
4335 | { | |||
4336 | } | |||
4337 | ||||
4338 | MicroMipsAttr *clone(ASTContext &C) const; | |||
4339 | void printPretty(raw_ostream &OS, | |||
4340 | const PrintingPolicy &Policy) const; | |||
4341 | const char *getSpelling() const; | |||
4342 | ||||
4343 | ||||
4344 | static bool classof(const Attr *A) { return A->getKind() == attr::MicroMips; } | |||
4345 | }; | |||
4346 | ||||
4347 | class MinSizeAttr : public InheritableAttr { | |||
4348 | public: | |||
4349 | static MinSizeAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4350 | auto *A = new (Ctx) MinSizeAttr(Loc, Ctx, 0); | |||
4351 | A->setImplicit(true); | |||
4352 | return A; | |||
4353 | } | |||
4354 | ||||
4355 | MinSizeAttr(SourceRange R, ASTContext &Ctx | |||
4356 | , unsigned SI | |||
4357 | ) | |||
4358 | : InheritableAttr(attr::MinSize, R, SI, false, false) | |||
4359 | { | |||
4360 | } | |||
4361 | ||||
4362 | MinSizeAttr *clone(ASTContext &C) const; | |||
4363 | void printPretty(raw_ostream &OS, | |||
4364 | const PrintingPolicy &Policy) const; | |||
4365 | const char *getSpelling() const; | |||
4366 | ||||
4367 | ||||
4368 | static bool classof(const Attr *A) { return A->getKind() == attr::MinSize; } | |||
4369 | }; | |||
4370 | ||||
4371 | class MinVectorWidthAttr : public InheritableAttr { | |||
4372 | unsigned vectorWidth; | |||
4373 | ||||
4374 | public: | |||
4375 | static MinVectorWidthAttr *CreateImplicit(ASTContext &Ctx, unsigned VectorWidth, SourceRange Loc = SourceRange()) { | |||
4376 | auto *A = new (Ctx) MinVectorWidthAttr(Loc, Ctx, VectorWidth, 0); | |||
4377 | A->setImplicit(true); | |||
4378 | return A; | |||
4379 | } | |||
4380 | ||||
4381 | MinVectorWidthAttr(SourceRange R, ASTContext &Ctx | |||
4382 | , unsigned VectorWidth | |||
4383 | , unsigned SI | |||
4384 | ) | |||
4385 | : InheritableAttr(attr::MinVectorWidth, R, SI, false, false) | |||
4386 | , vectorWidth(VectorWidth) | |||
4387 | { | |||
4388 | } | |||
4389 | ||||
4390 | MinVectorWidthAttr *clone(ASTContext &C) const; | |||
4391 | void printPretty(raw_ostream &OS, | |||
4392 | const PrintingPolicy &Policy) const; | |||
4393 | const char *getSpelling() const; | |||
4394 | unsigned getVectorWidth() const { | |||
4395 | return vectorWidth; | |||
4396 | } | |||
4397 | ||||
4398 | ||||
4399 | ||||
4400 | static bool classof(const Attr *A) { return A->getKind() == attr::MinVectorWidth; } | |||
4401 | }; | |||
4402 | ||||
4403 | class Mips16Attr : public InheritableAttr { | |||
4404 | public: | |||
4405 | static Mips16Attr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4406 | auto *A = new (Ctx) Mips16Attr(Loc, Ctx, 0); | |||
4407 | A->setImplicit(true); | |||
4408 | return A; | |||
4409 | } | |||
4410 | ||||
4411 | Mips16Attr(SourceRange R, ASTContext &Ctx | |||
4412 | , unsigned SI | |||
4413 | ) | |||
4414 | : InheritableAttr(attr::Mips16, R, SI, false, false) | |||
4415 | { | |||
4416 | } | |||
4417 | ||||
4418 | Mips16Attr *clone(ASTContext &C) const; | |||
4419 | void printPretty(raw_ostream &OS, | |||
4420 | const PrintingPolicy &Policy) const; | |||
4421 | const char *getSpelling() const; | |||
4422 | ||||
4423 | ||||
4424 | static bool classof(const Attr *A) { return A->getKind() == attr::Mips16; } | |||
4425 | }; | |||
4426 | ||||
4427 | class MipsInterruptAttr : public InheritableAttr { | |||
4428 | public: | |||
4429 | enum InterruptType { | |||
4430 | sw0, | |||
4431 | sw1, | |||
4432 | hw0, | |||
4433 | hw1, | |||
4434 | hw2, | |||
4435 | hw3, | |||
4436 | hw4, | |||
4437 | hw5, | |||
4438 | eic | |||
4439 | }; | |||
4440 | private: | |||
4441 | InterruptType interrupt; | |||
4442 | ||||
4443 | public: | |||
4444 | static MipsInterruptAttr *CreateImplicit(ASTContext &Ctx, InterruptType Interrupt, SourceRange Loc = SourceRange()) { | |||
4445 | auto *A = new (Ctx) MipsInterruptAttr(Loc, Ctx, Interrupt, 0); | |||
4446 | A->setImplicit(true); | |||
4447 | return A; | |||
4448 | } | |||
4449 | ||||
4450 | MipsInterruptAttr(SourceRange R, ASTContext &Ctx | |||
4451 | , InterruptType Interrupt | |||
4452 | , unsigned SI | |||
4453 | ) | |||
4454 | : InheritableAttr(attr::MipsInterrupt, R, SI, false, false) | |||
4455 | , interrupt(Interrupt) | |||
4456 | { | |||
4457 | } | |||
4458 | ||||
4459 | MipsInterruptAttr *clone(ASTContext &C) const; | |||
4460 | void printPretty(raw_ostream &OS, | |||
4461 | const PrintingPolicy &Policy) const; | |||
4462 | const char *getSpelling() const; | |||
4463 | InterruptType getInterrupt() const { | |||
4464 | return interrupt; | |||
4465 | } | |||
4466 | ||||
4467 | static bool ConvertStrToInterruptType(StringRef Val, InterruptType &Out) { | |||
4468 | Optional<InterruptType> R = llvm::StringSwitch<Optional<InterruptType>>(Val) | |||
4469 | .Case("vector=sw0", MipsInterruptAttr::sw0) | |||
4470 | .Case("vector=sw1", MipsInterruptAttr::sw1) | |||
4471 | .Case("vector=hw0", MipsInterruptAttr::hw0) | |||
4472 | .Case("vector=hw1", MipsInterruptAttr::hw1) | |||
4473 | .Case("vector=hw2", MipsInterruptAttr::hw2) | |||
4474 | .Case("vector=hw3", MipsInterruptAttr::hw3) | |||
4475 | .Case("vector=hw4", MipsInterruptAttr::hw4) | |||
4476 | .Case("vector=hw5", MipsInterruptAttr::hw5) | |||
4477 | .Case("eic", MipsInterruptAttr::eic) | |||
4478 | .Case("", MipsInterruptAttr::eic) | |||
4479 | .Default(Optional<InterruptType>()); | |||
4480 | if (R) { | |||
4481 | Out = *R; | |||
4482 | return true; | |||
4483 | } | |||
4484 | return false; | |||
4485 | } | |||
4486 | ||||
4487 | static const char *ConvertInterruptTypeToStr(InterruptType Val) { | |||
4488 | switch(Val) { | |||
4489 | case MipsInterruptAttr::sw0: return "vector=sw0"; | |||
4490 | case MipsInterruptAttr::sw1: return "vector=sw1"; | |||
4491 | case MipsInterruptAttr::hw0: return "vector=hw0"; | |||
4492 | case MipsInterruptAttr::hw1: return "vector=hw1"; | |||
4493 | case MipsInterruptAttr::hw2: return "vector=hw2"; | |||
4494 | case MipsInterruptAttr::hw3: return "vector=hw3"; | |||
4495 | case MipsInterruptAttr::hw4: return "vector=hw4"; | |||
4496 | case MipsInterruptAttr::hw5: return "vector=hw5"; | |||
4497 | case MipsInterruptAttr::eic: return "eic"; | |||
4498 | } | |||
4499 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 4499); | |||
4500 | } | |||
4501 | ||||
4502 | ||||
4503 | static bool classof(const Attr *A) { return A->getKind() == attr::MipsInterrupt; } | |||
4504 | }; | |||
4505 | ||||
4506 | class MipsLongCallAttr : public InheritableAttr { | |||
4507 | public: | |||
4508 | enum Spelling { | |||
4509 | GNU_long_call = 0, | |||
4510 | CXX11_gnu_long_call = 1, | |||
4511 | GNU_far = 2, | |||
4512 | CXX11_gnu_far = 3 | |||
4513 | }; | |||
4514 | ||||
4515 | static MipsLongCallAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
4516 | auto *A = new (Ctx) MipsLongCallAttr(Loc, Ctx, S); | |||
4517 | A->setImplicit(true); | |||
4518 | return A; | |||
4519 | } | |||
4520 | ||||
4521 | MipsLongCallAttr(SourceRange R, ASTContext &Ctx | |||
4522 | , unsigned SI | |||
4523 | ) | |||
4524 | : InheritableAttr(attr::MipsLongCall, R, SI, false, false) | |||
4525 | { | |||
4526 | } | |||
4527 | ||||
4528 | MipsLongCallAttr *clone(ASTContext &C) const; | |||
4529 | void printPretty(raw_ostream &OS, | |||
4530 | const PrintingPolicy &Policy) const; | |||
4531 | const char *getSpelling() const; | |||
4532 | Spelling getSemanticSpelling() const { | |||
4533 | switch (SpellingListIndex) { | |||
4534 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 4534); | |||
4535 | case 0: return GNU_long_call; | |||
4536 | case 1: return CXX11_gnu_long_call; | |||
4537 | case 2: return GNU_far; | |||
4538 | case 3: return CXX11_gnu_far; | |||
4539 | } | |||
4540 | } | |||
4541 | ||||
4542 | ||||
4543 | static bool classof(const Attr *A) { return A->getKind() == attr::MipsLongCall; } | |||
4544 | }; | |||
4545 | ||||
4546 | class MipsShortCallAttr : public InheritableAttr { | |||
4547 | public: | |||
4548 | enum Spelling { | |||
4549 | GNU_short_call = 0, | |||
4550 | CXX11_gnu_short_call = 1, | |||
4551 | GNU_near = 2, | |||
4552 | CXX11_gnu_near = 3 | |||
4553 | }; | |||
4554 | ||||
4555 | static MipsShortCallAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
4556 | auto *A = new (Ctx) MipsShortCallAttr(Loc, Ctx, S); | |||
4557 | A->setImplicit(true); | |||
4558 | return A; | |||
4559 | } | |||
4560 | ||||
4561 | MipsShortCallAttr(SourceRange R, ASTContext &Ctx | |||
4562 | , unsigned SI | |||
4563 | ) | |||
4564 | : InheritableAttr(attr::MipsShortCall, R, SI, false, false) | |||
4565 | { | |||
4566 | } | |||
4567 | ||||
4568 | MipsShortCallAttr *clone(ASTContext &C) const; | |||
4569 | void printPretty(raw_ostream &OS, | |||
4570 | const PrintingPolicy &Policy) const; | |||
4571 | const char *getSpelling() const; | |||
4572 | Spelling getSemanticSpelling() const { | |||
4573 | switch (SpellingListIndex) { | |||
4574 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 4574); | |||
4575 | case 0: return GNU_short_call; | |||
4576 | case 1: return CXX11_gnu_short_call; | |||
4577 | case 2: return GNU_near; | |||
4578 | case 3: return CXX11_gnu_near; | |||
4579 | } | |||
4580 | } | |||
4581 | ||||
4582 | ||||
4583 | static bool classof(const Attr *A) { return A->getKind() == attr::MipsShortCall; } | |||
4584 | }; | |||
4585 | ||||
4586 | class ModeAttr : public Attr { | |||
4587 | IdentifierInfo * mode; | |||
4588 | ||||
4589 | public: | |||
4590 | static ModeAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Mode, SourceRange Loc = SourceRange()) { | |||
4591 | auto *A = new (Ctx) ModeAttr(Loc, Ctx, Mode, 0); | |||
4592 | A->setImplicit(true); | |||
4593 | return A; | |||
4594 | } | |||
4595 | ||||
4596 | ModeAttr(SourceRange R, ASTContext &Ctx | |||
4597 | , IdentifierInfo * Mode | |||
4598 | , unsigned SI | |||
4599 | ) | |||
4600 | : Attr(attr::Mode, R, SI, false) | |||
4601 | , mode(Mode) | |||
4602 | { | |||
4603 | } | |||
4604 | ||||
4605 | ModeAttr *clone(ASTContext &C) const; | |||
4606 | void printPretty(raw_ostream &OS, | |||
4607 | const PrintingPolicy &Policy) const; | |||
4608 | const char *getSpelling() const; | |||
4609 | IdentifierInfo * getMode() const { | |||
4610 | return mode; | |||
4611 | } | |||
4612 | ||||
4613 | ||||
4614 | ||||
4615 | static bool classof(const Attr *A) { return A->getKind() == attr::Mode; } | |||
4616 | }; | |||
4617 | ||||
4618 | class NSConsumedAttr : public InheritableParamAttr { | |||
4619 | public: | |||
4620 | static NSConsumedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4621 | auto *A = new (Ctx) NSConsumedAttr(Loc, Ctx, 0); | |||
4622 | A->setImplicit(true); | |||
4623 | return A; | |||
4624 | } | |||
4625 | ||||
4626 | NSConsumedAttr(SourceRange R, ASTContext &Ctx | |||
4627 | , unsigned SI | |||
4628 | ) | |||
4629 | : InheritableParamAttr(attr::NSConsumed, R, SI, false, false) | |||
4630 | { | |||
4631 | } | |||
4632 | ||||
4633 | NSConsumedAttr *clone(ASTContext &C) const; | |||
4634 | void printPretty(raw_ostream &OS, | |||
4635 | const PrintingPolicy &Policy) const; | |||
4636 | const char *getSpelling() const; | |||
4637 | ||||
4638 | ||||
4639 | static bool classof(const Attr *A) { return A->getKind() == attr::NSConsumed; } | |||
4640 | }; | |||
4641 | ||||
4642 | class NSConsumesSelfAttr : public InheritableAttr { | |||
4643 | public: | |||
4644 | static NSConsumesSelfAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4645 | auto *A = new (Ctx) NSConsumesSelfAttr(Loc, Ctx, 0); | |||
4646 | A->setImplicit(true); | |||
4647 | return A; | |||
4648 | } | |||
4649 | ||||
4650 | NSConsumesSelfAttr(SourceRange R, ASTContext &Ctx | |||
4651 | , unsigned SI | |||
4652 | ) | |||
4653 | : InheritableAttr(attr::NSConsumesSelf, R, SI, false, false) | |||
4654 | { | |||
4655 | } | |||
4656 | ||||
4657 | NSConsumesSelfAttr *clone(ASTContext &C) const; | |||
4658 | void printPretty(raw_ostream &OS, | |||
4659 | const PrintingPolicy &Policy) const; | |||
4660 | const char *getSpelling() const; | |||
4661 | ||||
4662 | ||||
4663 | static bool classof(const Attr *A) { return A->getKind() == attr::NSConsumesSelf; } | |||
4664 | }; | |||
4665 | ||||
4666 | class NSReturnsAutoreleasedAttr : public InheritableAttr { | |||
4667 | public: | |||
4668 | static NSReturnsAutoreleasedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4669 | auto *A = new (Ctx) NSReturnsAutoreleasedAttr(Loc, Ctx, 0); | |||
4670 | A->setImplicit(true); | |||
4671 | return A; | |||
4672 | } | |||
4673 | ||||
4674 | NSReturnsAutoreleasedAttr(SourceRange R, ASTContext &Ctx | |||
4675 | , unsigned SI | |||
4676 | ) | |||
4677 | : InheritableAttr(attr::NSReturnsAutoreleased, R, SI, false, false) | |||
4678 | { | |||
4679 | } | |||
4680 | ||||
4681 | NSReturnsAutoreleasedAttr *clone(ASTContext &C) const; | |||
4682 | void printPretty(raw_ostream &OS, | |||
4683 | const PrintingPolicy &Policy) const; | |||
4684 | const char *getSpelling() const; | |||
4685 | ||||
4686 | ||||
4687 | static bool classof(const Attr *A) { return A->getKind() == attr::NSReturnsAutoreleased; } | |||
4688 | }; | |||
4689 | ||||
4690 | class NSReturnsNotRetainedAttr : public InheritableAttr { | |||
4691 | public: | |||
4692 | static NSReturnsNotRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4693 | auto *A = new (Ctx) NSReturnsNotRetainedAttr(Loc, Ctx, 0); | |||
4694 | A->setImplicit(true); | |||
4695 | return A; | |||
4696 | } | |||
4697 | ||||
4698 | NSReturnsNotRetainedAttr(SourceRange R, ASTContext &Ctx | |||
4699 | , unsigned SI | |||
4700 | ) | |||
4701 | : InheritableAttr(attr::NSReturnsNotRetained, R, SI, false, false) | |||
4702 | { | |||
4703 | } | |||
4704 | ||||
4705 | NSReturnsNotRetainedAttr *clone(ASTContext &C) const; | |||
4706 | void printPretty(raw_ostream &OS, | |||
4707 | const PrintingPolicy &Policy) const; | |||
4708 | const char *getSpelling() const; | |||
4709 | ||||
4710 | ||||
4711 | static bool classof(const Attr *A) { return A->getKind() == attr::NSReturnsNotRetained; } | |||
4712 | }; | |||
4713 | ||||
4714 | class NSReturnsRetainedAttr : public InheritableAttr { | |||
4715 | public: | |||
4716 | static NSReturnsRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4717 | auto *A = new (Ctx) NSReturnsRetainedAttr(Loc, Ctx, 0); | |||
4718 | A->setImplicit(true); | |||
4719 | return A; | |||
4720 | } | |||
4721 | ||||
4722 | NSReturnsRetainedAttr(SourceRange R, ASTContext &Ctx | |||
4723 | , unsigned SI | |||
4724 | ) | |||
4725 | : InheritableAttr(attr::NSReturnsRetained, R, SI, false, false) | |||
4726 | { | |||
4727 | } | |||
4728 | ||||
4729 | NSReturnsRetainedAttr *clone(ASTContext &C) const; | |||
4730 | void printPretty(raw_ostream &OS, | |||
4731 | const PrintingPolicy &Policy) const; | |||
4732 | const char *getSpelling() const; | |||
4733 | ||||
4734 | ||||
4735 | static bool classof(const Attr *A) { return A->getKind() == attr::NSReturnsRetained; } | |||
4736 | }; | |||
4737 | ||||
4738 | class NakedAttr : public InheritableAttr { | |||
4739 | public: | |||
4740 | static NakedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4741 | auto *A = new (Ctx) NakedAttr(Loc, Ctx, 0); | |||
4742 | A->setImplicit(true); | |||
4743 | return A; | |||
4744 | } | |||
4745 | ||||
4746 | NakedAttr(SourceRange R, ASTContext &Ctx | |||
4747 | , unsigned SI | |||
4748 | ) | |||
4749 | : InheritableAttr(attr::Naked, R, SI, false, false) | |||
4750 | { | |||
4751 | } | |||
4752 | ||||
4753 | NakedAttr *clone(ASTContext &C) const; | |||
4754 | void printPretty(raw_ostream &OS, | |||
4755 | const PrintingPolicy &Policy) const; | |||
4756 | const char *getSpelling() const; | |||
4757 | ||||
4758 | ||||
4759 | static bool classof(const Attr *A) { return A->getKind() == attr::Naked; } | |||
4760 | }; | |||
4761 | ||||
4762 | class NoAliasAttr : public InheritableAttr { | |||
4763 | public: | |||
4764 | static NoAliasAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4765 | auto *A = new (Ctx) NoAliasAttr(Loc, Ctx, 0); | |||
4766 | A->setImplicit(true); | |||
4767 | return A; | |||
4768 | } | |||
4769 | ||||
4770 | NoAliasAttr(SourceRange R, ASTContext &Ctx | |||
4771 | , unsigned SI | |||
4772 | ) | |||
4773 | : InheritableAttr(attr::NoAlias, R, SI, false, false) | |||
4774 | { | |||
4775 | } | |||
4776 | ||||
4777 | NoAliasAttr *clone(ASTContext &C) const; | |||
4778 | void printPretty(raw_ostream &OS, | |||
4779 | const PrintingPolicy &Policy) const; | |||
4780 | const char *getSpelling() const; | |||
4781 | ||||
4782 | ||||
4783 | static bool classof(const Attr *A) { return A->getKind() == attr::NoAlias; } | |||
4784 | }; | |||
4785 | ||||
4786 | class NoCommonAttr : public InheritableAttr { | |||
4787 | public: | |||
4788 | static NoCommonAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4789 | auto *A = new (Ctx) NoCommonAttr(Loc, Ctx, 0); | |||
4790 | A->setImplicit(true); | |||
4791 | return A; | |||
4792 | } | |||
4793 | ||||
4794 | NoCommonAttr(SourceRange R, ASTContext &Ctx | |||
4795 | , unsigned SI | |||
4796 | ) | |||
4797 | : InheritableAttr(attr::NoCommon, R, SI, false, false) | |||
4798 | { | |||
4799 | } | |||
4800 | ||||
4801 | NoCommonAttr *clone(ASTContext &C) const; | |||
4802 | void printPretty(raw_ostream &OS, | |||
4803 | const PrintingPolicy &Policy) const; | |||
4804 | const char *getSpelling() const; | |||
4805 | ||||
4806 | ||||
4807 | static bool classof(const Attr *A) { return A->getKind() == attr::NoCommon; } | |||
4808 | }; | |||
4809 | ||||
4810 | class NoDebugAttr : public InheritableAttr { | |||
4811 | public: | |||
4812 | static NoDebugAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4813 | auto *A = new (Ctx) NoDebugAttr(Loc, Ctx, 0); | |||
4814 | A->setImplicit(true); | |||
4815 | return A; | |||
4816 | } | |||
4817 | ||||
4818 | NoDebugAttr(SourceRange R, ASTContext &Ctx | |||
4819 | , unsigned SI | |||
4820 | ) | |||
4821 | : InheritableAttr(attr::NoDebug, R, SI, false, false) | |||
4822 | { | |||
4823 | } | |||
4824 | ||||
4825 | NoDebugAttr *clone(ASTContext &C) const; | |||
4826 | void printPretty(raw_ostream &OS, | |||
4827 | const PrintingPolicy &Policy) const; | |||
4828 | const char *getSpelling() const; | |||
4829 | ||||
4830 | ||||
4831 | static bool classof(const Attr *A) { return A->getKind() == attr::NoDebug; } | |||
4832 | }; | |||
4833 | ||||
4834 | class NoDuplicateAttr : public InheritableAttr { | |||
4835 | public: | |||
4836 | static NoDuplicateAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4837 | auto *A = new (Ctx) NoDuplicateAttr(Loc, Ctx, 0); | |||
4838 | A->setImplicit(true); | |||
4839 | return A; | |||
4840 | } | |||
4841 | ||||
4842 | NoDuplicateAttr(SourceRange R, ASTContext &Ctx | |||
4843 | , unsigned SI | |||
4844 | ) | |||
4845 | : InheritableAttr(attr::NoDuplicate, R, SI, false, false) | |||
4846 | { | |||
4847 | } | |||
4848 | ||||
4849 | NoDuplicateAttr *clone(ASTContext &C) const; | |||
4850 | void printPretty(raw_ostream &OS, | |||
4851 | const PrintingPolicy &Policy) const; | |||
4852 | const char *getSpelling() const; | |||
4853 | ||||
4854 | ||||
4855 | static bool classof(const Attr *A) { return A->getKind() == attr::NoDuplicate; } | |||
4856 | }; | |||
4857 | ||||
4858 | class NoEscapeAttr : public Attr { | |||
4859 | public: | |||
4860 | static NoEscapeAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4861 | auto *A = new (Ctx) NoEscapeAttr(Loc, Ctx, 0); | |||
4862 | A->setImplicit(true); | |||
4863 | return A; | |||
4864 | } | |||
4865 | ||||
4866 | NoEscapeAttr(SourceRange R, ASTContext &Ctx | |||
4867 | , unsigned SI | |||
4868 | ) | |||
4869 | : Attr(attr::NoEscape, R, SI, false) | |||
4870 | { | |||
4871 | } | |||
4872 | ||||
4873 | NoEscapeAttr *clone(ASTContext &C) const; | |||
4874 | void printPretty(raw_ostream &OS, | |||
4875 | const PrintingPolicy &Policy) const; | |||
4876 | const char *getSpelling() const; | |||
4877 | ||||
4878 | ||||
4879 | static bool classof(const Attr *A) { return A->getKind() == attr::NoEscape; } | |||
4880 | }; | |||
4881 | ||||
4882 | class NoInlineAttr : public InheritableAttr { | |||
4883 | public: | |||
4884 | static NoInlineAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4885 | auto *A = new (Ctx) NoInlineAttr(Loc, Ctx, 0); | |||
4886 | A->setImplicit(true); | |||
4887 | return A; | |||
4888 | } | |||
4889 | ||||
4890 | NoInlineAttr(SourceRange R, ASTContext &Ctx | |||
4891 | , unsigned SI | |||
4892 | ) | |||
4893 | : InheritableAttr(attr::NoInline, R, SI, false, false) | |||
4894 | { | |||
4895 | } | |||
4896 | ||||
4897 | NoInlineAttr *clone(ASTContext &C) const; | |||
4898 | void printPretty(raw_ostream &OS, | |||
4899 | const PrintingPolicy &Policy) const; | |||
4900 | const char *getSpelling() const; | |||
4901 | ||||
4902 | ||||
4903 | static bool classof(const Attr *A) { return A->getKind() == attr::NoInline; } | |||
4904 | }; | |||
4905 | ||||
4906 | class NoInstrumentFunctionAttr : public InheritableAttr { | |||
4907 | public: | |||
4908 | static NoInstrumentFunctionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4909 | auto *A = new (Ctx) NoInstrumentFunctionAttr(Loc, Ctx, 0); | |||
4910 | A->setImplicit(true); | |||
4911 | return A; | |||
4912 | } | |||
4913 | ||||
4914 | NoInstrumentFunctionAttr(SourceRange R, ASTContext &Ctx | |||
4915 | , unsigned SI | |||
4916 | ) | |||
4917 | : InheritableAttr(attr::NoInstrumentFunction, R, SI, false, false) | |||
4918 | { | |||
4919 | } | |||
4920 | ||||
4921 | NoInstrumentFunctionAttr *clone(ASTContext &C) const; | |||
4922 | void printPretty(raw_ostream &OS, | |||
4923 | const PrintingPolicy &Policy) const; | |||
4924 | const char *getSpelling() const; | |||
4925 | ||||
4926 | ||||
4927 | static bool classof(const Attr *A) { return A->getKind() == attr::NoInstrumentFunction; } | |||
4928 | }; | |||
4929 | ||||
4930 | class NoMicroMipsAttr : public InheritableAttr { | |||
4931 | public: | |||
4932 | static NoMicroMipsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4933 | auto *A = new (Ctx) NoMicroMipsAttr(Loc, Ctx, 0); | |||
4934 | A->setImplicit(true); | |||
4935 | return A; | |||
4936 | } | |||
4937 | ||||
4938 | NoMicroMipsAttr(SourceRange R, ASTContext &Ctx | |||
4939 | , unsigned SI | |||
4940 | ) | |||
4941 | : InheritableAttr(attr::NoMicroMips, R, SI, false, false) | |||
4942 | { | |||
4943 | } | |||
4944 | ||||
4945 | NoMicroMipsAttr *clone(ASTContext &C) const; | |||
4946 | void printPretty(raw_ostream &OS, | |||
4947 | const PrintingPolicy &Policy) const; | |||
4948 | const char *getSpelling() const; | |||
4949 | ||||
4950 | ||||
4951 | static bool classof(const Attr *A) { return A->getKind() == attr::NoMicroMips; } | |||
4952 | }; | |||
4953 | ||||
4954 | class NoMips16Attr : public InheritableAttr { | |||
4955 | public: | |||
4956 | static NoMips16Attr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4957 | auto *A = new (Ctx) NoMips16Attr(Loc, Ctx, 0); | |||
4958 | A->setImplicit(true); | |||
4959 | return A; | |||
4960 | } | |||
4961 | ||||
4962 | NoMips16Attr(SourceRange R, ASTContext &Ctx | |||
4963 | , unsigned SI | |||
4964 | ) | |||
4965 | : InheritableAttr(attr::NoMips16, R, SI, false, false) | |||
4966 | { | |||
4967 | } | |||
4968 | ||||
4969 | NoMips16Attr *clone(ASTContext &C) const; | |||
4970 | void printPretty(raw_ostream &OS, | |||
4971 | const PrintingPolicy &Policy) const; | |||
4972 | const char *getSpelling() const; | |||
4973 | ||||
4974 | ||||
4975 | static bool classof(const Attr *A) { return A->getKind() == attr::NoMips16; } | |||
4976 | }; | |||
4977 | ||||
4978 | class NoReturnAttr : public InheritableAttr { | |||
4979 | public: | |||
4980 | static NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
4981 | auto *A = new (Ctx) NoReturnAttr(Loc, Ctx, 0); | |||
4982 | A->setImplicit(true); | |||
4983 | return A; | |||
4984 | } | |||
4985 | ||||
4986 | NoReturnAttr(SourceRange R, ASTContext &Ctx | |||
4987 | , unsigned SI | |||
4988 | ) | |||
4989 | : InheritableAttr(attr::NoReturn, R, SI, false, false) | |||
4990 | { | |||
4991 | } | |||
4992 | ||||
4993 | NoReturnAttr *clone(ASTContext &C) const; | |||
4994 | void printPretty(raw_ostream &OS, | |||
4995 | const PrintingPolicy &Policy) const; | |||
4996 | const char *getSpelling() const; | |||
4997 | ||||
4998 | ||||
4999 | static bool classof(const Attr *A) { return A->getKind() == attr::NoReturn; } | |||
5000 | }; | |||
5001 | ||||
5002 | class NoSanitizeAttr : public InheritableAttr { | |||
5003 | unsigned sanitizers_Size; | |||
5004 | StringRef *sanitizers_; | |||
5005 | ||||
5006 | public: | |||
5007 | static NoSanitizeAttr *CreateImplicit(ASTContext &Ctx, StringRef *Sanitizers, unsigned SanitizersSize, SourceRange Loc = SourceRange()) { | |||
5008 | auto *A = new (Ctx) NoSanitizeAttr(Loc, Ctx, Sanitizers, SanitizersSize, 0); | |||
5009 | A->setImplicit(true); | |||
5010 | return A; | |||
5011 | } | |||
5012 | ||||
5013 | NoSanitizeAttr(SourceRange R, ASTContext &Ctx | |||
5014 | , StringRef *Sanitizers, unsigned SanitizersSize | |||
5015 | , unsigned SI | |||
5016 | ) | |||
5017 | : InheritableAttr(attr::NoSanitize, R, SI, false, false) | |||
5018 | , sanitizers_Size(SanitizersSize), sanitizers_(new (Ctx, 16) StringRef[sanitizers_Size]) | |||
5019 | { | |||
5020 | for (size_t I = 0, E = sanitizers_Size; I != E; | |||
5021 | ++I) { | |||
5022 | StringRef Ref = Sanitizers[I]; | |||
5023 | if (!Ref.empty()) { | |||
5024 | char *Mem = new (Ctx, 1) char[Ref.size()]; | |||
5025 | std::memcpy(Mem, Ref.data(), Ref.size()); | |||
5026 | sanitizers_[I] = StringRef(Mem, Ref.size()); | |||
5027 | } | |||
5028 | } | |||
5029 | } | |||
5030 | ||||
5031 | NoSanitizeAttr(SourceRange R, ASTContext &Ctx | |||
5032 | , unsigned SI | |||
5033 | ) | |||
5034 | : InheritableAttr(attr::NoSanitize, R, SI, false, false) | |||
5035 | , sanitizers_Size(0), sanitizers_(nullptr) | |||
5036 | { | |||
5037 | } | |||
5038 | ||||
5039 | NoSanitizeAttr *clone(ASTContext &C) const; | |||
5040 | void printPretty(raw_ostream &OS, | |||
5041 | const PrintingPolicy &Policy) const; | |||
5042 | const char *getSpelling() const; | |||
5043 | typedef StringRef* sanitizers_iterator; | |||
5044 | sanitizers_iterator sanitizers_begin() const { return sanitizers_; } | |||
5045 | sanitizers_iterator sanitizers_end() const { return sanitizers_ + sanitizers_Size; } | |||
5046 | unsigned sanitizers_size() const { return sanitizers_Size; } | |||
5047 | llvm::iterator_range<sanitizers_iterator> sanitizers() const { return llvm::make_range(sanitizers_begin(), sanitizers_end()); } | |||
5048 | ||||
5049 | ||||
5050 | ||||
5051 | SanitizerMask getMask() const { | |||
5052 | SanitizerMask Mask = 0; | |||
5053 | for (auto SanitizerName : sanitizers()) { | |||
5054 | SanitizerMask ParsedMask = | |||
5055 | parseSanitizerValue(SanitizerName, /*AllowGroups=*/true); | |||
5056 | Mask |= expandSanitizerGroups(ParsedMask); | |||
5057 | } | |||
5058 | return Mask; | |||
5059 | } | |||
5060 | ||||
5061 | ||||
5062 | static bool classof(const Attr *A) { return A->getKind() == attr::NoSanitize; } | |||
5063 | }; | |||
5064 | ||||
5065 | class NoSplitStackAttr : public InheritableAttr { | |||
5066 | public: | |||
5067 | static NoSplitStackAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5068 | auto *A = new (Ctx) NoSplitStackAttr(Loc, Ctx, 0); | |||
5069 | A->setImplicit(true); | |||
5070 | return A; | |||
5071 | } | |||
5072 | ||||
5073 | NoSplitStackAttr(SourceRange R, ASTContext &Ctx | |||
5074 | , unsigned SI | |||
5075 | ) | |||
5076 | : InheritableAttr(attr::NoSplitStack, R, SI, false, false) | |||
5077 | { | |||
5078 | } | |||
5079 | ||||
5080 | NoSplitStackAttr *clone(ASTContext &C) const; | |||
5081 | void printPretty(raw_ostream &OS, | |||
5082 | const PrintingPolicy &Policy) const; | |||
5083 | const char *getSpelling() const; | |||
5084 | ||||
5085 | ||||
5086 | static bool classof(const Attr *A) { return A->getKind() == attr::NoSplitStack; } | |||
5087 | }; | |||
5088 | ||||
5089 | class NoStackProtectorAttr : public InheritableAttr { | |||
5090 | public: | |||
5091 | static NoStackProtectorAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5092 | auto *A = new (Ctx) NoStackProtectorAttr(Loc, Ctx, 0); | |||
5093 | A->setImplicit(true); | |||
5094 | return A; | |||
5095 | } | |||
5096 | ||||
5097 | NoStackProtectorAttr(SourceRange R, ASTContext &Ctx | |||
5098 | , unsigned SI | |||
5099 | ) | |||
5100 | : InheritableAttr(attr::NoStackProtector, R, SI, false, false) | |||
5101 | { | |||
5102 | } | |||
5103 | ||||
5104 | NoStackProtectorAttr *clone(ASTContext &C) const; | |||
5105 | void printPretty(raw_ostream &OS, | |||
5106 | const PrintingPolicy &Policy) const; | |||
5107 | const char *getSpelling() const; | |||
5108 | ||||
5109 | ||||
5110 | static bool classof(const Attr *A) { return A->getKind() == attr::NoStackProtector; } | |||
5111 | }; | |||
5112 | ||||
5113 | class NoThreadSafetyAnalysisAttr : public InheritableAttr { | |||
5114 | public: | |||
5115 | static NoThreadSafetyAnalysisAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5116 | auto *A = new (Ctx) NoThreadSafetyAnalysisAttr(Loc, Ctx, 0); | |||
5117 | A->setImplicit(true); | |||
5118 | return A; | |||
5119 | } | |||
5120 | ||||
5121 | NoThreadSafetyAnalysisAttr(SourceRange R, ASTContext &Ctx | |||
5122 | , unsigned SI | |||
5123 | ) | |||
5124 | : InheritableAttr(attr::NoThreadSafetyAnalysis, R, SI, false, false) | |||
5125 | { | |||
5126 | } | |||
5127 | ||||
5128 | NoThreadSafetyAnalysisAttr *clone(ASTContext &C) const; | |||
5129 | void printPretty(raw_ostream &OS, | |||
5130 | const PrintingPolicy &Policy) const; | |||
5131 | const char *getSpelling() const; | |||
5132 | ||||
5133 | ||||
5134 | static bool classof(const Attr *A) { return A->getKind() == attr::NoThreadSafetyAnalysis; } | |||
5135 | }; | |||
5136 | ||||
5137 | class NoThrowAttr : public InheritableAttr { | |||
5138 | public: | |||
5139 | static NoThrowAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5140 | auto *A = new (Ctx) NoThrowAttr(Loc, Ctx, 0); | |||
5141 | A->setImplicit(true); | |||
5142 | return A; | |||
5143 | } | |||
5144 | ||||
5145 | NoThrowAttr(SourceRange R, ASTContext &Ctx | |||
5146 | , unsigned SI | |||
5147 | ) | |||
5148 | : InheritableAttr(attr::NoThrow, R, SI, false, false) | |||
5149 | { | |||
5150 | } | |||
5151 | ||||
5152 | NoThrowAttr *clone(ASTContext &C) const; | |||
5153 | void printPretty(raw_ostream &OS, | |||
5154 | const PrintingPolicy &Policy) const; | |||
5155 | const char *getSpelling() const; | |||
5156 | ||||
5157 | ||||
5158 | static bool classof(const Attr *A) { return A->getKind() == attr::NoThrow; } | |||
5159 | }; | |||
5160 | ||||
5161 | class NonNullAttr : public InheritableParamAttr { | |||
5162 | unsigned args_Size; | |||
5163 | ParamIdx *args_; | |||
5164 | ||||
5165 | public: | |||
5166 | static NonNullAttr *CreateImplicit(ASTContext &Ctx, ParamIdx *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
5167 | auto *A = new (Ctx) NonNullAttr(Loc, Ctx, Args, ArgsSize, 0); | |||
5168 | A->setImplicit(true); | |||
5169 | return A; | |||
5170 | } | |||
5171 | ||||
5172 | NonNullAttr(SourceRange R, ASTContext &Ctx | |||
5173 | , ParamIdx *Args, unsigned ArgsSize | |||
5174 | , unsigned SI | |||
5175 | ) | |||
5176 | : InheritableParamAttr(attr::NonNull, R, SI, false, true) | |||
5177 | , args_Size(ArgsSize), args_(new (Ctx, 16) ParamIdx[args_Size]) | |||
5178 | { | |||
5179 | std::copy(Args, Args + args_Size, args_); | |||
5180 | } | |||
5181 | ||||
5182 | NonNullAttr(SourceRange R, ASTContext &Ctx | |||
5183 | , unsigned SI | |||
5184 | ) | |||
5185 | : InheritableParamAttr(attr::NonNull, R, SI, false, true) | |||
5186 | , args_Size(0), args_(nullptr) | |||
5187 | { | |||
5188 | } | |||
5189 | ||||
5190 | NonNullAttr *clone(ASTContext &C) const; | |||
5191 | void printPretty(raw_ostream &OS, | |||
5192 | const PrintingPolicy &Policy) const; | |||
5193 | const char *getSpelling() const; | |||
5194 | typedef ParamIdx* args_iterator; | |||
5195 | args_iterator args_begin() const { return args_; } | |||
5196 | args_iterator args_end() const { return args_ + args_Size; } | |||
5197 | unsigned args_size() const { return args_Size; } | |||
5198 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
5199 | ||||
5200 | ||||
5201 | ||||
5202 | bool isNonNull(unsigned IdxAST) const { | |||
5203 | if (!args_size()) | |||
5204 | return true; | |||
5205 | return args_end() != std::find_if( | |||
5206 | args_begin(), args_end(), | |||
5207 | [=](const ParamIdx &Idx) { return Idx.getASTIndex() == IdxAST; }); | |||
5208 | } | |||
5209 | ||||
5210 | ||||
5211 | static bool classof(const Attr *A) { return A->getKind() == attr::NonNull; } | |||
5212 | }; | |||
5213 | ||||
5214 | class NotTailCalledAttr : public InheritableAttr { | |||
5215 | public: | |||
5216 | static NotTailCalledAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5217 | auto *A = new (Ctx) NotTailCalledAttr(Loc, Ctx, 0); | |||
5218 | A->setImplicit(true); | |||
5219 | return A; | |||
5220 | } | |||
5221 | ||||
5222 | NotTailCalledAttr(SourceRange R, ASTContext &Ctx | |||
5223 | , unsigned SI | |||
5224 | ) | |||
5225 | : InheritableAttr(attr::NotTailCalled, R, SI, false, false) | |||
5226 | { | |||
5227 | } | |||
5228 | ||||
5229 | NotTailCalledAttr *clone(ASTContext &C) const; | |||
5230 | void printPretty(raw_ostream &OS, | |||
5231 | const PrintingPolicy &Policy) const; | |||
5232 | const char *getSpelling() const; | |||
5233 | ||||
5234 | ||||
5235 | static bool classof(const Attr *A) { return A->getKind() == attr::NotTailCalled; } | |||
5236 | }; | |||
5237 | ||||
5238 | class OMPCaptureKindAttr : public Attr { | |||
5239 | unsigned captureKind; | |||
5240 | ||||
5241 | public: | |||
5242 | static OMPCaptureKindAttr *CreateImplicit(ASTContext &Ctx, unsigned CaptureKind, SourceRange Loc = SourceRange()) { | |||
5243 | auto *A = new (Ctx) OMPCaptureKindAttr(Loc, Ctx, CaptureKind, 0); | |||
5244 | A->setImplicit(true); | |||
5245 | return A; | |||
5246 | } | |||
5247 | ||||
5248 | OMPCaptureKindAttr(SourceRange R, ASTContext &Ctx | |||
5249 | , unsigned CaptureKind | |||
5250 | , unsigned SI | |||
5251 | ) | |||
5252 | : Attr(attr::OMPCaptureKind, R, SI, false) | |||
5253 | , captureKind(CaptureKind) | |||
5254 | { | |||
5255 | } | |||
5256 | ||||
5257 | OMPCaptureKindAttr *clone(ASTContext &C) const; | |||
5258 | void printPretty(raw_ostream &OS, | |||
5259 | const PrintingPolicy &Policy) const; | |||
5260 | const char *getSpelling() const; | |||
5261 | unsigned getCaptureKind() const { | |||
5262 | return captureKind; | |||
5263 | } | |||
5264 | ||||
5265 | ||||
5266 | ||||
5267 | static bool classof(const Attr *A) { return A->getKind() == attr::OMPCaptureKind; } | |||
5268 | }; | |||
5269 | ||||
5270 | class OMPCaptureNoInitAttr : public InheritableAttr { | |||
5271 | public: | |||
5272 | static OMPCaptureNoInitAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5273 | auto *A = new (Ctx) OMPCaptureNoInitAttr(Loc, Ctx, 0); | |||
5274 | A->setImplicit(true); | |||
5275 | return A; | |||
5276 | } | |||
5277 | ||||
5278 | OMPCaptureNoInitAttr(SourceRange R, ASTContext &Ctx | |||
5279 | , unsigned SI | |||
5280 | ) | |||
5281 | : InheritableAttr(attr::OMPCaptureNoInit, R, SI, false, false) | |||
5282 | { | |||
5283 | } | |||
5284 | ||||
5285 | OMPCaptureNoInitAttr *clone(ASTContext &C) const; | |||
5286 | void printPretty(raw_ostream &OS, | |||
5287 | const PrintingPolicy &Policy) const; | |||
5288 | const char *getSpelling() const; | |||
5289 | ||||
5290 | ||||
5291 | static bool classof(const Attr *A) { return A->getKind() == attr::OMPCaptureNoInit; } | |||
5292 | }; | |||
5293 | ||||
5294 | class OMPDeclareSimdDeclAttr : public Attr { | |||
5295 | public: | |||
5296 | enum BranchStateTy { | |||
5297 | BS_Undefined, | |||
5298 | BS_Inbranch, | |||
5299 | BS_Notinbranch | |||
5300 | }; | |||
5301 | private: | |||
5302 | BranchStateTy branchState; | |||
5303 | ||||
5304 | Expr * simdlen; | |||
5305 | ||||
5306 | unsigned uniforms_Size; | |||
5307 | Expr * *uniforms_; | |||
5308 | ||||
5309 | unsigned aligneds_Size; | |||
5310 | Expr * *aligneds_; | |||
5311 | ||||
5312 | unsigned alignments_Size; | |||
5313 | Expr * *alignments_; | |||
5314 | ||||
5315 | unsigned linears_Size; | |||
5316 | Expr * *linears_; | |||
5317 | ||||
5318 | unsigned modifiers_Size; | |||
5319 | unsigned *modifiers_; | |||
5320 | ||||
5321 | unsigned steps_Size; | |||
5322 | Expr * *steps_; | |||
5323 | ||||
5324 | public: | |||
5325 | 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()) { | |||
5326 | auto *A = new (Ctx) OMPDeclareSimdDeclAttr(Loc, Ctx, BranchState, Simdlen, Uniforms, UniformsSize, Aligneds, AlignedsSize, Alignments, AlignmentsSize, Linears, LinearsSize, Modifiers, ModifiersSize, Steps, StepsSize, 0); | |||
5327 | A->setImplicit(true); | |||
5328 | return A; | |||
5329 | } | |||
5330 | ||||
5331 | OMPDeclareSimdDeclAttr(SourceRange R, ASTContext &Ctx | |||
5332 | , BranchStateTy BranchState | |||
5333 | , Expr * Simdlen | |||
5334 | , Expr * *Uniforms, unsigned UniformsSize | |||
5335 | , Expr * *Aligneds, unsigned AlignedsSize | |||
5336 | , Expr * *Alignments, unsigned AlignmentsSize | |||
5337 | , Expr * *Linears, unsigned LinearsSize | |||
5338 | , unsigned *Modifiers, unsigned ModifiersSize | |||
5339 | , Expr * *Steps, unsigned StepsSize | |||
5340 | , unsigned SI | |||
5341 | ) | |||
5342 | : Attr(attr::OMPDeclareSimdDecl, R, SI, false) | |||
5343 | , branchState(BranchState) | |||
5344 | , simdlen(Simdlen) | |||
5345 | , uniforms_Size(UniformsSize), uniforms_(new (Ctx, 16) Expr *[uniforms_Size]) | |||
5346 | , aligneds_Size(AlignedsSize), aligneds_(new (Ctx, 16) Expr *[aligneds_Size]) | |||
5347 | , alignments_Size(AlignmentsSize), alignments_(new (Ctx, 16) Expr *[alignments_Size]) | |||
5348 | , linears_Size(LinearsSize), linears_(new (Ctx, 16) Expr *[linears_Size]) | |||
5349 | , modifiers_Size(ModifiersSize), modifiers_(new (Ctx, 16) unsigned[modifiers_Size]) | |||
5350 | , steps_Size(StepsSize), steps_(new (Ctx, 16) Expr *[steps_Size]) | |||
5351 | { | |||
5352 | std::copy(Uniforms, Uniforms + uniforms_Size, uniforms_); | |||
5353 | std::copy(Aligneds, Aligneds + aligneds_Size, aligneds_); | |||
5354 | std::copy(Alignments, Alignments + alignments_Size, alignments_); | |||
5355 | std::copy(Linears, Linears + linears_Size, linears_); | |||
5356 | std::copy(Modifiers, Modifiers + modifiers_Size, modifiers_); | |||
5357 | std::copy(Steps, Steps + steps_Size, steps_); | |||
5358 | } | |||
5359 | ||||
5360 | OMPDeclareSimdDeclAttr(SourceRange R, ASTContext &Ctx | |||
5361 | , BranchStateTy BranchState | |||
5362 | , Expr * Simdlen | |||
5363 | , unsigned SI | |||
5364 | ) | |||
5365 | : Attr(attr::OMPDeclareSimdDecl, R, SI, false) | |||
5366 | , branchState(BranchState) | |||
5367 | , simdlen(Simdlen) | |||
5368 | , uniforms_Size(0), uniforms_(nullptr) | |||
5369 | , aligneds_Size(0), aligneds_(nullptr) | |||
5370 | , alignments_Size(0), alignments_(nullptr) | |||
5371 | , linears_Size(0), linears_(nullptr) | |||
5372 | , modifiers_Size(0), modifiers_(nullptr) | |||
5373 | , steps_Size(0), steps_(nullptr) | |||
5374 | { | |||
5375 | } | |||
5376 | ||||
5377 | OMPDeclareSimdDeclAttr *clone(ASTContext &C) const; | |||
5378 | void printPretty(raw_ostream &OS, | |||
5379 | const PrintingPolicy &Policy) const; | |||
5380 | const char *getSpelling() const; | |||
5381 | BranchStateTy getBranchState() const { | |||
5382 | return branchState; | |||
5383 | } | |||
5384 | ||||
5385 | static bool ConvertStrToBranchStateTy(StringRef Val, BranchStateTy &Out) { | |||
5386 | Optional<BranchStateTy> R = llvm::StringSwitch<Optional<BranchStateTy>>(Val) | |||
5387 | .Case("", OMPDeclareSimdDeclAttr::BS_Undefined) | |||
5388 | .Case("inbranch", OMPDeclareSimdDeclAttr::BS_Inbranch) | |||
5389 | .Case("notinbranch", OMPDeclareSimdDeclAttr::BS_Notinbranch) | |||
5390 | .Default(Optional<BranchStateTy>()); | |||
5391 | if (R) { | |||
5392 | Out = *R; | |||
5393 | return true; | |||
5394 | } | |||
5395 | return false; | |||
5396 | } | |||
5397 | ||||
5398 | static const char *ConvertBranchStateTyToStr(BranchStateTy Val) { | |||
5399 | switch(Val) { | |||
5400 | case OMPDeclareSimdDeclAttr::BS_Undefined: return ""; | |||
5401 | case OMPDeclareSimdDeclAttr::BS_Inbranch: return "inbranch"; | |||
5402 | case OMPDeclareSimdDeclAttr::BS_Notinbranch: return "notinbranch"; | |||
5403 | } | |||
5404 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 5404); | |||
5405 | } | |||
5406 | Expr * getSimdlen() const { | |||
5407 | return simdlen; | |||
5408 | } | |||
5409 | ||||
5410 | typedef Expr ** uniforms_iterator; | |||
5411 | uniforms_iterator uniforms_begin() const { return uniforms_; } | |||
5412 | uniforms_iterator uniforms_end() const { return uniforms_ + uniforms_Size; } | |||
5413 | unsigned uniforms_size() const { return uniforms_Size; } | |||
5414 | llvm::iterator_range<uniforms_iterator> uniforms() const { return llvm::make_range(uniforms_begin(), uniforms_end()); } | |||
5415 | ||||
5416 | ||||
5417 | typedef Expr ** aligneds_iterator; | |||
5418 | aligneds_iterator aligneds_begin() const { return aligneds_; } | |||
5419 | aligneds_iterator aligneds_end() const { return aligneds_ + aligneds_Size; } | |||
5420 | unsigned aligneds_size() const { return aligneds_Size; } | |||
5421 | llvm::iterator_range<aligneds_iterator> aligneds() const { return llvm::make_range(aligneds_begin(), aligneds_end()); } | |||
5422 | ||||
5423 | ||||
5424 | typedef Expr ** alignments_iterator; | |||
5425 | alignments_iterator alignments_begin() const { return alignments_; } | |||
5426 | alignments_iterator alignments_end() const { return alignments_ + alignments_Size; } | |||
5427 | unsigned alignments_size() const { return alignments_Size; } | |||
5428 | llvm::iterator_range<alignments_iterator> alignments() const { return llvm::make_range(alignments_begin(), alignments_end()); } | |||
5429 | ||||
5430 | ||||
5431 | typedef Expr ** linears_iterator; | |||
5432 | linears_iterator linears_begin() const { return linears_; } | |||
5433 | linears_iterator linears_end() const { return linears_ + linears_Size; } | |||
5434 | unsigned linears_size() const { return linears_Size; } | |||
5435 | llvm::iterator_range<linears_iterator> linears() const { return llvm::make_range(linears_begin(), linears_end()); } | |||
5436 | ||||
5437 | ||||
5438 | typedef unsigned* modifiers_iterator; | |||
5439 | modifiers_iterator modifiers_begin() const { return modifiers_; } | |||
5440 | modifiers_iterator modifiers_end() const { return modifiers_ + modifiers_Size; } | |||
5441 | unsigned modifiers_size() const { return modifiers_Size; } | |||
5442 | llvm::iterator_range<modifiers_iterator> modifiers() const { return llvm::make_range(modifiers_begin(), modifiers_end()); } | |||
5443 | ||||
5444 | ||||
5445 | typedef Expr ** steps_iterator; | |||
5446 | steps_iterator steps_begin() const { return steps_; } | |||
5447 | steps_iterator steps_end() const { return steps_ + steps_Size; } | |||
5448 | unsigned steps_size() const { return steps_Size; } | |||
5449 | llvm::iterator_range<steps_iterator> steps() const { return llvm::make_range(steps_begin(), steps_end()); } | |||
5450 | ||||
5451 | ||||
5452 | ||||
5453 | void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy) | |||
5454 | const { | |||
5455 | if (getBranchState() != BS_Undefined) | |||
5456 | OS << ' ' << ConvertBranchStateTyToStr(getBranchState()); | |||
5457 | if (auto *E = getSimdlen()) { | |||
5458 | OS << " simdlen("; | |||
5459 | E->printPretty(OS, nullptr, Policy); | |||
5460 | OS << ")"; | |||
5461 | } | |||
5462 | if (uniforms_size() > 0) { | |||
5463 | OS << " uniform"; | |||
5464 | StringRef Sep = "("; | |||
5465 | for (auto *E : uniforms()) { | |||
5466 | OS << Sep; | |||
5467 | E->printPretty(OS, nullptr, Policy); | |||
5468 | Sep = ", "; | |||
5469 | } | |||
5470 | OS << ")"; | |||
5471 | } | |||
5472 | alignments_iterator NI = alignments_begin(); | |||
5473 | for (auto *E : aligneds()) { | |||
5474 | OS << " aligned("; | |||
5475 | E->printPretty(OS, nullptr, Policy); | |||
5476 | if (*NI) { | |||
5477 | OS << ": "; | |||
5478 | (*NI)->printPretty(OS, nullptr, Policy); | |||
5479 | } | |||
5480 | OS << ")"; | |||
5481 | ++NI; | |||
5482 | } | |||
5483 | steps_iterator I = steps_begin(); | |||
5484 | modifiers_iterator MI = modifiers_begin(); | |||
5485 | for (auto *E : linears()) { | |||
5486 | OS << " linear("; | |||
5487 | if (*MI != OMPC_LINEAR_unknown) | |||
5488 | OS << getOpenMPSimpleClauseTypeName(OMPC_linear, *MI) << "("; | |||
5489 | E->printPretty(OS, nullptr, Policy); | |||
5490 | if (*MI != OMPC_LINEAR_unknown) | |||
5491 | OS << ")"; | |||
5492 | if (*I) { | |||
5493 | OS << ": "; | |||
5494 | (*I)->printPretty(OS, nullptr, Policy); | |||
5495 | } | |||
5496 | OS << ")"; | |||
5497 | ++I; | |||
5498 | ++MI; | |||
5499 | } | |||
5500 | } | |||
5501 | ||||
5502 | ||||
5503 | static bool classof(const Attr *A) { return A->getKind() == attr::OMPDeclareSimdDecl; } | |||
5504 | }; | |||
5505 | ||||
5506 | class OMPDeclareTargetDeclAttr : public Attr { | |||
5507 | public: | |||
5508 | enum MapTypeTy { | |||
5509 | MT_To, | |||
5510 | MT_Link | |||
5511 | }; | |||
5512 | private: | |||
5513 | MapTypeTy mapType; | |||
5514 | ||||
5515 | public: | |||
5516 | static OMPDeclareTargetDeclAttr *CreateImplicit(ASTContext &Ctx, MapTypeTy MapType, SourceRange Loc = SourceRange()) { | |||
5517 | auto *A = new (Ctx) OMPDeclareTargetDeclAttr(Loc, Ctx, MapType, 0); | |||
5518 | A->setImplicit(true); | |||
5519 | return A; | |||
5520 | } | |||
5521 | ||||
5522 | OMPDeclareTargetDeclAttr(SourceRange R, ASTContext &Ctx | |||
5523 | , MapTypeTy MapType | |||
5524 | , unsigned SI | |||
5525 | ) | |||
5526 | : Attr(attr::OMPDeclareTargetDecl, R, SI, false) | |||
5527 | , mapType(MapType) | |||
5528 | { | |||
5529 | } | |||
5530 | ||||
5531 | OMPDeclareTargetDeclAttr *clone(ASTContext &C) const; | |||
5532 | void printPretty(raw_ostream &OS, | |||
5533 | const PrintingPolicy &Policy) const; | |||
5534 | const char *getSpelling() const; | |||
5535 | MapTypeTy getMapType() const { | |||
5536 | return mapType; | |||
5537 | } | |||
5538 | ||||
5539 | static bool ConvertStrToMapTypeTy(StringRef Val, MapTypeTy &Out) { | |||
5540 | Optional<MapTypeTy> R = llvm::StringSwitch<Optional<MapTypeTy>>(Val) | |||
5541 | .Case("to", OMPDeclareTargetDeclAttr::MT_To) | |||
5542 | .Case("link", OMPDeclareTargetDeclAttr::MT_Link) | |||
5543 | .Default(Optional<MapTypeTy>()); | |||
5544 | if (R) { | |||
5545 | Out = *R; | |||
5546 | return true; | |||
5547 | } | |||
5548 | return false; | |||
5549 | } | |||
5550 | ||||
5551 | static const char *ConvertMapTypeTyToStr(MapTypeTy Val) { | |||
5552 | switch(Val) { | |||
5553 | case OMPDeclareTargetDeclAttr::MT_To: return "to"; | |||
5554 | case OMPDeclareTargetDeclAttr::MT_Link: return "link"; | |||
5555 | } | |||
5556 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 5556); | |||
5557 | } | |||
5558 | ||||
5559 | void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const { | |||
5560 | // Use fake syntax because it is for testing and debugging purpose only. | |||
5561 | if (getMapType() != MT_To) | |||
5562 | OS << ' ' << ConvertMapTypeTyToStr(getMapType()); | |||
5563 | } | |||
5564 | ||||
5565 | ||||
5566 | static bool classof(const Attr *A) { return A->getKind() == attr::OMPDeclareTargetDecl; } | |||
5567 | }; | |||
5568 | ||||
5569 | class OMPReferencedVarAttr : public Attr { | |||
5570 | Expr * ref; | |||
5571 | ||||
5572 | public: | |||
5573 | static OMPReferencedVarAttr *CreateImplicit(ASTContext &Ctx, Expr * Ref, SourceRange Loc = SourceRange()) { | |||
5574 | auto *A = new (Ctx) OMPReferencedVarAttr(Loc, Ctx, Ref, 0); | |||
5575 | A->setImplicit(true); | |||
5576 | return A; | |||
5577 | } | |||
5578 | ||||
5579 | OMPReferencedVarAttr(SourceRange R, ASTContext &Ctx | |||
5580 | , Expr * Ref | |||
5581 | , unsigned SI | |||
5582 | ) | |||
5583 | : Attr(attr::OMPReferencedVar, R, SI, false) | |||
5584 | , ref(Ref) | |||
5585 | { | |||
5586 | } | |||
5587 | ||||
5588 | OMPReferencedVarAttr *clone(ASTContext &C) const; | |||
5589 | void printPretty(raw_ostream &OS, | |||
5590 | const PrintingPolicy &Policy) const; | |||
5591 | const char *getSpelling() const; | |||
5592 | Expr * getRef() const { | |||
5593 | return ref; | |||
5594 | } | |||
5595 | ||||
5596 | ||||
5597 | ||||
5598 | static bool classof(const Attr *A) { return A->getKind() == attr::OMPReferencedVar; } | |||
5599 | }; | |||
5600 | ||||
5601 | class OMPThreadPrivateDeclAttr : public InheritableAttr { | |||
5602 | public: | |||
5603 | static OMPThreadPrivateDeclAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5604 | auto *A = new (Ctx) OMPThreadPrivateDeclAttr(Loc, Ctx, 0); | |||
5605 | A->setImplicit(true); | |||
| ||||
5606 | return A; | |||
5607 | } | |||
5608 | ||||
5609 | OMPThreadPrivateDeclAttr(SourceRange R, ASTContext &Ctx | |||
5610 | , unsigned SI | |||
5611 | ) | |||
5612 | : InheritableAttr(attr::OMPThreadPrivateDecl, R, SI, false, false) | |||
5613 | { | |||
5614 | } | |||
5615 | ||||
5616 | OMPThreadPrivateDeclAttr *clone(ASTContext &C) const; | |||
5617 | void printPretty(raw_ostream &OS, | |||
5618 | const PrintingPolicy &Policy) const; | |||
5619 | const char *getSpelling() const; | |||
5620 | ||||
5621 | ||||
5622 | static bool classof(const Attr *A) { return A->getKind() == attr::OMPThreadPrivateDecl; } | |||
5623 | }; | |||
5624 | ||||
5625 | class ObjCBoxableAttr : public Attr { | |||
5626 | public: | |||
5627 | static ObjCBoxableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5628 | auto *A = new (Ctx) ObjCBoxableAttr(Loc, Ctx, 0); | |||
5629 | A->setImplicit(true); | |||
5630 | return A; | |||
5631 | } | |||
5632 | ||||
5633 | ObjCBoxableAttr(SourceRange R, ASTContext &Ctx | |||
5634 | , unsigned SI | |||
5635 | ) | |||
5636 | : Attr(attr::ObjCBoxable, R, SI, false) | |||
5637 | { | |||
5638 | } | |||
5639 | ||||
5640 | ObjCBoxableAttr *clone(ASTContext &C) const; | |||
5641 | void printPretty(raw_ostream &OS, | |||
5642 | const PrintingPolicy &Policy) const; | |||
5643 | const char *getSpelling() const; | |||
5644 | ||||
5645 | ||||
5646 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCBoxable; } | |||
5647 | }; | |||
5648 | ||||
5649 | class ObjCBridgeAttr : public InheritableAttr { | |||
5650 | IdentifierInfo * bridgedType; | |||
5651 | ||||
5652 | public: | |||
5653 | static ObjCBridgeAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * BridgedType, SourceRange Loc = SourceRange()) { | |||
5654 | auto *A = new (Ctx) ObjCBridgeAttr(Loc, Ctx, BridgedType, 0); | |||
5655 | A->setImplicit(true); | |||
5656 | return A; | |||
5657 | } | |||
5658 | ||||
5659 | ObjCBridgeAttr(SourceRange R, ASTContext &Ctx | |||
5660 | , IdentifierInfo * BridgedType | |||
5661 | , unsigned SI | |||
5662 | ) | |||
5663 | : InheritableAttr(attr::ObjCBridge, R, SI, false, false) | |||
5664 | , bridgedType(BridgedType) | |||
5665 | { | |||
5666 | } | |||
5667 | ||||
5668 | ObjCBridgeAttr *clone(ASTContext &C) const; | |||
5669 | void printPretty(raw_ostream &OS, | |||
5670 | const PrintingPolicy &Policy) const; | |||
5671 | const char *getSpelling() const; | |||
5672 | IdentifierInfo * getBridgedType() const { | |||
5673 | return bridgedType; | |||
5674 | } | |||
5675 | ||||
5676 | ||||
5677 | ||||
5678 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCBridge; } | |||
5679 | }; | |||
5680 | ||||
5681 | class ObjCBridgeMutableAttr : public InheritableAttr { | |||
5682 | IdentifierInfo * bridgedType; | |||
5683 | ||||
5684 | public: | |||
5685 | static ObjCBridgeMutableAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * BridgedType, SourceRange Loc = SourceRange()) { | |||
5686 | auto *A = new (Ctx) ObjCBridgeMutableAttr(Loc, Ctx, BridgedType, 0); | |||
5687 | A->setImplicit(true); | |||
5688 | return A; | |||
5689 | } | |||
5690 | ||||
5691 | ObjCBridgeMutableAttr(SourceRange R, ASTContext &Ctx | |||
5692 | , IdentifierInfo * BridgedType | |||
5693 | , unsigned SI | |||
5694 | ) | |||
5695 | : InheritableAttr(attr::ObjCBridgeMutable, R, SI, false, false) | |||
5696 | , bridgedType(BridgedType) | |||
5697 | { | |||
5698 | } | |||
5699 | ||||
5700 | ObjCBridgeMutableAttr *clone(ASTContext &C) const; | |||
5701 | void printPretty(raw_ostream &OS, | |||
5702 | const PrintingPolicy &Policy) const; | |||
5703 | const char *getSpelling() const; | |||
5704 | IdentifierInfo * getBridgedType() const { | |||
5705 | return bridgedType; | |||
5706 | } | |||
5707 | ||||
5708 | ||||
5709 | ||||
5710 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCBridgeMutable; } | |||
5711 | }; | |||
5712 | ||||
5713 | class ObjCBridgeRelatedAttr : public InheritableAttr { | |||
5714 | IdentifierInfo * relatedClass; | |||
5715 | ||||
5716 | IdentifierInfo * classMethod; | |||
5717 | ||||
5718 | IdentifierInfo * instanceMethod; | |||
5719 | ||||
5720 | public: | |||
5721 | static ObjCBridgeRelatedAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * RelatedClass, IdentifierInfo * ClassMethod, IdentifierInfo * InstanceMethod, SourceRange Loc = SourceRange()) { | |||
5722 | auto *A = new (Ctx) ObjCBridgeRelatedAttr(Loc, Ctx, RelatedClass, ClassMethod, InstanceMethod, 0); | |||
5723 | A->setImplicit(true); | |||
5724 | return A; | |||
5725 | } | |||
5726 | ||||
5727 | ObjCBridgeRelatedAttr(SourceRange R, ASTContext &Ctx | |||
5728 | , IdentifierInfo * RelatedClass | |||
5729 | , IdentifierInfo * ClassMethod | |||
5730 | , IdentifierInfo * InstanceMethod | |||
5731 | , unsigned SI | |||
5732 | ) | |||
5733 | : InheritableAttr(attr::ObjCBridgeRelated, R, SI, false, false) | |||
5734 | , relatedClass(RelatedClass) | |||
5735 | , classMethod(ClassMethod) | |||
5736 | , instanceMethod(InstanceMethod) | |||
5737 | { | |||
5738 | } | |||
5739 | ||||
5740 | ObjCBridgeRelatedAttr *clone(ASTContext &C) const; | |||
5741 | void printPretty(raw_ostream &OS, | |||
5742 | const PrintingPolicy &Policy) const; | |||
5743 | const char *getSpelling() const; | |||
5744 | IdentifierInfo * getRelatedClass() const { | |||
5745 | return relatedClass; | |||
5746 | } | |||
5747 | ||||
5748 | IdentifierInfo * getClassMethod() const { | |||
5749 | return classMethod; | |||
5750 | } | |||
5751 | ||||
5752 | IdentifierInfo * getInstanceMethod() const { | |||
5753 | return instanceMethod; | |||
5754 | } | |||
5755 | ||||
5756 | ||||
5757 | ||||
5758 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCBridgeRelated; } | |||
5759 | }; | |||
5760 | ||||
5761 | class ObjCDesignatedInitializerAttr : public Attr { | |||
5762 | public: | |||
5763 | static ObjCDesignatedInitializerAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5764 | auto *A = new (Ctx) ObjCDesignatedInitializerAttr(Loc, Ctx, 0); | |||
5765 | A->setImplicit(true); | |||
5766 | return A; | |||
5767 | } | |||
5768 | ||||
5769 | ObjCDesignatedInitializerAttr(SourceRange R, ASTContext &Ctx | |||
5770 | , unsigned SI | |||
5771 | ) | |||
5772 | : Attr(attr::ObjCDesignatedInitializer, R, SI, false) | |||
5773 | { | |||
5774 | } | |||
5775 | ||||
5776 | ObjCDesignatedInitializerAttr *clone(ASTContext &C) const; | |||
5777 | void printPretty(raw_ostream &OS, | |||
5778 | const PrintingPolicy &Policy) const; | |||
5779 | const char *getSpelling() const; | |||
5780 | ||||
5781 | ||||
5782 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCDesignatedInitializer; } | |||
5783 | }; | |||
5784 | ||||
5785 | class ObjCExceptionAttr : public InheritableAttr { | |||
5786 | public: | |||
5787 | static ObjCExceptionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5788 | auto *A = new (Ctx) ObjCExceptionAttr(Loc, Ctx, 0); | |||
5789 | A->setImplicit(true); | |||
5790 | return A; | |||
5791 | } | |||
5792 | ||||
5793 | ObjCExceptionAttr(SourceRange R, ASTContext &Ctx | |||
5794 | , unsigned SI | |||
5795 | ) | |||
5796 | : InheritableAttr(attr::ObjCException, R, SI, false, false) | |||
5797 | { | |||
5798 | } | |||
5799 | ||||
5800 | ObjCExceptionAttr *clone(ASTContext &C) const; | |||
5801 | void printPretty(raw_ostream &OS, | |||
5802 | const PrintingPolicy &Policy) const; | |||
5803 | const char *getSpelling() const; | |||
5804 | ||||
5805 | ||||
5806 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCException; } | |||
5807 | }; | |||
5808 | ||||
5809 | class ObjCExplicitProtocolImplAttr : public InheritableAttr { | |||
5810 | public: | |||
5811 | static ObjCExplicitProtocolImplAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5812 | auto *A = new (Ctx) ObjCExplicitProtocolImplAttr(Loc, Ctx, 0); | |||
5813 | A->setImplicit(true); | |||
5814 | return A; | |||
5815 | } | |||
5816 | ||||
5817 | ObjCExplicitProtocolImplAttr(SourceRange R, ASTContext &Ctx | |||
5818 | , unsigned SI | |||
5819 | ) | |||
5820 | : InheritableAttr(attr::ObjCExplicitProtocolImpl, R, SI, false, false) | |||
5821 | { | |||
5822 | } | |||
5823 | ||||
5824 | ObjCExplicitProtocolImplAttr *clone(ASTContext &C) const; | |||
5825 | void printPretty(raw_ostream &OS, | |||
5826 | const PrintingPolicy &Policy) const; | |||
5827 | const char *getSpelling() const; | |||
5828 | ||||
5829 | ||||
5830 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCExplicitProtocolImpl; } | |||
5831 | }; | |||
5832 | ||||
5833 | class ObjCIndependentClassAttr : public InheritableAttr { | |||
5834 | public: | |||
5835 | static ObjCIndependentClassAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5836 | auto *A = new (Ctx) ObjCIndependentClassAttr(Loc, Ctx, 0); | |||
5837 | A->setImplicit(true); | |||
5838 | return A; | |||
5839 | } | |||
5840 | ||||
5841 | ObjCIndependentClassAttr(SourceRange R, ASTContext &Ctx | |||
5842 | , unsigned SI | |||
5843 | ) | |||
5844 | : InheritableAttr(attr::ObjCIndependentClass, R, SI, false, false) | |||
5845 | { | |||
5846 | } | |||
5847 | ||||
5848 | ObjCIndependentClassAttr *clone(ASTContext &C) const; | |||
5849 | void printPretty(raw_ostream &OS, | |||
5850 | const PrintingPolicy &Policy) const; | |||
5851 | const char *getSpelling() const; | |||
5852 | ||||
5853 | ||||
5854 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCIndependentClass; } | |||
5855 | }; | |||
5856 | ||||
5857 | class ObjCMethodFamilyAttr : public InheritableAttr { | |||
5858 | public: | |||
5859 | enum FamilyKind { | |||
5860 | OMF_None, | |||
5861 | OMF_alloc, | |||
5862 | OMF_copy, | |||
5863 | OMF_init, | |||
5864 | OMF_mutableCopy, | |||
5865 | OMF_new | |||
5866 | }; | |||
5867 | private: | |||
5868 | FamilyKind family; | |||
5869 | ||||
5870 | public: | |||
5871 | static ObjCMethodFamilyAttr *CreateImplicit(ASTContext &Ctx, FamilyKind Family, SourceRange Loc = SourceRange()) { | |||
5872 | auto *A = new (Ctx) ObjCMethodFamilyAttr(Loc, Ctx, Family, 0); | |||
5873 | A->setImplicit(true); | |||
5874 | return A; | |||
5875 | } | |||
5876 | ||||
5877 | ObjCMethodFamilyAttr(SourceRange R, ASTContext &Ctx | |||
5878 | , FamilyKind Family | |||
5879 | , unsigned SI | |||
5880 | ) | |||
5881 | : InheritableAttr(attr::ObjCMethodFamily, R, SI, false, false) | |||
5882 | , family(Family) | |||
5883 | { | |||
5884 | } | |||
5885 | ||||
5886 | ObjCMethodFamilyAttr *clone(ASTContext &C) const; | |||
5887 | void printPretty(raw_ostream &OS, | |||
5888 | const PrintingPolicy &Policy) const; | |||
5889 | const char *getSpelling() const; | |||
5890 | FamilyKind getFamily() const { | |||
5891 | return family; | |||
5892 | } | |||
5893 | ||||
5894 | static bool ConvertStrToFamilyKind(StringRef Val, FamilyKind &Out) { | |||
5895 | Optional<FamilyKind> R = llvm::StringSwitch<Optional<FamilyKind>>(Val) | |||
5896 | .Case("none", ObjCMethodFamilyAttr::OMF_None) | |||
5897 | .Case("alloc", ObjCMethodFamilyAttr::OMF_alloc) | |||
5898 | .Case("copy", ObjCMethodFamilyAttr::OMF_copy) | |||
5899 | .Case("init", ObjCMethodFamilyAttr::OMF_init) | |||
5900 | .Case("mutableCopy", ObjCMethodFamilyAttr::OMF_mutableCopy) | |||
5901 | .Case("new", ObjCMethodFamilyAttr::OMF_new) | |||
5902 | .Default(Optional<FamilyKind>()); | |||
5903 | if (R) { | |||
5904 | Out = *R; | |||
5905 | return true; | |||
5906 | } | |||
5907 | return false; | |||
5908 | } | |||
5909 | ||||
5910 | static const char *ConvertFamilyKindToStr(FamilyKind Val) { | |||
5911 | switch(Val) { | |||
5912 | case ObjCMethodFamilyAttr::OMF_None: return "none"; | |||
5913 | case ObjCMethodFamilyAttr::OMF_alloc: return "alloc"; | |||
5914 | case ObjCMethodFamilyAttr::OMF_copy: return "copy"; | |||
5915 | case ObjCMethodFamilyAttr::OMF_init: return "init"; | |||
5916 | case ObjCMethodFamilyAttr::OMF_mutableCopy: return "mutableCopy"; | |||
5917 | case ObjCMethodFamilyAttr::OMF_new: return "new"; | |||
5918 | } | |||
5919 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 5919); | |||
5920 | } | |||
5921 | ||||
5922 | ||||
5923 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCMethodFamily; } | |||
5924 | }; | |||
5925 | ||||
5926 | class ObjCNSObjectAttr : public InheritableAttr { | |||
5927 | public: | |||
5928 | static ObjCNSObjectAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5929 | auto *A = new (Ctx) ObjCNSObjectAttr(Loc, Ctx, 0); | |||
5930 | A->setImplicit(true); | |||
5931 | return A; | |||
5932 | } | |||
5933 | ||||
5934 | ObjCNSObjectAttr(SourceRange R, ASTContext &Ctx | |||
5935 | , unsigned SI | |||
5936 | ) | |||
5937 | : InheritableAttr(attr::ObjCNSObject, R, SI, false, false) | |||
5938 | { | |||
5939 | } | |||
5940 | ||||
5941 | ObjCNSObjectAttr *clone(ASTContext &C) const; | |||
5942 | void printPretty(raw_ostream &OS, | |||
5943 | const PrintingPolicy &Policy) const; | |||
5944 | const char *getSpelling() const; | |||
5945 | ||||
5946 | ||||
5947 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCNSObject; } | |||
5948 | }; | |||
5949 | ||||
5950 | class ObjCPreciseLifetimeAttr : public InheritableAttr { | |||
5951 | public: | |||
5952 | static ObjCPreciseLifetimeAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5953 | auto *A = new (Ctx) ObjCPreciseLifetimeAttr(Loc, Ctx, 0); | |||
5954 | A->setImplicit(true); | |||
5955 | return A; | |||
5956 | } | |||
5957 | ||||
5958 | ObjCPreciseLifetimeAttr(SourceRange R, ASTContext &Ctx | |||
5959 | , unsigned SI | |||
5960 | ) | |||
5961 | : InheritableAttr(attr::ObjCPreciseLifetime, R, SI, false, false) | |||
5962 | { | |||
5963 | } | |||
5964 | ||||
5965 | ObjCPreciseLifetimeAttr *clone(ASTContext &C) const; | |||
5966 | void printPretty(raw_ostream &OS, | |||
5967 | const PrintingPolicy &Policy) const; | |||
5968 | const char *getSpelling() const; | |||
5969 | ||||
5970 | ||||
5971 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCPreciseLifetime; } | |||
5972 | }; | |||
5973 | ||||
5974 | class ObjCRequiresPropertyDefsAttr : public InheritableAttr { | |||
5975 | public: | |||
5976 | static ObjCRequiresPropertyDefsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
5977 | auto *A = new (Ctx) ObjCRequiresPropertyDefsAttr(Loc, Ctx, 0); | |||
5978 | A->setImplicit(true); | |||
5979 | return A; | |||
5980 | } | |||
5981 | ||||
5982 | ObjCRequiresPropertyDefsAttr(SourceRange R, ASTContext &Ctx | |||
5983 | , unsigned SI | |||
5984 | ) | |||
5985 | : InheritableAttr(attr::ObjCRequiresPropertyDefs, R, SI, false, false) | |||
5986 | { | |||
5987 | } | |||
5988 | ||||
5989 | ObjCRequiresPropertyDefsAttr *clone(ASTContext &C) const; | |||
5990 | void printPretty(raw_ostream &OS, | |||
5991 | const PrintingPolicy &Policy) const; | |||
5992 | const char *getSpelling() const; | |||
5993 | ||||
5994 | ||||
5995 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRequiresPropertyDefs; } | |||
5996 | }; | |||
5997 | ||||
5998 | class ObjCRequiresSuperAttr : public InheritableAttr { | |||
5999 | public: | |||
6000 | static ObjCRequiresSuperAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6001 | auto *A = new (Ctx) ObjCRequiresSuperAttr(Loc, Ctx, 0); | |||
6002 | A->setImplicit(true); | |||
6003 | return A; | |||
6004 | } | |||
6005 | ||||
6006 | ObjCRequiresSuperAttr(SourceRange R, ASTContext &Ctx | |||
6007 | , unsigned SI | |||
6008 | ) | |||
6009 | : InheritableAttr(attr::ObjCRequiresSuper, R, SI, false, false) | |||
6010 | { | |||
6011 | } | |||
6012 | ||||
6013 | ObjCRequiresSuperAttr *clone(ASTContext &C) const; | |||
6014 | void printPretty(raw_ostream &OS, | |||
6015 | const PrintingPolicy &Policy) const; | |||
6016 | const char *getSpelling() const; | |||
6017 | ||||
6018 | ||||
6019 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRequiresSuper; } | |||
6020 | }; | |||
6021 | ||||
6022 | class ObjCReturnsInnerPointerAttr : public InheritableAttr { | |||
6023 | public: | |||
6024 | static ObjCReturnsInnerPointerAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6025 | auto *A = new (Ctx) ObjCReturnsInnerPointerAttr(Loc, Ctx, 0); | |||
6026 | A->setImplicit(true); | |||
6027 | return A; | |||
6028 | } | |||
6029 | ||||
6030 | ObjCReturnsInnerPointerAttr(SourceRange R, ASTContext &Ctx | |||
6031 | , unsigned SI | |||
6032 | ) | |||
6033 | : InheritableAttr(attr::ObjCReturnsInnerPointer, R, SI, false, false) | |||
6034 | { | |||
6035 | } | |||
6036 | ||||
6037 | ObjCReturnsInnerPointerAttr *clone(ASTContext &C) const; | |||
6038 | void printPretty(raw_ostream &OS, | |||
6039 | const PrintingPolicy &Policy) const; | |||
6040 | const char *getSpelling() const; | |||
6041 | ||||
6042 | ||||
6043 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCReturnsInnerPointer; } | |||
6044 | }; | |||
6045 | ||||
6046 | class ObjCRootClassAttr : public InheritableAttr { | |||
6047 | public: | |||
6048 | static ObjCRootClassAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6049 | auto *A = new (Ctx) ObjCRootClassAttr(Loc, Ctx, 0); | |||
6050 | A->setImplicit(true); | |||
6051 | return A; | |||
6052 | } | |||
6053 | ||||
6054 | ObjCRootClassAttr(SourceRange R, ASTContext &Ctx | |||
6055 | , unsigned SI | |||
6056 | ) | |||
6057 | : InheritableAttr(attr::ObjCRootClass, R, SI, false, false) | |||
6058 | { | |||
6059 | } | |||
6060 | ||||
6061 | ObjCRootClassAttr *clone(ASTContext &C) const; | |||
6062 | void printPretty(raw_ostream &OS, | |||
6063 | const PrintingPolicy &Policy) const; | |||
6064 | const char *getSpelling() const; | |||
6065 | ||||
6066 | ||||
6067 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRootClass; } | |||
6068 | }; | |||
6069 | ||||
6070 | class ObjCRuntimeNameAttr : public Attr { | |||
6071 | unsigned metadataNameLength; | |||
6072 | char *metadataName; | |||
6073 | ||||
6074 | public: | |||
6075 | static ObjCRuntimeNameAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef MetadataName, SourceRange Loc = SourceRange()) { | |||
6076 | auto *A = new (Ctx) ObjCRuntimeNameAttr(Loc, Ctx, MetadataName, 0); | |||
6077 | A->setImplicit(true); | |||
6078 | return A; | |||
6079 | } | |||
6080 | ||||
6081 | ObjCRuntimeNameAttr(SourceRange R, ASTContext &Ctx | |||
6082 | , llvm::StringRef MetadataName | |||
6083 | , unsigned SI | |||
6084 | ) | |||
6085 | : Attr(attr::ObjCRuntimeName, R, SI, false) | |||
6086 | , metadataNameLength(MetadataName.size()),metadataName(new (Ctx, 1) char[metadataNameLength]) | |||
6087 | { | |||
6088 | if (!MetadataName.empty()) | |||
6089 | std::memcpy(metadataName, MetadataName.data(), metadataNameLength); | |||
6090 | } | |||
6091 | ||||
6092 | ObjCRuntimeNameAttr *clone(ASTContext &C) const; | |||
6093 | void printPretty(raw_ostream &OS, | |||
6094 | const PrintingPolicy &Policy) const; | |||
6095 | const char *getSpelling() const; | |||
6096 | llvm::StringRef getMetadataName() const { | |||
6097 | return llvm::StringRef(metadataName, metadataNameLength); | |||
6098 | } | |||
6099 | unsigned getMetadataNameLength() const { | |||
6100 | return metadataNameLength; | |||
6101 | } | |||
6102 | void setMetadataName(ASTContext &C, llvm::StringRef S) { | |||
6103 | metadataNameLength = S.size(); | |||
6104 | this->metadataName = new (C, 1) char [metadataNameLength]; | |||
6105 | if (!S.empty()) | |||
6106 | std::memcpy(this->metadataName, S.data(), metadataNameLength); | |||
6107 | } | |||
6108 | ||||
6109 | ||||
6110 | ||||
6111 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRuntimeName; } | |||
6112 | }; | |||
6113 | ||||
6114 | class ObjCRuntimeVisibleAttr : public Attr { | |||
6115 | public: | |||
6116 | static ObjCRuntimeVisibleAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6117 | auto *A = new (Ctx) ObjCRuntimeVisibleAttr(Loc, Ctx, 0); | |||
6118 | A->setImplicit(true); | |||
6119 | return A; | |||
6120 | } | |||
6121 | ||||
6122 | ObjCRuntimeVisibleAttr(SourceRange R, ASTContext &Ctx | |||
6123 | , unsigned SI | |||
6124 | ) | |||
6125 | : Attr(attr::ObjCRuntimeVisible, R, SI, false) | |||
6126 | { | |||
6127 | } | |||
6128 | ||||
6129 | ObjCRuntimeVisibleAttr *clone(ASTContext &C) const; | |||
6130 | void printPretty(raw_ostream &OS, | |||
6131 | const PrintingPolicy &Policy) const; | |||
6132 | const char *getSpelling() const; | |||
6133 | ||||
6134 | ||||
6135 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCRuntimeVisible; } | |||
6136 | }; | |||
6137 | ||||
6138 | class ObjCSubclassingRestrictedAttr : public InheritableAttr { | |||
6139 | public: | |||
6140 | static ObjCSubclassingRestrictedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6141 | auto *A = new (Ctx) ObjCSubclassingRestrictedAttr(Loc, Ctx, 0); | |||
6142 | A->setImplicit(true); | |||
6143 | return A; | |||
6144 | } | |||
6145 | ||||
6146 | ObjCSubclassingRestrictedAttr(SourceRange R, ASTContext &Ctx | |||
6147 | , unsigned SI | |||
6148 | ) | |||
6149 | : InheritableAttr(attr::ObjCSubclassingRestricted, R, SI, false, false) | |||
6150 | { | |||
6151 | } | |||
6152 | ||||
6153 | ObjCSubclassingRestrictedAttr *clone(ASTContext &C) const; | |||
6154 | void printPretty(raw_ostream &OS, | |||
6155 | const PrintingPolicy &Policy) const; | |||
6156 | const char *getSpelling() const; | |||
6157 | ||||
6158 | ||||
6159 | static bool classof(const Attr *A) { return A->getKind() == attr::ObjCSubclassingRestricted; } | |||
6160 | }; | |||
6161 | ||||
6162 | class OpenCLAccessAttr : public Attr { | |||
6163 | public: | |||
6164 | enum Spelling { | |||
6165 | Keyword_read_only = 0, | |||
6166 | Keyword_write_only = 2, | |||
6167 | Keyword_read_write = 4 | |||
6168 | }; | |||
6169 | ||||
6170 | static OpenCLAccessAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
6171 | auto *A = new (Ctx) OpenCLAccessAttr(Loc, Ctx, S); | |||
6172 | A->setImplicit(true); | |||
6173 | return A; | |||
6174 | } | |||
6175 | ||||
6176 | OpenCLAccessAttr(SourceRange R, ASTContext &Ctx | |||
6177 | , unsigned SI | |||
6178 | ) | |||
6179 | : Attr(attr::OpenCLAccess, R, SI, false) | |||
6180 | { | |||
6181 | } | |||
6182 | ||||
6183 | OpenCLAccessAttr *clone(ASTContext &C) const; | |||
6184 | void printPretty(raw_ostream &OS, | |||
6185 | const PrintingPolicy &Policy) const; | |||
6186 | const char *getSpelling() const; | |||
6187 | Spelling getSemanticSpelling() const { | |||
6188 | switch (SpellingListIndex) { | |||
6189 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 6189); | |||
6190 | case 0: return Keyword_read_only; | |||
6191 | case 1: return Keyword_read_only; | |||
6192 | case 2: return Keyword_write_only; | |||
6193 | case 3: return Keyword_write_only; | |||
6194 | case 4: return Keyword_read_write; | |||
6195 | case 5: return Keyword_read_write; | |||
6196 | } | |||
6197 | } | |||
6198 | bool isReadOnly() const { return SpellingListIndex == 0 || | |||
6199 | SpellingListIndex == 1; } | |||
6200 | bool isReadWrite() const { return SpellingListIndex == 4 || | |||
6201 | SpellingListIndex == 5; } | |||
6202 | bool isWriteOnly() const { return SpellingListIndex == 2 || | |||
6203 | SpellingListIndex == 3; } | |||
6204 | ||||
6205 | ||||
6206 | static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLAccess; } | |||
6207 | }; | |||
6208 | ||||
6209 | class OpenCLIntelReqdSubGroupSizeAttr : public InheritableAttr { | |||
6210 | unsigned subGroupSize; | |||
6211 | ||||
6212 | public: | |||
6213 | static OpenCLIntelReqdSubGroupSizeAttr *CreateImplicit(ASTContext &Ctx, unsigned SubGroupSize, SourceRange Loc = SourceRange()) { | |||
6214 | auto *A = new (Ctx) OpenCLIntelReqdSubGroupSizeAttr(Loc, Ctx, SubGroupSize, 0); | |||
6215 | A->setImplicit(true); | |||
6216 | return A; | |||
6217 | } | |||
6218 | ||||
6219 | OpenCLIntelReqdSubGroupSizeAttr(SourceRange R, ASTContext &Ctx | |||
6220 | , unsigned SubGroupSize | |||
6221 | , unsigned SI | |||
6222 | ) | |||
6223 | : InheritableAttr(attr::OpenCLIntelReqdSubGroupSize, R, SI, false, false) | |||
6224 | , subGroupSize(SubGroupSize) | |||
6225 | { | |||
6226 | } | |||
6227 | ||||
6228 | OpenCLIntelReqdSubGroupSizeAttr *clone(ASTContext &C) const; | |||
6229 | void printPretty(raw_ostream &OS, | |||
6230 | const PrintingPolicy &Policy) const; | |||
6231 | const char *getSpelling() const; | |||
6232 | unsigned getSubGroupSize() const { | |||
6233 | return subGroupSize; | |||
6234 | } | |||
6235 | ||||
6236 | ||||
6237 | ||||
6238 | static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLIntelReqdSubGroupSize; } | |||
6239 | }; | |||
6240 | ||||
6241 | class OpenCLKernelAttr : public InheritableAttr { | |||
6242 | public: | |||
6243 | static OpenCLKernelAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6244 | auto *A = new (Ctx) OpenCLKernelAttr(Loc, Ctx, 0); | |||
6245 | A->setImplicit(true); | |||
6246 | return A; | |||
6247 | } | |||
6248 | ||||
6249 | OpenCLKernelAttr(SourceRange R, ASTContext &Ctx | |||
6250 | , unsigned SI | |||
6251 | ) | |||
6252 | : InheritableAttr(attr::OpenCLKernel, R, SI, false, false) | |||
6253 | { | |||
6254 | } | |||
6255 | ||||
6256 | OpenCLKernelAttr *clone(ASTContext &C) const; | |||
6257 | void printPretty(raw_ostream &OS, | |||
6258 | const PrintingPolicy &Policy) const; | |||
6259 | const char *getSpelling() const; | |||
6260 | ||||
6261 | ||||
6262 | static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLKernel; } | |||
6263 | }; | |||
6264 | ||||
6265 | class OpenCLUnrollHintAttr : public InheritableAttr { | |||
6266 | unsigned unrollHint; | |||
6267 | ||||
6268 | public: | |||
6269 | static OpenCLUnrollHintAttr *CreateImplicit(ASTContext &Ctx, unsigned UnrollHint, SourceRange Loc = SourceRange()) { | |||
6270 | auto *A = new (Ctx) OpenCLUnrollHintAttr(Loc, Ctx, UnrollHint, 0); | |||
6271 | A->setImplicit(true); | |||
6272 | return A; | |||
6273 | } | |||
6274 | ||||
6275 | OpenCLUnrollHintAttr(SourceRange R, ASTContext &Ctx | |||
6276 | , unsigned UnrollHint | |||
6277 | , unsigned SI | |||
6278 | ) | |||
6279 | : InheritableAttr(attr::OpenCLUnrollHint, R, SI, false, false) | |||
6280 | , unrollHint(UnrollHint) | |||
6281 | { | |||
6282 | } | |||
6283 | ||||
6284 | OpenCLUnrollHintAttr *clone(ASTContext &C) const; | |||
6285 | void printPretty(raw_ostream &OS, | |||
6286 | const PrintingPolicy &Policy) const; | |||
6287 | const char *getSpelling() const; | |||
6288 | unsigned getUnrollHint() const { | |||
6289 | return unrollHint; | |||
6290 | } | |||
6291 | ||||
6292 | ||||
6293 | ||||
6294 | static bool classof(const Attr *A) { return A->getKind() == attr::OpenCLUnrollHint; } | |||
6295 | }; | |||
6296 | ||||
6297 | class OptimizeNoneAttr : public InheritableAttr { | |||
6298 | public: | |||
6299 | static OptimizeNoneAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6300 | auto *A = new (Ctx) OptimizeNoneAttr(Loc, Ctx, 0); | |||
6301 | A->setImplicit(true); | |||
6302 | return A; | |||
6303 | } | |||
6304 | ||||
6305 | OptimizeNoneAttr(SourceRange R, ASTContext &Ctx | |||
6306 | , unsigned SI | |||
6307 | ) | |||
6308 | : InheritableAttr(attr::OptimizeNone, R, SI, false, false) | |||
6309 | { | |||
6310 | } | |||
6311 | ||||
6312 | OptimizeNoneAttr *clone(ASTContext &C) const; | |||
6313 | void printPretty(raw_ostream &OS, | |||
6314 | const PrintingPolicy &Policy) const; | |||
6315 | const char *getSpelling() const; | |||
6316 | ||||
6317 | ||||
6318 | static bool classof(const Attr *A) { return A->getKind() == attr::OptimizeNone; } | |||
6319 | }; | |||
6320 | ||||
6321 | class OverloadableAttr : public Attr { | |||
6322 | public: | |||
6323 | static OverloadableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6324 | auto *A = new (Ctx) OverloadableAttr(Loc, Ctx, 0); | |||
6325 | A->setImplicit(true); | |||
6326 | return A; | |||
6327 | } | |||
6328 | ||||
6329 | OverloadableAttr(SourceRange R, ASTContext &Ctx | |||
6330 | , unsigned SI | |||
6331 | ) | |||
6332 | : Attr(attr::Overloadable, R, SI, false) | |||
6333 | { | |||
6334 | } | |||
6335 | ||||
6336 | OverloadableAttr *clone(ASTContext &C) const; | |||
6337 | void printPretty(raw_ostream &OS, | |||
6338 | const PrintingPolicy &Policy) const; | |||
6339 | const char *getSpelling() const; | |||
6340 | ||||
6341 | ||||
6342 | static bool classof(const Attr *A) { return A->getKind() == attr::Overloadable; } | |||
6343 | }; | |||
6344 | ||||
6345 | class OverrideAttr : public InheritableAttr { | |||
6346 | public: | |||
6347 | static OverrideAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6348 | auto *A = new (Ctx) OverrideAttr(Loc, Ctx, 0); | |||
6349 | A->setImplicit(true); | |||
6350 | return A; | |||
6351 | } | |||
6352 | ||||
6353 | OverrideAttr(SourceRange R, ASTContext &Ctx | |||
6354 | , unsigned SI | |||
6355 | ) | |||
6356 | : InheritableAttr(attr::Override, R, SI, false, false) | |||
6357 | { | |||
6358 | } | |||
6359 | ||||
6360 | OverrideAttr *clone(ASTContext &C) const; | |||
6361 | void printPretty(raw_ostream &OS, | |||
6362 | const PrintingPolicy &Policy) const; | |||
6363 | const char *getSpelling() const; | |||
6364 | ||||
6365 | ||||
6366 | static bool classof(const Attr *A) { return A->getKind() == attr::Override; } | |||
6367 | }; | |||
6368 | ||||
6369 | class OwnershipAttr : public InheritableAttr { | |||
6370 | IdentifierInfo * module; | |||
6371 | ||||
6372 | unsigned args_Size; | |||
6373 | ParamIdx *args_; | |||
6374 | ||||
6375 | public: | |||
6376 | enum Spelling { | |||
6377 | GNU_ownership_holds = 0, | |||
6378 | CXX11_clang_ownership_holds = 1, | |||
6379 | C2x_clang_ownership_holds = 2, | |||
6380 | GNU_ownership_returns = 3, | |||
6381 | CXX11_clang_ownership_returns = 4, | |||
6382 | C2x_clang_ownership_returns = 5, | |||
6383 | GNU_ownership_takes = 6, | |||
6384 | CXX11_clang_ownership_takes = 7, | |||
6385 | C2x_clang_ownership_takes = 8 | |||
6386 | }; | |||
6387 | ||||
6388 | static OwnershipAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * Module, ParamIdx *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
6389 | auto *A = new (Ctx) OwnershipAttr(Loc, Ctx, Module, Args, ArgsSize, S); | |||
6390 | A->setImplicit(true); | |||
6391 | return A; | |||
6392 | } | |||
6393 | ||||
6394 | OwnershipAttr(SourceRange R, ASTContext &Ctx | |||
6395 | , IdentifierInfo * Module | |||
6396 | , ParamIdx *Args, unsigned ArgsSize | |||
6397 | , unsigned SI | |||
6398 | ) | |||
6399 | : InheritableAttr(attr::Ownership, R, SI, false, false) | |||
6400 | , module(Module) | |||
6401 | , args_Size(ArgsSize), args_(new (Ctx, 16) ParamIdx[args_Size]) | |||
6402 | { | |||
6403 | std::copy(Args, Args + args_Size, args_); | |||
6404 | } | |||
6405 | ||||
6406 | OwnershipAttr(SourceRange R, ASTContext &Ctx | |||
6407 | , IdentifierInfo * Module | |||
6408 | , unsigned SI | |||
6409 | ) | |||
6410 | : InheritableAttr(attr::Ownership, R, SI, false, false) | |||
6411 | , module(Module) | |||
6412 | , args_Size(0), args_(nullptr) | |||
6413 | { | |||
6414 | } | |||
6415 | ||||
6416 | OwnershipAttr *clone(ASTContext &C) const; | |||
6417 | void printPretty(raw_ostream &OS, | |||
6418 | const PrintingPolicy &Policy) const; | |||
6419 | const char *getSpelling() const; | |||
6420 | Spelling getSemanticSpelling() const { | |||
6421 | switch (SpellingListIndex) { | |||
6422 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 6422); | |||
6423 | case 0: return GNU_ownership_holds; | |||
6424 | case 1: return CXX11_clang_ownership_holds; | |||
6425 | case 2: return C2x_clang_ownership_holds; | |||
6426 | case 3: return GNU_ownership_returns; | |||
6427 | case 4: return CXX11_clang_ownership_returns; | |||
6428 | case 5: return C2x_clang_ownership_returns; | |||
6429 | case 6: return GNU_ownership_takes; | |||
6430 | case 7: return CXX11_clang_ownership_takes; | |||
6431 | case 8: return C2x_clang_ownership_takes; | |||
6432 | } | |||
6433 | } | |||
6434 | bool isHolds() const { return SpellingListIndex == 0 || | |||
6435 | SpellingListIndex == 1 || | |||
6436 | SpellingListIndex == 2; } | |||
6437 | bool isReturns() const { return SpellingListIndex == 3 || | |||
6438 | SpellingListIndex == 4 || | |||
6439 | SpellingListIndex == 5; } | |||
6440 | bool isTakes() const { return SpellingListIndex == 6 || | |||
6441 | SpellingListIndex == 7 || | |||
6442 | SpellingListIndex == 8; } | |||
6443 | IdentifierInfo * getModule() const { | |||
6444 | return module; | |||
6445 | } | |||
6446 | ||||
6447 | typedef ParamIdx* args_iterator; | |||
6448 | args_iterator args_begin() const { return args_; } | |||
6449 | args_iterator args_end() const { return args_ + args_Size; } | |||
6450 | unsigned args_size() const { return args_Size; } | |||
6451 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
6452 | ||||
6453 | ||||
6454 | ||||
6455 | enum OwnershipKind { Holds, Returns, Takes }; | |||
6456 | OwnershipKind getOwnKind() const { | |||
6457 | return isHolds() ? Holds : | |||
6458 | isTakes() ? Takes : | |||
6459 | Returns; | |||
6460 | } | |||
6461 | ||||
6462 | ||||
6463 | static bool classof(const Attr *A) { return A->getKind() == attr::Ownership; } | |||
6464 | }; | |||
6465 | ||||
6466 | class PackedAttr : public InheritableAttr { | |||
6467 | public: | |||
6468 | static PackedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6469 | auto *A = new (Ctx) PackedAttr(Loc, Ctx, 0); | |||
6470 | A->setImplicit(true); | |||
6471 | return A; | |||
6472 | } | |||
6473 | ||||
6474 | PackedAttr(SourceRange R, ASTContext &Ctx | |||
6475 | , unsigned SI | |||
6476 | ) | |||
6477 | : InheritableAttr(attr::Packed, R, SI, false, false) | |||
6478 | { | |||
6479 | } | |||
6480 | ||||
6481 | PackedAttr *clone(ASTContext &C) const; | |||
6482 | void printPretty(raw_ostream &OS, | |||
6483 | const PrintingPolicy &Policy) const; | |||
6484 | const char *getSpelling() const; | |||
6485 | ||||
6486 | ||||
6487 | static bool classof(const Attr *A) { return A->getKind() == attr::Packed; } | |||
6488 | }; | |||
6489 | ||||
6490 | class ParamTypestateAttr : public InheritableAttr { | |||
6491 | public: | |||
6492 | enum ConsumedState { | |||
6493 | Unknown, | |||
6494 | Consumed, | |||
6495 | Unconsumed | |||
6496 | }; | |||
6497 | private: | |||
6498 | ConsumedState paramState; | |||
6499 | ||||
6500 | public: | |||
6501 | static ParamTypestateAttr *CreateImplicit(ASTContext &Ctx, ConsumedState ParamState, SourceRange Loc = SourceRange()) { | |||
6502 | auto *A = new (Ctx) ParamTypestateAttr(Loc, Ctx, ParamState, 0); | |||
6503 | A->setImplicit(true); | |||
6504 | return A; | |||
6505 | } | |||
6506 | ||||
6507 | ParamTypestateAttr(SourceRange R, ASTContext &Ctx | |||
6508 | , ConsumedState ParamState | |||
6509 | , unsigned SI | |||
6510 | ) | |||
6511 | : InheritableAttr(attr::ParamTypestate, R, SI, false, false) | |||
6512 | , paramState(ParamState) | |||
6513 | { | |||
6514 | } | |||
6515 | ||||
6516 | ParamTypestateAttr *clone(ASTContext &C) const; | |||
6517 | void printPretty(raw_ostream &OS, | |||
6518 | const PrintingPolicy &Policy) const; | |||
6519 | const char *getSpelling() const; | |||
6520 | ConsumedState getParamState() const { | |||
6521 | return paramState; | |||
6522 | } | |||
6523 | ||||
6524 | static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) { | |||
6525 | Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val) | |||
6526 | .Case("unknown", ParamTypestateAttr::Unknown) | |||
6527 | .Case("consumed", ParamTypestateAttr::Consumed) | |||
6528 | .Case("unconsumed", ParamTypestateAttr::Unconsumed) | |||
6529 | .Default(Optional<ConsumedState>()); | |||
6530 | if (R) { | |||
6531 | Out = *R; | |||
6532 | return true; | |||
6533 | } | |||
6534 | return false; | |||
6535 | } | |||
6536 | ||||
6537 | static const char *ConvertConsumedStateToStr(ConsumedState Val) { | |||
6538 | switch(Val) { | |||
6539 | case ParamTypestateAttr::Unknown: return "unknown"; | |||
6540 | case ParamTypestateAttr::Consumed: return "consumed"; | |||
6541 | case ParamTypestateAttr::Unconsumed: return "unconsumed"; | |||
6542 | } | |||
6543 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 6543); | |||
6544 | } | |||
6545 | ||||
6546 | ||||
6547 | static bool classof(const Attr *A) { return A->getKind() == attr::ParamTypestate; } | |||
6548 | }; | |||
6549 | ||||
6550 | class PascalAttr : public InheritableAttr { | |||
6551 | public: | |||
6552 | static PascalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6553 | auto *A = new (Ctx) PascalAttr(Loc, Ctx, 0); | |||
6554 | A->setImplicit(true); | |||
6555 | return A; | |||
6556 | } | |||
6557 | ||||
6558 | PascalAttr(SourceRange R, ASTContext &Ctx | |||
6559 | , unsigned SI | |||
6560 | ) | |||
6561 | : InheritableAttr(attr::Pascal, R, SI, false, false) | |||
6562 | { | |||
6563 | } | |||
6564 | ||||
6565 | PascalAttr *clone(ASTContext &C) const; | |||
6566 | void printPretty(raw_ostream &OS, | |||
6567 | const PrintingPolicy &Policy) const; | |||
6568 | const char *getSpelling() const; | |||
6569 | ||||
6570 | ||||
6571 | static bool classof(const Attr *A) { return A->getKind() == attr::Pascal; } | |||
6572 | }; | |||
6573 | ||||
6574 | class PassObjectSizeAttr : public InheritableParamAttr { | |||
6575 | int type; | |||
6576 | ||||
6577 | public: | |||
6578 | static PassObjectSizeAttr *CreateImplicit(ASTContext &Ctx, int Type, SourceRange Loc = SourceRange()) { | |||
6579 | auto *A = new (Ctx) PassObjectSizeAttr(Loc, Ctx, Type, 0); | |||
6580 | A->setImplicit(true); | |||
6581 | return A; | |||
6582 | } | |||
6583 | ||||
6584 | PassObjectSizeAttr(SourceRange R, ASTContext &Ctx | |||
6585 | , int Type | |||
6586 | , unsigned SI | |||
6587 | ) | |||
6588 | : InheritableParamAttr(attr::PassObjectSize, R, SI, false, false) | |||
6589 | , type(Type) | |||
6590 | { | |||
6591 | } | |||
6592 | ||||
6593 | PassObjectSizeAttr *clone(ASTContext &C) const; | |||
6594 | void printPretty(raw_ostream &OS, | |||
6595 | const PrintingPolicy &Policy) const; | |||
6596 | const char *getSpelling() const; | |||
6597 | int getType() const { | |||
6598 | return type; | |||
6599 | } | |||
6600 | ||||
6601 | ||||
6602 | ||||
6603 | static bool classof(const Attr *A) { return A->getKind() == attr::PassObjectSize; } | |||
6604 | }; | |||
6605 | ||||
6606 | class PcsAttr : public InheritableAttr { | |||
6607 | public: | |||
6608 | enum PCSType { | |||
6609 | AAPCS, | |||
6610 | AAPCS_VFP | |||
6611 | }; | |||
6612 | private: | |||
6613 | PCSType pCS; | |||
6614 | ||||
6615 | public: | |||
6616 | static PcsAttr *CreateImplicit(ASTContext &Ctx, PCSType PCS, SourceRange Loc = SourceRange()) { | |||
6617 | auto *A = new (Ctx) PcsAttr(Loc, Ctx, PCS, 0); | |||
6618 | A->setImplicit(true); | |||
6619 | return A; | |||
6620 | } | |||
6621 | ||||
6622 | PcsAttr(SourceRange R, ASTContext &Ctx | |||
6623 | , PCSType PCS | |||
6624 | , unsigned SI | |||
6625 | ) | |||
6626 | : InheritableAttr(attr::Pcs, R, SI, false, false) | |||
6627 | , pCS(PCS) | |||
6628 | { | |||
6629 | } | |||
6630 | ||||
6631 | PcsAttr *clone(ASTContext &C) const; | |||
6632 | void printPretty(raw_ostream &OS, | |||
6633 | const PrintingPolicy &Policy) const; | |||
6634 | const char *getSpelling() const; | |||
6635 | PCSType getPCS() const { | |||
6636 | return pCS; | |||
6637 | } | |||
6638 | ||||
6639 | static bool ConvertStrToPCSType(StringRef Val, PCSType &Out) { | |||
6640 | Optional<PCSType> R = llvm::StringSwitch<Optional<PCSType>>(Val) | |||
6641 | .Case("aapcs", PcsAttr::AAPCS) | |||
6642 | .Case("aapcs-vfp", PcsAttr::AAPCS_VFP) | |||
6643 | .Default(Optional<PCSType>()); | |||
6644 | if (R) { | |||
6645 | Out = *R; | |||
6646 | return true; | |||
6647 | } | |||
6648 | return false; | |||
6649 | } | |||
6650 | ||||
6651 | static const char *ConvertPCSTypeToStr(PCSType Val) { | |||
6652 | switch(Val) { | |||
6653 | case PcsAttr::AAPCS: return "aapcs"; | |||
6654 | case PcsAttr::AAPCS_VFP: return "aapcs-vfp"; | |||
6655 | } | |||
6656 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 6656); | |||
6657 | } | |||
6658 | ||||
6659 | ||||
6660 | static bool classof(const Attr *A) { return A->getKind() == attr::Pcs; } | |||
6661 | }; | |||
6662 | ||||
6663 | class PragmaClangBSSSectionAttr : public InheritableAttr { | |||
6664 | unsigned nameLength; | |||
6665 | char *name; | |||
6666 | ||||
6667 | public: | |||
6668 | static PragmaClangBSSSectionAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) { | |||
6669 | auto *A = new (Ctx) PragmaClangBSSSectionAttr(Loc, Ctx, Name, 0); | |||
6670 | A->setImplicit(true); | |||
6671 | return A; | |||
6672 | } | |||
6673 | ||||
6674 | PragmaClangBSSSectionAttr(SourceRange R, ASTContext &Ctx | |||
6675 | , llvm::StringRef Name | |||
6676 | , unsigned SI | |||
6677 | ) | |||
6678 | : InheritableAttr(attr::PragmaClangBSSSection, R, SI, false, false) | |||
6679 | , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength]) | |||
6680 | { | |||
6681 | if (!Name.empty()) | |||
6682 | std::memcpy(name, Name.data(), nameLength); | |||
6683 | } | |||
6684 | ||||
6685 | PragmaClangBSSSectionAttr *clone(ASTContext &C) const; | |||
6686 | void printPretty(raw_ostream &OS, | |||
6687 | const PrintingPolicy &Policy) const; | |||
6688 | const char *getSpelling() const; | |||
6689 | llvm::StringRef getName() const { | |||
6690 | return llvm::StringRef(name, nameLength); | |||
6691 | } | |||
6692 | unsigned getNameLength() const { | |||
6693 | return nameLength; | |||
6694 | } | |||
6695 | void setName(ASTContext &C, llvm::StringRef S) { | |||
6696 | nameLength = S.size(); | |||
6697 | this->name = new (C, 1) char [nameLength]; | |||
6698 | if (!S.empty()) | |||
6699 | std::memcpy(this->name, S.data(), nameLength); | |||
6700 | } | |||
6701 | ||||
6702 | ||||
6703 | ||||
6704 | static bool classof(const Attr *A) { return A->getKind() == attr::PragmaClangBSSSection; } | |||
6705 | }; | |||
6706 | ||||
6707 | class PragmaClangDataSectionAttr : public InheritableAttr { | |||
6708 | unsigned nameLength; | |||
6709 | char *name; | |||
6710 | ||||
6711 | public: | |||
6712 | static PragmaClangDataSectionAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) { | |||
6713 | auto *A = new (Ctx) PragmaClangDataSectionAttr(Loc, Ctx, Name, 0); | |||
6714 | A->setImplicit(true); | |||
6715 | return A; | |||
6716 | } | |||
6717 | ||||
6718 | PragmaClangDataSectionAttr(SourceRange R, ASTContext &Ctx | |||
6719 | , llvm::StringRef Name | |||
6720 | , unsigned SI | |||
6721 | ) | |||
6722 | : InheritableAttr(attr::PragmaClangDataSection, R, SI, false, false) | |||
6723 | , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength]) | |||
6724 | { | |||
6725 | if (!Name.empty()) | |||
6726 | std::memcpy(name, Name.data(), nameLength); | |||
6727 | } | |||
6728 | ||||
6729 | PragmaClangDataSectionAttr *clone(ASTContext &C) const; | |||
6730 | void printPretty(raw_ostream &OS, | |||
6731 | const PrintingPolicy &Policy) const; | |||
6732 | const char *getSpelling() const; | |||
6733 | llvm::StringRef getName() const { | |||
6734 | return llvm::StringRef(name, nameLength); | |||
6735 | } | |||
6736 | unsigned getNameLength() const { | |||
6737 | return nameLength; | |||
6738 | } | |||
6739 | void setName(ASTContext &C, llvm::StringRef S) { | |||
6740 | nameLength = S.size(); | |||
6741 | this->name = new (C, 1) char [nameLength]; | |||
6742 | if (!S.empty()) | |||
6743 | std::memcpy(this->name, S.data(), nameLength); | |||
6744 | } | |||
6745 | ||||
6746 | ||||
6747 | ||||
6748 | static bool classof(const Attr *A) { return A->getKind() == attr::PragmaClangDataSection; } | |||
6749 | }; | |||
6750 | ||||
6751 | class PragmaClangRodataSectionAttr : public InheritableAttr { | |||
6752 | unsigned nameLength; | |||
6753 | char *name; | |||
6754 | ||||
6755 | public: | |||
6756 | static PragmaClangRodataSectionAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) { | |||
6757 | auto *A = new (Ctx) PragmaClangRodataSectionAttr(Loc, Ctx, Name, 0); | |||
6758 | A->setImplicit(true); | |||
6759 | return A; | |||
6760 | } | |||
6761 | ||||
6762 | PragmaClangRodataSectionAttr(SourceRange R, ASTContext &Ctx | |||
6763 | , llvm::StringRef Name | |||
6764 | , unsigned SI | |||
6765 | ) | |||
6766 | : InheritableAttr(attr::PragmaClangRodataSection, R, SI, false, false) | |||
6767 | , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength]) | |||
6768 | { | |||
6769 | if (!Name.empty()) | |||
6770 | std::memcpy(name, Name.data(), nameLength); | |||
6771 | } | |||
6772 | ||||
6773 | PragmaClangRodataSectionAttr *clone(ASTContext &C) const; | |||
6774 | void printPretty(raw_ostream &OS, | |||
6775 | const PrintingPolicy &Policy) const; | |||
6776 | const char *getSpelling() const; | |||
6777 | llvm::StringRef getName() const { | |||
6778 | return llvm::StringRef(name, nameLength); | |||
6779 | } | |||
6780 | unsigned getNameLength() const { | |||
6781 | return nameLength; | |||
6782 | } | |||
6783 | void setName(ASTContext &C, llvm::StringRef S) { | |||
6784 | nameLength = S.size(); | |||
6785 | this->name = new (C, 1) char [nameLength]; | |||
6786 | if (!S.empty()) | |||
6787 | std::memcpy(this->name, S.data(), nameLength); | |||
6788 | } | |||
6789 | ||||
6790 | ||||
6791 | ||||
6792 | static bool classof(const Attr *A) { return A->getKind() == attr::PragmaClangRodataSection; } | |||
6793 | }; | |||
6794 | ||||
6795 | class PragmaClangTextSectionAttr : public InheritableAttr { | |||
6796 | unsigned nameLength; | |||
6797 | char *name; | |||
6798 | ||||
6799 | public: | |||
6800 | static PragmaClangTextSectionAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) { | |||
6801 | auto *A = new (Ctx) PragmaClangTextSectionAttr(Loc, Ctx, Name, 0); | |||
6802 | A->setImplicit(true); | |||
6803 | return A; | |||
6804 | } | |||
6805 | ||||
6806 | PragmaClangTextSectionAttr(SourceRange R, ASTContext &Ctx | |||
6807 | , llvm::StringRef Name | |||
6808 | , unsigned SI | |||
6809 | ) | |||
6810 | : InheritableAttr(attr::PragmaClangTextSection, R, SI, false, false) | |||
6811 | , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength]) | |||
6812 | { | |||
6813 | if (!Name.empty()) | |||
6814 | std::memcpy(name, Name.data(), nameLength); | |||
6815 | } | |||
6816 | ||||
6817 | PragmaClangTextSectionAttr *clone(ASTContext &C) const; | |||
6818 | void printPretty(raw_ostream &OS, | |||
6819 | const PrintingPolicy &Policy) const; | |||
6820 | const char *getSpelling() const; | |||
6821 | llvm::StringRef getName() const { | |||
6822 | return llvm::StringRef(name, nameLength); | |||
6823 | } | |||
6824 | unsigned getNameLength() const { | |||
6825 | return nameLength; | |||
6826 | } | |||
6827 | void setName(ASTContext &C, llvm::StringRef S) { | |||
6828 | nameLength = S.size(); | |||
6829 | this->name = new (C, 1) char [nameLength]; | |||
6830 | if (!S.empty()) | |||
6831 | std::memcpy(this->name, S.data(), nameLength); | |||
6832 | } | |||
6833 | ||||
6834 | ||||
6835 | ||||
6836 | static bool classof(const Attr *A) { return A->getKind() == attr::PragmaClangTextSection; } | |||
6837 | }; | |||
6838 | ||||
6839 | class PreserveAllAttr : public InheritableAttr { | |||
6840 | public: | |||
6841 | static PreserveAllAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6842 | auto *A = new (Ctx) PreserveAllAttr(Loc, Ctx, 0); | |||
6843 | A->setImplicit(true); | |||
6844 | return A; | |||
6845 | } | |||
6846 | ||||
6847 | PreserveAllAttr(SourceRange R, ASTContext &Ctx | |||
6848 | , unsigned SI | |||
6849 | ) | |||
6850 | : InheritableAttr(attr::PreserveAll, R, SI, false, false) | |||
6851 | { | |||
6852 | } | |||
6853 | ||||
6854 | PreserveAllAttr *clone(ASTContext &C) const; | |||
6855 | void printPretty(raw_ostream &OS, | |||
6856 | const PrintingPolicy &Policy) const; | |||
6857 | const char *getSpelling() const; | |||
6858 | ||||
6859 | ||||
6860 | static bool classof(const Attr *A) { return A->getKind() == attr::PreserveAll; } | |||
6861 | }; | |||
6862 | ||||
6863 | class PreserveMostAttr : public InheritableAttr { | |||
6864 | public: | |||
6865 | static PreserveMostAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6866 | auto *A = new (Ctx) PreserveMostAttr(Loc, Ctx, 0); | |||
6867 | A->setImplicit(true); | |||
6868 | return A; | |||
6869 | } | |||
6870 | ||||
6871 | PreserveMostAttr(SourceRange R, ASTContext &Ctx | |||
6872 | , unsigned SI | |||
6873 | ) | |||
6874 | : InheritableAttr(attr::PreserveMost, R, SI, false, false) | |||
6875 | { | |||
6876 | } | |||
6877 | ||||
6878 | PreserveMostAttr *clone(ASTContext &C) const; | |||
6879 | void printPretty(raw_ostream &OS, | |||
6880 | const PrintingPolicy &Policy) const; | |||
6881 | const char *getSpelling() const; | |||
6882 | ||||
6883 | ||||
6884 | static bool classof(const Attr *A) { return A->getKind() == attr::PreserveMost; } | |||
6885 | }; | |||
6886 | ||||
6887 | class PtGuardedByAttr : public InheritableAttr { | |||
6888 | Expr * arg; | |||
6889 | ||||
6890 | public: | |||
6891 | static PtGuardedByAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) { | |||
6892 | auto *A = new (Ctx) PtGuardedByAttr(Loc, Ctx, Arg, 0); | |||
6893 | A->setImplicit(true); | |||
6894 | return A; | |||
6895 | } | |||
6896 | ||||
6897 | PtGuardedByAttr(SourceRange R, ASTContext &Ctx | |||
6898 | , Expr * Arg | |||
6899 | , unsigned SI | |||
6900 | ) | |||
6901 | : InheritableAttr(attr::PtGuardedBy, R, SI, true, true) | |||
6902 | , arg(Arg) | |||
6903 | { | |||
6904 | } | |||
6905 | ||||
6906 | PtGuardedByAttr *clone(ASTContext &C) const; | |||
6907 | void printPretty(raw_ostream &OS, | |||
6908 | const PrintingPolicy &Policy) const; | |||
6909 | const char *getSpelling() const; | |||
6910 | Expr * getArg() const { | |||
6911 | return arg; | |||
6912 | } | |||
6913 | ||||
6914 | ||||
6915 | ||||
6916 | static bool classof(const Attr *A) { return A->getKind() == attr::PtGuardedBy; } | |||
6917 | }; | |||
6918 | ||||
6919 | class PtGuardedVarAttr : public InheritableAttr { | |||
6920 | public: | |||
6921 | static PtGuardedVarAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6922 | auto *A = new (Ctx) PtGuardedVarAttr(Loc, Ctx, 0); | |||
6923 | A->setImplicit(true); | |||
6924 | return A; | |||
6925 | } | |||
6926 | ||||
6927 | PtGuardedVarAttr(SourceRange R, ASTContext &Ctx | |||
6928 | , unsigned SI | |||
6929 | ) | |||
6930 | : InheritableAttr(attr::PtGuardedVar, R, SI, false, false) | |||
6931 | { | |||
6932 | } | |||
6933 | ||||
6934 | PtGuardedVarAttr *clone(ASTContext &C) const; | |||
6935 | void printPretty(raw_ostream &OS, | |||
6936 | const PrintingPolicy &Policy) const; | |||
6937 | const char *getSpelling() const; | |||
6938 | ||||
6939 | ||||
6940 | static bool classof(const Attr *A) { return A->getKind() == attr::PtGuardedVar; } | |||
6941 | }; | |||
6942 | ||||
6943 | class PureAttr : public InheritableAttr { | |||
6944 | public: | |||
6945 | static PureAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
6946 | auto *A = new (Ctx) PureAttr(Loc, Ctx, 0); | |||
6947 | A->setImplicit(true); | |||
6948 | return A; | |||
6949 | } | |||
6950 | ||||
6951 | PureAttr(SourceRange R, ASTContext &Ctx | |||
6952 | , unsigned SI | |||
6953 | ) | |||
6954 | : InheritableAttr(attr::Pure, R, SI, false, false) | |||
6955 | { | |||
6956 | } | |||
6957 | ||||
6958 | PureAttr *clone(ASTContext &C) const; | |||
6959 | void printPretty(raw_ostream &OS, | |||
6960 | const PrintingPolicy &Policy) const; | |||
6961 | const char *getSpelling() const; | |||
6962 | ||||
6963 | ||||
6964 | static bool classof(const Attr *A) { return A->getKind() == attr::Pure; } | |||
6965 | }; | |||
6966 | ||||
6967 | class RISCVInterruptAttr : public InheritableAttr { | |||
6968 | public: | |||
6969 | enum InterruptType { | |||
6970 | user, | |||
6971 | supervisor, | |||
6972 | machine | |||
6973 | }; | |||
6974 | private: | |||
6975 | InterruptType interrupt; | |||
6976 | ||||
6977 | public: | |||
6978 | static RISCVInterruptAttr *CreateImplicit(ASTContext &Ctx, InterruptType Interrupt, SourceRange Loc = SourceRange()) { | |||
6979 | auto *A = new (Ctx) RISCVInterruptAttr(Loc, Ctx, Interrupt, 0); | |||
6980 | A->setImplicit(true); | |||
6981 | return A; | |||
6982 | } | |||
6983 | ||||
6984 | RISCVInterruptAttr(SourceRange R, ASTContext &Ctx | |||
6985 | , InterruptType Interrupt | |||
6986 | , unsigned SI | |||
6987 | ) | |||
6988 | : InheritableAttr(attr::RISCVInterrupt, R, SI, false, false) | |||
6989 | , interrupt(Interrupt) | |||
6990 | { | |||
6991 | } | |||
6992 | ||||
6993 | RISCVInterruptAttr(SourceRange R, ASTContext &Ctx | |||
6994 | , unsigned SI | |||
6995 | ) | |||
6996 | : InheritableAttr(attr::RISCVInterrupt, R, SI, false, false) | |||
6997 | , interrupt(InterruptType(0)) | |||
6998 | { | |||
6999 | } | |||
7000 | ||||
7001 | RISCVInterruptAttr *clone(ASTContext &C) const; | |||
7002 | void printPretty(raw_ostream &OS, | |||
7003 | const PrintingPolicy &Policy) const; | |||
7004 | const char *getSpelling() const; | |||
7005 | InterruptType getInterrupt() const { | |||
7006 | return interrupt; | |||
7007 | } | |||
7008 | ||||
7009 | static bool ConvertStrToInterruptType(StringRef Val, InterruptType &Out) { | |||
7010 | Optional<InterruptType> R = llvm::StringSwitch<Optional<InterruptType>>(Val) | |||
7011 | .Case("user", RISCVInterruptAttr::user) | |||
7012 | .Case("supervisor", RISCVInterruptAttr::supervisor) | |||
7013 | .Case("machine", RISCVInterruptAttr::machine) | |||
7014 | .Default(Optional<InterruptType>()); | |||
7015 | if (R) { | |||
7016 | Out = *R; | |||
7017 | return true; | |||
7018 | } | |||
7019 | return false; | |||
7020 | } | |||
7021 | ||||
7022 | static const char *ConvertInterruptTypeToStr(InterruptType Val) { | |||
7023 | switch(Val) { | |||
7024 | case RISCVInterruptAttr::user: return "user"; | |||
7025 | case RISCVInterruptAttr::supervisor: return "supervisor"; | |||
7026 | case RISCVInterruptAttr::machine: return "machine"; | |||
7027 | } | |||
7028 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 7028); | |||
7029 | } | |||
7030 | ||||
7031 | ||||
7032 | static bool classof(const Attr *A) { return A->getKind() == attr::RISCVInterrupt; } | |||
7033 | }; | |||
7034 | ||||
7035 | class RegCallAttr : public InheritableAttr { | |||
7036 | public: | |||
7037 | static RegCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7038 | auto *A = new (Ctx) RegCallAttr(Loc, Ctx, 0); | |||
7039 | A->setImplicit(true); | |||
7040 | return A; | |||
7041 | } | |||
7042 | ||||
7043 | RegCallAttr(SourceRange R, ASTContext &Ctx | |||
7044 | , unsigned SI | |||
7045 | ) | |||
7046 | : InheritableAttr(attr::RegCall, R, SI, false, false) | |||
7047 | { | |||
7048 | } | |||
7049 | ||||
7050 | RegCallAttr *clone(ASTContext &C) const; | |||
7051 | void printPretty(raw_ostream &OS, | |||
7052 | const PrintingPolicy &Policy) const; | |||
7053 | const char *getSpelling() const; | |||
7054 | ||||
7055 | ||||
7056 | static bool classof(const Attr *A) { return A->getKind() == attr::RegCall; } | |||
7057 | }; | |||
7058 | ||||
7059 | class ReleaseCapabilityAttr : public InheritableAttr { | |||
7060 | unsigned args_Size; | |||
7061 | Expr * *args_; | |||
7062 | ||||
7063 | public: | |||
7064 | enum Spelling { | |||
7065 | GNU_release_capability = 0, | |||
7066 | CXX11_clang_release_capability = 1, | |||
7067 | GNU_release_shared_capability = 2, | |||
7068 | CXX11_clang_release_shared_capability = 3, | |||
7069 | GNU_release_generic_capability = 4, | |||
7070 | CXX11_clang_release_generic_capability = 5, | |||
7071 | GNU_unlock_function = 6, | |||
7072 | CXX11_clang_unlock_function = 7 | |||
7073 | }; | |||
7074 | ||||
7075 | static ReleaseCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
7076 | auto *A = new (Ctx) ReleaseCapabilityAttr(Loc, Ctx, Args, ArgsSize, S); | |||
7077 | A->setImplicit(true); | |||
7078 | return A; | |||
7079 | } | |||
7080 | ||||
7081 | ReleaseCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
7082 | , Expr * *Args, unsigned ArgsSize | |||
7083 | , unsigned SI | |||
7084 | ) | |||
7085 | : InheritableAttr(attr::ReleaseCapability, R, SI, true, true) | |||
7086 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
7087 | { | |||
7088 | std::copy(Args, Args + args_Size, args_); | |||
7089 | } | |||
7090 | ||||
7091 | ReleaseCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
7092 | , unsigned SI | |||
7093 | ) | |||
7094 | : InheritableAttr(attr::ReleaseCapability, R, SI, true, true) | |||
7095 | , args_Size(0), args_(nullptr) | |||
7096 | { | |||
7097 | } | |||
7098 | ||||
7099 | ReleaseCapabilityAttr *clone(ASTContext &C) const; | |||
7100 | void printPretty(raw_ostream &OS, | |||
7101 | const PrintingPolicy &Policy) const; | |||
7102 | const char *getSpelling() const; | |||
7103 | Spelling getSemanticSpelling() const { | |||
7104 | switch (SpellingListIndex) { | |||
7105 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 7105); | |||
7106 | case 0: return GNU_release_capability; | |||
7107 | case 1: return CXX11_clang_release_capability; | |||
7108 | case 2: return GNU_release_shared_capability; | |||
7109 | case 3: return CXX11_clang_release_shared_capability; | |||
7110 | case 4: return GNU_release_generic_capability; | |||
7111 | case 5: return CXX11_clang_release_generic_capability; | |||
7112 | case 6: return GNU_unlock_function; | |||
7113 | case 7: return CXX11_clang_unlock_function; | |||
7114 | } | |||
7115 | } | |||
7116 | bool isShared() const { return SpellingListIndex == 2 || | |||
7117 | SpellingListIndex == 3; } | |||
7118 | bool isGeneric() const { return SpellingListIndex == 4 || | |||
7119 | SpellingListIndex == 5 || | |||
7120 | SpellingListIndex == 6 || | |||
7121 | SpellingListIndex == 7; } | |||
7122 | typedef Expr ** args_iterator; | |||
7123 | args_iterator args_begin() const { return args_; } | |||
7124 | args_iterator args_end() const { return args_ + args_Size; } | |||
7125 | unsigned args_size() const { return args_Size; } | |||
7126 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
7127 | ||||
7128 | ||||
7129 | ||||
7130 | ||||
7131 | static bool classof(const Attr *A) { return A->getKind() == attr::ReleaseCapability; } | |||
7132 | }; | |||
7133 | ||||
7134 | class RenderScriptKernelAttr : public Attr { | |||
7135 | public: | |||
7136 | static RenderScriptKernelAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7137 | auto *A = new (Ctx) RenderScriptKernelAttr(Loc, Ctx, 0); | |||
7138 | A->setImplicit(true); | |||
7139 | return A; | |||
7140 | } | |||
7141 | ||||
7142 | RenderScriptKernelAttr(SourceRange R, ASTContext &Ctx | |||
7143 | , unsigned SI | |||
7144 | ) | |||
7145 | : Attr(attr::RenderScriptKernel, R, SI, false) | |||
7146 | { | |||
7147 | } | |||
7148 | ||||
7149 | RenderScriptKernelAttr *clone(ASTContext &C) const; | |||
7150 | void printPretty(raw_ostream &OS, | |||
7151 | const PrintingPolicy &Policy) const; | |||
7152 | const char *getSpelling() const; | |||
7153 | ||||
7154 | ||||
7155 | static bool classof(const Attr *A) { return A->getKind() == attr::RenderScriptKernel; } | |||
7156 | }; | |||
7157 | ||||
7158 | class ReqdWorkGroupSizeAttr : public InheritableAttr { | |||
7159 | unsigned xDim; | |||
7160 | ||||
7161 | unsigned yDim; | |||
7162 | ||||
7163 | unsigned zDim; | |||
7164 | ||||
7165 | public: | |||
7166 | static ReqdWorkGroupSizeAttr *CreateImplicit(ASTContext &Ctx, unsigned XDim, unsigned YDim, unsigned ZDim, SourceRange Loc = SourceRange()) { | |||
7167 | auto *A = new (Ctx) ReqdWorkGroupSizeAttr(Loc, Ctx, XDim, YDim, ZDim, 0); | |||
7168 | A->setImplicit(true); | |||
7169 | return A; | |||
7170 | } | |||
7171 | ||||
7172 | ReqdWorkGroupSizeAttr(SourceRange R, ASTContext &Ctx | |||
7173 | , unsigned XDim | |||
7174 | , unsigned YDim | |||
7175 | , unsigned ZDim | |||
7176 | , unsigned SI | |||
7177 | ) | |||
7178 | : InheritableAttr(attr::ReqdWorkGroupSize, R, SI, false, false) | |||
7179 | , xDim(XDim) | |||
7180 | , yDim(YDim) | |||
7181 | , zDim(ZDim) | |||
7182 | { | |||
7183 | } | |||
7184 | ||||
7185 | ReqdWorkGroupSizeAttr *clone(ASTContext &C) const; | |||
7186 | void printPretty(raw_ostream &OS, | |||
7187 | const PrintingPolicy &Policy) const; | |||
7188 | const char *getSpelling() const; | |||
7189 | unsigned getXDim() const { | |||
7190 | return xDim; | |||
7191 | } | |||
7192 | ||||
7193 | unsigned getYDim() const { | |||
7194 | return yDim; | |||
7195 | } | |||
7196 | ||||
7197 | unsigned getZDim() const { | |||
7198 | return zDim; | |||
7199 | } | |||
7200 | ||||
7201 | ||||
7202 | ||||
7203 | static bool classof(const Attr *A) { return A->getKind() == attr::ReqdWorkGroupSize; } | |||
7204 | }; | |||
7205 | ||||
7206 | class RequireConstantInitAttr : public InheritableAttr { | |||
7207 | public: | |||
7208 | static RequireConstantInitAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7209 | auto *A = new (Ctx) RequireConstantInitAttr(Loc, Ctx, 0); | |||
7210 | A->setImplicit(true); | |||
7211 | return A; | |||
7212 | } | |||
7213 | ||||
7214 | RequireConstantInitAttr(SourceRange R, ASTContext &Ctx | |||
7215 | , unsigned SI | |||
7216 | ) | |||
7217 | : InheritableAttr(attr::RequireConstantInit, R, SI, false, false) | |||
7218 | { | |||
7219 | } | |||
7220 | ||||
7221 | RequireConstantInitAttr *clone(ASTContext &C) const; | |||
7222 | void printPretty(raw_ostream &OS, | |||
7223 | const PrintingPolicy &Policy) const; | |||
7224 | const char *getSpelling() const; | |||
7225 | ||||
7226 | ||||
7227 | static bool classof(const Attr *A) { return A->getKind() == attr::RequireConstantInit; } | |||
7228 | }; | |||
7229 | ||||
7230 | class RequiresCapabilityAttr : public InheritableAttr { | |||
7231 | unsigned args_Size; | |||
7232 | Expr * *args_; | |||
7233 | ||||
7234 | public: | |||
7235 | enum Spelling { | |||
7236 | GNU_requires_capability = 0, | |||
7237 | CXX11_clang_requires_capability = 1, | |||
7238 | GNU_exclusive_locks_required = 2, | |||
7239 | CXX11_clang_exclusive_locks_required = 3, | |||
7240 | GNU_requires_shared_capability = 4, | |||
7241 | CXX11_clang_requires_shared_capability = 5, | |||
7242 | GNU_shared_locks_required = 6, | |||
7243 | CXX11_clang_shared_locks_required = 7 | |||
7244 | }; | |||
7245 | ||||
7246 | static RequiresCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
7247 | auto *A = new (Ctx) RequiresCapabilityAttr(Loc, Ctx, Args, ArgsSize, S); | |||
7248 | A->setImplicit(true); | |||
7249 | return A; | |||
7250 | } | |||
7251 | ||||
7252 | RequiresCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
7253 | , Expr * *Args, unsigned ArgsSize | |||
7254 | , unsigned SI | |||
7255 | ) | |||
7256 | : InheritableAttr(attr::RequiresCapability, R, SI, true, true) | |||
7257 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
7258 | { | |||
7259 | std::copy(Args, Args + args_Size, args_); | |||
7260 | } | |||
7261 | ||||
7262 | RequiresCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
7263 | , unsigned SI | |||
7264 | ) | |||
7265 | : InheritableAttr(attr::RequiresCapability, R, SI, true, true) | |||
7266 | , args_Size(0), args_(nullptr) | |||
7267 | { | |||
7268 | } | |||
7269 | ||||
7270 | RequiresCapabilityAttr *clone(ASTContext &C) const; | |||
7271 | void printPretty(raw_ostream &OS, | |||
7272 | const PrintingPolicy &Policy) const; | |||
7273 | const char *getSpelling() const; | |||
7274 | Spelling getSemanticSpelling() const { | |||
7275 | switch (SpellingListIndex) { | |||
7276 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 7276); | |||
7277 | case 0: return GNU_requires_capability; | |||
7278 | case 1: return CXX11_clang_requires_capability; | |||
7279 | case 2: return GNU_exclusive_locks_required; | |||
7280 | case 3: return CXX11_clang_exclusive_locks_required; | |||
7281 | case 4: return GNU_requires_shared_capability; | |||
7282 | case 5: return CXX11_clang_requires_shared_capability; | |||
7283 | case 6: return GNU_shared_locks_required; | |||
7284 | case 7: return CXX11_clang_shared_locks_required; | |||
7285 | } | |||
7286 | } | |||
7287 | bool isShared() const { return SpellingListIndex == 4 || | |||
7288 | SpellingListIndex == 5 || | |||
7289 | SpellingListIndex == 6 || | |||
7290 | SpellingListIndex == 7; } | |||
7291 | typedef Expr ** args_iterator; | |||
7292 | args_iterator args_begin() const { return args_; } | |||
7293 | args_iterator args_end() const { return args_ + args_Size; } | |||
7294 | unsigned args_size() const { return args_Size; } | |||
7295 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
7296 | ||||
7297 | ||||
7298 | ||||
7299 | ||||
7300 | static bool classof(const Attr *A) { return A->getKind() == attr::RequiresCapability; } | |||
7301 | }; | |||
7302 | ||||
7303 | class RestrictAttr : public InheritableAttr { | |||
7304 | public: | |||
7305 | enum Spelling { | |||
7306 | Declspec_restrict = 0, | |||
7307 | GNU_malloc = 1, | |||
7308 | CXX11_gnu_malloc = 2 | |||
7309 | }; | |||
7310 | ||||
7311 | static RestrictAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
7312 | auto *A = new (Ctx) RestrictAttr(Loc, Ctx, S); | |||
7313 | A->setImplicit(true); | |||
7314 | return A; | |||
7315 | } | |||
7316 | ||||
7317 | RestrictAttr(SourceRange R, ASTContext &Ctx | |||
7318 | , unsigned SI | |||
7319 | ) | |||
7320 | : InheritableAttr(attr::Restrict, R, SI, false, false) | |||
7321 | { | |||
7322 | } | |||
7323 | ||||
7324 | RestrictAttr *clone(ASTContext &C) const; | |||
7325 | void printPretty(raw_ostream &OS, | |||
7326 | const PrintingPolicy &Policy) const; | |||
7327 | const char *getSpelling() const; | |||
7328 | Spelling getSemanticSpelling() const { | |||
7329 | switch (SpellingListIndex) { | |||
7330 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 7330); | |||
7331 | case 0: return Declspec_restrict; | |||
7332 | case 1: return GNU_malloc; | |||
7333 | case 2: return CXX11_gnu_malloc; | |||
7334 | } | |||
7335 | } | |||
7336 | ||||
7337 | ||||
7338 | static bool classof(const Attr *A) { return A->getKind() == attr::Restrict; } | |||
7339 | }; | |||
7340 | ||||
7341 | class ReturnTypestateAttr : public InheritableAttr { | |||
7342 | public: | |||
7343 | enum ConsumedState { | |||
7344 | Unknown, | |||
7345 | Consumed, | |||
7346 | Unconsumed | |||
7347 | }; | |||
7348 | private: | |||
7349 | ConsumedState state; | |||
7350 | ||||
7351 | public: | |||
7352 | static ReturnTypestateAttr *CreateImplicit(ASTContext &Ctx, ConsumedState State, SourceRange Loc = SourceRange()) { | |||
7353 | auto *A = new (Ctx) ReturnTypestateAttr(Loc, Ctx, State, 0); | |||
7354 | A->setImplicit(true); | |||
7355 | return A; | |||
7356 | } | |||
7357 | ||||
7358 | ReturnTypestateAttr(SourceRange R, ASTContext &Ctx | |||
7359 | , ConsumedState State | |||
7360 | , unsigned SI | |||
7361 | ) | |||
7362 | : InheritableAttr(attr::ReturnTypestate, R, SI, false, false) | |||
7363 | , state(State) | |||
7364 | { | |||
7365 | } | |||
7366 | ||||
7367 | ReturnTypestateAttr *clone(ASTContext &C) const; | |||
7368 | void printPretty(raw_ostream &OS, | |||
7369 | const PrintingPolicy &Policy) const; | |||
7370 | const char *getSpelling() const; | |||
7371 | ConsumedState getState() const { | |||
7372 | return state; | |||
7373 | } | |||
7374 | ||||
7375 | static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) { | |||
7376 | Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val) | |||
7377 | .Case("unknown", ReturnTypestateAttr::Unknown) | |||
7378 | .Case("consumed", ReturnTypestateAttr::Consumed) | |||
7379 | .Case("unconsumed", ReturnTypestateAttr::Unconsumed) | |||
7380 | .Default(Optional<ConsumedState>()); | |||
7381 | if (R) { | |||
7382 | Out = *R; | |||
7383 | return true; | |||
7384 | } | |||
7385 | return false; | |||
7386 | } | |||
7387 | ||||
7388 | static const char *ConvertConsumedStateToStr(ConsumedState Val) { | |||
7389 | switch(Val) { | |||
7390 | case ReturnTypestateAttr::Unknown: return "unknown"; | |||
7391 | case ReturnTypestateAttr::Consumed: return "consumed"; | |||
7392 | case ReturnTypestateAttr::Unconsumed: return "unconsumed"; | |||
7393 | } | |||
7394 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 7394); | |||
7395 | } | |||
7396 | ||||
7397 | ||||
7398 | static bool classof(const Attr *A) { return A->getKind() == attr::ReturnTypestate; } | |||
7399 | }; | |||
7400 | ||||
7401 | class ReturnsNonNullAttr : public InheritableAttr { | |||
7402 | public: | |||
7403 | static ReturnsNonNullAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7404 | auto *A = new (Ctx) ReturnsNonNullAttr(Loc, Ctx, 0); | |||
7405 | A->setImplicit(true); | |||
7406 | return A; | |||
7407 | } | |||
7408 | ||||
7409 | ReturnsNonNullAttr(SourceRange R, ASTContext &Ctx | |||
7410 | , unsigned SI | |||
7411 | ) | |||
7412 | : InheritableAttr(attr::ReturnsNonNull, R, SI, false, false) | |||
7413 | { | |||
7414 | } | |||
7415 | ||||
7416 | ReturnsNonNullAttr *clone(ASTContext &C) const; | |||
7417 | void printPretty(raw_ostream &OS, | |||
7418 | const PrintingPolicy &Policy) const; | |||
7419 | const char *getSpelling() const; | |||
7420 | ||||
7421 | ||||
7422 | static bool classof(const Attr *A) { return A->getKind() == attr::ReturnsNonNull; } | |||
7423 | }; | |||
7424 | ||||
7425 | class ReturnsTwiceAttr : public InheritableAttr { | |||
7426 | public: | |||
7427 | static ReturnsTwiceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7428 | auto *A = new (Ctx) ReturnsTwiceAttr(Loc, Ctx, 0); | |||
7429 | A->setImplicit(true); | |||
7430 | return A; | |||
7431 | } | |||
7432 | ||||
7433 | ReturnsTwiceAttr(SourceRange R, ASTContext &Ctx | |||
7434 | , unsigned SI | |||
7435 | ) | |||
7436 | : InheritableAttr(attr::ReturnsTwice, R, SI, false, false) | |||
7437 | { | |||
7438 | } | |||
7439 | ||||
7440 | ReturnsTwiceAttr *clone(ASTContext &C) const; | |||
7441 | void printPretty(raw_ostream &OS, | |||
7442 | const PrintingPolicy &Policy) const; | |||
7443 | const char *getSpelling() const; | |||
7444 | ||||
7445 | ||||
7446 | static bool classof(const Attr *A) { return A->getKind() == attr::ReturnsTwice; } | |||
7447 | }; | |||
7448 | ||||
7449 | class ScopedLockableAttr : public InheritableAttr { | |||
7450 | public: | |||
7451 | static ScopedLockableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7452 | auto *A = new (Ctx) ScopedLockableAttr(Loc, Ctx, 0); | |||
7453 | A->setImplicit(true); | |||
7454 | return A; | |||
7455 | } | |||
7456 | ||||
7457 | ScopedLockableAttr(SourceRange R, ASTContext &Ctx | |||
7458 | , unsigned SI | |||
7459 | ) | |||
7460 | : InheritableAttr(attr::ScopedLockable, R, SI, false, false) | |||
7461 | { | |||
7462 | } | |||
7463 | ||||
7464 | ScopedLockableAttr *clone(ASTContext &C) const; | |||
7465 | void printPretty(raw_ostream &OS, | |||
7466 | const PrintingPolicy &Policy) const; | |||
7467 | const char *getSpelling() const; | |||
7468 | ||||
7469 | ||||
7470 | static bool classof(const Attr *A) { return A->getKind() == attr::ScopedLockable; } | |||
7471 | }; | |||
7472 | ||||
7473 | class SectionAttr : public InheritableAttr { | |||
7474 | unsigned nameLength; | |||
7475 | char *name; | |||
7476 | ||||
7477 | public: | |||
7478 | enum Spelling { | |||
7479 | GNU_section = 0, | |||
7480 | CXX11_gnu_section = 1, | |||
7481 | Declspec_allocate = 2 | |||
7482 | }; | |||
7483 | ||||
7484 | static SectionAttr *CreateImplicit(ASTContext &Ctx, Spelling S, llvm::StringRef Name, SourceRange Loc = SourceRange()) { | |||
7485 | auto *A = new (Ctx) SectionAttr(Loc, Ctx, Name, S); | |||
7486 | A->setImplicit(true); | |||
7487 | return A; | |||
7488 | } | |||
7489 | ||||
7490 | SectionAttr(SourceRange R, ASTContext &Ctx | |||
7491 | , llvm::StringRef Name | |||
7492 | , unsigned SI | |||
7493 | ) | |||
7494 | : InheritableAttr(attr::Section, R, SI, false, false) | |||
7495 | , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength]) | |||
7496 | { | |||
7497 | if (!Name.empty()) | |||
7498 | std::memcpy(name, Name.data(), nameLength); | |||
7499 | } | |||
7500 | ||||
7501 | SectionAttr *clone(ASTContext &C) const; | |||
7502 | void printPretty(raw_ostream &OS, | |||
7503 | const PrintingPolicy &Policy) const; | |||
7504 | const char *getSpelling() const; | |||
7505 | Spelling getSemanticSpelling() const { | |||
7506 | switch (SpellingListIndex) { | |||
7507 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 7507); | |||
7508 | case 0: return GNU_section; | |||
7509 | case 1: return CXX11_gnu_section; | |||
7510 | case 2: return Declspec_allocate; | |||
7511 | } | |||
7512 | } | |||
7513 | llvm::StringRef getName() const { | |||
7514 | return llvm::StringRef(name, nameLength); | |||
7515 | } | |||
7516 | unsigned getNameLength() const { | |||
7517 | return nameLength; | |||
7518 | } | |||
7519 | void setName(ASTContext &C, llvm::StringRef S) { | |||
7520 | nameLength = S.size(); | |||
7521 | this->name = new (C, 1) char [nameLength]; | |||
7522 | if (!S.empty()) | |||
7523 | std::memcpy(this->name, S.data(), nameLength); | |||
7524 | } | |||
7525 | ||||
7526 | ||||
7527 | ||||
7528 | static bool classof(const Attr *A) { return A->getKind() == attr::Section; } | |||
7529 | }; | |||
7530 | ||||
7531 | class SelectAnyAttr : public InheritableAttr { | |||
7532 | public: | |||
7533 | static SelectAnyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7534 | auto *A = new (Ctx) SelectAnyAttr(Loc, Ctx, 0); | |||
7535 | A->setImplicit(true); | |||
7536 | return A; | |||
7537 | } | |||
7538 | ||||
7539 | SelectAnyAttr(SourceRange R, ASTContext &Ctx | |||
7540 | , unsigned SI | |||
7541 | ) | |||
7542 | : InheritableAttr(attr::SelectAny, R, SI, false, false) | |||
7543 | { | |||
7544 | } | |||
7545 | ||||
7546 | SelectAnyAttr *clone(ASTContext &C) const; | |||
7547 | void printPretty(raw_ostream &OS, | |||
7548 | const PrintingPolicy &Policy) const; | |||
7549 | const char *getSpelling() const; | |||
7550 | ||||
7551 | ||||
7552 | static bool classof(const Attr *A) { return A->getKind() == attr::SelectAny; } | |||
7553 | }; | |||
7554 | ||||
7555 | class SentinelAttr : public InheritableAttr { | |||
7556 | int sentinel; | |||
7557 | ||||
7558 | int nullPos; | |||
7559 | ||||
7560 | public: | |||
7561 | static SentinelAttr *CreateImplicit(ASTContext &Ctx, int Sentinel, int NullPos, SourceRange Loc = SourceRange()) { | |||
7562 | auto *A = new (Ctx) SentinelAttr(Loc, Ctx, Sentinel, NullPos, 0); | |||
7563 | A->setImplicit(true); | |||
7564 | return A; | |||
7565 | } | |||
7566 | ||||
7567 | SentinelAttr(SourceRange R, ASTContext &Ctx | |||
7568 | , int Sentinel | |||
7569 | , int NullPos | |||
7570 | , unsigned SI | |||
7571 | ) | |||
7572 | : InheritableAttr(attr::Sentinel, R, SI, false, false) | |||
7573 | , sentinel(Sentinel) | |||
7574 | , nullPos(NullPos) | |||
7575 | { | |||
7576 | } | |||
7577 | ||||
7578 | SentinelAttr(SourceRange R, ASTContext &Ctx | |||
7579 | , unsigned SI | |||
7580 | ) | |||
7581 | : InheritableAttr(attr::Sentinel, R, SI, false, false) | |||
7582 | , sentinel() | |||
7583 | , nullPos() | |||
7584 | { | |||
7585 | } | |||
7586 | ||||
7587 | SentinelAttr *clone(ASTContext &C) const; | |||
7588 | void printPretty(raw_ostream &OS, | |||
7589 | const PrintingPolicy &Policy) const; | |||
7590 | const char *getSpelling() const; | |||
7591 | int getSentinel() const { | |||
7592 | return sentinel; | |||
7593 | } | |||
7594 | ||||
7595 | static const int DefaultSentinel = 0; | |||
7596 | ||||
7597 | int getNullPos() const { | |||
7598 | return nullPos; | |||
7599 | } | |||
7600 | ||||
7601 | static const int DefaultNullPos = 0; | |||
7602 | ||||
7603 | ||||
7604 | ||||
7605 | static bool classof(const Attr *A) { return A->getKind() == attr::Sentinel; } | |||
7606 | }; | |||
7607 | ||||
7608 | class SetTypestateAttr : public InheritableAttr { | |||
7609 | public: | |||
7610 | enum ConsumedState { | |||
7611 | Unknown, | |||
7612 | Consumed, | |||
7613 | Unconsumed | |||
7614 | }; | |||
7615 | private: | |||
7616 | ConsumedState newState; | |||
7617 | ||||
7618 | public: | |||
7619 | static SetTypestateAttr *CreateImplicit(ASTContext &Ctx, ConsumedState NewState, SourceRange Loc = SourceRange()) { | |||
7620 | auto *A = new (Ctx) SetTypestateAttr(Loc, Ctx, NewState, 0); | |||
7621 | A->setImplicit(true); | |||
7622 | return A; | |||
7623 | } | |||
7624 | ||||
7625 | SetTypestateAttr(SourceRange R, ASTContext &Ctx | |||
7626 | , ConsumedState NewState | |||
7627 | , unsigned SI | |||
7628 | ) | |||
7629 | : InheritableAttr(attr::SetTypestate, R, SI, false, false) | |||
7630 | , newState(NewState) | |||
7631 | { | |||
7632 | } | |||
7633 | ||||
7634 | SetTypestateAttr *clone(ASTContext &C) const; | |||
7635 | void printPretty(raw_ostream &OS, | |||
7636 | const PrintingPolicy &Policy) const; | |||
7637 | const char *getSpelling() const; | |||
7638 | ConsumedState getNewState() const { | |||
7639 | return newState; | |||
7640 | } | |||
7641 | ||||
7642 | static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) { | |||
7643 | Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val) | |||
7644 | .Case("unknown", SetTypestateAttr::Unknown) | |||
7645 | .Case("consumed", SetTypestateAttr::Consumed) | |||
7646 | .Case("unconsumed", SetTypestateAttr::Unconsumed) | |||
7647 | .Default(Optional<ConsumedState>()); | |||
7648 | if (R) { | |||
7649 | Out = *R; | |||
7650 | return true; | |||
7651 | } | |||
7652 | return false; | |||
7653 | } | |||
7654 | ||||
7655 | static const char *ConvertConsumedStateToStr(ConsumedState Val) { | |||
7656 | switch(Val) { | |||
7657 | case SetTypestateAttr::Unknown: return "unknown"; | |||
7658 | case SetTypestateAttr::Consumed: return "consumed"; | |||
7659 | case SetTypestateAttr::Unconsumed: return "unconsumed"; | |||
7660 | } | |||
7661 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 7661); | |||
7662 | } | |||
7663 | ||||
7664 | ||||
7665 | static bool classof(const Attr *A) { return A->getKind() == attr::SetTypestate; } | |||
7666 | }; | |||
7667 | ||||
7668 | class SharedTrylockFunctionAttr : public InheritableAttr { | |||
7669 | Expr * successValue; | |||
7670 | ||||
7671 | unsigned args_Size; | |||
7672 | Expr * *args_; | |||
7673 | ||||
7674 | public: | |||
7675 | static SharedTrylockFunctionAttr *CreateImplicit(ASTContext &Ctx, Expr * SuccessValue, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
7676 | auto *A = new (Ctx) SharedTrylockFunctionAttr(Loc, Ctx, SuccessValue, Args, ArgsSize, 0); | |||
7677 | A->setImplicit(true); | |||
7678 | return A; | |||
7679 | } | |||
7680 | ||||
7681 | SharedTrylockFunctionAttr(SourceRange R, ASTContext &Ctx | |||
7682 | , Expr * SuccessValue | |||
7683 | , Expr * *Args, unsigned ArgsSize | |||
7684 | , unsigned SI | |||
7685 | ) | |||
7686 | : InheritableAttr(attr::SharedTrylockFunction, R, SI, true, true) | |||
7687 | , successValue(SuccessValue) | |||
7688 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
7689 | { | |||
7690 | std::copy(Args, Args + args_Size, args_); | |||
7691 | } | |||
7692 | ||||
7693 | SharedTrylockFunctionAttr(SourceRange R, ASTContext &Ctx | |||
7694 | , Expr * SuccessValue | |||
7695 | , unsigned SI | |||
7696 | ) | |||
7697 | : InheritableAttr(attr::SharedTrylockFunction, R, SI, true, true) | |||
7698 | , successValue(SuccessValue) | |||
7699 | , args_Size(0), args_(nullptr) | |||
7700 | { | |||
7701 | } | |||
7702 | ||||
7703 | SharedTrylockFunctionAttr *clone(ASTContext &C) const; | |||
7704 | void printPretty(raw_ostream &OS, | |||
7705 | const PrintingPolicy &Policy) const; | |||
7706 | const char *getSpelling() const; | |||
7707 | Expr * getSuccessValue() const { | |||
7708 | return successValue; | |||
7709 | } | |||
7710 | ||||
7711 | typedef Expr ** args_iterator; | |||
7712 | args_iterator args_begin() const { return args_; } | |||
7713 | args_iterator args_end() const { return args_ + args_Size; } | |||
7714 | unsigned args_size() const { return args_Size; } | |||
7715 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
7716 | ||||
7717 | ||||
7718 | ||||
7719 | ||||
7720 | static bool classof(const Attr *A) { return A->getKind() == attr::SharedTrylockFunction; } | |||
7721 | }; | |||
7722 | ||||
7723 | class StdCallAttr : public InheritableAttr { | |||
7724 | public: | |||
7725 | static StdCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7726 | auto *A = new (Ctx) StdCallAttr(Loc, Ctx, 0); | |||
7727 | A->setImplicit(true); | |||
7728 | return A; | |||
7729 | } | |||
7730 | ||||
7731 | StdCallAttr(SourceRange R, ASTContext &Ctx | |||
7732 | , unsigned SI | |||
7733 | ) | |||
7734 | : InheritableAttr(attr::StdCall, R, SI, false, false) | |||
7735 | { | |||
7736 | } | |||
7737 | ||||
7738 | StdCallAttr *clone(ASTContext &C) const; | |||
7739 | void printPretty(raw_ostream &OS, | |||
7740 | const PrintingPolicy &Policy) const; | |||
7741 | const char *getSpelling() const; | |||
7742 | ||||
7743 | ||||
7744 | static bool classof(const Attr *A) { return A->getKind() == attr::StdCall; } | |||
7745 | }; | |||
7746 | ||||
7747 | class SuppressAttr : public StmtAttr { | |||
7748 | unsigned diagnosticIdentifiers_Size; | |||
7749 | StringRef *diagnosticIdentifiers_; | |||
7750 | ||||
7751 | public: | |||
7752 | static SuppressAttr *CreateImplicit(ASTContext &Ctx, StringRef *DiagnosticIdentifiers, unsigned DiagnosticIdentifiersSize, SourceRange Loc = SourceRange()) { | |||
7753 | auto *A = new (Ctx) SuppressAttr(Loc, Ctx, DiagnosticIdentifiers, DiagnosticIdentifiersSize, 0); | |||
7754 | A->setImplicit(true); | |||
7755 | return A; | |||
7756 | } | |||
7757 | ||||
7758 | SuppressAttr(SourceRange R, ASTContext &Ctx | |||
7759 | , StringRef *DiagnosticIdentifiers, unsigned DiagnosticIdentifiersSize | |||
7760 | , unsigned SI | |||
7761 | ) | |||
7762 | : StmtAttr(attr::Suppress, R, SI, false) | |||
7763 | , diagnosticIdentifiers_Size(DiagnosticIdentifiersSize), diagnosticIdentifiers_(new (Ctx, 16) StringRef[diagnosticIdentifiers_Size]) | |||
7764 | { | |||
7765 | for (size_t I = 0, E = diagnosticIdentifiers_Size; I != E; | |||
7766 | ++I) { | |||
7767 | StringRef Ref = DiagnosticIdentifiers[I]; | |||
7768 | if (!Ref.empty()) { | |||
7769 | char *Mem = new (Ctx, 1) char[Ref.size()]; | |||
7770 | std::memcpy(Mem, Ref.data(), Ref.size()); | |||
7771 | diagnosticIdentifiers_[I] = StringRef(Mem, Ref.size()); | |||
7772 | } | |||
7773 | } | |||
7774 | } | |||
7775 | ||||
7776 | SuppressAttr(SourceRange R, ASTContext &Ctx | |||
7777 | , unsigned SI | |||
7778 | ) | |||
7779 | : StmtAttr(attr::Suppress, R, SI, false) | |||
7780 | , diagnosticIdentifiers_Size(0), diagnosticIdentifiers_(nullptr) | |||
7781 | { | |||
7782 | } | |||
7783 | ||||
7784 | SuppressAttr *clone(ASTContext &C) const; | |||
7785 | void printPretty(raw_ostream &OS, | |||
7786 | const PrintingPolicy &Policy) const; | |||
7787 | const char *getSpelling() const; | |||
7788 | typedef StringRef* diagnosticIdentifiers_iterator; | |||
7789 | diagnosticIdentifiers_iterator diagnosticIdentifiers_begin() const { return diagnosticIdentifiers_; } | |||
7790 | diagnosticIdentifiers_iterator diagnosticIdentifiers_end() const { return diagnosticIdentifiers_ + diagnosticIdentifiers_Size; } | |||
7791 | unsigned diagnosticIdentifiers_size() const { return diagnosticIdentifiers_Size; } | |||
7792 | llvm::iterator_range<diagnosticIdentifiers_iterator> diagnosticIdentifiers() const { return llvm::make_range(diagnosticIdentifiers_begin(), diagnosticIdentifiers_end()); } | |||
7793 | ||||
7794 | ||||
7795 | ||||
7796 | ||||
7797 | static bool classof(const Attr *A) { return A->getKind() == attr::Suppress; } | |||
7798 | }; | |||
7799 | ||||
7800 | class SwiftCallAttr : public InheritableAttr { | |||
7801 | public: | |||
7802 | static SwiftCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7803 | auto *A = new (Ctx) SwiftCallAttr(Loc, Ctx, 0); | |||
7804 | A->setImplicit(true); | |||
7805 | return A; | |||
7806 | } | |||
7807 | ||||
7808 | SwiftCallAttr(SourceRange R, ASTContext &Ctx | |||
7809 | , unsigned SI | |||
7810 | ) | |||
7811 | : InheritableAttr(attr::SwiftCall, R, SI, false, false) | |||
7812 | { | |||
7813 | } | |||
7814 | ||||
7815 | SwiftCallAttr *clone(ASTContext &C) const; | |||
7816 | void printPretty(raw_ostream &OS, | |||
7817 | const PrintingPolicy &Policy) const; | |||
7818 | const char *getSpelling() const; | |||
7819 | ||||
7820 | ||||
7821 | static bool classof(const Attr *A) { return A->getKind() == attr::SwiftCall; } | |||
7822 | }; | |||
7823 | ||||
7824 | class SwiftContextAttr : public ParameterABIAttr { | |||
7825 | public: | |||
7826 | static SwiftContextAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7827 | auto *A = new (Ctx) SwiftContextAttr(Loc, Ctx, 0); | |||
7828 | A->setImplicit(true); | |||
7829 | return A; | |||
7830 | } | |||
7831 | ||||
7832 | SwiftContextAttr(SourceRange R, ASTContext &Ctx | |||
7833 | , unsigned SI | |||
7834 | ) | |||
7835 | : ParameterABIAttr(attr::SwiftContext, R, SI, false, false) | |||
7836 | { | |||
7837 | } | |||
7838 | ||||
7839 | SwiftContextAttr *clone(ASTContext &C) const; | |||
7840 | void printPretty(raw_ostream &OS, | |||
7841 | const PrintingPolicy &Policy) const; | |||
7842 | const char *getSpelling() const; | |||
7843 | ||||
7844 | ||||
7845 | static bool classof(const Attr *A) { return A->getKind() == attr::SwiftContext; } | |||
7846 | }; | |||
7847 | ||||
7848 | class SwiftErrorResultAttr : public ParameterABIAttr { | |||
7849 | public: | |||
7850 | static SwiftErrorResultAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7851 | auto *A = new (Ctx) SwiftErrorResultAttr(Loc, Ctx, 0); | |||
7852 | A->setImplicit(true); | |||
7853 | return A; | |||
7854 | } | |||
7855 | ||||
7856 | SwiftErrorResultAttr(SourceRange R, ASTContext &Ctx | |||
7857 | , unsigned SI | |||
7858 | ) | |||
7859 | : ParameterABIAttr(attr::SwiftErrorResult, R, SI, false, false) | |||
7860 | { | |||
7861 | } | |||
7862 | ||||
7863 | SwiftErrorResultAttr *clone(ASTContext &C) const; | |||
7864 | void printPretty(raw_ostream &OS, | |||
7865 | const PrintingPolicy &Policy) const; | |||
7866 | const char *getSpelling() const; | |||
7867 | ||||
7868 | ||||
7869 | static bool classof(const Attr *A) { return A->getKind() == attr::SwiftErrorResult; } | |||
7870 | }; | |||
7871 | ||||
7872 | class SwiftIndirectResultAttr : public ParameterABIAttr { | |||
7873 | public: | |||
7874 | static SwiftIndirectResultAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7875 | auto *A = new (Ctx) SwiftIndirectResultAttr(Loc, Ctx, 0); | |||
7876 | A->setImplicit(true); | |||
7877 | return A; | |||
7878 | } | |||
7879 | ||||
7880 | SwiftIndirectResultAttr(SourceRange R, ASTContext &Ctx | |||
7881 | , unsigned SI | |||
7882 | ) | |||
7883 | : ParameterABIAttr(attr::SwiftIndirectResult, R, SI, false, false) | |||
7884 | { | |||
7885 | } | |||
7886 | ||||
7887 | SwiftIndirectResultAttr *clone(ASTContext &C) const; | |||
7888 | void printPretty(raw_ostream &OS, | |||
7889 | const PrintingPolicy &Policy) const; | |||
7890 | const char *getSpelling() const; | |||
7891 | ||||
7892 | ||||
7893 | static bool classof(const Attr *A) { return A->getKind() == attr::SwiftIndirectResult; } | |||
7894 | }; | |||
7895 | ||||
7896 | class SysVABIAttr : public InheritableAttr { | |||
7897 | public: | |||
7898 | static SysVABIAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
7899 | auto *A = new (Ctx) SysVABIAttr(Loc, Ctx, 0); | |||
7900 | A->setImplicit(true); | |||
7901 | return A; | |||
7902 | } | |||
7903 | ||||
7904 | SysVABIAttr(SourceRange R, ASTContext &Ctx | |||
7905 | , unsigned SI | |||
7906 | ) | |||
7907 | : InheritableAttr(attr::SysVABI, R, SI, false, false) | |||
7908 | { | |||
7909 | } | |||
7910 | ||||
7911 | SysVABIAttr *clone(ASTContext &C) const; | |||
7912 | void printPretty(raw_ostream &OS, | |||
7913 | const PrintingPolicy &Policy) const; | |||
7914 | const char *getSpelling() const; | |||
7915 | ||||
7916 | ||||
7917 | static bool classof(const Attr *A) { return A->getKind() == attr::SysVABI; } | |||
7918 | }; | |||
7919 | ||||
7920 | class TLSModelAttr : public InheritableAttr { | |||
7921 | unsigned modelLength; | |||
7922 | char *model; | |||
7923 | ||||
7924 | public: | |||
7925 | static TLSModelAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Model, SourceRange Loc = SourceRange()) { | |||
7926 | auto *A = new (Ctx) TLSModelAttr(Loc, Ctx, Model, 0); | |||
7927 | A->setImplicit(true); | |||
7928 | return A; | |||
7929 | } | |||
7930 | ||||
7931 | TLSModelAttr(SourceRange R, ASTContext &Ctx | |||
7932 | , llvm::StringRef Model | |||
7933 | , unsigned SI | |||
7934 | ) | |||
7935 | : InheritableAttr(attr::TLSModel, R, SI, false, false) | |||
7936 | , modelLength(Model.size()),model(new (Ctx, 1) char[modelLength]) | |||
7937 | { | |||
7938 | if (!Model.empty()) | |||
7939 | std::memcpy(model, Model.data(), modelLength); | |||
7940 | } | |||
7941 | ||||
7942 | TLSModelAttr *clone(ASTContext &C) const; | |||
7943 | void printPretty(raw_ostream &OS, | |||
7944 | const PrintingPolicy &Policy) const; | |||
7945 | const char *getSpelling() const; | |||
7946 | llvm::StringRef getModel() const { | |||
7947 | return llvm::StringRef(model, modelLength); | |||
7948 | } | |||
7949 | unsigned getModelLength() const { | |||
7950 | return modelLength; | |||
7951 | } | |||
7952 | void setModel(ASTContext &C, llvm::StringRef S) { | |||
7953 | modelLength = S.size(); | |||
7954 | this->model = new (C, 1) char [modelLength]; | |||
7955 | if (!S.empty()) | |||
7956 | std::memcpy(this->model, S.data(), modelLength); | |||
7957 | } | |||
7958 | ||||
7959 | ||||
7960 | ||||
7961 | static bool classof(const Attr *A) { return A->getKind() == attr::TLSModel; } | |||
7962 | }; | |||
7963 | ||||
7964 | class TargetAttr : public InheritableAttr { | |||
7965 | unsigned featuresStrLength; | |||
7966 | char *featuresStr; | |||
7967 | ||||
7968 | public: | |||
7969 | static TargetAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef FeaturesStr, SourceRange Loc = SourceRange()) { | |||
7970 | auto *A = new (Ctx) TargetAttr(Loc, Ctx, FeaturesStr, 0); | |||
7971 | A->setImplicit(true); | |||
7972 | return A; | |||
7973 | } | |||
7974 | ||||
7975 | TargetAttr(SourceRange R, ASTContext &Ctx | |||
7976 | , llvm::StringRef FeaturesStr | |||
7977 | , unsigned SI | |||
7978 | ) | |||
7979 | : InheritableAttr(attr::Target, R, SI, false, false) | |||
7980 | , featuresStrLength(FeaturesStr.size()),featuresStr(new (Ctx, 1) char[featuresStrLength]) | |||
7981 | { | |||
7982 | if (!FeaturesStr.empty()) | |||
7983 | std::memcpy(featuresStr, FeaturesStr.data(), featuresStrLength); | |||
7984 | } | |||
7985 | ||||
7986 | TargetAttr *clone(ASTContext &C) const; | |||
7987 | void printPretty(raw_ostream &OS, | |||
7988 | const PrintingPolicy &Policy) const; | |||
7989 | const char *getSpelling() const; | |||
7990 | llvm::StringRef getFeaturesStr() const { | |||
7991 | return llvm::StringRef(featuresStr, featuresStrLength); | |||
7992 | } | |||
7993 | unsigned getFeaturesStrLength() const { | |||
7994 | return featuresStrLength; | |||
7995 | } | |||
7996 | void setFeaturesStr(ASTContext &C, llvm::StringRef S) { | |||
7997 | featuresStrLength = S.size(); | |||
7998 | this->featuresStr = new (C, 1) char [featuresStrLength]; | |||
7999 | if (!S.empty()) | |||
8000 | std::memcpy(this->featuresStr, S.data(), featuresStrLength); | |||
8001 | } | |||
8002 | ||||
8003 | ||||
8004 | struct ParsedTargetAttr { | |||
8005 | std::vector<std::string> Features; | |||
8006 | StringRef Architecture; | |||
8007 | bool DuplicateArchitecture = false; | |||
8008 | bool operator ==(const ParsedTargetAttr &Other) const { | |||
8009 | return DuplicateArchitecture == Other.DuplicateArchitecture && | |||
8010 | Architecture == Other.Architecture && Features == Other.Features; | |||
8011 | } | |||
8012 | }; | |||
8013 | ParsedTargetAttr parse() const { | |||
8014 | return parse(getFeaturesStr()); | |||
8015 | } | |||
8016 | ||||
8017 | template<class Compare> | |||
8018 | ParsedTargetAttr parse(Compare cmp) const { | |||
8019 | ParsedTargetAttr Attrs = parse(); | |||
8020 | llvm::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp); | |||
8021 | return Attrs; | |||
8022 | } | |||
8023 | ||||
8024 | bool isDefaultVersion() const { return getFeaturesStr() == "default"; } | |||
8025 | ||||
8026 | static ParsedTargetAttr parse(StringRef Features) { | |||
8027 | ParsedTargetAttr Ret; | |||
8028 | if (Features == "default") return Ret; | |||
8029 | SmallVector<StringRef, 1> AttrFeatures; | |||
8030 | Features.split(AttrFeatures, ","); | |||
8031 | ||||
8032 | // Grab the various features and prepend a "+" to turn on the feature to | |||
8033 | // the backend and add them to our existing set of features. | |||
8034 | for (auto &Feature : AttrFeatures) { | |||
8035 | // Go ahead and trim whitespace rather than either erroring or | |||
8036 | // accepting it weirdly. | |||
8037 | Feature = Feature.trim(); | |||
8038 | ||||
8039 | // We don't support cpu tuning this way currently. | |||
8040 | // TODO: Support the fpmath option. It will require checking | |||
8041 | // overall feature validity for the function with the rest of the | |||
8042 | // attributes on the function. | |||
8043 | if (Feature.startswith("fpmath=") || Feature.startswith("tune=")) | |||
8044 | continue; | |||
8045 | ||||
8046 | // While we're here iterating check for a different target cpu. | |||
8047 | if (Feature.startswith("arch=")) { | |||
8048 | if (!Ret.Architecture.empty()) | |||
8049 | Ret.DuplicateArchitecture = true; | |||
8050 | else | |||
8051 | Ret.Architecture = Feature.split("=").second.trim(); | |||
8052 | } else if (Feature.startswith("no-")) | |||
8053 | Ret.Features.push_back("-" + Feature.split("-").second.str()); | |||
8054 | else | |||
8055 | Ret.Features.push_back("+" + Feature.str()); | |||
8056 | } | |||
8057 | return Ret; | |||
8058 | } | |||
8059 | ||||
8060 | ||||
8061 | static bool classof(const Attr *A) { return A->getKind() == attr::Target; } | |||
8062 | }; | |||
8063 | ||||
8064 | class TestTypestateAttr : public InheritableAttr { | |||
8065 | public: | |||
8066 | enum ConsumedState { | |||
8067 | Consumed, | |||
8068 | Unconsumed | |||
8069 | }; | |||
8070 | private: | |||
8071 | ConsumedState testState; | |||
8072 | ||||
8073 | public: | |||
8074 | static TestTypestateAttr *CreateImplicit(ASTContext &Ctx, ConsumedState TestState, SourceRange Loc = SourceRange()) { | |||
8075 | auto *A = new (Ctx) TestTypestateAttr(Loc, Ctx, TestState, 0); | |||
8076 | A->setImplicit(true); | |||
8077 | return A; | |||
8078 | } | |||
8079 | ||||
8080 | TestTypestateAttr(SourceRange R, ASTContext &Ctx | |||
8081 | , ConsumedState TestState | |||
8082 | , unsigned SI | |||
8083 | ) | |||
8084 | : InheritableAttr(attr::TestTypestate, R, SI, false, false) | |||
8085 | , testState(TestState) | |||
8086 | { | |||
8087 | } | |||
8088 | ||||
8089 | TestTypestateAttr *clone(ASTContext &C) const; | |||
8090 | void printPretty(raw_ostream &OS, | |||
8091 | const PrintingPolicy &Policy) const; | |||
8092 | const char *getSpelling() const; | |||
8093 | ConsumedState getTestState() const { | |||
8094 | return testState; | |||
8095 | } | |||
8096 | ||||
8097 | static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) { | |||
8098 | Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val) | |||
8099 | .Case("consumed", TestTypestateAttr::Consumed) | |||
8100 | .Case("unconsumed", TestTypestateAttr::Unconsumed) | |||
8101 | .Default(Optional<ConsumedState>()); | |||
8102 | if (R) { | |||
8103 | Out = *R; | |||
8104 | return true; | |||
8105 | } | |||
8106 | return false; | |||
8107 | } | |||
8108 | ||||
8109 | static const char *ConvertConsumedStateToStr(ConsumedState Val) { | |||
8110 | switch(Val) { | |||
8111 | case TestTypestateAttr::Consumed: return "consumed"; | |||
8112 | case TestTypestateAttr::Unconsumed: return "unconsumed"; | |||
8113 | } | |||
8114 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 8114); | |||
8115 | } | |||
8116 | ||||
8117 | ||||
8118 | static bool classof(const Attr *A) { return A->getKind() == attr::TestTypestate; } | |||
8119 | }; | |||
8120 | ||||
8121 | class ThisCallAttr : public InheritableAttr { | |||
8122 | public: | |||
8123 | static ThisCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8124 | auto *A = new (Ctx) ThisCallAttr(Loc, Ctx, 0); | |||
8125 | A->setImplicit(true); | |||
8126 | return A; | |||
8127 | } | |||
8128 | ||||
8129 | ThisCallAttr(SourceRange R, ASTContext &Ctx | |||
8130 | , unsigned SI | |||
8131 | ) | |||
8132 | : InheritableAttr(attr::ThisCall, R, SI, false, false) | |||
8133 | { | |||
8134 | } | |||
8135 | ||||
8136 | ThisCallAttr *clone(ASTContext &C) const; | |||
8137 | void printPretty(raw_ostream &OS, | |||
8138 | const PrintingPolicy &Policy) const; | |||
8139 | const char *getSpelling() const; | |||
8140 | ||||
8141 | ||||
8142 | static bool classof(const Attr *A) { return A->getKind() == attr::ThisCall; } | |||
8143 | }; | |||
8144 | ||||
8145 | class ThreadAttr : public Attr { | |||
8146 | public: | |||
8147 | static ThreadAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8148 | auto *A = new (Ctx) ThreadAttr(Loc, Ctx, 0); | |||
8149 | A->setImplicit(true); | |||
8150 | return A; | |||
8151 | } | |||
8152 | ||||
8153 | ThreadAttr(SourceRange R, ASTContext &Ctx | |||
8154 | , unsigned SI | |||
8155 | ) | |||
8156 | : Attr(attr::Thread, R, SI, false) | |||
8157 | { | |||
8158 | } | |||
8159 | ||||
8160 | ThreadAttr *clone(ASTContext &C) const; | |||
8161 | void printPretty(raw_ostream &OS, | |||
8162 | const PrintingPolicy &Policy) const; | |||
8163 | const char *getSpelling() const; | |||
8164 | ||||
8165 | ||||
8166 | static bool classof(const Attr *A) { return A->getKind() == attr::Thread; } | |||
8167 | }; | |||
8168 | ||||
8169 | class TransparentUnionAttr : public InheritableAttr { | |||
8170 | public: | |||
8171 | static TransparentUnionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8172 | auto *A = new (Ctx) TransparentUnionAttr(Loc, Ctx, 0); | |||
8173 | A->setImplicit(true); | |||
8174 | return A; | |||
8175 | } | |||
8176 | ||||
8177 | TransparentUnionAttr(SourceRange R, ASTContext &Ctx | |||
8178 | , unsigned SI | |||
8179 | ) | |||
8180 | : InheritableAttr(attr::TransparentUnion, R, SI, false, false) | |||
8181 | { | |||
8182 | } | |||
8183 | ||||
8184 | TransparentUnionAttr *clone(ASTContext &C) const; | |||
8185 | void printPretty(raw_ostream &OS, | |||
8186 | const PrintingPolicy &Policy) const; | |||
8187 | const char *getSpelling() const; | |||
8188 | ||||
8189 | ||||
8190 | static bool classof(const Attr *A) { return A->getKind() == attr::TransparentUnion; } | |||
8191 | }; | |||
8192 | ||||
8193 | class TrivialABIAttr : public InheritableAttr { | |||
8194 | public: | |||
8195 | static TrivialABIAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8196 | auto *A = new (Ctx) TrivialABIAttr(Loc, Ctx, 0); | |||
8197 | A->setImplicit(true); | |||
8198 | return A; | |||
8199 | } | |||
8200 | ||||
8201 | TrivialABIAttr(SourceRange R, ASTContext &Ctx | |||
8202 | , unsigned SI | |||
8203 | ) | |||
8204 | : InheritableAttr(attr::TrivialABI, R, SI, false, false) | |||
8205 | { | |||
8206 | } | |||
8207 | ||||
8208 | TrivialABIAttr *clone(ASTContext &C) const; | |||
8209 | void printPretty(raw_ostream &OS, | |||
8210 | const PrintingPolicy &Policy) const; | |||
8211 | const char *getSpelling() const; | |||
8212 | ||||
8213 | ||||
8214 | static bool classof(const Attr *A) { return A->getKind() == attr::TrivialABI; } | |||
8215 | }; | |||
8216 | ||||
8217 | class TryAcquireCapabilityAttr : public InheritableAttr { | |||
8218 | Expr * successValue; | |||
8219 | ||||
8220 | unsigned args_Size; | |||
8221 | Expr * *args_; | |||
8222 | ||||
8223 | public: | |||
8224 | enum Spelling { | |||
8225 | GNU_try_acquire_capability = 0, | |||
8226 | CXX11_clang_try_acquire_capability = 1, | |||
8227 | GNU_try_acquire_shared_capability = 2, | |||
8228 | CXX11_clang_try_acquire_shared_capability = 3 | |||
8229 | }; | |||
8230 | ||||
8231 | static TryAcquireCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * SuccessValue, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) { | |||
8232 | auto *A = new (Ctx) TryAcquireCapabilityAttr(Loc, Ctx, SuccessValue, Args, ArgsSize, S); | |||
8233 | A->setImplicit(true); | |||
8234 | return A; | |||
8235 | } | |||
8236 | ||||
8237 | TryAcquireCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
8238 | , Expr * SuccessValue | |||
8239 | , Expr * *Args, unsigned ArgsSize | |||
8240 | , unsigned SI | |||
8241 | ) | |||
8242 | : InheritableAttr(attr::TryAcquireCapability, R, SI, true, true) | |||
8243 | , successValue(SuccessValue) | |||
8244 | , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size]) | |||
8245 | { | |||
8246 | std::copy(Args, Args + args_Size, args_); | |||
8247 | } | |||
8248 | ||||
8249 | TryAcquireCapabilityAttr(SourceRange R, ASTContext &Ctx | |||
8250 | , Expr * SuccessValue | |||
8251 | , unsigned SI | |||
8252 | ) | |||
8253 | : InheritableAttr(attr::TryAcquireCapability, R, SI, true, true) | |||
8254 | , successValue(SuccessValue) | |||
8255 | , args_Size(0), args_(nullptr) | |||
8256 | { | |||
8257 | } | |||
8258 | ||||
8259 | TryAcquireCapabilityAttr *clone(ASTContext &C) const; | |||
8260 | void printPretty(raw_ostream &OS, | |||
8261 | const PrintingPolicy &Policy) const; | |||
8262 | const char *getSpelling() const; | |||
8263 | Spelling getSemanticSpelling() const { | |||
8264 | switch (SpellingListIndex) { | |||
8265 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 8265); | |||
8266 | case 0: return GNU_try_acquire_capability; | |||
8267 | case 1: return CXX11_clang_try_acquire_capability; | |||
8268 | case 2: return GNU_try_acquire_shared_capability; | |||
8269 | case 3: return CXX11_clang_try_acquire_shared_capability; | |||
8270 | } | |||
8271 | } | |||
8272 | bool isShared() const { return SpellingListIndex == 2 || | |||
8273 | SpellingListIndex == 3; } | |||
8274 | Expr * getSuccessValue() const { | |||
8275 | return successValue; | |||
8276 | } | |||
8277 | ||||
8278 | typedef Expr ** args_iterator; | |||
8279 | args_iterator args_begin() const { return args_; } | |||
8280 | args_iterator args_end() const { return args_ + args_Size; } | |||
8281 | unsigned args_size() const { return args_Size; } | |||
8282 | llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); } | |||
8283 | ||||
8284 | ||||
8285 | ||||
8286 | ||||
8287 | static bool classof(const Attr *A) { return A->getKind() == attr::TryAcquireCapability; } | |||
8288 | }; | |||
8289 | ||||
8290 | class TypeTagForDatatypeAttr : public InheritableAttr { | |||
8291 | IdentifierInfo * argumentKind; | |||
8292 | ||||
8293 | TypeSourceInfo * matchingCType; | |||
8294 | ||||
8295 | bool layoutCompatible; | |||
8296 | ||||
8297 | bool mustBeNull; | |||
8298 | ||||
8299 | public: | |||
8300 | static TypeTagForDatatypeAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * ArgumentKind, TypeSourceInfo * MatchingCType, bool LayoutCompatible, bool MustBeNull, SourceRange Loc = SourceRange()) { | |||
8301 | auto *A = new (Ctx) TypeTagForDatatypeAttr(Loc, Ctx, ArgumentKind, MatchingCType, LayoutCompatible, MustBeNull, 0); | |||
8302 | A->setImplicit(true); | |||
8303 | return A; | |||
8304 | } | |||
8305 | ||||
8306 | TypeTagForDatatypeAttr(SourceRange R, ASTContext &Ctx | |||
8307 | , IdentifierInfo * ArgumentKind | |||
8308 | , TypeSourceInfo * MatchingCType | |||
8309 | , bool LayoutCompatible | |||
8310 | , bool MustBeNull | |||
8311 | , unsigned SI | |||
8312 | ) | |||
8313 | : InheritableAttr(attr::TypeTagForDatatype, R, SI, false, false) | |||
8314 | , argumentKind(ArgumentKind) | |||
8315 | , matchingCType(MatchingCType) | |||
8316 | , layoutCompatible(LayoutCompatible) | |||
8317 | , mustBeNull(MustBeNull) | |||
8318 | { | |||
8319 | } | |||
8320 | ||||
8321 | TypeTagForDatatypeAttr *clone(ASTContext &C) const; | |||
8322 | void printPretty(raw_ostream &OS, | |||
8323 | const PrintingPolicy &Policy) const; | |||
8324 | const char *getSpelling() const; | |||
8325 | IdentifierInfo * getArgumentKind() const { | |||
8326 | return argumentKind; | |||
8327 | } | |||
8328 | ||||
8329 | QualType getMatchingCType() const { | |||
8330 | return matchingCType->getType(); | |||
8331 | } TypeSourceInfo * getMatchingCTypeLoc() const { | |||
8332 | return matchingCType; | |||
8333 | } | |||
8334 | ||||
8335 | bool getLayoutCompatible() const { | |||
8336 | return layoutCompatible; | |||
8337 | } | |||
8338 | ||||
8339 | bool getMustBeNull() const { | |||
8340 | return mustBeNull; | |||
8341 | } | |||
8342 | ||||
8343 | ||||
8344 | ||||
8345 | static bool classof(const Attr *A) { return A->getKind() == attr::TypeTagForDatatype; } | |||
8346 | }; | |||
8347 | ||||
8348 | class TypeVisibilityAttr : public InheritableAttr { | |||
8349 | public: | |||
8350 | enum VisibilityType { | |||
8351 | Default, | |||
8352 | Hidden, | |||
8353 | Protected | |||
8354 | }; | |||
8355 | private: | |||
8356 | VisibilityType visibility; | |||
8357 | ||||
8358 | public: | |||
8359 | static TypeVisibilityAttr *CreateImplicit(ASTContext &Ctx, VisibilityType Visibility, SourceRange Loc = SourceRange()) { | |||
8360 | auto *A = new (Ctx) TypeVisibilityAttr(Loc, Ctx, Visibility, 0); | |||
8361 | A->setImplicit(true); | |||
8362 | return A; | |||
8363 | } | |||
8364 | ||||
8365 | TypeVisibilityAttr(SourceRange R, ASTContext &Ctx | |||
8366 | , VisibilityType Visibility | |||
8367 | , unsigned SI | |||
8368 | ) | |||
8369 | : InheritableAttr(attr::TypeVisibility, R, SI, false, false) | |||
8370 | , visibility(Visibility) | |||
8371 | { | |||
8372 | } | |||
8373 | ||||
8374 | TypeVisibilityAttr *clone(ASTContext &C) const; | |||
8375 | void printPretty(raw_ostream &OS, | |||
8376 | const PrintingPolicy &Policy) const; | |||
8377 | const char *getSpelling() const; | |||
8378 | VisibilityType getVisibility() const { | |||
8379 | return visibility; | |||
8380 | } | |||
8381 | ||||
8382 | static bool ConvertStrToVisibilityType(StringRef Val, VisibilityType &Out) { | |||
8383 | Optional<VisibilityType> R = llvm::StringSwitch<Optional<VisibilityType>>(Val) | |||
8384 | .Case("default", TypeVisibilityAttr::Default) | |||
8385 | .Case("hidden", TypeVisibilityAttr::Hidden) | |||
8386 | .Case("internal", TypeVisibilityAttr::Hidden) | |||
8387 | .Case("protected", TypeVisibilityAttr::Protected) | |||
8388 | .Default(Optional<VisibilityType>()); | |||
8389 | if (R) { | |||
8390 | Out = *R; | |||
8391 | return true; | |||
8392 | } | |||
8393 | return false; | |||
8394 | } | |||
8395 | ||||
8396 | static const char *ConvertVisibilityTypeToStr(VisibilityType Val) { | |||
8397 | switch(Val) { | |||
8398 | case TypeVisibilityAttr::Default: return "default"; | |||
8399 | case TypeVisibilityAttr::Hidden: return "hidden"; | |||
8400 | case TypeVisibilityAttr::Protected: return "protected"; | |||
8401 | } | |||
8402 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 8402); | |||
8403 | } | |||
8404 | ||||
8405 | ||||
8406 | static bool classof(const Attr *A) { return A->getKind() == attr::TypeVisibility; } | |||
8407 | }; | |||
8408 | ||||
8409 | class UnavailableAttr : public InheritableAttr { | |||
8410 | unsigned messageLength; | |||
8411 | char *message; | |||
8412 | ||||
8413 | public: | |||
8414 | enum ImplicitReason { | |||
8415 | IR_None, | |||
8416 | IR_ARCForbiddenType, | |||
8417 | IR_ForbiddenWeak, | |||
8418 | IR_ARCForbiddenConversion, | |||
8419 | IR_ARCInitReturnsUnrelated, | |||
8420 | IR_ARCFieldWithOwnership | |||
8421 | }; | |||
8422 | private: | |||
8423 | ImplicitReason implicitReason; | |||
8424 | ||||
8425 | public: | |||
8426 | static UnavailableAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Message, ImplicitReason ImplicitReason, SourceRange Loc = SourceRange()) { | |||
8427 | auto *A = new (Ctx) UnavailableAttr(Loc, Ctx, Message, ImplicitReason, 0); | |||
8428 | A->setImplicit(true); | |||
8429 | return A; | |||
8430 | } | |||
8431 | ||||
8432 | static UnavailableAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Message, SourceRange Loc = SourceRange()) { | |||
8433 | auto *A = new (Ctx) UnavailableAttr(Loc, Ctx, Message, 0); | |||
8434 | A->setImplicit(true); | |||
8435 | return A; | |||
8436 | } | |||
8437 | ||||
8438 | UnavailableAttr(SourceRange R, ASTContext &Ctx | |||
8439 | , llvm::StringRef Message | |||
8440 | , ImplicitReason ImplicitReason | |||
8441 | , unsigned SI | |||
8442 | ) | |||
8443 | : InheritableAttr(attr::Unavailable, R, SI, false, false) | |||
8444 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
8445 | , implicitReason(ImplicitReason) | |||
8446 | { | |||
8447 | if (!Message.empty()) | |||
8448 | std::memcpy(message, Message.data(), messageLength); | |||
8449 | } | |||
8450 | ||||
8451 | UnavailableAttr(SourceRange R, ASTContext &Ctx | |||
8452 | , llvm::StringRef Message | |||
8453 | , unsigned SI | |||
8454 | ) | |||
8455 | : InheritableAttr(attr::Unavailable, R, SI, false, false) | |||
8456 | , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength]) | |||
8457 | , implicitReason(ImplicitReason(0)) | |||
8458 | { | |||
8459 | if (!Message.empty()) | |||
8460 | std::memcpy(message, Message.data(), messageLength); | |||
8461 | } | |||
8462 | ||||
8463 | UnavailableAttr(SourceRange R, ASTContext &Ctx | |||
8464 | , unsigned SI | |||
8465 | ) | |||
8466 | : InheritableAttr(attr::Unavailable, R, SI, false, false) | |||
8467 | , messageLength(0),message(nullptr) | |||
8468 | , implicitReason(ImplicitReason(0)) | |||
8469 | { | |||
8470 | } | |||
8471 | ||||
8472 | UnavailableAttr *clone(ASTContext &C) const; | |||
8473 | void printPretty(raw_ostream &OS, | |||
8474 | const PrintingPolicy &Policy) const; | |||
8475 | const char *getSpelling() const; | |||
8476 | llvm::StringRef getMessage() const { | |||
8477 | return llvm::StringRef(message, messageLength); | |||
8478 | } | |||
8479 | unsigned getMessageLength() const { | |||
8480 | return messageLength; | |||
8481 | } | |||
8482 | void setMessage(ASTContext &C, llvm::StringRef S) { | |||
8483 | messageLength = S.size(); | |||
8484 | this->message = new (C, 1) char [messageLength]; | |||
8485 | if (!S.empty()) | |||
8486 | std::memcpy(this->message, S.data(), messageLength); | |||
8487 | } | |||
8488 | ||||
8489 | ImplicitReason getImplicitReason() const { | |||
8490 | return implicitReason; | |||
8491 | } | |||
8492 | ||||
8493 | ||||
8494 | ||||
8495 | static bool classof(const Attr *A) { return A->getKind() == attr::Unavailable; } | |||
8496 | }; | |||
8497 | ||||
8498 | class UnusedAttr : public InheritableAttr { | |||
8499 | public: | |||
8500 | enum Spelling { | |||
8501 | CXX11_maybe_unused = 0, | |||
8502 | GNU_unused = 1, | |||
8503 | CXX11_gnu_unused = 2, | |||
8504 | C2x_maybe_unused = 3 | |||
8505 | }; | |||
8506 | ||||
8507 | static UnusedAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
8508 | auto *A = new (Ctx) UnusedAttr(Loc, Ctx, S); | |||
8509 | A->setImplicit(true); | |||
8510 | return A; | |||
8511 | } | |||
8512 | ||||
8513 | UnusedAttr(SourceRange R, ASTContext &Ctx | |||
8514 | , unsigned SI | |||
8515 | ) | |||
8516 | : InheritableAttr(attr::Unused, R, SI, false, false) | |||
8517 | { | |||
8518 | } | |||
8519 | ||||
8520 | UnusedAttr *clone(ASTContext &C) const; | |||
8521 | void printPretty(raw_ostream &OS, | |||
8522 | const PrintingPolicy &Policy) const; | |||
8523 | const char *getSpelling() const; | |||
8524 | Spelling getSemanticSpelling() const { | |||
8525 | switch (SpellingListIndex) { | |||
8526 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 8526); | |||
8527 | case 0: return CXX11_maybe_unused; | |||
8528 | case 1: return GNU_unused; | |||
8529 | case 2: return CXX11_gnu_unused; | |||
8530 | case 3: return C2x_maybe_unused; | |||
8531 | } | |||
8532 | } | |||
8533 | ||||
8534 | ||||
8535 | static bool classof(const Attr *A) { return A->getKind() == attr::Unused; } | |||
8536 | }; | |||
8537 | ||||
8538 | class UsedAttr : public InheritableAttr { | |||
8539 | public: | |||
8540 | static UsedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8541 | auto *A = new (Ctx) UsedAttr(Loc, Ctx, 0); | |||
8542 | A->setImplicit(true); | |||
8543 | return A; | |||
8544 | } | |||
8545 | ||||
8546 | UsedAttr(SourceRange R, ASTContext &Ctx | |||
8547 | , unsigned SI | |||
8548 | ) | |||
8549 | : InheritableAttr(attr::Used, R, SI, false, false) | |||
8550 | { | |||
8551 | } | |||
8552 | ||||
8553 | UsedAttr *clone(ASTContext &C) const; | |||
8554 | void printPretty(raw_ostream &OS, | |||
8555 | const PrintingPolicy &Policy) const; | |||
8556 | const char *getSpelling() const; | |||
8557 | ||||
8558 | ||||
8559 | static bool classof(const Attr *A) { return A->getKind() == attr::Used; } | |||
8560 | }; | |||
8561 | ||||
8562 | class UuidAttr : public InheritableAttr { | |||
8563 | unsigned guidLength; | |||
8564 | char *guid; | |||
8565 | ||||
8566 | public: | |||
8567 | static UuidAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Guid, SourceRange Loc = SourceRange()) { | |||
8568 | auto *A = new (Ctx) UuidAttr(Loc, Ctx, Guid, 0); | |||
8569 | A->setImplicit(true); | |||
8570 | return A; | |||
8571 | } | |||
8572 | ||||
8573 | UuidAttr(SourceRange R, ASTContext &Ctx | |||
8574 | , llvm::StringRef Guid | |||
8575 | , unsigned SI | |||
8576 | ) | |||
8577 | : InheritableAttr(attr::Uuid, R, SI, false, false) | |||
8578 | , guidLength(Guid.size()),guid(new (Ctx, 1) char[guidLength]) | |||
8579 | { | |||
8580 | if (!Guid.empty()) | |||
8581 | std::memcpy(guid, Guid.data(), guidLength); | |||
8582 | } | |||
8583 | ||||
8584 | UuidAttr *clone(ASTContext &C) const; | |||
8585 | void printPretty(raw_ostream &OS, | |||
8586 | const PrintingPolicy &Policy) const; | |||
8587 | const char *getSpelling() const; | |||
8588 | llvm::StringRef getGuid() const { | |||
8589 | return llvm::StringRef(guid, guidLength); | |||
8590 | } | |||
8591 | unsigned getGuidLength() const { | |||
8592 | return guidLength; | |||
8593 | } | |||
8594 | void setGuid(ASTContext &C, llvm::StringRef S) { | |||
8595 | guidLength = S.size(); | |||
8596 | this->guid = new (C, 1) char [guidLength]; | |||
8597 | if (!S.empty()) | |||
8598 | std::memcpy(this->guid, S.data(), guidLength); | |||
8599 | } | |||
8600 | ||||
8601 | ||||
8602 | ||||
8603 | static bool classof(const Attr *A) { return A->getKind() == attr::Uuid; } | |||
8604 | }; | |||
8605 | ||||
8606 | class VecReturnAttr : public InheritableAttr { | |||
8607 | public: | |||
8608 | static VecReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8609 | auto *A = new (Ctx) VecReturnAttr(Loc, Ctx, 0); | |||
8610 | A->setImplicit(true); | |||
8611 | return A; | |||
8612 | } | |||
8613 | ||||
8614 | VecReturnAttr(SourceRange R, ASTContext &Ctx | |||
8615 | , unsigned SI | |||
8616 | ) | |||
8617 | : InheritableAttr(attr::VecReturn, R, SI, false, false) | |||
8618 | { | |||
8619 | } | |||
8620 | ||||
8621 | VecReturnAttr *clone(ASTContext &C) const; | |||
8622 | void printPretty(raw_ostream &OS, | |||
8623 | const PrintingPolicy &Policy) const; | |||
8624 | const char *getSpelling() const; | |||
8625 | ||||
8626 | ||||
8627 | static bool classof(const Attr *A) { return A->getKind() == attr::VecReturn; } | |||
8628 | }; | |||
8629 | ||||
8630 | class VecTypeHintAttr : public InheritableAttr { | |||
8631 | TypeSourceInfo * typeHint; | |||
8632 | ||||
8633 | public: | |||
8634 | static VecTypeHintAttr *CreateImplicit(ASTContext &Ctx, TypeSourceInfo * TypeHint, SourceRange Loc = SourceRange()) { | |||
8635 | auto *A = new (Ctx) VecTypeHintAttr(Loc, Ctx, TypeHint, 0); | |||
8636 | A->setImplicit(true); | |||
8637 | return A; | |||
8638 | } | |||
8639 | ||||
8640 | VecTypeHintAttr(SourceRange R, ASTContext &Ctx | |||
8641 | , TypeSourceInfo * TypeHint | |||
8642 | , unsigned SI | |||
8643 | ) | |||
8644 | : InheritableAttr(attr::VecTypeHint, R, SI, false, false) | |||
8645 | , typeHint(TypeHint) | |||
8646 | { | |||
8647 | } | |||
8648 | ||||
8649 | VecTypeHintAttr *clone(ASTContext &C) const; | |||
8650 | void printPretty(raw_ostream &OS, | |||
8651 | const PrintingPolicy &Policy) const; | |||
8652 | const char *getSpelling() const; | |||
8653 | QualType getTypeHint() const { | |||
8654 | return typeHint->getType(); | |||
8655 | } TypeSourceInfo * getTypeHintLoc() const { | |||
8656 | return typeHint; | |||
8657 | } | |||
8658 | ||||
8659 | ||||
8660 | ||||
8661 | static bool classof(const Attr *A) { return A->getKind() == attr::VecTypeHint; } | |||
8662 | }; | |||
8663 | ||||
8664 | class VectorCallAttr : public InheritableAttr { | |||
8665 | public: | |||
8666 | static VectorCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8667 | auto *A = new (Ctx) VectorCallAttr(Loc, Ctx, 0); | |||
8668 | A->setImplicit(true); | |||
8669 | return A; | |||
8670 | } | |||
8671 | ||||
8672 | VectorCallAttr(SourceRange R, ASTContext &Ctx | |||
8673 | , unsigned SI | |||
8674 | ) | |||
8675 | : InheritableAttr(attr::VectorCall, R, SI, false, false) | |||
8676 | { | |||
8677 | } | |||
8678 | ||||
8679 | VectorCallAttr *clone(ASTContext &C) const; | |||
8680 | void printPretty(raw_ostream &OS, | |||
8681 | const PrintingPolicy &Policy) const; | |||
8682 | const char *getSpelling() const; | |||
8683 | ||||
8684 | ||||
8685 | static bool classof(const Attr *A) { return A->getKind() == attr::VectorCall; } | |||
8686 | }; | |||
8687 | ||||
8688 | class VisibilityAttr : public InheritableAttr { | |||
8689 | public: | |||
8690 | enum VisibilityType { | |||
8691 | Default, | |||
8692 | Hidden, | |||
8693 | Protected | |||
8694 | }; | |||
8695 | private: | |||
8696 | VisibilityType visibility; | |||
8697 | ||||
8698 | public: | |||
8699 | static VisibilityAttr *CreateImplicit(ASTContext &Ctx, VisibilityType Visibility, SourceRange Loc = SourceRange()) { | |||
8700 | auto *A = new (Ctx) VisibilityAttr(Loc, Ctx, Visibility, 0); | |||
8701 | A->setImplicit(true); | |||
8702 | return A; | |||
8703 | } | |||
8704 | ||||
8705 | VisibilityAttr(SourceRange R, ASTContext &Ctx | |||
8706 | , VisibilityType Visibility | |||
8707 | , unsigned SI | |||
8708 | ) | |||
8709 | : InheritableAttr(attr::Visibility, R, SI, false, false) | |||
8710 | , visibility(Visibility) | |||
8711 | { | |||
8712 | } | |||
8713 | ||||
8714 | VisibilityAttr *clone(ASTContext &C) const; | |||
8715 | void printPretty(raw_ostream &OS, | |||
8716 | const PrintingPolicy &Policy) const; | |||
8717 | const char *getSpelling() const; | |||
8718 | VisibilityType getVisibility() const { | |||
8719 | return visibility; | |||
8720 | } | |||
8721 | ||||
8722 | static bool ConvertStrToVisibilityType(StringRef Val, VisibilityType &Out) { | |||
8723 | Optional<VisibilityType> R = llvm::StringSwitch<Optional<VisibilityType>>(Val) | |||
8724 | .Case("default", VisibilityAttr::Default) | |||
8725 | .Case("hidden", VisibilityAttr::Hidden) | |||
8726 | .Case("internal", VisibilityAttr::Hidden) | |||
8727 | .Case("protected", VisibilityAttr::Protected) | |||
8728 | .Default(Optional<VisibilityType>()); | |||
8729 | if (R) { | |||
8730 | Out = *R; | |||
8731 | return true; | |||
8732 | } | |||
8733 | return false; | |||
8734 | } | |||
8735 | ||||
8736 | static const char *ConvertVisibilityTypeToStr(VisibilityType Val) { | |||
8737 | switch(Val) { | |||
8738 | case VisibilityAttr::Default: return "default"; | |||
8739 | case VisibilityAttr::Hidden: return "hidden"; | |||
8740 | case VisibilityAttr::Protected: return "protected"; | |||
8741 | } | |||
8742 | llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 8742); | |||
8743 | } | |||
8744 | ||||
8745 | ||||
8746 | static bool classof(const Attr *A) { return A->getKind() == attr::Visibility; } | |||
8747 | }; | |||
8748 | ||||
8749 | class WarnUnusedAttr : public InheritableAttr { | |||
8750 | public: | |||
8751 | static WarnUnusedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8752 | auto *A = new (Ctx) WarnUnusedAttr(Loc, Ctx, 0); | |||
8753 | A->setImplicit(true); | |||
8754 | return A; | |||
8755 | } | |||
8756 | ||||
8757 | WarnUnusedAttr(SourceRange R, ASTContext &Ctx | |||
8758 | , unsigned SI | |||
8759 | ) | |||
8760 | : InheritableAttr(attr::WarnUnused, R, SI, false, false) | |||
8761 | { | |||
8762 | } | |||
8763 | ||||
8764 | WarnUnusedAttr *clone(ASTContext &C) const; | |||
8765 | void printPretty(raw_ostream &OS, | |||
8766 | const PrintingPolicy &Policy) const; | |||
8767 | const char *getSpelling() const; | |||
8768 | ||||
8769 | ||||
8770 | static bool classof(const Attr *A) { return A->getKind() == attr::WarnUnused; } | |||
8771 | }; | |||
8772 | ||||
8773 | class WarnUnusedResultAttr : public InheritableAttr { | |||
8774 | public: | |||
8775 | enum Spelling { | |||
8776 | CXX11_nodiscard = 0, | |||
8777 | C2x_nodiscard = 1, | |||
8778 | CXX11_clang_warn_unused_result = 2, | |||
8779 | GNU_warn_unused_result = 3, | |||
8780 | CXX11_gnu_warn_unused_result = 4 | |||
8781 | }; | |||
8782 | ||||
8783 | static WarnUnusedResultAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
8784 | auto *A = new (Ctx) WarnUnusedResultAttr(Loc, Ctx, S); | |||
8785 | A->setImplicit(true); | |||
8786 | return A; | |||
8787 | } | |||
8788 | ||||
8789 | WarnUnusedResultAttr(SourceRange R, ASTContext &Ctx | |||
8790 | , unsigned SI | |||
8791 | ) | |||
8792 | : InheritableAttr(attr::WarnUnusedResult, R, SI, false, false) | |||
8793 | { | |||
8794 | } | |||
8795 | ||||
8796 | WarnUnusedResultAttr *clone(ASTContext &C) const; | |||
8797 | void printPretty(raw_ostream &OS, | |||
8798 | const PrintingPolicy &Policy) const; | |||
8799 | const char *getSpelling() const; | |||
8800 | Spelling getSemanticSpelling() const { | |||
8801 | switch (SpellingListIndex) { | |||
8802 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 8802); | |||
8803 | case 0: return CXX11_nodiscard; | |||
8804 | case 1: return C2x_nodiscard; | |||
8805 | case 2: return CXX11_clang_warn_unused_result; | |||
8806 | case 3: return GNU_warn_unused_result; | |||
8807 | case 4: return CXX11_gnu_warn_unused_result; | |||
8808 | } | |||
8809 | } | |||
8810 | ||||
8811 | ||||
8812 | static bool classof(const Attr *A) { return A->getKind() == attr::WarnUnusedResult; } | |||
8813 | }; | |||
8814 | ||||
8815 | class WeakAttr : public InheritableAttr { | |||
8816 | public: | |||
8817 | static WeakAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8818 | auto *A = new (Ctx) WeakAttr(Loc, Ctx, 0); | |||
8819 | A->setImplicit(true); | |||
8820 | return A; | |||
8821 | } | |||
8822 | ||||
8823 | WeakAttr(SourceRange R, ASTContext &Ctx | |||
8824 | , unsigned SI | |||
8825 | ) | |||
8826 | : InheritableAttr(attr::Weak, R, SI, false, false) | |||
8827 | { | |||
8828 | } | |||
8829 | ||||
8830 | WeakAttr *clone(ASTContext &C) const; | |||
8831 | void printPretty(raw_ostream &OS, | |||
8832 | const PrintingPolicy &Policy) const; | |||
8833 | const char *getSpelling() const; | |||
8834 | ||||
8835 | ||||
8836 | static bool classof(const Attr *A) { return A->getKind() == attr::Weak; } | |||
8837 | }; | |||
8838 | ||||
8839 | class WeakImportAttr : public InheritableAttr { | |||
8840 | public: | |||
8841 | static WeakImportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8842 | auto *A = new (Ctx) WeakImportAttr(Loc, Ctx, 0); | |||
8843 | A->setImplicit(true); | |||
8844 | return A; | |||
8845 | } | |||
8846 | ||||
8847 | WeakImportAttr(SourceRange R, ASTContext &Ctx | |||
8848 | , unsigned SI | |||
8849 | ) | |||
8850 | : InheritableAttr(attr::WeakImport, R, SI, false, false) | |||
8851 | { | |||
8852 | } | |||
8853 | ||||
8854 | WeakImportAttr *clone(ASTContext &C) const; | |||
8855 | void printPretty(raw_ostream &OS, | |||
8856 | const PrintingPolicy &Policy) const; | |||
8857 | const char *getSpelling() const; | |||
8858 | ||||
8859 | ||||
8860 | static bool classof(const Attr *A) { return A->getKind() == attr::WeakImport; } | |||
8861 | }; | |||
8862 | ||||
8863 | class WeakRefAttr : public InheritableAttr { | |||
8864 | unsigned aliaseeLength; | |||
8865 | char *aliasee; | |||
8866 | ||||
8867 | public: | |||
8868 | static WeakRefAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Aliasee, SourceRange Loc = SourceRange()) { | |||
8869 | auto *A = new (Ctx) WeakRefAttr(Loc, Ctx, Aliasee, 0); | |||
8870 | A->setImplicit(true); | |||
8871 | return A; | |||
8872 | } | |||
8873 | ||||
8874 | WeakRefAttr(SourceRange R, ASTContext &Ctx | |||
8875 | , llvm::StringRef Aliasee | |||
8876 | , unsigned SI | |||
8877 | ) | |||
8878 | : InheritableAttr(attr::WeakRef, R, SI, false, false) | |||
8879 | , aliaseeLength(Aliasee.size()),aliasee(new (Ctx, 1) char[aliaseeLength]) | |||
8880 | { | |||
8881 | if (!Aliasee.empty()) | |||
8882 | std::memcpy(aliasee, Aliasee.data(), aliaseeLength); | |||
8883 | } | |||
8884 | ||||
8885 | WeakRefAttr(SourceRange R, ASTContext &Ctx | |||
8886 | , unsigned SI | |||
8887 | ) | |||
8888 | : InheritableAttr(attr::WeakRef, R, SI, false, false) | |||
8889 | , aliaseeLength(0),aliasee(nullptr) | |||
8890 | { | |||
8891 | } | |||
8892 | ||||
8893 | WeakRefAttr *clone(ASTContext &C) const; | |||
8894 | void printPretty(raw_ostream &OS, | |||
8895 | const PrintingPolicy &Policy) const; | |||
8896 | const char *getSpelling() const; | |||
8897 | llvm::StringRef getAliasee() const { | |||
8898 | return llvm::StringRef(aliasee, aliaseeLength); | |||
8899 | } | |||
8900 | unsigned getAliaseeLength() const { | |||
8901 | return aliaseeLength; | |||
8902 | } | |||
8903 | void setAliasee(ASTContext &C, llvm::StringRef S) { | |||
8904 | aliaseeLength = S.size(); | |||
8905 | this->aliasee = new (C, 1) char [aliaseeLength]; | |||
8906 | if (!S.empty()) | |||
8907 | std::memcpy(this->aliasee, S.data(), aliaseeLength); | |||
8908 | } | |||
8909 | ||||
8910 | ||||
8911 | ||||
8912 | static bool classof(const Attr *A) { return A->getKind() == attr::WeakRef; } | |||
8913 | }; | |||
8914 | ||||
8915 | class WorkGroupSizeHintAttr : public InheritableAttr { | |||
8916 | unsigned xDim; | |||
8917 | ||||
8918 | unsigned yDim; | |||
8919 | ||||
8920 | unsigned zDim; | |||
8921 | ||||
8922 | public: | |||
8923 | static WorkGroupSizeHintAttr *CreateImplicit(ASTContext &Ctx, unsigned XDim, unsigned YDim, unsigned ZDim, SourceRange Loc = SourceRange()) { | |||
8924 | auto *A = new (Ctx) WorkGroupSizeHintAttr(Loc, Ctx, XDim, YDim, ZDim, 0); | |||
8925 | A->setImplicit(true); | |||
8926 | return A; | |||
8927 | } | |||
8928 | ||||
8929 | WorkGroupSizeHintAttr(SourceRange R, ASTContext &Ctx | |||
8930 | , unsigned XDim | |||
8931 | , unsigned YDim | |||
8932 | , unsigned ZDim | |||
8933 | , unsigned SI | |||
8934 | ) | |||
8935 | : InheritableAttr(attr::WorkGroupSizeHint, R, SI, false, false) | |||
8936 | , xDim(XDim) | |||
8937 | , yDim(YDim) | |||
8938 | , zDim(ZDim) | |||
8939 | { | |||
8940 | } | |||
8941 | ||||
8942 | WorkGroupSizeHintAttr *clone(ASTContext &C) const; | |||
8943 | void printPretty(raw_ostream &OS, | |||
8944 | const PrintingPolicy &Policy) const; | |||
8945 | const char *getSpelling() const; | |||
8946 | unsigned getXDim() const { | |||
8947 | return xDim; | |||
8948 | } | |||
8949 | ||||
8950 | unsigned getYDim() const { | |||
8951 | return yDim; | |||
8952 | } | |||
8953 | ||||
8954 | unsigned getZDim() const { | |||
8955 | return zDim; | |||
8956 | } | |||
8957 | ||||
8958 | ||||
8959 | ||||
8960 | static bool classof(const Attr *A) { return A->getKind() == attr::WorkGroupSizeHint; } | |||
8961 | }; | |||
8962 | ||||
8963 | class X86ForceAlignArgPointerAttr : public InheritableAttr { | |||
8964 | public: | |||
8965 | static X86ForceAlignArgPointerAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) { | |||
8966 | auto *A = new (Ctx) X86ForceAlignArgPointerAttr(Loc, Ctx, 0); | |||
8967 | A->setImplicit(true); | |||
8968 | return A; | |||
8969 | } | |||
8970 | ||||
8971 | X86ForceAlignArgPointerAttr(SourceRange R, ASTContext &Ctx | |||
8972 | , unsigned SI | |||
8973 | ) | |||
8974 | : InheritableAttr(attr::X86ForceAlignArgPointer, R, SI, false, false) | |||
8975 | { | |||
8976 | } | |||
8977 | ||||
8978 | X86ForceAlignArgPointerAttr *clone(ASTContext &C) const; | |||
8979 | void printPretty(raw_ostream &OS, | |||
8980 | const PrintingPolicy &Policy) const; | |||
8981 | const char *getSpelling() const; | |||
8982 | ||||
8983 | ||||
8984 | static bool classof(const Attr *A) { return A->getKind() == attr::X86ForceAlignArgPointer; } | |||
8985 | }; | |||
8986 | ||||
8987 | class XRayInstrumentAttr : public InheritableAttr { | |||
8988 | public: | |||
8989 | enum Spelling { | |||
8990 | GNU_xray_always_instrument = 0, | |||
8991 | CXX11_clang_xray_always_instrument = 1, | |||
8992 | C2x_clang_xray_always_instrument = 2, | |||
8993 | GNU_xray_never_instrument = 3, | |||
8994 | CXX11_clang_xray_never_instrument = 4, | |||
8995 | C2x_clang_xray_never_instrument = 5 | |||
8996 | }; | |||
8997 | ||||
8998 | static XRayInstrumentAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) { | |||
8999 | auto *A = new (Ctx) XRayInstrumentAttr(Loc, Ctx, S); | |||
9000 | A->setImplicit(true); | |||
9001 | return A; | |||
9002 | } | |||
9003 | ||||
9004 | XRayInstrumentAttr(SourceRange R, ASTContext &Ctx | |||
9005 | , unsigned SI | |||
9006 | ) | |||
9007 | : InheritableAttr(attr::XRayInstrument, R, SI, false, false) | |||
9008 | { | |||
9009 | } | |||
9010 | ||||
9011 | XRayInstrumentAttr *clone(ASTContext &C) const; | |||
9012 | void printPretty(raw_ostream &OS, | |||
9013 | const PrintingPolicy &Policy) const; | |||
9014 | const char *getSpelling() const; | |||
9015 | Spelling getSemanticSpelling() const { | |||
9016 | switch (SpellingListIndex) { | |||
9017 | default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index" , "/build/llvm-toolchain-snapshot-7~svn338205/build-llvm/tools/clang/include/clang/AST/Attrs.inc" , 9017); | |||
9018 | case 0: return GNU_xray_always_instrument; | |||
9019 | case 1: return CXX11_clang_xray_always_instrument; | |||
9020 | case 2: return C2x_clang_xray_always_instrument; | |||
9021 | case 3: return GNU_xray_never_instrument; | |||
9022 | case 4: return CXX11_clang_xray_never_instrument; | |||
9023 | case 5: return C2x_clang_xray_never_instrument; | |||
9024 | } | |||
9025 | } | |||
9026 | bool alwaysXRayInstrument() const { return SpellingListIndex == 0 || | |||
9027 | SpellingListIndex == 1 || | |||
9028 | SpellingListIndex == 2; } | |||
9029 | bool neverXRayInstrument() const { return SpellingListIndex == 3 || | |||
9030 | SpellingListIndex == 4 || | |||
9031 | SpellingListIndex == 5; } | |||
9032 | ||||
9033 | ||||
9034 | static bool classof(const Attr *A) { return A->getKind() == attr::XRayInstrument; } | |||
9035 | }; | |||
9036 | ||||
9037 | class XRayLogArgsAttr : public InheritableAttr { | |||
9038 | unsigned argumentCount; | |||
9039 | ||||
9040 | public: | |||
9041 | static XRayLogArgsAttr *CreateImplicit(ASTContext &Ctx, unsigned ArgumentCount, SourceRange Loc = SourceRange()) { | |||
9042 | auto *A = new (Ctx) XRayLogArgsAttr(Loc, Ctx, ArgumentCount, 0); | |||
9043 | A->setImplicit(true); | |||
9044 | return A; | |||
9045 | } | |||
9046 | ||||
9047 | XRayLogArgsAttr(SourceRange R, ASTContext &Ctx | |||
9048 | , unsigned ArgumentCount | |||
9049 | , unsigned SI | |||
9050 | ) | |||
9051 | : InheritableAttr(attr::XRayLogArgs, R, SI, false, false) | |||
9052 | , argumentCount(ArgumentCount) | |||
9053 | { | |||
9054 | } | |||
9055 | ||||
9056 | XRayLogArgsAttr *clone(ASTContext &C) const; | |||
9057 | void printPretty(raw_ostream &OS, | |||
9058 | const PrintingPolicy &Policy) const; | |||
9059 | const char *getSpelling() const; | |||
9060 | unsigned getArgumentCount() const { | |||
9061 | return argumentCount; | |||
9062 | } | |||
9063 | ||||
9064 | ||||
9065 | ||||
9066 | static bool classof(const Attr *A) { return A->getKind() == attr::XRayLogArgs; } | |||
9067 | }; | |||
9068 | ||||
9069 | #endif // LLVM_CLANG_ATTR_CLASSES_INC |