Bug Summary

File:build-llvm/tools/clang/include/clang/AST/Attrs.inc
Warning:line 4923, column 5
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name DeclObjC.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mthread-model posix -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-9/lib/clang/9.0.0 -D CLANG_VENDOR="Debian " -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/lib/AST -I /build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST -I /build/llvm-toolchain-snapshot-9~svn362543/tools/clang/include -I /build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include -I /build/llvm-toolchain-snapshot-9~svn362543/build-llvm/include -I /build/llvm-toolchain-snapshot-9~svn362543/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward -internal-isystem /usr/include/clang/9.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-9/lib/clang/9.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/lib/AST -fdebug-prefix-map=/build/llvm-toolchain-snapshot-9~svn362543=. -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -stack-protector 2 -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -o /tmp/scan-build-2019-06-05-060531-1271-1 -x c++ /build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp -faddrsig

/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp

1//===- DeclObjC.cpp - ObjC Declaration AST Node Implementation ------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the Objective-C related Decl classes.
10//
11//===----------------------------------------------------------------------===//
12
13#include "clang/AST/DeclObjC.h"
14#include "clang/AST/ASTContext.h"
15#include "clang/AST/ASTMutationListener.h"
16#include "clang/AST/Attr.h"
17#include "clang/AST/Decl.h"
18#include "clang/AST/DeclBase.h"
19#include "clang/AST/Stmt.h"
20#include "clang/AST/Type.h"
21#include "clang/AST/TypeLoc.h"
22#include "clang/Basic/IdentifierTable.h"
23#include "clang/Basic/LLVM.h"
24#include "clang/Basic/LangOptions.h"
25#include "clang/Basic/SourceLocation.h"
26#include "llvm/ADT/None.h"
27#include "llvm/ADT/SmallString.h"
28#include "llvm/ADT/SmallVector.h"
29#include "llvm/Support/Casting.h"
30#include "llvm/Support/ErrorHandling.h"
31#include "llvm/Support/raw_ostream.h"
32#include <algorithm>
33#include <cassert>
34#include <cstdint>
35#include <cstring>
36#include <utility>
37
38using namespace clang;
39
40//===----------------------------------------------------------------------===//
41// ObjCListBase
42//===----------------------------------------------------------------------===//
43
44void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) {
45 List = nullptr;
46 if (Elts == 0) return; // Setting to an empty list is a noop.
47
48 List = new (Ctx) void*[Elts];
49 NumElts = Elts;
50 memcpy(List, InList, sizeof(void*)*Elts);
51}
52
53void ObjCProtocolList::set(ObjCProtocolDecl* const* InList, unsigned Elts,
54 const SourceLocation *Locs, ASTContext &Ctx) {
55 if (Elts == 0)
56 return;
57
58 Locations = new (Ctx) SourceLocation[Elts];
59 memcpy(Locations, Locs, sizeof(SourceLocation) * Elts);
60 set(InList, Elts, Ctx);
61}
62
63//===----------------------------------------------------------------------===//
64// ObjCInterfaceDecl
65//===----------------------------------------------------------------------===//
66
67ObjCContainerDecl::ObjCContainerDecl(Kind DK, DeclContext *DC,
68 IdentifierInfo *Id, SourceLocation nameLoc,
69 SourceLocation atStartLoc)
70 : NamedDecl(DK, DC, nameLoc, Id), DeclContext(DK) {
71 setAtStartLoc(atStartLoc);
72}
73
74void ObjCContainerDecl::anchor() {}
75
76/// getIvarDecl - This method looks up an ivar in this ContextDecl.
77///
78ObjCIvarDecl *
79ObjCContainerDecl::getIvarDecl(IdentifierInfo *Id) const {
80 lookup_result R = lookup(Id);
81 for (lookup_iterator Ivar = R.begin(), IvarEnd = R.end();
82 Ivar != IvarEnd; ++Ivar) {
83 if (auto *ivar = dyn_cast<ObjCIvarDecl>(*Ivar))
84 return ivar;
85 }
86 return nullptr;
87}
88
89// Get the local instance/class method declared in this interface.
90ObjCMethodDecl *
91ObjCContainerDecl::getMethod(Selector Sel, bool isInstance,
92 bool AllowHidden) const {
93 // If this context is a hidden protocol definition, don't find any
94 // methods there.
95 if (const auto *Proto = dyn_cast<ObjCProtocolDecl>(this)) {
96 if (const ObjCProtocolDecl *Def = Proto->getDefinition())
97 if (Def->isHidden() && !AllowHidden)
98 return nullptr;
99 }
100
101 // Since instance & class methods can have the same name, the loop below
102 // ensures we get the correct method.
103 //
104 // @interface Whatever
105 // - (int) class_method;
106 // + (float) class_method;
107 // @end
108 lookup_result R = lookup(Sel);
109 for (lookup_iterator Meth = R.begin(), MethEnd = R.end();
110 Meth != MethEnd; ++Meth) {
111 auto *MD = dyn_cast<ObjCMethodDecl>(*Meth);
112 if (MD && MD->isInstanceMethod() == isInstance)
113 return MD;
114 }
115 return nullptr;
116}
117
118/// This routine returns 'true' if a user declared setter method was
119/// found in the class, its protocols, its super classes or categories.
120/// It also returns 'true' if one of its categories has declared a 'readwrite'
121/// property. This is because, user must provide a setter method for the
122/// category's 'readwrite' property.
123bool ObjCContainerDecl::HasUserDeclaredSetterMethod(
124 const ObjCPropertyDecl *Property) const {
125 Selector Sel = Property->getSetterName();
126 lookup_result R = lookup(Sel);
127 for (lookup_iterator Meth = R.begin(), MethEnd = R.end();
128 Meth != MethEnd; ++Meth) {
129 auto *MD = dyn_cast<ObjCMethodDecl>(*Meth);
130 if (MD && MD->isInstanceMethod() && !MD->isImplicit())
131 return true;
132 }
133
134 if (const auto *ID = dyn_cast<ObjCInterfaceDecl>(this)) {
135 // Also look into categories, including class extensions, looking
136 // for a user declared instance method.
137 for (const auto *Cat : ID->visible_categories()) {
138 if (ObjCMethodDecl *MD = Cat->getInstanceMethod(Sel))
139 if (!MD->isImplicit())
140 return true;
141 if (Cat->IsClassExtension())
142 continue;
143 // Also search through the categories looking for a 'readwrite'
144 // declaration of this property. If one found, presumably a setter will
145 // be provided (properties declared in categories will not get
146 // auto-synthesized).
147 for (const auto *P : Cat->properties())
148 if (P->getIdentifier() == Property->getIdentifier()) {
149 if (P->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_readwrite)
150 return true;
151 break;
152 }
153 }
154
155 // Also look into protocols, for a user declared instance method.
156 for (const auto *Proto : ID->all_referenced_protocols())
157 if (Proto->HasUserDeclaredSetterMethod(Property))
158 return true;
159
160 // And in its super class.
161 ObjCInterfaceDecl *OSC = ID->getSuperClass();
162 while (OSC) {
163 if (OSC->HasUserDeclaredSetterMethod(Property))
164 return true;
165 OSC = OSC->getSuperClass();
166 }
167 }
168 if (const auto *PD = dyn_cast<ObjCProtocolDecl>(this))
169 for (const auto *PI : PD->protocols())
170 if (PI->HasUserDeclaredSetterMethod(Property))
171 return true;
172 return false;
173}
174
175ObjCPropertyDecl *
176ObjCPropertyDecl::findPropertyDecl(const DeclContext *DC,
177 const IdentifierInfo *propertyID,
178 ObjCPropertyQueryKind queryKind) {
179 // If this context is a hidden protocol definition, don't find any
180 // property.
181 if (const auto *Proto = dyn_cast<ObjCProtocolDecl>(DC)) {
182 if (const ObjCProtocolDecl *Def = Proto->getDefinition())
183 if (Def->isHidden())
184 return nullptr;
185 }
186
187 // If context is class, then lookup property in its visible extensions.
188 // This comes before property is looked up in primary class.
189 if (auto *IDecl = dyn_cast<ObjCInterfaceDecl>(DC)) {
190 for (const auto *Ext : IDecl->visible_extensions())
191 if (ObjCPropertyDecl *PD = ObjCPropertyDecl::findPropertyDecl(Ext,
192 propertyID,
193 queryKind))
194 return PD;
195 }
196
197 DeclContext::lookup_result R = DC->lookup(propertyID);
198 ObjCPropertyDecl *classProp = nullptr;
199 for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E;
200 ++I)
201 if (auto *PD = dyn_cast<ObjCPropertyDecl>(*I)) {
202 // If queryKind is unknown, we return the instance property if one
203 // exists; otherwise we return the class property.
204 if ((queryKind == ObjCPropertyQueryKind::OBJC_PR_query_unknown &&
205 !PD->isClassProperty()) ||
206 (queryKind == ObjCPropertyQueryKind::OBJC_PR_query_class &&
207 PD->isClassProperty()) ||
208 (queryKind == ObjCPropertyQueryKind::OBJC_PR_query_instance &&
209 !PD->isClassProperty()))
210 return PD;
211
212 if (PD->isClassProperty())
213 classProp = PD;
214 }
215
216 if (queryKind == ObjCPropertyQueryKind::OBJC_PR_query_unknown)
217 // We can't find the instance property, return the class property.
218 return classProp;
219
220 return nullptr;
221}
222
223IdentifierInfo *
224ObjCPropertyDecl::getDefaultSynthIvarName(ASTContext &Ctx) const {
225 SmallString<128> ivarName;
226 {
227 llvm::raw_svector_ostream os(ivarName);
228 os << '_' << getIdentifier()->getName();
229 }
230 return &Ctx.Idents.get(ivarName.str());
231}
232
233/// FindPropertyDeclaration - Finds declaration of the property given its name
234/// in 'PropertyId' and returns it. It returns 0, if not found.
235ObjCPropertyDecl *ObjCContainerDecl::FindPropertyDeclaration(
236 const IdentifierInfo *PropertyId,
237 ObjCPropertyQueryKind QueryKind) const {
238 // Don't find properties within hidden protocol definitions.
239 if (const auto *Proto = dyn_cast<ObjCProtocolDecl>(this)) {
240 if (const ObjCProtocolDecl *Def = Proto->getDefinition())
241 if (Def->isHidden())
242 return nullptr;
243 }
244
245 // Search the extensions of a class first; they override what's in
246 // the class itself.
247 if (const auto *ClassDecl = dyn_cast<ObjCInterfaceDecl>(this)) {
248 for (const auto *Ext : ClassDecl->visible_extensions()) {
249 if (auto *P = Ext->FindPropertyDeclaration(PropertyId, QueryKind))
250 return P;
251 }
252 }
253
254 if (ObjCPropertyDecl *PD =
255 ObjCPropertyDecl::findPropertyDecl(cast<DeclContext>(this), PropertyId,
256 QueryKind))
257 return PD;
258
259 switch (getKind()) {
260 default:
261 break;
262 case Decl::ObjCProtocol: {
263 const auto *PID = cast<ObjCProtocolDecl>(this);
264 for (const auto *I : PID->protocols())
265 if (ObjCPropertyDecl *P = I->FindPropertyDeclaration(PropertyId,
266 QueryKind))
267 return P;
268 break;
269 }
270 case Decl::ObjCInterface: {
271 const auto *OID = cast<ObjCInterfaceDecl>(this);
272 // Look through categories (but not extensions; they were handled above).
273 for (const auto *Cat : OID->visible_categories()) {
274 if (!Cat->IsClassExtension())
275 if (ObjCPropertyDecl *P = Cat->FindPropertyDeclaration(
276 PropertyId, QueryKind))
277 return P;
278 }
279
280 // Look through protocols.
281 for (const auto *I : OID->all_referenced_protocols())
282 if (ObjCPropertyDecl *P = I->FindPropertyDeclaration(PropertyId,
283 QueryKind))
284 return P;
285
286 // Finally, check the super class.
287 if (const ObjCInterfaceDecl *superClass = OID->getSuperClass())
288 return superClass->FindPropertyDeclaration(PropertyId, QueryKind);
289 break;
290 }
291 case Decl::ObjCCategory: {
292 const auto *OCD = cast<ObjCCategoryDecl>(this);
293 // Look through protocols.
294 if (!OCD->IsClassExtension())
295 for (const auto *I : OCD->protocols())
296 if (ObjCPropertyDecl *P = I->FindPropertyDeclaration(PropertyId,
297 QueryKind))
298 return P;
299 break;
300 }
301 }
302 return nullptr;
303}
304
305void ObjCInterfaceDecl::anchor() {}
306
307ObjCTypeParamList *ObjCInterfaceDecl::getTypeParamList() const {
308 // If this particular declaration has a type parameter list, return it.
309 if (ObjCTypeParamList *written = getTypeParamListAsWritten())
310 return written;
311
312 // If there is a definition, return its type parameter list.
313 if (const ObjCInterfaceDecl *def = getDefinition())
314 return def->getTypeParamListAsWritten();
315
316 // Otherwise, look at previous declarations to determine whether any
317 // of them has a type parameter list, skipping over those
318 // declarations that do not.
319 for (const ObjCInterfaceDecl *decl = getMostRecentDecl(); decl;
320 decl = decl->getPreviousDecl()) {
321 if (ObjCTypeParamList *written = decl->getTypeParamListAsWritten())
322 return written;
323 }
324
325 return nullptr;
326}
327
328void ObjCInterfaceDecl::setTypeParamList(ObjCTypeParamList *TPL) {
329 TypeParamList = TPL;
330 if (!TPL)
331 return;
332 // Set the declaration context of each of the type parameters.
333 for (auto *typeParam : *TypeParamList)
334 typeParam->setDeclContext(this);
335}
336
337ObjCInterfaceDecl *ObjCInterfaceDecl::getSuperClass() const {
338 // FIXME: Should make sure no callers ever do this.
339 if (!hasDefinition())
340 return nullptr;
341
342 if (data().ExternallyCompleted)
343 LoadExternalDefinition();
344
345 if (const ObjCObjectType *superType = getSuperClassType()) {
346 if (ObjCInterfaceDecl *superDecl = superType->getInterface()) {
347 if (ObjCInterfaceDecl *superDef = superDecl->getDefinition())
348 return superDef;
349
350 return superDecl;
351 }
352 }
353
354 return nullptr;
355}
356
357SourceLocation ObjCInterfaceDecl::getSuperClassLoc() const {
358 if (TypeSourceInfo *superTInfo = getSuperClassTInfo())
359 return superTInfo->getTypeLoc().getBeginLoc();
360
361 return SourceLocation();
362}
363
364/// FindPropertyVisibleInPrimaryClass - Finds declaration of the property
365/// with name 'PropertyId' in the primary class; including those in protocols
366/// (direct or indirect) used by the primary class.
367ObjCPropertyDecl *
368ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass(
369 IdentifierInfo *PropertyId,
370 ObjCPropertyQueryKind QueryKind) const {
371 // FIXME: Should make sure no callers ever do this.
372 if (!hasDefinition())
373 return nullptr;
374
375 if (data().ExternallyCompleted)
376 LoadExternalDefinition();
377
378 if (ObjCPropertyDecl *PD =
379 ObjCPropertyDecl::findPropertyDecl(cast<DeclContext>(this), PropertyId,
380 QueryKind))
381 return PD;
382
383 // Look through protocols.
384 for (const auto *I : all_referenced_protocols())
385 if (ObjCPropertyDecl *P = I->FindPropertyDeclaration(PropertyId,
386 QueryKind))
387 return P;
388
389 return nullptr;
390}
391
392void ObjCInterfaceDecl::collectPropertiesToImplement(PropertyMap &PM,
393 PropertyDeclOrder &PO) const {
394 for (auto *Prop : properties()) {
395 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
396 PO.push_back(Prop);
397 }
398 for (const auto *Ext : known_extensions()) {
399 const ObjCCategoryDecl *ClassExt = Ext;
400 for (auto *Prop : ClassExt->properties()) {
401 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
402 PO.push_back(Prop);
403 }
404 }
405 for (const auto *PI : all_referenced_protocols())
406 PI->collectPropertiesToImplement(PM, PO);
407 // Note, the properties declared only in class extensions are still copied
408 // into the main @interface's property list, and therefore we don't
409 // explicitly, have to search class extension properties.
410}
411
412bool ObjCInterfaceDecl::isArcWeakrefUnavailable() const {
413 const ObjCInterfaceDecl *Class = this;
414 while (Class) {
415 if (Class->hasAttr<ArcWeakrefUnavailableAttr>())
416 return true;
417 Class = Class->getSuperClass();
418 }
419 return false;
420}
421
422const ObjCInterfaceDecl *ObjCInterfaceDecl::isObjCRequiresPropertyDefs() const {
423 const ObjCInterfaceDecl *Class = this;
424 while (Class) {
425 if (Class->hasAttr<ObjCRequiresPropertyDefsAttr>())
426 return Class;
427 Class = Class->getSuperClass();
428 }
429 return nullptr;
430}
431
432void ObjCInterfaceDecl::mergeClassExtensionProtocolList(
433 ObjCProtocolDecl *const* ExtList, unsigned ExtNum,
434 ASTContext &C) {
435 if (data().ExternallyCompleted)
436 LoadExternalDefinition();
437
438 if (data().AllReferencedProtocols.empty() &&
439 data().ReferencedProtocols.empty()) {
440 data().AllReferencedProtocols.set(ExtList, ExtNum, C);
441 return;
442 }
443
444 // Check for duplicate protocol in class's protocol list.
445 // This is O(n*m). But it is extremely rare and number of protocols in
446 // class or its extension are very few.
447 SmallVector<ObjCProtocolDecl *, 8> ProtocolRefs;
448 for (unsigned i = 0; i < ExtNum; i++) {
449 bool protocolExists = false;
450 ObjCProtocolDecl *ProtoInExtension = ExtList[i];
451 for (auto *Proto : all_referenced_protocols()) {
452 if (C.ProtocolCompatibleWithProtocol(ProtoInExtension, Proto)) {
453 protocolExists = true;
454 break;
455 }
456 }
457 // Do we want to warn on a protocol in extension class which
458 // already exist in the class? Probably not.
459 if (!protocolExists)
460 ProtocolRefs.push_back(ProtoInExtension);
461 }
462
463 if (ProtocolRefs.empty())
464 return;
465
466 // Merge ProtocolRefs into class's protocol list;
467 ProtocolRefs.append(all_referenced_protocol_begin(),
468 all_referenced_protocol_end());
469
470 data().AllReferencedProtocols.set(ProtocolRefs.data(), ProtocolRefs.size(),C);
471}
472
473const ObjCInterfaceDecl *
474ObjCInterfaceDecl::findInterfaceWithDesignatedInitializers() const {
475 const ObjCInterfaceDecl *IFace = this;
476 while (IFace) {
477 if (IFace->hasDesignatedInitializers())
478 return IFace;
479 if (!IFace->inheritsDesignatedInitializers())
480 break;
481 IFace = IFace->getSuperClass();
482 }
483 return nullptr;
484}
485
486static bool isIntroducingInitializers(const ObjCInterfaceDecl *D) {
487 for (const auto *MD : D->instance_methods()) {
488 if (MD->getMethodFamily() == OMF_init && !MD->isOverriding())
489 return true;
490 }
491 for (const auto *Ext : D->visible_extensions()) {
492 for (const auto *MD : Ext->instance_methods()) {
493 if (MD->getMethodFamily() == OMF_init && !MD->isOverriding())
494 return true;
495 }
496 }
497 if (const auto *ImplD = D->getImplementation()) {
498 for (const auto *MD : ImplD->instance_methods()) {
499 if (MD->getMethodFamily() == OMF_init && !MD->isOverriding())
500 return true;
501 }
502 }
503 return false;
504}
505
506bool ObjCInterfaceDecl::inheritsDesignatedInitializers() const {
507 switch (data().InheritedDesignatedInitializers) {
508 case DefinitionData::IDI_Inherited:
509 return true;
510 case DefinitionData::IDI_NotInherited:
511 return false;
512 case DefinitionData::IDI_Unknown:
513 // If the class introduced initializers we conservatively assume that we
514 // don't know if any of them is a designated initializer to avoid possible
515 // misleading warnings.
516 if (isIntroducingInitializers(this)) {
517 data().InheritedDesignatedInitializers = DefinitionData::IDI_NotInherited;
518 } else {
519 if (auto SuperD = getSuperClass()) {
520 data().InheritedDesignatedInitializers =
521 SuperD->declaresOrInheritsDesignatedInitializers() ?
522 DefinitionData::IDI_Inherited :
523 DefinitionData::IDI_NotInherited;
524 } else {
525 data().InheritedDesignatedInitializers =
526 DefinitionData::IDI_NotInherited;
527 }
528 }
529 assert(data().InheritedDesignatedInitializers((data().InheritedDesignatedInitializers != DefinitionData::IDI_Unknown
) ? static_cast<void> (0) : __assert_fail ("data().InheritedDesignatedInitializers != DefinitionData::IDI_Unknown"
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 530, __PRETTY_FUNCTION__))
530 != DefinitionData::IDI_Unknown)((data().InheritedDesignatedInitializers != DefinitionData::IDI_Unknown
) ? static_cast<void> (0) : __assert_fail ("data().InheritedDesignatedInitializers != DefinitionData::IDI_Unknown"
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 530, __PRETTY_FUNCTION__))
;
531 return data().InheritedDesignatedInitializers ==
532 DefinitionData::IDI_Inherited;
533 }
534
535 llvm_unreachable("unexpected InheritedDesignatedInitializers value")::llvm::llvm_unreachable_internal("unexpected InheritedDesignatedInitializers value"
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 535)
;
536}
537
538void ObjCInterfaceDecl::getDesignatedInitializers(
539 llvm::SmallVectorImpl<const ObjCMethodDecl *> &Methods) const {
540 // Check for a complete definition and recover if not so.
541 if (!isThisDeclarationADefinition())
542 return;
543 if (data().ExternallyCompleted)
544 LoadExternalDefinition();
545
546 const ObjCInterfaceDecl *IFace= findInterfaceWithDesignatedInitializers();
547 if (!IFace)
548 return;
549
550 for (const auto *MD : IFace->instance_methods())
551 if (MD->isThisDeclarationADesignatedInitializer())
552 Methods.push_back(MD);
553 for (const auto *Ext : IFace->visible_extensions()) {
554 for (const auto *MD : Ext->instance_methods())
555 if (MD->isThisDeclarationADesignatedInitializer())
556 Methods.push_back(MD);
557 }
558}
559
560bool ObjCInterfaceDecl::isDesignatedInitializer(Selector Sel,
561 const ObjCMethodDecl **InitMethod) const {
562 bool HasCompleteDef = isThisDeclarationADefinition();
563 // During deserialization the data record for the ObjCInterfaceDecl could
564 // be made invariant by reusing the canonical decl. Take this into account
565 // when checking for the complete definition.
566 if (!HasCompleteDef && getCanonicalDecl()->hasDefinition() &&
567 getCanonicalDecl()->getDefinition() == getDefinition())
568 HasCompleteDef = true;
569
570 // Check for a complete definition and recover if not so.
571 if (!HasCompleteDef)
572 return false;
573
574 if (data().ExternallyCompleted)
575 LoadExternalDefinition();
576
577 const ObjCInterfaceDecl *IFace= findInterfaceWithDesignatedInitializers();
578 if (!IFace)
579 return false;
580
581 if (const ObjCMethodDecl *MD = IFace->getInstanceMethod(Sel)) {
582 if (MD->isThisDeclarationADesignatedInitializer()) {
583 if (InitMethod)
584 *InitMethod = MD;
585 return true;
586 }
587 }
588 for (const auto *Ext : IFace->visible_extensions()) {
589 if (const ObjCMethodDecl *MD = Ext->getInstanceMethod(Sel)) {
590 if (MD->isThisDeclarationADesignatedInitializer()) {
591 if (InitMethod)
592 *InitMethod = MD;
593 return true;
594 }
595 }
596 }
597 return false;
598}
599
600void ObjCInterfaceDecl::allocateDefinitionData() {
601 assert(!hasDefinition() && "ObjC class already has a definition")((!hasDefinition() && "ObjC class already has a definition"
) ? static_cast<void> (0) : __assert_fail ("!hasDefinition() && \"ObjC class already has a definition\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 601, __PRETTY_FUNCTION__))
;
602 Data.setPointer(new (getASTContext()) DefinitionData());
603 Data.getPointer()->Definition = this;
604
605 // Make the type point at the definition, now that we have one.
606 if (TypeForDecl)
607 cast<ObjCInterfaceType>(TypeForDecl)->Decl = this;
608}
609
610void ObjCInterfaceDecl::startDefinition() {
611 allocateDefinitionData();
612
613 // Update all of the declarations with a pointer to the definition.
614 for (auto *RD : redecls()) {
615 if (RD != this)
616 RD->Data = Data;
617 }
618}
619
620ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(IdentifierInfo *ID,
621 ObjCInterfaceDecl *&clsDeclared) {
622 // FIXME: Should make sure no callers ever do this.
623 if (!hasDefinition())
624 return nullptr;
625
626 if (data().ExternallyCompleted)
627 LoadExternalDefinition();
628
629 ObjCInterfaceDecl* ClassDecl = this;
630 while (ClassDecl != nullptr) {
631 if (ObjCIvarDecl *I = ClassDecl->getIvarDecl(ID)) {
632 clsDeclared = ClassDecl;
633 return I;
634 }
635
636 for (const auto *Ext : ClassDecl->visible_extensions()) {
637 if (ObjCIvarDecl *I = Ext->getIvarDecl(ID)) {
638 clsDeclared = ClassDecl;
639 return I;
640 }
641 }
642
643 ClassDecl = ClassDecl->getSuperClass();
644 }
645 return nullptr;
646}
647
648/// lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super
649/// class whose name is passed as argument. If it is not one of the super classes
650/// the it returns NULL.
651ObjCInterfaceDecl *ObjCInterfaceDecl::lookupInheritedClass(
652 const IdentifierInfo*ICName) {
653 // FIXME: Should make sure no callers ever do this.
654 if (!hasDefinition())
655 return nullptr;
656
657 if (data().ExternallyCompleted)
658 LoadExternalDefinition();
659
660 ObjCInterfaceDecl* ClassDecl = this;
661 while (ClassDecl != nullptr) {
662 if (ClassDecl->getIdentifier() == ICName)
663 return ClassDecl;
664 ClassDecl = ClassDecl->getSuperClass();
665 }
666 return nullptr;
667}
668
669ObjCProtocolDecl *
670ObjCInterfaceDecl::lookupNestedProtocol(IdentifierInfo *Name) {
671 for (auto *P : all_referenced_protocols())
672 if (P->lookupProtocolNamed(Name))
673 return P;
674 ObjCInterfaceDecl *SuperClass = getSuperClass();
675 return SuperClass ? SuperClass->lookupNestedProtocol(Name) : nullptr;
676}
677
678/// lookupMethod - This method returns an instance/class method by looking in
679/// the class, its categories, and its super classes (using a linear search).
680/// When argument category "C" is specified, any implicit method found
681/// in this category is ignored.
682ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
683 bool isInstance,
684 bool shallowCategoryLookup,
685 bool followSuper,
686 const ObjCCategoryDecl *C) const
687{
688 // FIXME: Should make sure no callers ever do this.
689 if (!hasDefinition())
690 return nullptr;
691
692 const ObjCInterfaceDecl* ClassDecl = this;
693 ObjCMethodDecl *MethodDecl = nullptr;
694
695 if (data().ExternallyCompleted)
696 LoadExternalDefinition();
697
698 while (ClassDecl) {
699 // 1. Look through primary class.
700 if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance)))
701 return MethodDecl;
702
703 // 2. Didn't find one yet - now look through categories.
704 for (const auto *Cat : ClassDecl->visible_categories())
705 if ((MethodDecl = Cat->getMethod(Sel, isInstance)))
706 if (C != Cat || !MethodDecl->isImplicit())
707 return MethodDecl;
708
709 // 3. Didn't find one yet - look through primary class's protocols.
710 for (const auto *I : ClassDecl->protocols())
711 if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
712 return MethodDecl;
713
714 // 4. Didn't find one yet - now look through categories' protocols
715 if (!shallowCategoryLookup)
716 for (const auto *Cat : ClassDecl->visible_categories()) {
717 // Didn't find one yet - look through protocols.
718 const ObjCList<ObjCProtocolDecl> &Protocols =
719 Cat->getReferencedProtocols();
720 for (auto *Protocol : Protocols)
721 if ((MethodDecl = Protocol->lookupMethod(Sel, isInstance)))
722 if (C != Cat || !MethodDecl->isImplicit())
723 return MethodDecl;
724 }
725
726
727 if (!followSuper)
728 return nullptr;
729
730 // 5. Get to the super class (if any).
731 ClassDecl = ClassDecl->getSuperClass();
732 }
733 return nullptr;
734}
735
736// Will search "local" class/category implementations for a method decl.
737// If failed, then we search in class's root for an instance method.
738// Returns 0 if no method is found.
739ObjCMethodDecl *ObjCInterfaceDecl::lookupPrivateMethod(
740 const Selector &Sel,
741 bool Instance) const {
742 // FIXME: Should make sure no callers ever do this.
743 if (!hasDefinition())
744 return nullptr;
745
746 if (data().ExternallyCompleted)
747 LoadExternalDefinition();
748
749 ObjCMethodDecl *Method = nullptr;
750 if (ObjCImplementationDecl *ImpDecl = getImplementation())
751 Method = Instance ? ImpDecl->getInstanceMethod(Sel)
752 : ImpDecl->getClassMethod(Sel);
753
754 // Look through local category implementations associated with the class.
755 if (!Method)
756 Method = getCategoryMethod(Sel, Instance);
757
758 // Before we give up, check if the selector is an instance method.
759 // But only in the root. This matches gcc's behavior and what the
760 // runtime expects.
761 if (!Instance && !Method && !getSuperClass()) {
762 Method = lookupInstanceMethod(Sel);
763 // Look through local category implementations associated
764 // with the root class.
765 if (!Method)
766 Method = lookupPrivateMethod(Sel, true);
767 }
768
769 if (!Method && getSuperClass())
770 return getSuperClass()->lookupPrivateMethod(Sel, Instance);
771 return Method;
772}
773
774//===----------------------------------------------------------------------===//
775// ObjCMethodDecl
776//===----------------------------------------------------------------------===//
777
778ObjCMethodDecl::ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc,
779 Selector SelInfo, QualType T,
780 TypeSourceInfo *ReturnTInfo,
781 DeclContext *contextDecl, bool isInstance,
782 bool isVariadic, bool isPropertyAccessor,
783 bool isImplicitlyDeclared, bool isDefined,
784 ImplementationControl impControl,
785 bool HasRelatedResultType)
786 : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo),
787 DeclContext(ObjCMethod), MethodDeclType(T), ReturnTInfo(ReturnTInfo),
788 DeclEndLoc(endLoc) {
789
790 // Initialized the bits stored in DeclContext.
791 ObjCMethodDeclBits.Family =
792 static_cast<ObjCMethodFamily>(InvalidObjCMethodFamily);
793 setInstanceMethod(isInstance);
794 setVariadic(isVariadic);
795 setPropertyAccessor(isPropertyAccessor);
796 setDefined(isDefined);
797 setIsRedeclaration(false);
798 setHasRedeclaration(false);
799 setDeclImplementation(impControl);
800 setObjCDeclQualifier(OBJC_TQ_None);
801 setRelatedResultType(HasRelatedResultType);
802 setSelLocsKind(SelLoc_StandardNoSpace);
803 setOverriding(false);
804 setHasSkippedBody(false);
805
806 setImplicit(isImplicitlyDeclared);
807}
808
809ObjCMethodDecl *ObjCMethodDecl::Create(
810 ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc,
811 Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo,
812 DeclContext *contextDecl, bool isInstance, bool isVariadic,
813 bool isPropertyAccessor, bool isImplicitlyDeclared, bool isDefined,
814 ImplementationControl impControl, bool HasRelatedResultType) {
815 return new (C, contextDecl) ObjCMethodDecl(
816 beginLoc, endLoc, SelInfo, T, ReturnTInfo, contextDecl, isInstance,
817 isVariadic, isPropertyAccessor, isImplicitlyDeclared, isDefined,
818 impControl, HasRelatedResultType);
819}
820
821ObjCMethodDecl *ObjCMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
822 return new (C, ID) ObjCMethodDecl(SourceLocation(), SourceLocation(),
823 Selector(), QualType(), nullptr, nullptr);
824}
825
826bool ObjCMethodDecl::isThisDeclarationADesignatedInitializer() const {
827 return getMethodFamily() == OMF_init &&
828 hasAttr<ObjCDesignatedInitializerAttr>();
829}
830
831bool ObjCMethodDecl::definedInNSObject(const ASTContext &Ctx) const {
832 if (const auto *PD = dyn_cast<const ObjCProtocolDecl>(getDeclContext()))
833 return PD->getIdentifier() == Ctx.getNSObjectName();
834 if (const auto *ID = dyn_cast<const ObjCInterfaceDecl>(getDeclContext()))
835 return ID->getIdentifier() == Ctx.getNSObjectName();
836 return false;
837}
838
839bool ObjCMethodDecl::isDesignatedInitializerForTheInterface(
840 const ObjCMethodDecl **InitMethod) const {
841 if (getMethodFamily() != OMF_init)
842 return false;
843 const DeclContext *DC = getDeclContext();
844 if (isa<ObjCProtocolDecl>(DC))
845 return false;
846 if (const ObjCInterfaceDecl *ID = getClassInterface())
847 return ID->isDesignatedInitializer(getSelector(), InitMethod);
848 return false;
849}
850
851Stmt *ObjCMethodDecl::getBody() const {
852 return Body.get(getASTContext().getExternalSource());
853}
854
855void ObjCMethodDecl::setAsRedeclaration(const ObjCMethodDecl *PrevMethod) {
856 assert(PrevMethod)((PrevMethod) ? static_cast<void> (0) : __assert_fail (
"PrevMethod", "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 856, __PRETTY_FUNCTION__))
;
857 getASTContext().setObjCMethodRedeclaration(PrevMethod, this);
858 setIsRedeclaration(true);
859 PrevMethod->setHasRedeclaration(true);
860}
861
862void ObjCMethodDecl::setParamsAndSelLocs(ASTContext &C,
863 ArrayRef<ParmVarDecl*> Params,
864 ArrayRef<SourceLocation> SelLocs) {
865 ParamsAndSelLocs = nullptr;
866 NumParams = Params.size();
867 if (Params.empty() && SelLocs.empty())
868 return;
869
870 static_assert(alignof(ParmVarDecl *) >= alignof(SourceLocation),
871 "Alignment not sufficient for SourceLocation");
872
873 unsigned Size = sizeof(ParmVarDecl *) * NumParams +
874 sizeof(SourceLocation) * SelLocs.size();
875 ParamsAndSelLocs = C.Allocate(Size);
876 std::copy(Params.begin(), Params.end(), getParams());
877 std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
878}
879
880void ObjCMethodDecl::getSelectorLocs(
881 SmallVectorImpl<SourceLocation> &SelLocs) const {
882 for (unsigned i = 0, e = getNumSelectorLocs(); i != e; ++i)
883 SelLocs.push_back(getSelectorLoc(i));
884}
885
886void ObjCMethodDecl::setMethodParams(ASTContext &C,
887 ArrayRef<ParmVarDecl*> Params,
888 ArrayRef<SourceLocation> SelLocs) {
889 assert((!SelLocs.empty() || isImplicit()) &&(((!SelLocs.empty() || isImplicit()) && "No selector locs for non-implicit method"
) ? static_cast<void> (0) : __assert_fail ("(!SelLocs.empty() || isImplicit()) && \"No selector locs for non-implicit method\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 890, __PRETTY_FUNCTION__))
890 "No selector locs for non-implicit method")(((!SelLocs.empty() || isImplicit()) && "No selector locs for non-implicit method"
) ? static_cast<void> (0) : __assert_fail ("(!SelLocs.empty() || isImplicit()) && \"No selector locs for non-implicit method\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 890, __PRETTY_FUNCTION__))
;
891 if (isImplicit())
892 return setParamsAndSelLocs(C, Params, llvm::None);
893
894 setSelLocsKind(hasStandardSelectorLocs(getSelector(), SelLocs, Params,
895 DeclEndLoc));
896 if (getSelLocsKind() != SelLoc_NonStandard)
897 return setParamsAndSelLocs(C, Params, llvm::None);
898
899 setParamsAndSelLocs(C, Params, SelLocs);
900}
901
902/// A definition will return its interface declaration.
903/// An interface declaration will return its definition.
904/// Otherwise it will return itself.
905ObjCMethodDecl *ObjCMethodDecl::getNextRedeclarationImpl() {
906 ASTContext &Ctx = getASTContext();
907 ObjCMethodDecl *Redecl = nullptr;
908 if (hasRedeclaration())
909 Redecl = const_cast<ObjCMethodDecl*>(Ctx.getObjCMethodRedeclaration(this));
910 if (Redecl)
911 return Redecl;
912
913 auto *CtxD = cast<Decl>(getDeclContext());
914
915 if (!CtxD->isInvalidDecl()) {
916 if (auto *IFD = dyn_cast<ObjCInterfaceDecl>(CtxD)) {
917 if (ObjCImplementationDecl *ImplD = Ctx.getObjCImplementation(IFD))
918 if (!ImplD->isInvalidDecl())
919 Redecl = ImplD->getMethod(getSelector(), isInstanceMethod());
920
921 } else if (auto *CD = dyn_cast<ObjCCategoryDecl>(CtxD)) {
922 if (ObjCCategoryImplDecl *ImplD = Ctx.getObjCImplementation(CD))
923 if (!ImplD->isInvalidDecl())
924 Redecl = ImplD->getMethod(getSelector(), isInstanceMethod());
925
926 } else if (auto *ImplD = dyn_cast<ObjCImplementationDecl>(CtxD)) {
927 if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface())
928 if (!IFD->isInvalidDecl())
929 Redecl = IFD->getMethod(getSelector(), isInstanceMethod());
930
931 } else if (auto *CImplD = dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
932 if (ObjCCategoryDecl *CatD = CImplD->getCategoryDecl())
933 if (!CatD->isInvalidDecl())
934 Redecl = CatD->getMethod(getSelector(), isInstanceMethod());
935 }
936 }
937
938 // Ensure that the discovered method redeclaration has a valid declaration
939 // context. Used to prevent infinite loops when iterating redeclarations in
940 // a partially invalid AST.
941 if (Redecl && cast<Decl>(Redecl->getDeclContext())->isInvalidDecl())
942 Redecl = nullptr;
943
944 if (!Redecl && isRedeclaration()) {
945 // This is the last redeclaration, go back to the first method.
946 return cast<ObjCContainerDecl>(CtxD)->getMethod(getSelector(),
947 isInstanceMethod());
948 }
949
950 return Redecl ? Redecl : this;
951}
952
953ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() {
954 auto *CtxD = cast<Decl>(getDeclContext());
955
956 if (auto *ImplD = dyn_cast<ObjCImplementationDecl>(CtxD)) {
957 if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface())
958 if (ObjCMethodDecl *MD = IFD->getMethod(getSelector(),
959 isInstanceMethod()))
960 return MD;
961 } else if (auto *CImplD = dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
962 if (ObjCCategoryDecl *CatD = CImplD->getCategoryDecl())
963 if (ObjCMethodDecl *MD = CatD->getMethod(getSelector(),
964 isInstanceMethod()))
965 return MD;
966 }
967
968 if (isRedeclaration()) {
969 // It is possible that we have not done deserializing the ObjCMethod yet.
970 ObjCMethodDecl *MD =
971 cast<ObjCContainerDecl>(CtxD)->getMethod(getSelector(),
972 isInstanceMethod());
973 return MD ? MD : this;
974 }
975
976 return this;
977}
978
979SourceLocation ObjCMethodDecl::getEndLoc() const {
980 if (Stmt *Body = getBody())
981 return Body->getEndLoc();
982 return DeclEndLoc;
983}
984
985ObjCMethodFamily ObjCMethodDecl::getMethodFamily() const {
986 auto family = static_cast<ObjCMethodFamily>(ObjCMethodDeclBits.Family);
987 if (family != static_cast<unsigned>(InvalidObjCMethodFamily))
988 return family;
989
990 // Check for an explicit attribute.
991 if (const ObjCMethodFamilyAttr *attr = getAttr<ObjCMethodFamilyAttr>()) {
992 // The unfortunate necessity of mapping between enums here is due
993 // to the attributes framework.
994 switch (attr->getFamily()) {
995 case ObjCMethodFamilyAttr::OMF_None: family = OMF_None; break;
996 case ObjCMethodFamilyAttr::OMF_alloc: family = OMF_alloc; break;
997 case ObjCMethodFamilyAttr::OMF_copy: family = OMF_copy; break;
998 case ObjCMethodFamilyAttr::OMF_init: family = OMF_init; break;
999 case ObjCMethodFamilyAttr::OMF_mutableCopy: family = OMF_mutableCopy; break;
1000 case ObjCMethodFamilyAttr::OMF_new: family = OMF_new; break;
1001 }
1002 ObjCMethodDeclBits.Family = family;
1003 return family;
1004 }
1005
1006 family = getSelector().getMethodFamily();
1007 switch (family) {
1008 case OMF_None: break;
1009
1010 // init only has a conventional meaning for an instance method, and
1011 // it has to return an object.
1012 case OMF_init:
1013 if (!isInstanceMethod() || !getReturnType()->isObjCObjectPointerType())
1014 family = OMF_None;
1015 break;
1016
1017 // alloc/copy/new have a conventional meaning for both class and
1018 // instance methods, but they require an object return.
1019 case OMF_alloc:
1020 case OMF_copy:
1021 case OMF_mutableCopy:
1022 case OMF_new:
1023 if (!getReturnType()->isObjCObjectPointerType())
1024 family = OMF_None;
1025 break;
1026
1027 // These selectors have a conventional meaning only for instance methods.
1028 case OMF_dealloc:
1029 case OMF_finalize:
1030 case OMF_retain:
1031 case OMF_release:
1032 case OMF_autorelease:
1033 case OMF_retainCount:
1034 case OMF_self:
1035 if (!isInstanceMethod())
1036 family = OMF_None;
1037 break;
1038
1039 case OMF_initialize:
1040 if (isInstanceMethod() || !getReturnType()->isVoidType())
1041 family = OMF_None;
1042 break;
1043
1044 case OMF_performSelector:
1045 if (!isInstanceMethod() || !getReturnType()->isObjCIdType())
1046 family = OMF_None;
1047 else {
1048 unsigned noParams = param_size();
1049 if (noParams < 1 || noParams > 3)
1050 family = OMF_None;
1051 else {
1052 ObjCMethodDecl::param_type_iterator it = param_type_begin();
1053 QualType ArgT = (*it);
1054 if (!ArgT->isObjCSelType()) {
1055 family = OMF_None;
1056 break;
1057 }
1058 while (--noParams) {
1059 it++;
1060 ArgT = (*it);
1061 if (!ArgT->isObjCIdType()) {
1062 family = OMF_None;
1063 break;
1064 }
1065 }
1066 }
1067 }
1068 break;
1069
1070 }
1071
1072 // Cache the result.
1073 ObjCMethodDeclBits.Family = family;
1074 return family;
1075}
1076
1077QualType ObjCMethodDecl::getSelfType(ASTContext &Context,
1078 const ObjCInterfaceDecl *OID,
1079 bool &selfIsPseudoStrong,
1080 bool &selfIsConsumed) {
1081 QualType selfTy;
1082 selfIsPseudoStrong = false;
1083 selfIsConsumed = false;
1084 if (isInstanceMethod()) {
1085 // There may be no interface context due to error in declaration
1086 // of the interface (which has been reported). Recover gracefully.
1087 if (OID) {
1088 selfTy = Context.getObjCInterfaceType(OID);
1089 selfTy = Context.getObjCObjectPointerType(selfTy);
1090 } else {
1091 selfTy = Context.getObjCIdType();
1092 }
1093 } else // we have a factory method.
1094 selfTy = Context.getObjCClassType();
1095
1096 if (Context.getLangOpts().ObjCAutoRefCount) {
1097 if (isInstanceMethod()) {
1098 selfIsConsumed = hasAttr<NSConsumesSelfAttr>();
1099
1100 // 'self' is always __strong. It's actually pseudo-strong except
1101 // in init methods (or methods labeled ns_consumes_self), though.
1102 Qualifiers qs;
1103 qs.setObjCLifetime(Qualifiers::OCL_Strong);
1104 selfTy = Context.getQualifiedType(selfTy, qs);
1105
1106 // In addition, 'self' is const unless this is an init method.
1107 if (getMethodFamily() != OMF_init && !selfIsConsumed) {
1108 selfTy = selfTy.withConst();
1109 selfIsPseudoStrong = true;
1110 }
1111 }
1112 else {
1113 assert(isClassMethod())((isClassMethod()) ? static_cast<void> (0) : __assert_fail
("isClassMethod()", "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1113, __PRETTY_FUNCTION__))
;
1114 // 'self' is always const in class methods.
1115 selfTy = selfTy.withConst();
1116 selfIsPseudoStrong = true;
1117 }
1118 }
1119 return selfTy;
1120}
1121
1122void ObjCMethodDecl::createImplicitParams(ASTContext &Context,
1123 const ObjCInterfaceDecl *OID) {
1124 bool selfIsPseudoStrong, selfIsConsumed;
1125 QualType selfTy =
1126 getSelfType(Context, OID, selfIsPseudoStrong, selfIsConsumed);
1127 auto *Self = ImplicitParamDecl::Create(Context, this, SourceLocation(),
1128 &Context.Idents.get("self"), selfTy,
1129 ImplicitParamDecl::ObjCSelf);
1130 setSelfDecl(Self);
1131
1132 if (selfIsConsumed)
1
Taking true branch
1133 Self->addAttr(NSConsumedAttr::CreateImplicit(Context));
2
Calling 'NSConsumedAttr::CreateImplicit'
1134
1135 if (selfIsPseudoStrong)
1136 Self->setARCPseudoStrong(true);
1137
1138 setCmdDecl(ImplicitParamDecl::Create(
1139 Context, this, SourceLocation(), &Context.Idents.get("_cmd"),
1140 Context.getObjCSelType(), ImplicitParamDecl::ObjCCmd));
1141}
1142
1143ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() {
1144 if (auto *ID = dyn_cast<ObjCInterfaceDecl>(getDeclContext()))
1145 return ID;
1146 if (auto *CD = dyn_cast<ObjCCategoryDecl>(getDeclContext()))
1147 return CD->getClassInterface();
1148 if (auto *IMD = dyn_cast<ObjCImplDecl>(getDeclContext()))
1149 return IMD->getClassInterface();
1150 if (isa<ObjCProtocolDecl>(getDeclContext()))
1151 return nullptr;
1152 llvm_unreachable("unknown method context")::llvm::llvm_unreachable_internal("unknown method context", "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1152)
;
1153}
1154
1155SourceRange ObjCMethodDecl::getReturnTypeSourceRange() const {
1156 const auto *TSI = getReturnTypeSourceInfo();
1157 if (TSI)
1158 return TSI->getTypeLoc().getSourceRange();
1159 return SourceRange();
1160}
1161
1162QualType ObjCMethodDecl::getSendResultType() const {
1163 ASTContext &Ctx = getASTContext();
1164 return getReturnType().getNonLValueExprType(Ctx)
1165 .substObjCTypeArgs(Ctx, {}, ObjCSubstitutionContext::Result);
1166}
1167
1168QualType ObjCMethodDecl::getSendResultType(QualType receiverType) const {
1169 // FIXME: Handle related result types here.
1170
1171 return getReturnType().getNonLValueExprType(getASTContext())
1172 .substObjCMemberType(receiverType, getDeclContext(),
1173 ObjCSubstitutionContext::Result);
1174}
1175
1176static void CollectOverriddenMethodsRecurse(const ObjCContainerDecl *Container,
1177 const ObjCMethodDecl *Method,
1178 SmallVectorImpl<const ObjCMethodDecl *> &Methods,
1179 bool MovedToSuper) {
1180 if (!Container)
1181 return;
1182
1183 // In categories look for overridden methods from protocols. A method from
1184 // category is not "overridden" since it is considered as the "same" method
1185 // (same USR) as the one from the interface.
1186 if (const auto *Category = dyn_cast<ObjCCategoryDecl>(Container)) {
1187 // Check whether we have a matching method at this category but only if we
1188 // are at the super class level.
1189 if (MovedToSuper)
1190 if (ObjCMethodDecl *
1191 Overridden = Container->getMethod(Method->getSelector(),
1192 Method->isInstanceMethod(),
1193 /*AllowHidden=*/true))
1194 if (Method != Overridden) {
1195 // We found an override at this category; there is no need to look
1196 // into its protocols.
1197 Methods.push_back(Overridden);
1198 return;
1199 }
1200
1201 for (const auto *P : Category->protocols())
1202 CollectOverriddenMethodsRecurse(P, Method, Methods, MovedToSuper);
1203 return;
1204 }
1205
1206 // Check whether we have a matching method at this level.
1207 if (const ObjCMethodDecl *
1208 Overridden = Container->getMethod(Method->getSelector(),
1209 Method->isInstanceMethod(),
1210 /*AllowHidden=*/true))
1211 if (Method != Overridden) {
1212 // We found an override at this level; there is no need to look
1213 // into other protocols or categories.
1214 Methods.push_back(Overridden);
1215 return;
1216 }
1217
1218 if (const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)){
1219 for (const auto *P : Protocol->protocols())
1220 CollectOverriddenMethodsRecurse(P, Method, Methods, MovedToSuper);
1221 }
1222
1223 if (const auto *Interface = dyn_cast<ObjCInterfaceDecl>(Container)) {
1224 for (const auto *P : Interface->protocols())
1225 CollectOverriddenMethodsRecurse(P, Method, Methods, MovedToSuper);
1226
1227 for (const auto *Cat : Interface->known_categories())
1228 CollectOverriddenMethodsRecurse(Cat, Method, Methods, MovedToSuper);
1229
1230 if (const ObjCInterfaceDecl *Super = Interface->getSuperClass())
1231 return CollectOverriddenMethodsRecurse(Super, Method, Methods,
1232 /*MovedToSuper=*/true);
1233 }
1234}
1235
1236static inline void CollectOverriddenMethods(const ObjCContainerDecl *Container,
1237 const ObjCMethodDecl *Method,
1238 SmallVectorImpl<const ObjCMethodDecl *> &Methods) {
1239 CollectOverriddenMethodsRecurse(Container, Method, Methods,
1240 /*MovedToSuper=*/false);
1241}
1242
1243static void collectOverriddenMethodsSlow(const ObjCMethodDecl *Method,
1244 SmallVectorImpl<const ObjCMethodDecl *> &overridden) {
1245 assert(Method->isOverriding())((Method->isOverriding()) ? static_cast<void> (0) : __assert_fail
("Method->isOverriding()", "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1245, __PRETTY_FUNCTION__))
;
1246
1247 if (const auto *ProtD =
1248 dyn_cast<ObjCProtocolDecl>(Method->getDeclContext())) {
1249 CollectOverriddenMethods(ProtD, Method, overridden);
1250
1251 } else if (const auto *IMD =
1252 dyn_cast<ObjCImplDecl>(Method->getDeclContext())) {
1253 const ObjCInterfaceDecl *ID = IMD->getClassInterface();
1254 if (!ID)
1255 return;
1256 // Start searching for overridden methods using the method from the
1257 // interface as starting point.
1258 if (const ObjCMethodDecl *IFaceMeth = ID->getMethod(Method->getSelector(),
1259 Method->isInstanceMethod(),
1260 /*AllowHidden=*/true))
1261 Method = IFaceMeth;
1262 CollectOverriddenMethods(ID, Method, overridden);
1263
1264 } else if (const auto *CatD =
1265 dyn_cast<ObjCCategoryDecl>(Method->getDeclContext())) {
1266 const ObjCInterfaceDecl *ID = CatD->getClassInterface();
1267 if (!ID)
1268 return;
1269 // Start searching for overridden methods using the method from the
1270 // interface as starting point.
1271 if (const ObjCMethodDecl *IFaceMeth = ID->getMethod(Method->getSelector(),
1272 Method->isInstanceMethod(),
1273 /*AllowHidden=*/true))
1274 Method = IFaceMeth;
1275 CollectOverriddenMethods(ID, Method, overridden);
1276
1277 } else {
1278 CollectOverriddenMethods(
1279 dyn_cast_or_null<ObjCContainerDecl>(Method->getDeclContext()),
1280 Method, overridden);
1281 }
1282}
1283
1284void ObjCMethodDecl::getOverriddenMethods(
1285 SmallVectorImpl<const ObjCMethodDecl *> &Overridden) const {
1286 const ObjCMethodDecl *Method = this;
1287
1288 if (Method->isRedeclaration()) {
1289 Method = cast<ObjCContainerDecl>(Method->getDeclContext())->
1290 getMethod(Method->getSelector(), Method->isInstanceMethod());
1291 }
1292
1293 if (Method->isOverriding()) {
1294 collectOverriddenMethodsSlow(Method, Overridden);
1295 assert(!Overridden.empty() &&((!Overridden.empty() && "ObjCMethodDecl's overriding bit is not as expected"
) ? static_cast<void> (0) : __assert_fail ("!Overridden.empty() && \"ObjCMethodDecl's overriding bit is not as expected\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1296, __PRETTY_FUNCTION__))
1296 "ObjCMethodDecl's overriding bit is not as expected")((!Overridden.empty() && "ObjCMethodDecl's overriding bit is not as expected"
) ? static_cast<void> (0) : __assert_fail ("!Overridden.empty() && \"ObjCMethodDecl's overriding bit is not as expected\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1296, __PRETTY_FUNCTION__))
;
1297 }
1298}
1299
1300const ObjCPropertyDecl *
1301ObjCMethodDecl::findPropertyDecl(bool CheckOverrides) const {
1302 Selector Sel = getSelector();
1303 unsigned NumArgs = Sel.getNumArgs();
1304 if (NumArgs > 1)
1305 return nullptr;
1306
1307 if (isPropertyAccessor()) {
1308 const auto *Container = cast<ObjCContainerDecl>(getParent());
1309 bool IsGetter = (NumArgs == 0);
1310 bool IsInstance = isInstanceMethod();
1311
1312 /// Local function that attempts to find a matching property within the
1313 /// given Objective-C container.
1314 auto findMatchingProperty =
1315 [&](const ObjCContainerDecl *Container) -> const ObjCPropertyDecl * {
1316 if (IsInstance) {
1317 for (const auto *I : Container->instance_properties()) {
1318 Selector NextSel = IsGetter ? I->getGetterName()
1319 : I->getSetterName();
1320 if (NextSel == Sel)
1321 return I;
1322 }
1323 } else {
1324 for (const auto *I : Container->class_properties()) {
1325 Selector NextSel = IsGetter ? I->getGetterName()
1326 : I->getSetterName();
1327 if (NextSel == Sel)
1328 return I;
1329 }
1330 }
1331
1332 return nullptr;
1333 };
1334
1335 // Look in the container we were given.
1336 if (const auto *Found = findMatchingProperty(Container))
1337 return Found;
1338
1339 // If we're in a category or extension, look in the main class.
1340 const ObjCInterfaceDecl *ClassDecl = nullptr;
1341 if (const auto *Category = dyn_cast<ObjCCategoryDecl>(Container)) {
1342 ClassDecl = Category->getClassInterface();
1343 if (const auto *Found = findMatchingProperty(ClassDecl))
1344 return Found;
1345 } else {
1346 // Determine whether the container is a class.
1347 ClassDecl = dyn_cast<ObjCInterfaceDecl>(Container);
1348 }
1349
1350 // If we have a class, check its visible extensions.
1351 if (ClassDecl) {
1352 for (const auto *Ext : ClassDecl->visible_extensions()) {
1353 if (Ext == Container)
1354 continue;
1355
1356 if (const auto *Found = findMatchingProperty(Ext))
1357 return Found;
1358 }
1359 }
1360
1361 llvm_unreachable("Marked as a property accessor but no property found!")::llvm::llvm_unreachable_internal("Marked as a property accessor but no property found!"
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1361)
;
1362 }
1363
1364 if (!CheckOverrides)
1365 return nullptr;
1366
1367 using OverridesTy = SmallVector<const ObjCMethodDecl *, 8>;
1368
1369 OverridesTy Overrides;
1370 getOverriddenMethods(Overrides);
1371 for (const auto *Override : Overrides)
1372 if (const ObjCPropertyDecl *Prop = Override->findPropertyDecl(false))
1373 return Prop;
1374
1375 return nullptr;
1376}
1377
1378//===----------------------------------------------------------------------===//
1379// ObjCTypeParamDecl
1380//===----------------------------------------------------------------------===//
1381
1382void ObjCTypeParamDecl::anchor() {}
1383
1384ObjCTypeParamDecl *ObjCTypeParamDecl::Create(ASTContext &ctx, DeclContext *dc,
1385 ObjCTypeParamVariance variance,
1386 SourceLocation varianceLoc,
1387 unsigned index,
1388 SourceLocation nameLoc,
1389 IdentifierInfo *name,
1390 SourceLocation colonLoc,
1391 TypeSourceInfo *boundInfo) {
1392 auto *TPDecl =
1393 new (ctx, dc) ObjCTypeParamDecl(ctx, dc, variance, varianceLoc, index,
1394 nameLoc, name, colonLoc, boundInfo);
1395 QualType TPType = ctx.getObjCTypeParamType(TPDecl, {});
1396 TPDecl->setTypeForDecl(TPType.getTypePtr());
1397 return TPDecl;
1398}
1399
1400ObjCTypeParamDecl *ObjCTypeParamDecl::CreateDeserialized(ASTContext &ctx,
1401 unsigned ID) {
1402 return new (ctx, ID) ObjCTypeParamDecl(ctx, nullptr,
1403 ObjCTypeParamVariance::Invariant,
1404 SourceLocation(), 0, SourceLocation(),
1405 nullptr, SourceLocation(), nullptr);
1406}
1407
1408SourceRange ObjCTypeParamDecl::getSourceRange() const {
1409 SourceLocation startLoc = VarianceLoc;
1410 if (startLoc.isInvalid())
1411 startLoc = getLocation();
1412
1413 if (hasExplicitBound()) {
1414 return SourceRange(startLoc,
1415 getTypeSourceInfo()->getTypeLoc().getEndLoc());
1416 }
1417
1418 return SourceRange(startLoc);
1419}
1420
1421//===----------------------------------------------------------------------===//
1422// ObjCTypeParamList
1423//===----------------------------------------------------------------------===//
1424ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc,
1425 ArrayRef<ObjCTypeParamDecl *> typeParams,
1426 SourceLocation rAngleLoc)
1427 : NumParams(typeParams.size()) {
1428 Brackets.Begin = lAngleLoc.getRawEncoding();
1429 Brackets.End = rAngleLoc.getRawEncoding();
1430 std::copy(typeParams.begin(), typeParams.end(), begin());
1431}
1432
1433ObjCTypeParamList *ObjCTypeParamList::create(
1434 ASTContext &ctx,
1435 SourceLocation lAngleLoc,
1436 ArrayRef<ObjCTypeParamDecl *> typeParams,
1437 SourceLocation rAngleLoc) {
1438 void *mem =
1439 ctx.Allocate(totalSizeToAlloc<ObjCTypeParamDecl *>(typeParams.size()),
1440 alignof(ObjCTypeParamList));
1441 return new (mem) ObjCTypeParamList(lAngleLoc, typeParams, rAngleLoc);
1442}
1443
1444void ObjCTypeParamList::gatherDefaultTypeArgs(
1445 SmallVectorImpl<QualType> &typeArgs) const {
1446 typeArgs.reserve(size());
1447 for (auto typeParam : *this)
1448 typeArgs.push_back(typeParam->getUnderlyingType());
1449}
1450
1451//===----------------------------------------------------------------------===//
1452// ObjCInterfaceDecl
1453//===----------------------------------------------------------------------===//
1454
1455ObjCInterfaceDecl *ObjCInterfaceDecl::Create(const ASTContext &C,
1456 DeclContext *DC,
1457 SourceLocation atLoc,
1458 IdentifierInfo *Id,
1459 ObjCTypeParamList *typeParamList,
1460 ObjCInterfaceDecl *PrevDecl,
1461 SourceLocation ClassLoc,
1462 bool isInternal){
1463 auto *Result = new (C, DC)
1464 ObjCInterfaceDecl(C, DC, atLoc, Id, typeParamList, ClassLoc, PrevDecl,
1465 isInternal);
1466 Result->Data.setInt(!C.getLangOpts().Modules);
1467 C.getObjCInterfaceType(Result, PrevDecl);
1468 return Result;
1469}
1470
1471ObjCInterfaceDecl *ObjCInterfaceDecl::CreateDeserialized(const ASTContext &C,
1472 unsigned ID) {
1473 auto *Result = new (C, ID)
1474 ObjCInterfaceDecl(C, nullptr, SourceLocation(), nullptr, nullptr,
1475 SourceLocation(), nullptr, false);
1476 Result->Data.setInt(!C.getLangOpts().Modules);
1477 return Result;
1478}
1479
1480ObjCInterfaceDecl::ObjCInterfaceDecl(const ASTContext &C, DeclContext *DC,
1481 SourceLocation AtLoc, IdentifierInfo *Id,
1482 ObjCTypeParamList *typeParamList,
1483 SourceLocation CLoc,
1484 ObjCInterfaceDecl *PrevDecl,
1485 bool IsInternal)
1486 : ObjCContainerDecl(ObjCInterface, DC, Id, CLoc, AtLoc),
1487 redeclarable_base(C) {
1488 setPreviousDecl(PrevDecl);
1489
1490 // Copy the 'data' pointer over.
1491 if (PrevDecl)
1492 Data = PrevDecl->Data;
1493
1494 setImplicit(IsInternal);
1495
1496 setTypeParamList(typeParamList);
1497}
1498
1499void ObjCInterfaceDecl::LoadExternalDefinition() const {
1500 assert(data().ExternallyCompleted && "Class is not externally completed")((data().ExternallyCompleted && "Class is not externally completed"
) ? static_cast<void> (0) : __assert_fail ("data().ExternallyCompleted && \"Class is not externally completed\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1500, __PRETTY_FUNCTION__))
;
1501 data().ExternallyCompleted = false;
1502 getASTContext().getExternalSource()->CompleteType(
1503 const_cast<ObjCInterfaceDecl *>(this));
1504}
1505
1506void ObjCInterfaceDecl::setExternallyCompleted() {
1507 assert(getASTContext().getExternalSource() &&((getASTContext().getExternalSource() && "Class can't be externally completed without an external source"
) ? static_cast<void> (0) : __assert_fail ("getASTContext().getExternalSource() && \"Class can't be externally completed without an external source\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1508, __PRETTY_FUNCTION__))
1508 "Class can't be externally completed without an external source")((getASTContext().getExternalSource() && "Class can't be externally completed without an external source"
) ? static_cast<void> (0) : __assert_fail ("getASTContext().getExternalSource() && \"Class can't be externally completed without an external source\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1508, __PRETTY_FUNCTION__))
;
1509 assert(hasDefinition() &&((hasDefinition() && "Forward declarations can't be externally completed"
) ? static_cast<void> (0) : __assert_fail ("hasDefinition() && \"Forward declarations can't be externally completed\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1510, __PRETTY_FUNCTION__))
1510 "Forward declarations can't be externally completed")((hasDefinition() && "Forward declarations can't be externally completed"
) ? static_cast<void> (0) : __assert_fail ("hasDefinition() && \"Forward declarations can't be externally completed\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1510, __PRETTY_FUNCTION__))
;
1511 data().ExternallyCompleted = true;
1512}
1513
1514void ObjCInterfaceDecl::setHasDesignatedInitializers() {
1515 // Check for a complete definition and recover if not so.
1516 if (!isThisDeclarationADefinition())
1517 return;
1518 data().HasDesignatedInitializers = true;
1519}
1520
1521bool ObjCInterfaceDecl::hasDesignatedInitializers() const {
1522 // Check for a complete definition and recover if not so.
1523 if (!isThisDeclarationADefinition())
1524 return false;
1525 if (data().ExternallyCompleted)
1526 LoadExternalDefinition();
1527
1528 return data().HasDesignatedInitializers;
1529}
1530
1531StringRef
1532ObjCInterfaceDecl::getObjCRuntimeNameAsString() const {
1533 if (const auto *ObjCRTName = getAttr<ObjCRuntimeNameAttr>())
1534 return ObjCRTName->getMetadataName();
1535
1536 return getName();
1537}
1538
1539StringRef
1540ObjCImplementationDecl::getObjCRuntimeNameAsString() const {
1541 if (ObjCInterfaceDecl *ID =
1542 const_cast<ObjCImplementationDecl*>(this)->getClassInterface())
1543 return ID->getObjCRuntimeNameAsString();
1544
1545 return getName();
1546}
1547
1548ObjCImplementationDecl *ObjCInterfaceDecl::getImplementation() const {
1549 if (const ObjCInterfaceDecl *Def = getDefinition()) {
1550 if (data().ExternallyCompleted)
1551 LoadExternalDefinition();
1552
1553 return getASTContext().getObjCImplementation(
1554 const_cast<ObjCInterfaceDecl*>(Def));
1555 }
1556
1557 // FIXME: Should make sure no callers ever do this.
1558 return nullptr;
1559}
1560
1561void ObjCInterfaceDecl::setImplementation(ObjCImplementationDecl *ImplD) {
1562 getASTContext().setObjCImplementation(getDefinition(), ImplD);
1563}
1564
1565namespace {
1566
1567struct SynthesizeIvarChunk {
1568 uint64_t Size;
1569 ObjCIvarDecl *Ivar;
1570
1571 SynthesizeIvarChunk(uint64_t size, ObjCIvarDecl *ivar)
1572 : Size(size), Ivar(ivar) {}
1573};
1574
1575bool operator<(const SynthesizeIvarChunk & LHS,
1576 const SynthesizeIvarChunk &RHS) {
1577 return LHS.Size < RHS.Size;
1578}
1579
1580} // namespace
1581
1582/// all_declared_ivar_begin - return first ivar declared in this class,
1583/// its extensions and its implementation. Lazily build the list on first
1584/// access.
1585///
1586/// Caveat: The list returned by this method reflects the current
1587/// state of the parser. The cache will be updated for every ivar
1588/// added by an extension or the implementation when they are
1589/// encountered.
1590/// See also ObjCIvarDecl::Create().
1591ObjCIvarDecl *ObjCInterfaceDecl::all_declared_ivar_begin() {
1592 // FIXME: Should make sure no callers ever do this.
1593 if (!hasDefinition())
1594 return nullptr;
1595
1596 ObjCIvarDecl *curIvar = nullptr;
1597 if (!data().IvarList) {
1598 if (!ivar_empty()) {
1599 ObjCInterfaceDecl::ivar_iterator I = ivar_begin(), E = ivar_end();
1600 data().IvarList = *I; ++I;
1601 for (curIvar = data().IvarList; I != E; curIvar = *I, ++I)
1602 curIvar->setNextIvar(*I);
1603 }
1604
1605 for (const auto *Ext : known_extensions()) {
1606 if (!Ext->ivar_empty()) {
1607 ObjCCategoryDecl::ivar_iterator
1608 I = Ext->ivar_begin(),
1609 E = Ext->ivar_end();
1610 if (!data().IvarList) {
1611 data().IvarList = *I; ++I;
1612 curIvar = data().IvarList;
1613 }
1614 for ( ;I != E; curIvar = *I, ++I)
1615 curIvar->setNextIvar(*I);
1616 }
1617 }
1618 data().IvarListMissingImplementation = true;
1619 }
1620
1621 // cached and complete!
1622 if (!data().IvarListMissingImplementation)
1623 return data().IvarList;
1624
1625 if (ObjCImplementationDecl *ImplDecl = getImplementation()) {
1626 data().IvarListMissingImplementation = false;
1627 if (!ImplDecl->ivar_empty()) {
1628 SmallVector<SynthesizeIvarChunk, 16> layout;
1629 for (auto *IV : ImplDecl->ivars()) {
1630 if (IV->getSynthesize() && !IV->isInvalidDecl()) {
1631 layout.push_back(SynthesizeIvarChunk(
1632 IV->getASTContext().getTypeSize(IV->getType()), IV));
1633 continue;
1634 }
1635 if (!data().IvarList)
1636 data().IvarList = IV;
1637 else
1638 curIvar->setNextIvar(IV);
1639 curIvar = IV;
1640 }
1641
1642 if (!layout.empty()) {
1643 // Order synthesized ivars by their size.
1644 llvm::stable_sort(layout);
1645 unsigned Ix = 0, EIx = layout.size();
1646 if (!data().IvarList) {
1647 data().IvarList = layout[0].Ivar; Ix++;
1648 curIvar = data().IvarList;
1649 }
1650 for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
1651 curIvar->setNextIvar(layout[Ix].Ivar);
1652 }
1653 }
1654 }
1655 return data().IvarList;
1656}
1657
1658/// FindCategoryDeclaration - Finds category declaration in the list of
1659/// categories for this class and returns it. Name of the category is passed
1660/// in 'CategoryId'. If category not found, return 0;
1661///
1662ObjCCategoryDecl *
1663ObjCInterfaceDecl::FindCategoryDeclaration(IdentifierInfo *CategoryId) const {
1664 // FIXME: Should make sure no callers ever do this.
1665 if (!hasDefinition())
1666 return nullptr;
1667
1668 if (data().ExternallyCompleted)
1669 LoadExternalDefinition();
1670
1671 for (auto *Cat : visible_categories())
1672 if (Cat->getIdentifier() == CategoryId)
1673 return Cat;
1674
1675 return nullptr;
1676}
1677
1678ObjCMethodDecl *
1679ObjCInterfaceDecl::getCategoryInstanceMethod(Selector Sel) const {
1680 for (const auto *Cat : visible_categories()) {
1681 if (ObjCCategoryImplDecl *Impl = Cat->getImplementation())
1682 if (ObjCMethodDecl *MD = Impl->getInstanceMethod(Sel))
1683 return MD;
1684 }
1685
1686 return nullptr;
1687}
1688
1689ObjCMethodDecl *ObjCInterfaceDecl::getCategoryClassMethod(Selector Sel) const {
1690 for (const auto *Cat : visible_categories()) {
1691 if (ObjCCategoryImplDecl *Impl = Cat->getImplementation())
1692 if (ObjCMethodDecl *MD = Impl->getClassMethod(Sel))
1693 return MD;
1694 }
1695
1696 return nullptr;
1697}
1698
1699/// ClassImplementsProtocol - Checks that 'lProto' protocol
1700/// has been implemented in IDecl class, its super class or categories (if
1701/// lookupCategory is true).
1702bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto,
1703 bool lookupCategory,
1704 bool RHSIsQualifiedID) {
1705 if (!hasDefinition())
1706 return false;
1707
1708 ObjCInterfaceDecl *IDecl = this;
1709 // 1st, look up the class.
1710 for (auto *PI : IDecl->protocols()){
1711 if (getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
1712 return true;
1713 // This is dubious and is added to be compatible with gcc. In gcc, it is
1714 // also allowed assigning a protocol-qualified 'id' type to a LHS object
1715 // when protocol in qualified LHS is in list of protocols in the rhs 'id'
1716 // object. This IMO, should be a bug.
1717 // FIXME: Treat this as an extension, and flag this as an error when GCC
1718 // extensions are not enabled.
1719 if (RHSIsQualifiedID &&
1720 getASTContext().ProtocolCompatibleWithProtocol(PI, lProto))
1721 return true;
1722 }
1723
1724 // 2nd, look up the category.
1725 if (lookupCategory)
1726 for (const auto *Cat : visible_categories()) {
1727 for (auto *PI : Cat->protocols())
1728 if (getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
1729 return true;
1730 }
1731
1732 // 3rd, look up the super class(s)
1733 if (IDecl->getSuperClass())
1734 return
1735 IDecl->getSuperClass()->ClassImplementsProtocol(lProto, lookupCategory,
1736 RHSIsQualifiedID);
1737
1738 return false;
1739}
1740
1741//===----------------------------------------------------------------------===//
1742// ObjCIvarDecl
1743//===----------------------------------------------------------------------===//
1744
1745void ObjCIvarDecl::anchor() {}
1746
1747ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, ObjCContainerDecl *DC,
1748 SourceLocation StartLoc,
1749 SourceLocation IdLoc, IdentifierInfo *Id,
1750 QualType T, TypeSourceInfo *TInfo,
1751 AccessControl ac, Expr *BW,
1752 bool synthesized) {
1753 if (DC) {
1754 // Ivar's can only appear in interfaces, implementations (via synthesized
1755 // properties), and class extensions (via direct declaration, or synthesized
1756 // properties).
1757 //
1758 // FIXME: This should really be asserting this:
1759 // (isa<ObjCCategoryDecl>(DC) &&
1760 // cast<ObjCCategoryDecl>(DC)->IsClassExtension()))
1761 // but unfortunately we sometimes place ivars into non-class extension
1762 // categories on error. This breaks an AST invariant, and should not be
1763 // fixed.
1764 assert((isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl>(DC) ||(((isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl
>(DC) || isa<ObjCCategoryDecl>(DC)) && "Invalid ivar decl context!"
) ? static_cast<void> (0) : __assert_fail ("(isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl>(DC) || isa<ObjCCategoryDecl>(DC)) && \"Invalid ivar decl context!\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1766, __PRETTY_FUNCTION__))
1765 isa<ObjCCategoryDecl>(DC)) &&(((isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl
>(DC) || isa<ObjCCategoryDecl>(DC)) && "Invalid ivar decl context!"
) ? static_cast<void> (0) : __assert_fail ("(isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl>(DC) || isa<ObjCCategoryDecl>(DC)) && \"Invalid ivar decl context!\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1766, __PRETTY_FUNCTION__))
1766 "Invalid ivar decl context!")(((isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl
>(DC) || isa<ObjCCategoryDecl>(DC)) && "Invalid ivar decl context!"
) ? static_cast<void> (0) : __assert_fail ("(isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl>(DC) || isa<ObjCCategoryDecl>(DC)) && \"Invalid ivar decl context!\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1766, __PRETTY_FUNCTION__))
;
1767 // Once a new ivar is created in any of class/class-extension/implementation
1768 // decl contexts, the previously built IvarList must be rebuilt.
1769 auto *ID = dyn_cast<ObjCInterfaceDecl>(DC);
1770 if (!ID) {
1771 if (auto *IM = dyn_cast<ObjCImplementationDecl>(DC))
1772 ID = IM->getClassInterface();
1773 else
1774 ID = cast<ObjCCategoryDecl>(DC)->getClassInterface();
1775 }
1776 ID->setIvarList(nullptr);
1777 }
1778
1779 return new (C, DC) ObjCIvarDecl(DC, StartLoc, IdLoc, Id, T, TInfo, ac, BW,
1780 synthesized);
1781}
1782
1783ObjCIvarDecl *ObjCIvarDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
1784 return new (C, ID) ObjCIvarDecl(nullptr, SourceLocation(), SourceLocation(),
1785 nullptr, QualType(), nullptr,
1786 ObjCIvarDecl::None, nullptr, false);
1787}
1788
1789const ObjCInterfaceDecl *ObjCIvarDecl::getContainingInterface() const {
1790 const auto *DC = cast<ObjCContainerDecl>(getDeclContext());
1791
1792 switch (DC->getKind()) {
1793 default:
1794 case ObjCCategoryImpl:
1795 case ObjCProtocol:
1796 llvm_unreachable("invalid ivar container!")::llvm::llvm_unreachable_internal("invalid ivar container!", "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1796)
;
1797
1798 // Ivars can only appear in class extension categories.
1799 case ObjCCategory: {
1800 const auto *CD = cast<ObjCCategoryDecl>(DC);
1801 assert(CD->IsClassExtension() && "invalid container for ivar!")((CD->IsClassExtension() && "invalid container for ivar!"
) ? static_cast<void> (0) : __assert_fail ("CD->IsClassExtension() && \"invalid container for ivar!\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1801, __PRETTY_FUNCTION__))
;
1802 return CD->getClassInterface();
1803 }
1804
1805 case ObjCImplementation:
1806 return cast<ObjCImplementationDecl>(DC)->getClassInterface();
1807
1808 case ObjCInterface:
1809 return cast<ObjCInterfaceDecl>(DC);
1810 }
1811}
1812
1813QualType ObjCIvarDecl::getUsageType(QualType objectType) const {
1814 return getType().substObjCMemberType(objectType, getDeclContext(),
1815 ObjCSubstitutionContext::Property);
1816}
1817
1818//===----------------------------------------------------------------------===//
1819// ObjCAtDefsFieldDecl
1820//===----------------------------------------------------------------------===//
1821
1822void ObjCAtDefsFieldDecl::anchor() {}
1823
1824ObjCAtDefsFieldDecl
1825*ObjCAtDefsFieldDecl::Create(ASTContext &C, DeclContext *DC,
1826 SourceLocation StartLoc, SourceLocation IdLoc,
1827 IdentifierInfo *Id, QualType T, Expr *BW) {
1828 return new (C, DC) ObjCAtDefsFieldDecl(DC, StartLoc, IdLoc, Id, T, BW);
1829}
1830
1831ObjCAtDefsFieldDecl *ObjCAtDefsFieldDecl::CreateDeserialized(ASTContext &C,
1832 unsigned ID) {
1833 return new (C, ID) ObjCAtDefsFieldDecl(nullptr, SourceLocation(),
1834 SourceLocation(), nullptr, QualType(),
1835 nullptr);
1836}
1837
1838//===----------------------------------------------------------------------===//
1839// ObjCProtocolDecl
1840//===----------------------------------------------------------------------===//
1841
1842void ObjCProtocolDecl::anchor() {}
1843
1844ObjCProtocolDecl::ObjCProtocolDecl(ASTContext &C, DeclContext *DC,
1845 IdentifierInfo *Id, SourceLocation nameLoc,
1846 SourceLocation atStartLoc,
1847 ObjCProtocolDecl *PrevDecl)
1848 : ObjCContainerDecl(ObjCProtocol, DC, Id, nameLoc, atStartLoc),
1849 redeclarable_base(C) {
1850 setPreviousDecl(PrevDecl);
1851 if (PrevDecl)
1852 Data = PrevDecl->Data;
1853}
1854
1855ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC,
1856 IdentifierInfo *Id,
1857 SourceLocation nameLoc,
1858 SourceLocation atStartLoc,
1859 ObjCProtocolDecl *PrevDecl) {
1860 auto *Result =
1861 new (C, DC) ObjCProtocolDecl(C, DC, Id, nameLoc, atStartLoc, PrevDecl);
1862 Result->Data.setInt(!C.getLangOpts().Modules);
1863 return Result;
1864}
1865
1866ObjCProtocolDecl *ObjCProtocolDecl::CreateDeserialized(ASTContext &C,
1867 unsigned ID) {
1868 ObjCProtocolDecl *Result =
1869 new (C, ID) ObjCProtocolDecl(C, nullptr, nullptr, SourceLocation(),
1870 SourceLocation(), nullptr);
1871 Result->Data.setInt(!C.getLangOpts().Modules);
1872 return Result;
1873}
1874
1875ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) {
1876 ObjCProtocolDecl *PDecl = this;
1877
1878 if (Name == getIdentifier())
1879 return PDecl;
1880
1881 for (auto *I : protocols())
1882 if ((PDecl = I->lookupProtocolNamed(Name)))
1883 return PDecl;
1884
1885 return nullptr;
1886}
1887
1888// lookupMethod - Lookup a instance/class method in the protocol and protocols
1889// it inherited.
1890ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel,
1891 bool isInstance) const {
1892 ObjCMethodDecl *MethodDecl = nullptr;
1893
1894 // If there is no definition or the definition is hidden, we don't find
1895 // anything.
1896 const ObjCProtocolDecl *Def = getDefinition();
1897 if (!Def || Def->isHidden())
1898 return nullptr;
1899
1900 if ((MethodDecl = getMethod(Sel, isInstance)))
1901 return MethodDecl;
1902
1903 for (const auto *I : protocols())
1904 if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
1905 return MethodDecl;
1906 return nullptr;
1907}
1908
1909void ObjCProtocolDecl::allocateDefinitionData() {
1910 assert(!Data.getPointer() && "Protocol already has a definition!")((!Data.getPointer() && "Protocol already has a definition!"
) ? static_cast<void> (0) : __assert_fail ("!Data.getPointer() && \"Protocol already has a definition!\""
, "/build/llvm-toolchain-snapshot-9~svn362543/tools/clang/lib/AST/DeclObjC.cpp"
, 1910, __PRETTY_FUNCTION__))
;
1911 Data.setPointer(new (getASTContext()) DefinitionData);
1912 Data.getPointer()->Definition = this;
1913}
1914
1915void ObjCProtocolDecl::startDefinition() {
1916 allocateDefinitionData();
1917
1918 // Update all of the declarations with a pointer to the definition.
1919 for (auto *RD : redecls())
1920 RD->Data = this->Data;
1921}
1922
1923void ObjCProtocolDecl::collectPropertiesToImplement(PropertyMap &PM,
1924 PropertyDeclOrder &PO) const {
1925 if (const ObjCProtocolDecl *PDecl = getDefinition()) {
1926 for (auto *Prop : PDecl->properties()) {
1927 // Insert into PM if not there already.
1928 PM.insert(std::make_pair(
1929 std::make_pair(Prop->getIdentifier(), Prop->isClassProperty()),
1930 Prop));
1931 PO.push_back(Prop);
1932 }
1933 // Scan through protocol's protocols.
1934 for (const auto *PI : PDecl->protocols())
1935 PI->collectPropertiesToImplement(PM, PO);
1936 }
1937}
1938
1939void ObjCProtocolDecl::collectInheritedProtocolProperties(
1940 const ObjCPropertyDecl *Property, ProtocolPropertySet &PS,
1941 PropertyDeclOrder &PO) const {
1942 if (const ObjCProtocolDecl *PDecl = getDefinition()) {
1943 if (!PS.insert(PDecl).second)
1944 return;
1945 for (auto *Prop : PDecl->properties()) {
1946 if (Prop == Property)
1947 continue;
1948 if (Prop->getIdentifier() == Property->getIdentifier()) {
1949 PO.push_back(Prop);
1950 return;
1951 }
1952 }
1953 // Scan through protocol's protocols which did not have a matching property.
1954 for (const auto *PI : PDecl->protocols())
1955 PI->collectInheritedProtocolProperties(Property, PS, PO);
1956 }
1957}
1958
1959StringRef
1960ObjCProtocolDecl::getObjCRuntimeNameAsString() const {
1961 if (const auto *ObjCRTName = getAttr<ObjCRuntimeNameAttr>())
1962 return ObjCRTName->getMetadataName();
1963
1964 return getName();
1965}
1966
1967//===----------------------------------------------------------------------===//
1968// ObjCCategoryDecl
1969//===----------------------------------------------------------------------===//
1970
1971void ObjCCategoryDecl::anchor() {}
1972
1973ObjCCategoryDecl::ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc,
1974 SourceLocation ClassNameLoc,
1975 SourceLocation CategoryNameLoc,
1976 IdentifierInfo *Id, ObjCInterfaceDecl *IDecl,
1977 ObjCTypeParamList *typeParamList,
1978 SourceLocation IvarLBraceLoc,
1979 SourceLocation IvarRBraceLoc)
1980 : ObjCContainerDecl(ObjCCategory, DC, Id, ClassNameLoc, AtLoc),
1981 ClassInterface(IDecl), CategoryNameLoc(CategoryNameLoc),
1982 IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc) {
1983 setTypeParamList(typeParamList);
1984}
1985
1986ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, DeclContext *DC,
1987 SourceLocation AtLoc,
1988 SourceLocation ClassNameLoc,
1989 SourceLocation CategoryNameLoc,
1990 IdentifierInfo *Id,
1991 ObjCInterfaceDecl *IDecl,
1992 ObjCTypeParamList *typeParamList,
1993 SourceLocation IvarLBraceLoc,
1994 SourceLocation IvarRBraceLoc) {
1995 auto *CatDecl =
1996 new (C, DC) ObjCCategoryDecl(DC, AtLoc, ClassNameLoc, CategoryNameLoc, Id,
1997 IDecl, typeParamList, IvarLBraceLoc,
1998 IvarRBraceLoc);
1999 if (IDecl) {
2000 // Link this category into its class's category list.
2001 CatDecl->NextClassCategory = IDecl->getCategoryListRaw();
2002 if (IDecl->hasDefinition()) {
2003 IDecl->setCategoryListRaw(CatDecl);
2004 if (ASTMutationListener *L = C.getASTMutationListener())
2005 L->AddedObjCCategoryToInterface(CatDecl, IDecl);
2006 }
2007 }
2008
2009 return CatDecl;
2010}
2011
2012ObjCCategoryDecl *ObjCCategoryDecl::CreateDeserialized(ASTContext &C,
2013 unsigned ID) {
2014 return new (C, ID) ObjCCategoryDecl(nullptr, SourceLocation(),
2015 SourceLocation(), SourceLocation(),
2016 nullptr, nullptr, nullptr);
2017}
2018
2019ObjCCategoryImplDecl *ObjCCategoryDecl::getImplementation() const {
2020 return getASTContext().getObjCImplementation(
2021 const_cast<ObjCCategoryDecl*>(this));
2022}
2023
2024void ObjCCategoryDecl::setImplementation(ObjCCategoryImplDecl *ImplD) {
2025 getASTContext().setObjCImplementation(this, ImplD);
2026}
2027
2028void ObjCCategoryDecl::setTypeParamList(ObjCTypeParamList *TPL) {
2029 TypeParamList = TPL;
2030 if (!TPL)
2031 return;
2032 // Set the declaration context of each of the type parameters.
2033 for (auto *typeParam : *TypeParamList)
2034 typeParam->setDeclContext(this);
2035}
2036
2037//===----------------------------------------------------------------------===//
2038// ObjCCategoryImplDecl
2039//===----------------------------------------------------------------------===//
2040
2041void ObjCCategoryImplDecl::anchor() {}
2042
2043ObjCCategoryImplDecl *
2044ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC,
2045 IdentifierInfo *Id,
2046 ObjCInterfaceDecl *ClassInterface,
2047 SourceLocation nameLoc,
2048 SourceLocation atStartLoc,
2049 SourceLocation CategoryNameLoc) {
2050 if (ClassInterface && ClassInterface->hasDefinition())
2051 ClassInterface = ClassInterface->getDefinition();
2052 return new (C, DC) ObjCCategoryImplDecl(DC, Id, ClassInterface, nameLoc,
2053 atStartLoc, CategoryNameLoc);
2054}
2055
2056ObjCCategoryImplDecl *ObjCCategoryImplDecl::CreateDeserialized(ASTContext &C,
2057 unsigned ID) {
2058 return new (C, ID) ObjCCategoryImplDecl(nullptr, nullptr, nullptr,
2059 SourceLocation(), SourceLocation(),
2060 SourceLocation());
2061}
2062
2063ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryDecl() const {
2064 // The class interface might be NULL if we are working with invalid code.
2065 if (const ObjCInterfaceDecl *ID = getClassInterface())
2066 return ID->FindCategoryDeclaration(getIdentifier());
2067 return nullptr;
2068}
2069
2070void ObjCImplDecl::anchor() {}
2071
2072void ObjCImplDecl::addPropertyImplementation(ObjCPropertyImplDecl *property) {
2073 // FIXME: The context should be correct before we get here.
2074 property->setLexicalDeclContext(this);
2075 addDecl(property);
2076}
2077
2078void ObjCImplDecl::setClassInterface(ObjCInterfaceDecl *IFace) {
2079 ASTContext &Ctx = getASTContext();
2080
2081 if (auto *ImplD = dyn_cast_or_null<ObjCImplementationDecl>(this)) {
2082 if (IFace)
2083 Ctx.setObjCImplementation(IFace, ImplD);
2084
2085 } else if (auto *ImplD = dyn_cast_or_null<ObjCCategoryImplDecl>(this)) {
2086 if (ObjCCategoryDecl *CD = IFace->FindCategoryDeclaration(getIdentifier()))
2087 Ctx.setObjCImplementation(CD, ImplD);
2088 }
2089
2090 ClassInterface = IFace;
2091}
2092
2093/// FindPropertyImplIvarDecl - This method lookup the ivar in the list of
2094/// properties implemented in this \@implementation block and returns
2095/// the implemented property that uses it.
2096ObjCPropertyImplDecl *ObjCImplDecl::
2097FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const {
2098 for (auto *PID : property_impls())
2099 if (PID->getPropertyIvarDecl() &&
2100 PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
2101 return PID;
2102 return nullptr;
2103}
2104
2105/// FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl
2106/// added to the list of those properties \@synthesized/\@dynamic in this
2107/// category \@implementation block.
2108ObjCPropertyImplDecl *ObjCImplDecl::
2109FindPropertyImplDecl(IdentifierInfo *Id,
2110 ObjCPropertyQueryKind QueryKind) const {
2111 ObjCPropertyImplDecl *ClassPropImpl = nullptr;
2112 for (auto *PID : property_impls())
2113 // If queryKind is unknown, we return the instance property if one
2114 // exists; otherwise we return the class property.
2115 if (PID->getPropertyDecl()->getIdentifier() == Id) {
2116 if ((QueryKind == ObjCPropertyQueryKind::OBJC_PR_query_unknown &&
2117 !PID->getPropertyDecl()->isClassProperty()) ||
2118 (QueryKind == ObjCPropertyQueryKind::OBJC_PR_query_class &&
2119 PID->getPropertyDecl()->isClassProperty()) ||
2120 (QueryKind == ObjCPropertyQueryKind::OBJC_PR_query_instance &&
2121 !PID->getPropertyDecl()->isClassProperty()))
2122 return PID;
2123
2124 if (PID->getPropertyDecl()->isClassProperty())
2125 ClassPropImpl = PID;
2126 }
2127
2128 if (QueryKind == ObjCPropertyQueryKind::OBJC_PR_query_unknown)
2129 // We can't find the instance property, return the class property.
2130 return ClassPropImpl;
2131
2132 return nullptr;
2133}
2134
2135raw_ostream &clang::operator<<(raw_ostream &OS,
2136 const ObjCCategoryImplDecl &CID) {
2137 OS << CID.getName();
2138 return OS;
2139}
2140
2141//===----------------------------------------------------------------------===//
2142// ObjCImplementationDecl
2143//===----------------------------------------------------------------------===//
2144
2145void ObjCImplementationDecl::anchor() {}
2146
2147ObjCImplementationDecl *
2148ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC,
2149 ObjCInterfaceDecl *ClassInterface,
2150 ObjCInterfaceDecl *SuperDecl,
2151 SourceLocation nameLoc,
2152 SourceLocation atStartLoc,
2153 SourceLocation superLoc,
2154 SourceLocation IvarLBraceLoc,
2155 SourceLocation IvarRBraceLoc) {
2156 if (ClassInterface && ClassInterface->hasDefinition())
2157 ClassInterface = ClassInterface->getDefinition();
2158 return new (C, DC) ObjCImplementationDecl(DC, ClassInterface, SuperDecl,
2159 nameLoc, atStartLoc, superLoc,
2160 IvarLBraceLoc, IvarRBraceLoc);
2161}
2162
2163ObjCImplementationDecl *
2164ObjCImplementationDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
2165 return new (C, ID) ObjCImplementationDecl(nullptr, nullptr, nullptr,
2166 SourceLocation(), SourceLocation());
2167}
2168
2169void ObjCImplementationDecl::setIvarInitializers(ASTContext &C,
2170 CXXCtorInitializer ** initializers,
2171 unsigned numInitializers) {
2172 if (numInitializers > 0) {
2173 NumIvarInitializers = numInitializers;
2174 auto **ivarInitializers = new (C) CXXCtorInitializer*[NumIvarInitializers];
2175 memcpy(ivarInitializers, initializers,
2176 numInitializers * sizeof(CXXCtorInitializer*));
2177 IvarInitializers = ivarInitializers;
2178 }
2179}
2180
2181ObjCImplementationDecl::init_const_iterator
2182ObjCImplementationDecl::init_begin() const {
2183 return IvarInitializers.get(getASTContext().getExternalSource());
2184}
2185
2186raw_ostream &clang::operator<<(raw_ostream &OS,
2187 const ObjCImplementationDecl &ID) {
2188 OS << ID.getName();
2189 return OS;
2190}
2191
2192//===----------------------------------------------------------------------===//
2193// ObjCCompatibleAliasDecl
2194//===----------------------------------------------------------------------===//
2195
2196void ObjCCompatibleAliasDecl::anchor() {}
2197
2198ObjCCompatibleAliasDecl *
2199ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC,
2200 SourceLocation L,
2201 IdentifierInfo *Id,
2202 ObjCInterfaceDecl* AliasedClass) {
2203 return new (C, DC) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass);
2204}
2205
2206ObjCCompatibleAliasDecl *
2207ObjCCompatibleAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
2208 return new (C, ID) ObjCCompatibleAliasDecl(nullptr, SourceLocation(),
2209 nullptr, nullptr);
2210}
2211
2212//===----------------------------------------------------------------------===//
2213// ObjCPropertyDecl
2214//===----------------------------------------------------------------------===//
2215
2216void ObjCPropertyDecl::anchor() {}
2217
2218ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, DeclContext *DC,
2219 SourceLocation L,
2220 IdentifierInfo *Id,
2221 SourceLocation AtLoc,
2222 SourceLocation LParenLoc,
2223 QualType T,
2224 TypeSourceInfo *TSI,
2225 PropertyControl propControl) {
2226 return new (C, DC) ObjCPropertyDecl(DC, L, Id, AtLoc, LParenLoc, T, TSI,
2227 propControl);
2228}
2229
2230ObjCPropertyDecl *ObjCPropertyDecl::CreateDeserialized(ASTContext &C,
2231 unsigned ID) {
2232 return new (C, ID) ObjCPropertyDecl(nullptr, SourceLocation(), nullptr,
2233 SourceLocation(), SourceLocation(),
2234 QualType(), nullptr, None);
2235}
2236
2237QualType ObjCPropertyDecl::getUsageType(QualType objectType) const {
2238 return DeclType.substObjCMemberType(objectType, getDeclContext(),
2239 ObjCSubstitutionContext::Property);
2240}
2241
2242//===----------------------------------------------------------------------===//
2243// ObjCPropertyImplDecl
2244//===----------------------------------------------------------------------===//
2245
2246ObjCPropertyImplDecl *ObjCPropertyImplDecl::Create(ASTContext &C,
2247 DeclContext *DC,
2248 SourceLocation atLoc,
2249 SourceLocation L,
2250 ObjCPropertyDecl *property,
2251 Kind PK,
2252 ObjCIvarDecl *ivar,
2253 SourceLocation ivarLoc) {
2254 return new (C, DC) ObjCPropertyImplDecl(DC, atLoc, L, property, PK, ivar,
2255 ivarLoc);
2256}
2257
2258ObjCPropertyImplDecl *ObjCPropertyImplDecl::CreateDeserialized(ASTContext &C,
2259 unsigned ID) {
2260 return new (C, ID) ObjCPropertyImplDecl(nullptr, SourceLocation(),
2261 SourceLocation(), nullptr, Dynamic,
2262 nullptr, SourceLocation());
2263}
2264
2265SourceRange ObjCPropertyImplDecl::getSourceRange() const {
2266 SourceLocation EndLoc = getLocation();
2267 if (IvarLoc.isValid())
2268 EndLoc = IvarLoc;
2269
2270 return SourceRange(AtLoc, EndLoc);
2271}

/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc

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
12class AArch64VectorPcsAttr : public InheritableAttr {
13public:
14 static AArch64VectorPcsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
15 auto *A = new (Ctx) AArch64VectorPcsAttr(Loc, Ctx, 0);
16 A->setImplicit(true);
17 return A;
18 }
19
20 AArch64VectorPcsAttr(SourceRange R, ASTContext &Ctx
21 , unsigned SI
22 )
23 : InheritableAttr(attr::AArch64VectorPcs, R, SI, false, false)
24 {
25 }
26
27 AArch64VectorPcsAttr *clone(ASTContext &C) const;
28 void printPretty(raw_ostream &OS,
29 const PrintingPolicy &Policy) const;
30 const char *getSpelling() const;
31
32
33 static bool classof(const Attr *A) { return A->getKind() == attr::AArch64VectorPcs; }
34};
35
36class AMDGPUFlatWorkGroupSizeAttr : public InheritableAttr {
37Expr * min;
38
39Expr * max;
40
41public:
42 static AMDGPUFlatWorkGroupSizeAttr *CreateImplicit(ASTContext &Ctx, Expr * Min, Expr * Max, SourceRange Loc = SourceRange()) {
43 auto *A = new (Ctx) AMDGPUFlatWorkGroupSizeAttr(Loc, Ctx, Min, Max, 0);
44 A->setImplicit(true);
45 return A;
46 }
47
48 AMDGPUFlatWorkGroupSizeAttr(SourceRange R, ASTContext &Ctx
49 , Expr * Min
50 , Expr * Max
51 , unsigned SI
52 )
53 : InheritableAttr(attr::AMDGPUFlatWorkGroupSize, R, SI, false, false)
54 , min(Min)
55 , max(Max)
56 {
57 }
58
59 AMDGPUFlatWorkGroupSizeAttr *clone(ASTContext &C) const;
60 void printPretty(raw_ostream &OS,
61 const PrintingPolicy &Policy) const;
62 const char *getSpelling() const;
63 Expr * getMin() const {
64 return min;
65 }
66
67 Expr * getMax() const {
68 return max;
69 }
70
71
72
73 static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUFlatWorkGroupSize; }
74};
75
76class AMDGPUNumSGPRAttr : public InheritableAttr {
77unsigned numSGPR;
78
79public:
80 static AMDGPUNumSGPRAttr *CreateImplicit(ASTContext &Ctx, unsigned NumSGPR, SourceRange Loc = SourceRange()) {
81 auto *A = new (Ctx) AMDGPUNumSGPRAttr(Loc, Ctx, NumSGPR, 0);
82 A->setImplicit(true);
83 return A;
84 }
85
86 AMDGPUNumSGPRAttr(SourceRange R, ASTContext &Ctx
87 , unsigned NumSGPR
88 , unsigned SI
89 )
90 : InheritableAttr(attr::AMDGPUNumSGPR, R, SI, false, false)
91 , numSGPR(NumSGPR)
92 {
93 }
94
95 AMDGPUNumSGPRAttr *clone(ASTContext &C) const;
96 void printPretty(raw_ostream &OS,
97 const PrintingPolicy &Policy) const;
98 const char *getSpelling() const;
99 unsigned getNumSGPR() const {
100 return numSGPR;
101 }
102
103
104
105 static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUNumSGPR; }
106};
107
108class AMDGPUNumVGPRAttr : public InheritableAttr {
109unsigned numVGPR;
110
111public:
112 static AMDGPUNumVGPRAttr *CreateImplicit(ASTContext &Ctx, unsigned NumVGPR, SourceRange Loc = SourceRange()) {
113 auto *A = new (Ctx) AMDGPUNumVGPRAttr(Loc, Ctx, NumVGPR, 0);
114 A->setImplicit(true);
115 return A;
116 }
117
118 AMDGPUNumVGPRAttr(SourceRange R, ASTContext &Ctx
119 , unsigned NumVGPR
120 , unsigned SI
121 )
122 : InheritableAttr(attr::AMDGPUNumVGPR, R, SI, false, false)
123 , numVGPR(NumVGPR)
124 {
125 }
126
127 AMDGPUNumVGPRAttr *clone(ASTContext &C) const;
128 void printPretty(raw_ostream &OS,
129 const PrintingPolicy &Policy) const;
130 const char *getSpelling() const;
131 unsigned getNumVGPR() const {
132 return numVGPR;
133 }
134
135
136
137 static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUNumVGPR; }
138};
139
140class AMDGPUWavesPerEUAttr : public InheritableAttr {
141Expr * min;
142
143Expr * max;
144
145public:
146 static AMDGPUWavesPerEUAttr *CreateImplicit(ASTContext &Ctx, Expr * Min, Expr * Max, SourceRange Loc = SourceRange()) {
147 auto *A = new (Ctx) AMDGPUWavesPerEUAttr(Loc, Ctx, Min, Max, 0);
148 A->setImplicit(true);
149 return A;
150 }
151
152 AMDGPUWavesPerEUAttr(SourceRange R, ASTContext &Ctx
153 , Expr * Min
154 , Expr * Max
155 , unsigned SI
156 )
157 : InheritableAttr(attr::AMDGPUWavesPerEU, R, SI, false, false)
158 , min(Min)
159 , max(Max)
160 {
161 }
162
163 AMDGPUWavesPerEUAttr(SourceRange R, ASTContext &Ctx
164 , Expr * Min
165 , unsigned SI
166 )
167 : InheritableAttr(attr::AMDGPUWavesPerEU, R, SI, false, false)
168 , min(Min)
169 , max()
170 {
171 }
172
173 AMDGPUWavesPerEUAttr *clone(ASTContext &C) const;
174 void printPretty(raw_ostream &OS,
175 const PrintingPolicy &Policy) const;
176 const char *getSpelling() const;
177 Expr * getMin() const {
178 return min;
179 }
180
181 Expr * getMax() const {
182 return max;
183 }
184
185
186
187 static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUWavesPerEU; }
188};
189
190class ARMInterruptAttr : public InheritableAttr {
191public:
192 enum InterruptType {
193 IRQ,
194 FIQ,
195 SWI,
196 ABORT,
197 UNDEF,
198 Generic
199 };
200private:
201 InterruptType interrupt;
202
203public:
204 static ARMInterruptAttr *CreateImplicit(ASTContext &Ctx, InterruptType Interrupt, SourceRange Loc = SourceRange()) {
205 auto *A = new (Ctx) ARMInterruptAttr(Loc, Ctx, Interrupt, 0);
206 A->setImplicit(true);
207 return A;
208 }
209
210 ARMInterruptAttr(SourceRange R, ASTContext &Ctx
211 , InterruptType Interrupt
212 , unsigned SI
213 )
214 : InheritableAttr(attr::ARMInterrupt, R, SI, false, false)
215 , interrupt(Interrupt)
216 {
217 }
218
219 ARMInterruptAttr(SourceRange R, ASTContext &Ctx
220 , unsigned SI
221 )
222 : InheritableAttr(attr::ARMInterrupt, R, SI, false, false)
223 , interrupt(InterruptType(0))
224 {
225 }
226
227 ARMInterruptAttr *clone(ASTContext &C) const;
228 void printPretty(raw_ostream &OS,
229 const PrintingPolicy &Policy) const;
230 const char *getSpelling() const;
231 InterruptType getInterrupt() const {
232 return interrupt;
233 }
234
235 static bool ConvertStrToInterruptType(StringRef Val, InterruptType &Out) {
236 Optional<InterruptType> R = llvm::StringSwitch<Optional<InterruptType>>(Val)
237 .Case("IRQ", ARMInterruptAttr::IRQ)
238 .Case("FIQ", ARMInterruptAttr::FIQ)
239 .Case("SWI", ARMInterruptAttr::SWI)
240 .Case("ABORT", ARMInterruptAttr::ABORT)
241 .Case("UNDEF", ARMInterruptAttr::UNDEF)
242 .Case("", ARMInterruptAttr::Generic)
243 .Default(Optional<InterruptType>());
244 if (R) {
245 Out = *R;
246 return true;
247 }
248 return false;
249 }
250
251 static const char *ConvertInterruptTypeToStr(InterruptType Val) {
252 switch(Val) {
253 case ARMInterruptAttr::IRQ: return "IRQ";
254 case ARMInterruptAttr::FIQ: return "FIQ";
255 case ARMInterruptAttr::SWI: return "SWI";
256 case ARMInterruptAttr::ABORT: return "ABORT";
257 case ARMInterruptAttr::UNDEF: return "UNDEF";
258 case ARMInterruptAttr::Generic: return "";
259 }
260 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 260)
;
261 }
262
263
264 static bool classof(const Attr *A) { return A->getKind() == attr::ARMInterrupt; }
265};
266
267class AVRInterruptAttr : public InheritableAttr {
268public:
269 static AVRInterruptAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
270 auto *A = new (Ctx) AVRInterruptAttr(Loc, Ctx, 0);
271 A->setImplicit(true);
272 return A;
273 }
274
275 AVRInterruptAttr(SourceRange R, ASTContext &Ctx
276 , unsigned SI
277 )
278 : InheritableAttr(attr::AVRInterrupt, R, SI, false, false)
279 {
280 }
281
282 AVRInterruptAttr *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::AVRInterrupt; }
289};
290
291class AVRSignalAttr : public InheritableAttr {
292public:
293 static AVRSignalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
294 auto *A = new (Ctx) AVRSignalAttr(Loc, Ctx, 0);
295 A->setImplicit(true);
296 return A;
297 }
298
299 AVRSignalAttr(SourceRange R, ASTContext &Ctx
300 , unsigned SI
301 )
302 : InheritableAttr(attr::AVRSignal, R, SI, false, false)
303 {
304 }
305
306 AVRSignalAttr *clone(ASTContext &C) const;
307 void printPretty(raw_ostream &OS,
308 const PrintingPolicy &Policy) const;
309 const char *getSpelling() const;
310
311
312 static bool classof(const Attr *A) { return A->getKind() == attr::AVRSignal; }
313};
314
315class AbiTagAttr : public Attr {
316 unsigned tags_Size;
317 StringRef *tags_;
318
319public:
320 static AbiTagAttr *CreateImplicit(ASTContext &Ctx, StringRef *Tags, unsigned TagsSize, SourceRange Loc = SourceRange()) {
321 auto *A = new (Ctx) AbiTagAttr(Loc, Ctx, Tags, TagsSize, 0);
322 A->setImplicit(true);
323 return A;
324 }
325
326 AbiTagAttr(SourceRange R, ASTContext &Ctx
327 , StringRef *Tags, unsigned TagsSize
328 , unsigned SI
329 )
330 : Attr(attr::AbiTag, R, SI, false)
331 , tags_Size(TagsSize), tags_(new (Ctx, 16) StringRef[tags_Size])
332 {
333 for (size_t I = 0, E = tags_Size; I != E;
334 ++I) {
335 StringRef Ref = Tags[I];
336 if (!Ref.empty()) {
337 char *Mem = new (Ctx, 1) char[Ref.size()];
338 std::memcpy(Mem, Ref.data(), Ref.size());
339 tags_[I] = StringRef(Mem, Ref.size());
340 }
341 }
342 }
343
344 AbiTagAttr(SourceRange R, ASTContext &Ctx
345 , unsigned SI
346 )
347 : Attr(attr::AbiTag, R, SI, false)
348 , tags_Size(0), tags_(nullptr)
349 {
350 }
351
352 AbiTagAttr *clone(ASTContext &C) const;
353 void printPretty(raw_ostream &OS,
354 const PrintingPolicy &Policy) const;
355 const char *getSpelling() const;
356 typedef StringRef* tags_iterator;
357 tags_iterator tags_begin() const { return tags_; }
358 tags_iterator tags_end() const { return tags_ + tags_Size; }
359 unsigned tags_size() const { return tags_Size; }
360 llvm::iterator_range<tags_iterator> tags() const { return llvm::make_range(tags_begin(), tags_end()); }
361
362
363
364
365 static bool classof(const Attr *A) { return A->getKind() == attr::AbiTag; }
366};
367
368class AcquireCapabilityAttr : public InheritableAttr {
369 unsigned args_Size;
370 Expr * *args_;
371
372public:
373 enum Spelling {
374 GNU_acquire_capability = 0,
375 CXX11_clang_acquire_capability = 1,
376 GNU_acquire_shared_capability = 2,
377 CXX11_clang_acquire_shared_capability = 3,
378 GNU_exclusive_lock_function = 4,
379 GNU_shared_lock_function = 5
380 };
381
382 static AcquireCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
383 auto *A = new (Ctx) AcquireCapabilityAttr(Loc, Ctx, Args, ArgsSize, S);
384 A->setImplicit(true);
385 return A;
386 }
387
388 AcquireCapabilityAttr(SourceRange R, ASTContext &Ctx
389 , Expr * *Args, unsigned ArgsSize
390 , unsigned SI
391 )
392 : InheritableAttr(attr::AcquireCapability, R, SI, true, true)
393 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
394 {
395 std::copy(Args, Args + args_Size, args_);
396 }
397
398 AcquireCapabilityAttr(SourceRange R, ASTContext &Ctx
399 , unsigned SI
400 )
401 : InheritableAttr(attr::AcquireCapability, R, SI, true, true)
402 , args_Size(0), args_(nullptr)
403 {
404 }
405
406 AcquireCapabilityAttr *clone(ASTContext &C) const;
407 void printPretty(raw_ostream &OS,
408 const PrintingPolicy &Policy) const;
409 const char *getSpelling() const;
410 Spelling getSemanticSpelling() const {
411 switch (SpellingListIndex) {
412 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 412)
;
413 case 0: return GNU_acquire_capability;
414 case 1: return CXX11_clang_acquire_capability;
415 case 2: return GNU_acquire_shared_capability;
416 case 3: return CXX11_clang_acquire_shared_capability;
417 case 4: return GNU_exclusive_lock_function;
418 case 5: return GNU_shared_lock_function;
419 }
420 }
421 bool isShared() const { return SpellingListIndex == 2 ||
422 SpellingListIndex == 3 ||
423 SpellingListIndex == 5; }
424 typedef Expr ** args_iterator;
425 args_iterator args_begin() const { return args_; }
426 args_iterator args_end() const { return args_ + args_Size; }
427 unsigned args_size() const { return args_Size; }
428 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
429
430
431
432
433 static bool classof(const Attr *A) { return A->getKind() == attr::AcquireCapability; }
434};
435
436class AcquiredAfterAttr : public InheritableAttr {
437 unsigned args_Size;
438 Expr * *args_;
439
440public:
441 static AcquiredAfterAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
442 auto *A = new (Ctx) AcquiredAfterAttr(Loc, Ctx, Args, ArgsSize, 0);
443 A->setImplicit(true);
444 return A;
445 }
446
447 AcquiredAfterAttr(SourceRange R, ASTContext &Ctx
448 , Expr * *Args, unsigned ArgsSize
449 , unsigned SI
450 )
451 : InheritableAttr(attr::AcquiredAfter, R, SI, true, true)
452 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
453 {
454 std::copy(Args, Args + args_Size, args_);
455 }
456
457 AcquiredAfterAttr(SourceRange R, ASTContext &Ctx
458 , unsigned SI
459 )
460 : InheritableAttr(attr::AcquiredAfter, R, SI, true, true)
461 , args_Size(0), args_(nullptr)
462 {
463 }
464
465 AcquiredAfterAttr *clone(ASTContext &C) const;
466 void printPretty(raw_ostream &OS,
467 const PrintingPolicy &Policy) const;
468 const char *getSpelling() const;
469 typedef Expr ** args_iterator;
470 args_iterator args_begin() const { return args_; }
471 args_iterator args_end() const { return args_ + args_Size; }
472 unsigned args_size() const { return args_Size; }
473 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
474
475
476
477
478 static bool classof(const Attr *A) { return A->getKind() == attr::AcquiredAfter; }
479};
480
481class AcquiredBeforeAttr : public InheritableAttr {
482 unsigned args_Size;
483 Expr * *args_;
484
485public:
486 static AcquiredBeforeAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
487 auto *A = new (Ctx) AcquiredBeforeAttr(Loc, Ctx, Args, ArgsSize, 0);
488 A->setImplicit(true);
489 return A;
490 }
491
492 AcquiredBeforeAttr(SourceRange R, ASTContext &Ctx
493 , Expr * *Args, unsigned ArgsSize
494 , unsigned SI
495 )
496 : InheritableAttr(attr::AcquiredBefore, R, SI, true, true)
497 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
498 {
499 std::copy(Args, Args + args_Size, args_);
500 }
501
502 AcquiredBeforeAttr(SourceRange R, ASTContext &Ctx
503 , unsigned SI
504 )
505 : InheritableAttr(attr::AcquiredBefore, R, SI, true, true)
506 , args_Size(0), args_(nullptr)
507 {
508 }
509
510 AcquiredBeforeAttr *clone(ASTContext &C) const;
511 void printPretty(raw_ostream &OS,
512 const PrintingPolicy &Policy) const;
513 const char *getSpelling() const;
514 typedef Expr ** args_iterator;
515 args_iterator args_begin() const { return args_; }
516 args_iterator args_end() const { return args_ + args_Size; }
517 unsigned args_size() const { return args_Size; }
518 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
519
520
521
522
523 static bool classof(const Attr *A) { return A->getKind() == attr::AcquiredBefore; }
524};
525
526class AddressSpaceAttr : public TypeAttr {
527int addressSpace;
528
529public:
530 static AddressSpaceAttr *CreateImplicit(ASTContext &Ctx, int AddressSpace, SourceRange Loc = SourceRange()) {
531 auto *A = new (Ctx) AddressSpaceAttr(Loc, Ctx, AddressSpace, 0);
532 A->setImplicit(true);
533 return A;
534 }
535
536 AddressSpaceAttr(SourceRange R, ASTContext &Ctx
537 , int AddressSpace
538 , unsigned SI
539 )
540 : TypeAttr(attr::AddressSpace, R, SI, false)
541 , addressSpace(AddressSpace)
542 {
543 }
544
545 AddressSpaceAttr *clone(ASTContext &C) const;
546 void printPretty(raw_ostream &OS,
547 const PrintingPolicy &Policy) const;
548 const char *getSpelling() const;
549 int getAddressSpace() const {
550 return addressSpace;
551 }
552
553
554
555 static bool classof(const Attr *A) { return A->getKind() == attr::AddressSpace; }
556};
557
558class AliasAttr : public Attr {
559unsigned aliaseeLength;
560char *aliasee;
561
562public:
563 static AliasAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Aliasee, SourceRange Loc = SourceRange()) {
564 auto *A = new (Ctx) AliasAttr(Loc, Ctx, Aliasee, 0);
565 A->setImplicit(true);
566 return A;
567 }
568
569 AliasAttr(SourceRange R, ASTContext &Ctx
570 , llvm::StringRef Aliasee
571 , unsigned SI
572 )
573 : Attr(attr::Alias, R, SI, false)
574 , aliaseeLength(Aliasee.size()),aliasee(new (Ctx, 1) char[aliaseeLength])
575 {
576 if (!Aliasee.empty())
577 std::memcpy(aliasee, Aliasee.data(), aliaseeLength);
578 }
579
580 AliasAttr *clone(ASTContext &C) const;
581 void printPretty(raw_ostream &OS,
582 const PrintingPolicy &Policy) const;
583 const char *getSpelling() const;
584 llvm::StringRef getAliasee() const {
585 return llvm::StringRef(aliasee, aliaseeLength);
586 }
587 unsigned getAliaseeLength() const {
588 return aliaseeLength;
589 }
590 void setAliasee(ASTContext &C, llvm::StringRef S) {
591 aliaseeLength = S.size();
592 this->aliasee = new (C, 1) char [aliaseeLength];
593 if (!S.empty())
594 std::memcpy(this->aliasee, S.data(), aliaseeLength);
595 }
596
597
598
599 static bool classof(const Attr *A) { return A->getKind() == attr::Alias; }
600};
601
602class AlignMac68kAttr : public InheritableAttr {
603public:
604 static AlignMac68kAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
605 auto *A = new (Ctx) AlignMac68kAttr(Loc, Ctx, 0);
606 A->setImplicit(true);
607 return A;
608 }
609
610 AlignMac68kAttr(SourceRange R, ASTContext &Ctx
611 , unsigned SI
612 )
613 : InheritableAttr(attr::AlignMac68k, R, SI, false, false)
614 {
615 }
616
617 AlignMac68kAttr *clone(ASTContext &C) const;
618 void printPretty(raw_ostream &OS,
619 const PrintingPolicy &Policy) const;
620 const char *getSpelling() const;
621
622
623 static bool classof(const Attr *A) { return A->getKind() == attr::AlignMac68k; }
624};
625
626class AlignValueAttr : public Attr {
627Expr * alignment;
628
629public:
630 static AlignValueAttr *CreateImplicit(ASTContext &Ctx, Expr * Alignment, SourceRange Loc = SourceRange()) {
631 auto *A = new (Ctx) AlignValueAttr(Loc, Ctx, Alignment, 0);
632 A->setImplicit(true);
633 return A;
634 }
635
636 AlignValueAttr(SourceRange R, ASTContext &Ctx
637 , Expr * Alignment
638 , unsigned SI
639 )
640 : Attr(attr::AlignValue, R, SI, false)
641 , alignment(Alignment)
642 {
643 }
644
645 AlignValueAttr *clone(ASTContext &C) const;
646 void printPretty(raw_ostream &OS,
647 const PrintingPolicy &Policy) const;
648 const char *getSpelling() const;
649 Expr * getAlignment() const {
650 return alignment;
651 }
652
653
654
655 static bool classof(const Attr *A) { return A->getKind() == attr::AlignValue; }
656};
657
658class AlignedAttr : public InheritableAttr {
659bool isalignmentExpr;
660union {
661Expr *alignmentExpr;
662TypeSourceInfo *alignmentType;
663};
664
665public:
666 enum Spelling {
667 GNU_aligned = 0,
668 CXX11_gnu_aligned = 1,
669 Declspec_align = 2,
670 Keyword_alignas = 3,
671 Keyword_Alignas = 4
672 };
673
674 static AlignedAttr *CreateImplicit(ASTContext &Ctx, Spelling S, bool IsAlignmentExpr, void *Alignment, SourceRange Loc = SourceRange()) {
675 auto *A = new (Ctx) AlignedAttr(Loc, Ctx, IsAlignmentExpr, Alignment, S);
676 A->setImplicit(true);
677 return A;
678 }
679
680 AlignedAttr(SourceRange R, ASTContext &Ctx
681 , bool IsAlignmentExpr, void *Alignment
682 , unsigned SI
683 )
684 : InheritableAttr(attr::Aligned, R, SI, false, false)
685 , isalignmentExpr(IsAlignmentExpr)
686 {
687 if (isalignmentExpr)
688 alignmentExpr = reinterpret_cast<Expr *>(Alignment);
689 else
690 alignmentType = reinterpret_cast<TypeSourceInfo *>(Alignment);
691 }
692
693 AlignedAttr(SourceRange R, ASTContext &Ctx
694 , unsigned SI
695 )
696 : InheritableAttr(attr::Aligned, R, SI, false, false)
697 , isalignmentExpr(false)
698 {
699 }
700
701 AlignedAttr *clone(ASTContext &C) const;
702 void printPretty(raw_ostream &OS,
703 const PrintingPolicy &Policy) const;
704 const char *getSpelling() const;
705 Spelling getSemanticSpelling() const {
706 switch (SpellingListIndex) {
707 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 707)
;
708 case 0: return GNU_aligned;
709 case 1: return CXX11_gnu_aligned;
710 case 2: return Declspec_align;
711 case 3: return Keyword_alignas;
712 case 4: return Keyword_Alignas;
713 }
714 }
715 bool isGNU() const { return SpellingListIndex == 0 ||
716 SpellingListIndex == 1; }
717 bool isC11() const { return SpellingListIndex == 4; }
718 bool isAlignas() const { return SpellingListIndex == 3 ||
719 SpellingListIndex == 4; }
720 bool isDeclspec() const { return SpellingListIndex == 2; }
721 bool isAlignmentDependent() const;
722 unsigned getAlignment(ASTContext &Ctx) const;
723 bool isAlignmentExpr() const {
724 return isalignmentExpr;
725 }
726 Expr *getAlignmentExpr() const {
727 assert(isalignmentExpr)((isalignmentExpr) ? static_cast<void> (0) : __assert_fail
("isalignmentExpr", "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 727, __PRETTY_FUNCTION__))
;
728 return alignmentExpr;
729 }
730 TypeSourceInfo *getAlignmentType() const {
731 assert(!isalignmentExpr)((!isalignmentExpr) ? static_cast<void> (0) : __assert_fail
("!isalignmentExpr", "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 731, __PRETTY_FUNCTION__))
;
732 return alignmentType;
733 }
734
735
736
737 static bool classof(const Attr *A) { return A->getKind() == attr::Aligned; }
738};
739
740class AllocAlignAttr : public InheritableAttr {
741ParamIdx paramIndex;
742
743public:
744 static AllocAlignAttr *CreateImplicit(ASTContext &Ctx, ParamIdx ParamIndex, SourceRange Loc = SourceRange()) {
745 auto *A = new (Ctx) AllocAlignAttr(Loc, Ctx, ParamIndex, 0);
746 A->setImplicit(true);
747 return A;
748 }
749
750 AllocAlignAttr(SourceRange R, ASTContext &Ctx
751 , ParamIdx ParamIndex
752 , unsigned SI
753 )
754 : InheritableAttr(attr::AllocAlign, R, SI, false, false)
755 , paramIndex(ParamIndex)
756 {
757 }
758
759 AllocAlignAttr *clone(ASTContext &C) const;
760 void printPretty(raw_ostream &OS,
761 const PrintingPolicy &Policy) const;
762 const char *getSpelling() const;
763 ParamIdx getParamIndex() const {
764 return paramIndex;
765 }
766
767
768
769 static bool classof(const Attr *A) { return A->getKind() == attr::AllocAlign; }
770};
771
772class AllocSizeAttr : public InheritableAttr {
773ParamIdx elemSizeParam;
774
775ParamIdx numElemsParam;
776
777public:
778 static AllocSizeAttr *CreateImplicit(ASTContext &Ctx, ParamIdx ElemSizeParam, ParamIdx NumElemsParam, SourceRange Loc = SourceRange()) {
779 auto *A = new (Ctx) AllocSizeAttr(Loc, Ctx, ElemSizeParam, NumElemsParam, 0);
780 A->setImplicit(true);
781 return A;
782 }
783
784 AllocSizeAttr(SourceRange R, ASTContext &Ctx
785 , ParamIdx ElemSizeParam
786 , ParamIdx NumElemsParam
787 , unsigned SI
788 )
789 : InheritableAttr(attr::AllocSize, R, SI, false, false)
790 , elemSizeParam(ElemSizeParam)
791 , numElemsParam(NumElemsParam)
792 {
793 }
794
795 AllocSizeAttr(SourceRange R, ASTContext &Ctx
796 , ParamIdx ElemSizeParam
797 , unsigned SI
798 )
799 : InheritableAttr(attr::AllocSize, R, SI, false, false)
800 , elemSizeParam(ElemSizeParam)
801 , numElemsParam()
802 {
803 }
804
805 AllocSizeAttr *clone(ASTContext &C) const;
806 void printPretty(raw_ostream &OS,
807 const PrintingPolicy &Policy) const;
808 const char *getSpelling() const;
809 ParamIdx getElemSizeParam() const {
810 return elemSizeParam;
811 }
812
813 ParamIdx getNumElemsParam() const {
814 return numElemsParam;
815 }
816
817
818
819 static bool classof(const Attr *A) { return A->getKind() == attr::AllocSize; }
820};
821
822class AlwaysDestroyAttr : public InheritableAttr {
823public:
824 static AlwaysDestroyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
825 auto *A = new (Ctx) AlwaysDestroyAttr(Loc, Ctx, 0);
826 A->setImplicit(true);
827 return A;
828 }
829
830 AlwaysDestroyAttr(SourceRange R, ASTContext &Ctx
831 , unsigned SI
832 )
833 : InheritableAttr(attr::AlwaysDestroy, R, SI, false, false)
834 {
835 }
836
837 AlwaysDestroyAttr *clone(ASTContext &C) const;
838 void printPretty(raw_ostream &OS,
839 const PrintingPolicy &Policy) const;
840 const char *getSpelling() const;
841
842
843 static bool classof(const Attr *A) { return A->getKind() == attr::AlwaysDestroy; }
844};
845
846class AlwaysInlineAttr : public InheritableAttr {
847public:
848 enum Spelling {
849 GNU_always_inline = 0,
850 CXX11_gnu_always_inline = 1,
851 Keyword_forceinline = 2
852 };
853
854 static AlwaysInlineAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
855 auto *A = new (Ctx) AlwaysInlineAttr(Loc, Ctx, S);
856 A->setImplicit(true);
857 return A;
858 }
859
860 AlwaysInlineAttr(SourceRange R, ASTContext &Ctx
861 , unsigned SI
862 )
863 : InheritableAttr(attr::AlwaysInline, R, SI, false, false)
864 {
865 }
866
867 AlwaysInlineAttr *clone(ASTContext &C) const;
868 void printPretty(raw_ostream &OS,
869 const PrintingPolicy &Policy) const;
870 const char *getSpelling() const;
871 Spelling getSemanticSpelling() const {
872 switch (SpellingListIndex) {
873 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 873)
;
874 case 0: return GNU_always_inline;
875 case 1: return CXX11_gnu_always_inline;
876 case 2: return Keyword_forceinline;
877 }
878 }
879
880
881 static bool classof(const Attr *A) { return A->getKind() == attr::AlwaysInline; }
882};
883
884class AnalyzerNoReturnAttr : public InheritableAttr {
885public:
886 static AnalyzerNoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
887 auto *A = new (Ctx) AnalyzerNoReturnAttr(Loc, Ctx, 0);
888 A->setImplicit(true);
889 return A;
890 }
891
892 AnalyzerNoReturnAttr(SourceRange R, ASTContext &Ctx
893 , unsigned SI
894 )
895 : InheritableAttr(attr::AnalyzerNoReturn, R, SI, false, false)
896 {
897 }
898
899 AnalyzerNoReturnAttr *clone(ASTContext &C) const;
900 void printPretty(raw_ostream &OS,
901 const PrintingPolicy &Policy) const;
902 const char *getSpelling() const;
903
904
905 static bool classof(const Attr *A) { return A->getKind() == attr::AnalyzerNoReturn; }
906};
907
908class AnnotateAttr : public InheritableParamAttr {
909unsigned annotationLength;
910char *annotation;
911
912public:
913 static AnnotateAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Annotation, SourceRange Loc = SourceRange()) {
914 auto *A = new (Ctx) AnnotateAttr(Loc, Ctx, Annotation, 0);
915 A->setImplicit(true);
916 return A;
917 }
918
919 AnnotateAttr(SourceRange R, ASTContext &Ctx
920 , llvm::StringRef Annotation
921 , unsigned SI
922 )
923 : InheritableParamAttr(attr::Annotate, R, SI, false, false)
924 , annotationLength(Annotation.size()),annotation(new (Ctx, 1) char[annotationLength])
925 {
926 if (!Annotation.empty())
927 std::memcpy(annotation, Annotation.data(), annotationLength);
928 }
929
930 AnnotateAttr *clone(ASTContext &C) const;
931 void printPretty(raw_ostream &OS,
932 const PrintingPolicy &Policy) const;
933 const char *getSpelling() const;
934 llvm::StringRef getAnnotation() const {
935 return llvm::StringRef(annotation, annotationLength);
936 }
937 unsigned getAnnotationLength() const {
938 return annotationLength;
939 }
940 void setAnnotation(ASTContext &C, llvm::StringRef S) {
941 annotationLength = S.size();
942 this->annotation = new (C, 1) char [annotationLength];
943 if (!S.empty())
944 std::memcpy(this->annotation, S.data(), annotationLength);
945 }
946
947
948
949 static bool classof(const Attr *A) { return A->getKind() == attr::Annotate; }
950};
951
952class AnyX86InterruptAttr : public InheritableAttr {
953public:
954 static AnyX86InterruptAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
955 auto *A = new (Ctx) AnyX86InterruptAttr(Loc, Ctx, 0);
956 A->setImplicit(true);
957 return A;
958 }
959
960 AnyX86InterruptAttr(SourceRange R, ASTContext &Ctx
961 , unsigned SI
962 )
963 : InheritableAttr(attr::AnyX86Interrupt, R, SI, false, false)
964 {
965 }
966
967 AnyX86InterruptAttr *clone(ASTContext &C) const;
968 void printPretty(raw_ostream &OS,
969 const PrintingPolicy &Policy) const;
970 const char *getSpelling() const;
971
972
973 static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86Interrupt; }
974};
975
976class AnyX86NoCallerSavedRegistersAttr : public InheritableAttr {
977public:
978 static AnyX86NoCallerSavedRegistersAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
979 auto *A = new (Ctx) AnyX86NoCallerSavedRegistersAttr(Loc, Ctx, 0);
980 A->setImplicit(true);
981 return A;
982 }
983
984 AnyX86NoCallerSavedRegistersAttr(SourceRange R, ASTContext &Ctx
985 , unsigned SI
986 )
987 : InheritableAttr(attr::AnyX86NoCallerSavedRegisters, R, SI, false, false)
988 {
989 }
990
991 AnyX86NoCallerSavedRegistersAttr *clone(ASTContext &C) const;
992 void printPretty(raw_ostream &OS,
993 const PrintingPolicy &Policy) const;
994 const char *getSpelling() const;
995
996
997 static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86NoCallerSavedRegisters; }
998};
999
1000class AnyX86NoCfCheckAttr : public InheritableAttr {
1001public:
1002 static AnyX86NoCfCheckAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1003 auto *A = new (Ctx) AnyX86NoCfCheckAttr(Loc, Ctx, 0);
1004 A->setImplicit(true);
1005 return A;
1006 }
1007
1008 AnyX86NoCfCheckAttr(SourceRange R, ASTContext &Ctx
1009 , unsigned SI
1010 )
1011 : InheritableAttr(attr::AnyX86NoCfCheck, R, SI, false, false)
1012 {
1013 }
1014
1015 AnyX86NoCfCheckAttr *clone(ASTContext &C) const;
1016 void printPretty(raw_ostream &OS,
1017 const PrintingPolicy &Policy) const;
1018 const char *getSpelling() const;
1019
1020
1021 static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86NoCfCheck; }
1022};
1023
1024class ArcWeakrefUnavailableAttr : public InheritableAttr {
1025public:
1026 static ArcWeakrefUnavailableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1027 auto *A = new (Ctx) ArcWeakrefUnavailableAttr(Loc, Ctx, 0);
1028 A->setImplicit(true);
1029 return A;
1030 }
1031
1032 ArcWeakrefUnavailableAttr(SourceRange R, ASTContext &Ctx
1033 , unsigned SI
1034 )
1035 : InheritableAttr(attr::ArcWeakrefUnavailable, R, SI, false, false)
1036 {
1037 }
1038
1039 ArcWeakrefUnavailableAttr *clone(ASTContext &C) const;
1040 void printPretty(raw_ostream &OS,
1041 const PrintingPolicy &Policy) const;
1042 const char *getSpelling() const;
1043
1044
1045 static bool classof(const Attr *A) { return A->getKind() == attr::ArcWeakrefUnavailable; }
1046};
1047
1048class ArgumentWithTypeTagAttr : public InheritableAttr {
1049IdentifierInfo * argumentKind;
1050
1051ParamIdx argumentIdx;
1052
1053ParamIdx typeTagIdx;
1054
1055bool isPointer;
1056
1057public:
1058 enum Spelling {
1059 GNU_argument_with_type_tag = 0,
1060 CXX11_clang_argument_with_type_tag = 1,
1061 C2x_clang_argument_with_type_tag = 2,
1062 GNU_pointer_with_type_tag = 3,
1063 CXX11_clang_pointer_with_type_tag = 4,
1064 C2x_clang_pointer_with_type_tag = 5
1065 };
1066
1067 static ArgumentWithTypeTagAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * ArgumentKind, ParamIdx ArgumentIdx, ParamIdx TypeTagIdx, bool IsPointer, SourceRange Loc = SourceRange()) {
1068 auto *A = new (Ctx) ArgumentWithTypeTagAttr(Loc, Ctx, ArgumentKind, ArgumentIdx, TypeTagIdx, IsPointer, S);
1069 A->setImplicit(true);
1070 return A;
1071 }
1072
1073 static ArgumentWithTypeTagAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * ArgumentKind, ParamIdx ArgumentIdx, ParamIdx TypeTagIdx, SourceRange Loc = SourceRange()) {
1074 auto *A = new (Ctx) ArgumentWithTypeTagAttr(Loc, Ctx, ArgumentKind, ArgumentIdx, TypeTagIdx, S);
1075 A->setImplicit(true);
1076 return A;
1077 }
1078
1079 ArgumentWithTypeTagAttr(SourceRange R, ASTContext &Ctx
1080 , IdentifierInfo * ArgumentKind
1081 , ParamIdx ArgumentIdx
1082 , ParamIdx TypeTagIdx
1083 , bool IsPointer
1084 , unsigned SI
1085 )
1086 : InheritableAttr(attr::ArgumentWithTypeTag, R, SI, false, false)
1087 , argumentKind(ArgumentKind)
1088 , argumentIdx(ArgumentIdx)
1089 , typeTagIdx(TypeTagIdx)
1090 , isPointer(IsPointer)
1091 {
1092 }
1093
1094 ArgumentWithTypeTagAttr(SourceRange R, ASTContext &Ctx
1095 , IdentifierInfo * ArgumentKind
1096 , ParamIdx ArgumentIdx
1097 , ParamIdx TypeTagIdx
1098 , unsigned SI
1099 )
1100 : InheritableAttr(attr::ArgumentWithTypeTag, R, SI, false, false)
1101 , argumentKind(ArgumentKind)
1102 , argumentIdx(ArgumentIdx)
1103 , typeTagIdx(TypeTagIdx)
1104 , isPointer()
1105 {
1106 }
1107
1108 ArgumentWithTypeTagAttr *clone(ASTContext &C) const;
1109 void printPretty(raw_ostream &OS,
1110 const PrintingPolicy &Policy) const;
1111 const char *getSpelling() const;
1112 Spelling getSemanticSpelling() const {
1113 switch (SpellingListIndex) {
1114 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 1114)
;
1115 case 0: return GNU_argument_with_type_tag;
1116 case 1: return CXX11_clang_argument_with_type_tag;
1117 case 2: return C2x_clang_argument_with_type_tag;
1118 case 3: return GNU_pointer_with_type_tag;
1119 case 4: return CXX11_clang_pointer_with_type_tag;
1120 case 5: return C2x_clang_pointer_with_type_tag;
1121 }
1122 }
1123 IdentifierInfo * getArgumentKind() const {
1124 return argumentKind;
1125 }
1126
1127 ParamIdx getArgumentIdx() const {
1128 return argumentIdx;
1129 }
1130
1131 ParamIdx getTypeTagIdx() const {
1132 return typeTagIdx;
1133 }
1134
1135 bool getIsPointer() const {
1136 return isPointer;
1137 }
1138
1139
1140
1141 static bool classof(const Attr *A) { return A->getKind() == attr::ArgumentWithTypeTag; }
1142};
1143
1144class ArtificialAttr : public InheritableAttr {
1145public:
1146 static ArtificialAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1147 auto *A = new (Ctx) ArtificialAttr(Loc, Ctx, 0);
1148 A->setImplicit(true);
1149 return A;
1150 }
1151
1152 ArtificialAttr(SourceRange R, ASTContext &Ctx
1153 , unsigned SI
1154 )
1155 : InheritableAttr(attr::Artificial, R, SI, false, false)
1156 {
1157 }
1158
1159 ArtificialAttr *clone(ASTContext &C) const;
1160 void printPretty(raw_ostream &OS,
1161 const PrintingPolicy &Policy) const;
1162 const char *getSpelling() const;
1163
1164
1165 static bool classof(const Attr *A) { return A->getKind() == attr::Artificial; }
1166};
1167
1168class AsmLabelAttr : public InheritableAttr {
1169unsigned labelLength;
1170char *label;
1171
1172public:
1173 static AsmLabelAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Label, SourceRange Loc = SourceRange()) {
1174 auto *A = new (Ctx) AsmLabelAttr(Loc, Ctx, Label, 0);
1175 A->setImplicit(true);
1176 return A;
1177 }
1178
1179 AsmLabelAttr(SourceRange R, ASTContext &Ctx
1180 , llvm::StringRef Label
1181 , unsigned SI
1182 )
1183 : InheritableAttr(attr::AsmLabel, R, SI, false, false)
1184 , labelLength(Label.size()),label(new (Ctx, 1) char[labelLength])
1185 {
1186 if (!Label.empty())
1187 std::memcpy(label, Label.data(), labelLength);
1188 }
1189
1190 AsmLabelAttr *clone(ASTContext &C) const;
1191 void printPretty(raw_ostream &OS,
1192 const PrintingPolicy &Policy) const;
1193 const char *getSpelling() const;
1194 llvm::StringRef getLabel() const {
1195 return llvm::StringRef(label, labelLength);
1196 }
1197 unsigned getLabelLength() const {
1198 return labelLength;
1199 }
1200 void setLabel(ASTContext &C, llvm::StringRef S) {
1201 labelLength = S.size();
1202 this->label = new (C, 1) char [labelLength];
1203 if (!S.empty())
1204 std::memcpy(this->label, S.data(), labelLength);
1205 }
1206
1207
1208
1209 static bool classof(const Attr *A) { return A->getKind() == attr::AsmLabel; }
1210};
1211
1212class AssertCapabilityAttr : public InheritableAttr {
1213 unsigned args_Size;
1214 Expr * *args_;
1215
1216public:
1217 enum Spelling {
1218 GNU_assert_capability = 0,
1219 CXX11_clang_assert_capability = 1,
1220 GNU_assert_shared_capability = 2,
1221 CXX11_clang_assert_shared_capability = 3
1222 };
1223
1224 static AssertCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
1225 auto *A = new (Ctx) AssertCapabilityAttr(Loc, Ctx, Args, ArgsSize, S);
1226 A->setImplicit(true);
1227 return A;
1228 }
1229
1230 AssertCapabilityAttr(SourceRange R, ASTContext &Ctx
1231 , Expr * *Args, unsigned ArgsSize
1232 , unsigned SI
1233 )
1234 : InheritableAttr(attr::AssertCapability, R, SI, true, true)
1235 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
1236 {
1237 std::copy(Args, Args + args_Size, args_);
1238 }
1239
1240 AssertCapabilityAttr(SourceRange R, ASTContext &Ctx
1241 , unsigned SI
1242 )
1243 : InheritableAttr(attr::AssertCapability, R, SI, true, true)
1244 , args_Size(0), args_(nullptr)
1245 {
1246 }
1247
1248 AssertCapabilityAttr *clone(ASTContext &C) const;
1249 void printPretty(raw_ostream &OS,
1250 const PrintingPolicy &Policy) const;
1251 const char *getSpelling() const;
1252 Spelling getSemanticSpelling() const {
1253 switch (SpellingListIndex) {
1254 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 1254)
;
1255 case 0: return GNU_assert_capability;
1256 case 1: return CXX11_clang_assert_capability;
1257 case 2: return GNU_assert_shared_capability;
1258 case 3: return CXX11_clang_assert_shared_capability;
1259 }
1260 }
1261 bool isShared() const { return SpellingListIndex == 2 ||
1262 SpellingListIndex == 3; }
1263 typedef Expr ** args_iterator;
1264 args_iterator args_begin() const { return args_; }
1265 args_iterator args_end() const { return args_ + args_Size; }
1266 unsigned args_size() const { return args_Size; }
1267 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
1268
1269
1270
1271
1272 static bool classof(const Attr *A) { return A->getKind() == attr::AssertCapability; }
1273};
1274
1275class AssertExclusiveLockAttr : public InheritableAttr {
1276 unsigned args_Size;
1277 Expr * *args_;
1278
1279public:
1280 static AssertExclusiveLockAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
1281 auto *A = new (Ctx) AssertExclusiveLockAttr(Loc, Ctx, Args, ArgsSize, 0);
1282 A->setImplicit(true);
1283 return A;
1284 }
1285
1286 AssertExclusiveLockAttr(SourceRange R, ASTContext &Ctx
1287 , Expr * *Args, unsigned ArgsSize
1288 , unsigned SI
1289 )
1290 : InheritableAttr(attr::AssertExclusiveLock, R, SI, true, true)
1291 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
1292 {
1293 std::copy(Args, Args + args_Size, args_);
1294 }
1295
1296 AssertExclusiveLockAttr(SourceRange R, ASTContext &Ctx
1297 , unsigned SI
1298 )
1299 : InheritableAttr(attr::AssertExclusiveLock, R, SI, true, true)
1300 , args_Size(0), args_(nullptr)
1301 {
1302 }
1303
1304 AssertExclusiveLockAttr *clone(ASTContext &C) const;
1305 void printPretty(raw_ostream &OS,
1306 const PrintingPolicy &Policy) const;
1307 const char *getSpelling() const;
1308 typedef Expr ** args_iterator;
1309 args_iterator args_begin() const { return args_; }
1310 args_iterator args_end() const { return args_ + args_Size; }
1311 unsigned args_size() const { return args_Size; }
1312 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
1313
1314
1315
1316
1317 static bool classof(const Attr *A) { return A->getKind() == attr::AssertExclusiveLock; }
1318};
1319
1320class AssertSharedLockAttr : public InheritableAttr {
1321 unsigned args_Size;
1322 Expr * *args_;
1323
1324public:
1325 static AssertSharedLockAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
1326 auto *A = new (Ctx) AssertSharedLockAttr(Loc, Ctx, Args, ArgsSize, 0);
1327 A->setImplicit(true);
1328 return A;
1329 }
1330
1331 AssertSharedLockAttr(SourceRange R, ASTContext &Ctx
1332 , Expr * *Args, unsigned ArgsSize
1333 , unsigned SI
1334 )
1335 : InheritableAttr(attr::AssertSharedLock, R, SI, true, true)
1336 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
1337 {
1338 std::copy(Args, Args + args_Size, args_);
1339 }
1340
1341 AssertSharedLockAttr(SourceRange R, ASTContext &Ctx
1342 , unsigned SI
1343 )
1344 : InheritableAttr(attr::AssertSharedLock, R, SI, true, true)
1345 , args_Size(0), args_(nullptr)
1346 {
1347 }
1348
1349 AssertSharedLockAttr *clone(ASTContext &C) const;
1350 void printPretty(raw_ostream &OS,
1351 const PrintingPolicy &Policy) const;
1352 const char *getSpelling() const;
1353 typedef Expr ** args_iterator;
1354 args_iterator args_begin() const { return args_; }
1355 args_iterator args_end() const { return args_ + args_Size; }
1356 unsigned args_size() const { return args_Size; }
1357 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
1358
1359
1360
1361
1362 static bool classof(const Attr *A) { return A->getKind() == attr::AssertSharedLock; }
1363};
1364
1365class AssumeAlignedAttr : public InheritableAttr {
1366Expr * alignment;
1367
1368Expr * offset;
1369
1370public:
1371 static AssumeAlignedAttr *CreateImplicit(ASTContext &Ctx, Expr * Alignment, Expr * Offset, SourceRange Loc = SourceRange()) {
1372 auto *A = new (Ctx) AssumeAlignedAttr(Loc, Ctx, Alignment, Offset, 0);
1373 A->setImplicit(true);
1374 return A;
1375 }
1376
1377 AssumeAlignedAttr(SourceRange R, ASTContext &Ctx
1378 , Expr * Alignment
1379 , Expr * Offset
1380 , unsigned SI
1381 )
1382 : InheritableAttr(attr::AssumeAligned, R, SI, false, false)
1383 , alignment(Alignment)
1384 , offset(Offset)
1385 {
1386 }
1387
1388 AssumeAlignedAttr(SourceRange R, ASTContext &Ctx
1389 , Expr * Alignment
1390 , unsigned SI
1391 )
1392 : InheritableAttr(attr::AssumeAligned, R, SI, false, false)
1393 , alignment(Alignment)
1394 , offset()
1395 {
1396 }
1397
1398 AssumeAlignedAttr *clone(ASTContext &C) const;
1399 void printPretty(raw_ostream &OS,
1400 const PrintingPolicy &Policy) const;
1401 const char *getSpelling() const;
1402 Expr * getAlignment() const {
1403 return alignment;
1404 }
1405
1406 Expr * getOffset() const {
1407 return offset;
1408 }
1409
1410
1411
1412 static bool classof(const Attr *A) { return A->getKind() == attr::AssumeAligned; }
1413};
1414
1415class AvailabilityAttr : public InheritableAttr {
1416IdentifierInfo * platform;
1417
1418VersionTuple introduced;
1419
1420
1421VersionTuple deprecated;
1422
1423
1424VersionTuple obsoleted;
1425
1426
1427bool unavailable;
1428
1429unsigned messageLength;
1430char *message;
1431
1432bool strict;
1433
1434unsigned replacementLength;
1435char *replacement;
1436
1437int priority;
1438
1439public:
1440 static AvailabilityAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Platform, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool Unavailable, llvm::StringRef Message, bool Strict, llvm::StringRef Replacement, int Priority, SourceRange Loc = SourceRange()) {
1441 auto *A = new (Ctx) AvailabilityAttr(Loc, Ctx, Platform, Introduced, Deprecated, Obsoleted, Unavailable, Message, Strict, Replacement, Priority, 0);
1442 A->setImplicit(true);
1443 return A;
1444 }
1445
1446 AvailabilityAttr(SourceRange R, ASTContext &Ctx
1447 , IdentifierInfo * Platform
1448 , VersionTuple Introduced
1449 , VersionTuple Deprecated
1450 , VersionTuple Obsoleted
1451 , bool Unavailable
1452 , llvm::StringRef Message
1453 , bool Strict
1454 , llvm::StringRef Replacement
1455 , int Priority
1456 , unsigned SI
1457 )
1458 : InheritableAttr(attr::Availability, R, SI, false, true)
1459 , platform(Platform)
1460 , introduced(Introduced)
1461 , deprecated(Deprecated)
1462 , obsoleted(Obsoleted)
1463 , unavailable(Unavailable)
1464 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
1465 , strict(Strict)
1466 , replacementLength(Replacement.size()),replacement(new (Ctx, 1) char[replacementLength])
1467 , priority(Priority)
1468 {
1469 if (!Message.empty())
1470 std::memcpy(message, Message.data(), messageLength);
1471 if (!Replacement.empty())
1472 std::memcpy(replacement, Replacement.data(), replacementLength);
1473 }
1474
1475 AvailabilityAttr *clone(ASTContext &C) const;
1476 void printPretty(raw_ostream &OS,
1477 const PrintingPolicy &Policy) const;
1478 const char *getSpelling() const;
1479 IdentifierInfo * getPlatform() const {
1480 return platform;
1481 }
1482
1483 VersionTuple getIntroduced() const {
1484 return introduced;
1485 }
1486 void setIntroduced(ASTContext &C, VersionTuple V) {
1487 introduced = V;
1488 }
1489
1490 VersionTuple getDeprecated() const {
1491 return deprecated;
1492 }
1493 void setDeprecated(ASTContext &C, VersionTuple V) {
1494 deprecated = V;
1495 }
1496
1497 VersionTuple getObsoleted() const {
1498 return obsoleted;
1499 }
1500 void setObsoleted(ASTContext &C, VersionTuple V) {
1501 obsoleted = V;
1502 }
1503
1504 bool getUnavailable() const {
1505 return unavailable;
1506 }
1507
1508 llvm::StringRef getMessage() const {
1509 return llvm::StringRef(message, messageLength);
1510 }
1511 unsigned getMessageLength() const {
1512 return messageLength;
1513 }
1514 void setMessage(ASTContext &C, llvm::StringRef S) {
1515 messageLength = S.size();
1516 this->message = new (C, 1) char [messageLength];
1517 if (!S.empty())
1518 std::memcpy(this->message, S.data(), messageLength);
1519 }
1520
1521 bool getStrict() const {
1522 return strict;
1523 }
1524
1525 llvm::StringRef getReplacement() const {
1526 return llvm::StringRef(replacement, replacementLength);
1527 }
1528 unsigned getReplacementLength() const {
1529 return replacementLength;
1530 }
1531 void setReplacement(ASTContext &C, llvm::StringRef S) {
1532 replacementLength = S.size();
1533 this->replacement = new (C, 1) char [replacementLength];
1534 if (!S.empty())
1535 std::memcpy(this->replacement, S.data(), replacementLength);
1536 }
1537
1538 int getPriority() const {
1539 return priority;
1540 }
1541
1542static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
1543 return llvm::StringSwitch<llvm::StringRef>(Platform)
1544 .Case("android", "Android")
1545 .Case("ios", "iOS")
1546 .Case("macos", "macOS")
1547 .Case("tvos", "tvOS")
1548 .Case("watchos", "watchOS")
1549 .Case("ios_app_extension", "iOS (App Extension)")
1550 .Case("macos_app_extension", "macOS (App Extension)")
1551 .Case("tvos_app_extension", "tvOS (App Extension)")
1552 .Case("watchos_app_extension", "watchOS (App Extension)")
1553 .Case("swift", "Swift")
1554 .Default(llvm::StringRef());
1555}
1556static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) {
1557 return llvm::StringSwitch<llvm::StringRef>(Platform)
1558 .Case("ios", "iOS")
1559 .Case("macos", "macOS")
1560 .Case("tvos", "tvOS")
1561 .Case("watchos", "watchOS")
1562 .Case("ios_app_extension", "iOSApplicationExtension")
1563 .Case("macos_app_extension", "macOSApplicationExtension")
1564 .Case("tvos_app_extension", "tvOSApplicationExtension")
1565 .Case("watchos_app_extension", "watchOSApplicationExtension")
1566 .Default(Platform);
1567}
1568static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
1569 return llvm::StringSwitch<llvm::StringRef>(Platform)
1570 .Case("iOS", "ios")
1571 .Case("macOS", "macos")
1572 .Case("tvOS", "tvos")
1573 .Case("watchOS", "watchos")
1574 .Case("iOSApplicationExtension", "ios_app_extension")
1575 .Case("macOSApplicationExtension", "macos_app_extension")
1576 .Case("tvOSApplicationExtension", "tvos_app_extension")
1577 .Case("watchOSApplicationExtension", "watchos_app_extension")
1578 .Default(Platform);
1579}
1580
1581 static bool classof(const Attr *A) { return A->getKind() == attr::Availability; }
1582};
1583
1584class BlocksAttr : public InheritableAttr {
1585public:
1586 enum BlockType {
1587 ByRef
1588 };
1589private:
1590 BlockType type;
1591
1592public:
1593 static BlocksAttr *CreateImplicit(ASTContext &Ctx, BlockType Type, SourceRange Loc = SourceRange()) {
1594 auto *A = new (Ctx) BlocksAttr(Loc, Ctx, Type, 0);
1595 A->setImplicit(true);
1596 return A;
1597 }
1598
1599 BlocksAttr(SourceRange R, ASTContext &Ctx
1600 , BlockType Type
1601 , unsigned SI
1602 )
1603 : InheritableAttr(attr::Blocks, R, SI, false, false)
1604 , type(Type)
1605 {
1606 }
1607
1608 BlocksAttr *clone(ASTContext &C) const;
1609 void printPretty(raw_ostream &OS,
1610 const PrintingPolicy &Policy) const;
1611 const char *getSpelling() const;
1612 BlockType getType() const {
1613 return type;
1614 }
1615
1616 static bool ConvertStrToBlockType(StringRef Val, BlockType &Out) {
1617 Optional<BlockType> R = llvm::StringSwitch<Optional<BlockType>>(Val)
1618 .Case("byref", BlocksAttr::ByRef)
1619 .Default(Optional<BlockType>());
1620 if (R) {
1621 Out = *R;
1622 return true;
1623 }
1624 return false;
1625 }
1626
1627 static const char *ConvertBlockTypeToStr(BlockType Val) {
1628 switch(Val) {
1629 case BlocksAttr::ByRef: return "byref";
1630 }
1631 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 1631)
;
1632 }
1633
1634
1635 static bool classof(const Attr *A) { return A->getKind() == attr::Blocks; }
1636};
1637
1638class C11NoReturnAttr : public InheritableAttr {
1639public:
1640 static C11NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1641 auto *A = new (Ctx) C11NoReturnAttr(Loc, Ctx, 0);
1642 A->setImplicit(true);
1643 return A;
1644 }
1645
1646 C11NoReturnAttr(SourceRange R, ASTContext &Ctx
1647 , unsigned SI
1648 )
1649 : InheritableAttr(attr::C11NoReturn, R, SI, false, false)
1650 {
1651 }
1652
1653 C11NoReturnAttr *clone(ASTContext &C) const;
1654 void printPretty(raw_ostream &OS,
1655 const PrintingPolicy &Policy) const;
1656 const char *getSpelling() const;
1657
1658
1659 static bool classof(const Attr *A) { return A->getKind() == attr::C11NoReturn; }
1660};
1661
1662class CDeclAttr : public InheritableAttr {
1663public:
1664 static CDeclAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1665 auto *A = new (Ctx) CDeclAttr(Loc, Ctx, 0);
1666 A->setImplicit(true);
1667 return A;
1668 }
1669
1670 CDeclAttr(SourceRange R, ASTContext &Ctx
1671 , unsigned SI
1672 )
1673 : InheritableAttr(attr::CDecl, R, SI, false, false)
1674 {
1675 }
1676
1677 CDeclAttr *clone(ASTContext &C) const;
1678 void printPretty(raw_ostream &OS,
1679 const PrintingPolicy &Policy) const;
1680 const char *getSpelling() const;
1681
1682
1683 static bool classof(const Attr *A) { return A->getKind() == attr::CDecl; }
1684};
1685
1686class CFAuditedTransferAttr : public InheritableAttr {
1687public:
1688 static CFAuditedTransferAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1689 auto *A = new (Ctx) CFAuditedTransferAttr(Loc, Ctx, 0);
1690 A->setImplicit(true);
1691 return A;
1692 }
1693
1694 CFAuditedTransferAttr(SourceRange R, ASTContext &Ctx
1695 , unsigned SI
1696 )
1697 : InheritableAttr(attr::CFAuditedTransfer, R, SI, false, false)
1698 {
1699 }
1700
1701 CFAuditedTransferAttr *clone(ASTContext &C) const;
1702 void printPretty(raw_ostream &OS,
1703 const PrintingPolicy &Policy) const;
1704 const char *getSpelling() const;
1705
1706
1707 static bool classof(const Attr *A) { return A->getKind() == attr::CFAuditedTransfer; }
1708};
1709
1710class CFConsumedAttr : public InheritableParamAttr {
1711public:
1712 static CFConsumedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1713 auto *A = new (Ctx) CFConsumedAttr(Loc, Ctx, 0);
1714 A->setImplicit(true);
1715 return A;
1716 }
1717
1718 CFConsumedAttr(SourceRange R, ASTContext &Ctx
1719 , unsigned SI
1720 )
1721 : InheritableParamAttr(attr::CFConsumed, R, SI, false, false)
1722 {
1723 }
1724
1725 CFConsumedAttr *clone(ASTContext &C) const;
1726 void printPretty(raw_ostream &OS,
1727 const PrintingPolicy &Policy) const;
1728 const char *getSpelling() const;
1729
1730
1731 static bool classof(const Attr *A) { return A->getKind() == attr::CFConsumed; }
1732};
1733
1734class CFReturnsNotRetainedAttr : public InheritableAttr {
1735public:
1736 static CFReturnsNotRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1737 auto *A = new (Ctx) CFReturnsNotRetainedAttr(Loc, Ctx, 0);
1738 A->setImplicit(true);
1739 return A;
1740 }
1741
1742 CFReturnsNotRetainedAttr(SourceRange R, ASTContext &Ctx
1743 , unsigned SI
1744 )
1745 : InheritableAttr(attr::CFReturnsNotRetained, R, SI, false, false)
1746 {
1747 }
1748
1749 CFReturnsNotRetainedAttr *clone(ASTContext &C) const;
1750 void printPretty(raw_ostream &OS,
1751 const PrintingPolicy &Policy) const;
1752 const char *getSpelling() const;
1753
1754
1755 static bool classof(const Attr *A) { return A->getKind() == attr::CFReturnsNotRetained; }
1756};
1757
1758class CFReturnsRetainedAttr : public InheritableAttr {
1759public:
1760 static CFReturnsRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1761 auto *A = new (Ctx) CFReturnsRetainedAttr(Loc, Ctx, 0);
1762 A->setImplicit(true);
1763 return A;
1764 }
1765
1766 CFReturnsRetainedAttr(SourceRange R, ASTContext &Ctx
1767 , unsigned SI
1768 )
1769 : InheritableAttr(attr::CFReturnsRetained, R, SI, false, false)
1770 {
1771 }
1772
1773 CFReturnsRetainedAttr *clone(ASTContext &C) const;
1774 void printPretty(raw_ostream &OS,
1775 const PrintingPolicy &Policy) const;
1776 const char *getSpelling() const;
1777
1778
1779 static bool classof(const Attr *A) { return A->getKind() == attr::CFReturnsRetained; }
1780};
1781
1782class CFUnknownTransferAttr : public InheritableAttr {
1783public:
1784 static CFUnknownTransferAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1785 auto *A = new (Ctx) CFUnknownTransferAttr(Loc, Ctx, 0);
1786 A->setImplicit(true);
1787 return A;
1788 }
1789
1790 CFUnknownTransferAttr(SourceRange R, ASTContext &Ctx
1791 , unsigned SI
1792 )
1793 : InheritableAttr(attr::CFUnknownTransfer, R, SI, false, false)
1794 {
1795 }
1796
1797 CFUnknownTransferAttr *clone(ASTContext &C) const;
1798 void printPretty(raw_ostream &OS,
1799 const PrintingPolicy &Policy) const;
1800 const char *getSpelling() const;
1801
1802
1803 static bool classof(const Attr *A) { return A->getKind() == attr::CFUnknownTransfer; }
1804};
1805
1806class CPUDispatchAttr : public InheritableAttr {
1807 unsigned cpus_Size;
1808 IdentifierInfo * *cpus_;
1809
1810public:
1811 static CPUDispatchAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * *Cpus, unsigned CpusSize, SourceRange Loc = SourceRange()) {
1812 auto *A = new (Ctx) CPUDispatchAttr(Loc, Ctx, Cpus, CpusSize, 0);
1813 A->setImplicit(true);
1814 return A;
1815 }
1816
1817 CPUDispatchAttr(SourceRange R, ASTContext &Ctx
1818 , IdentifierInfo * *Cpus, unsigned CpusSize
1819 , unsigned SI
1820 )
1821 : InheritableAttr(attr::CPUDispatch, R, SI, false, false)
1822 , cpus_Size(CpusSize), cpus_(new (Ctx, 16) IdentifierInfo *[cpus_Size])
1823 {
1824 std::copy(Cpus, Cpus + cpus_Size, cpus_);
1825 }
1826
1827 CPUDispatchAttr(SourceRange R, ASTContext &Ctx
1828 , unsigned SI
1829 )
1830 : InheritableAttr(attr::CPUDispatch, R, SI, false, false)
1831 , cpus_Size(0), cpus_(nullptr)
1832 {
1833 }
1834
1835 CPUDispatchAttr *clone(ASTContext &C) const;
1836 void printPretty(raw_ostream &OS,
1837 const PrintingPolicy &Policy) const;
1838 const char *getSpelling() const;
1839 typedef IdentifierInfo ** cpus_iterator;
1840 cpus_iterator cpus_begin() const { return cpus_; }
1841 cpus_iterator cpus_end() const { return cpus_ + cpus_Size; }
1842 unsigned cpus_size() const { return cpus_Size; }
1843 llvm::iterator_range<cpus_iterator> cpus() const { return llvm::make_range(cpus_begin(), cpus_end()); }
1844
1845
1846
1847
1848 static bool classof(const Attr *A) { return A->getKind() == attr::CPUDispatch; }
1849};
1850
1851class CPUSpecificAttr : public InheritableAttr {
1852 unsigned cpus_Size;
1853 IdentifierInfo * *cpus_;
1854
1855public:
1856 static CPUSpecificAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * *Cpus, unsigned CpusSize, SourceRange Loc = SourceRange()) {
1857 auto *A = new (Ctx) CPUSpecificAttr(Loc, Ctx, Cpus, CpusSize, 0);
1858 A->setImplicit(true);
1859 return A;
1860 }
1861
1862 CPUSpecificAttr(SourceRange R, ASTContext &Ctx
1863 , IdentifierInfo * *Cpus, unsigned CpusSize
1864 , unsigned SI
1865 )
1866 : InheritableAttr(attr::CPUSpecific, R, SI, false, false)
1867 , cpus_Size(CpusSize), cpus_(new (Ctx, 16) IdentifierInfo *[cpus_Size])
1868 {
1869 std::copy(Cpus, Cpus + cpus_Size, cpus_);
1870 }
1871
1872 CPUSpecificAttr(SourceRange R, ASTContext &Ctx
1873 , unsigned SI
1874 )
1875 : InheritableAttr(attr::CPUSpecific, R, SI, false, false)
1876 , cpus_Size(0), cpus_(nullptr)
1877 {
1878 }
1879
1880 CPUSpecificAttr *clone(ASTContext &C) const;
1881 void printPretty(raw_ostream &OS,
1882 const PrintingPolicy &Policy) const;
1883 const char *getSpelling() const;
1884 typedef IdentifierInfo ** cpus_iterator;
1885 cpus_iterator cpus_begin() const { return cpus_; }
1886 cpus_iterator cpus_end() const { return cpus_ + cpus_Size; }
1887 unsigned cpus_size() const { return cpus_Size; }
1888 llvm::iterator_range<cpus_iterator> cpus() const { return llvm::make_range(cpus_begin(), cpus_end()); }
1889
1890
1891
1892 IdentifierInfo *getCPUName(unsigned Index) const {
1893 return *(cpus_begin() + Index);
1894 }
1895
1896
1897 static bool classof(const Attr *A) { return A->getKind() == attr::CPUSpecific; }
1898};
1899
1900class CUDAConstantAttr : public InheritableAttr {
1901public:
1902 static CUDAConstantAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1903 auto *A = new (Ctx) CUDAConstantAttr(Loc, Ctx, 0);
1904 A->setImplicit(true);
1905 return A;
1906 }
1907
1908 CUDAConstantAttr(SourceRange R, ASTContext &Ctx
1909 , unsigned SI
1910 )
1911 : InheritableAttr(attr::CUDAConstant, R, SI, false, false)
1912 {
1913 }
1914
1915 CUDAConstantAttr *clone(ASTContext &C) const;
1916 void printPretty(raw_ostream &OS,
1917 const PrintingPolicy &Policy) const;
1918 const char *getSpelling() const;
1919
1920
1921 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAConstant; }
1922};
1923
1924class CUDADeviceAttr : public InheritableAttr {
1925public:
1926 static CUDADeviceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1927 auto *A = new (Ctx) CUDADeviceAttr(Loc, Ctx, 0);
1928 A->setImplicit(true);
1929 return A;
1930 }
1931
1932 CUDADeviceAttr(SourceRange R, ASTContext &Ctx
1933 , unsigned SI
1934 )
1935 : InheritableAttr(attr::CUDADevice, R, SI, false, false)
1936 {
1937 }
1938
1939 CUDADeviceAttr *clone(ASTContext &C) const;
1940 void printPretty(raw_ostream &OS,
1941 const PrintingPolicy &Policy) const;
1942 const char *getSpelling() const;
1943
1944
1945 static bool classof(const Attr *A) { return A->getKind() == attr::CUDADevice; }
1946};
1947
1948class CUDAGlobalAttr : public InheritableAttr {
1949public:
1950 static CUDAGlobalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1951 auto *A = new (Ctx) CUDAGlobalAttr(Loc, Ctx, 0);
1952 A->setImplicit(true);
1953 return A;
1954 }
1955
1956 CUDAGlobalAttr(SourceRange R, ASTContext &Ctx
1957 , unsigned SI
1958 )
1959 : InheritableAttr(attr::CUDAGlobal, R, SI, false, false)
1960 {
1961 }
1962
1963 CUDAGlobalAttr *clone(ASTContext &C) const;
1964 void printPretty(raw_ostream &OS,
1965 const PrintingPolicy &Policy) const;
1966 const char *getSpelling() const;
1967
1968
1969 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAGlobal; }
1970};
1971
1972class CUDAHostAttr : public InheritableAttr {
1973public:
1974 static CUDAHostAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1975 auto *A = new (Ctx) CUDAHostAttr(Loc, Ctx, 0);
1976 A->setImplicit(true);
1977 return A;
1978 }
1979
1980 CUDAHostAttr(SourceRange R, ASTContext &Ctx
1981 , unsigned SI
1982 )
1983 : InheritableAttr(attr::CUDAHost, R, SI, false, false)
1984 {
1985 }
1986
1987 CUDAHostAttr *clone(ASTContext &C) const;
1988 void printPretty(raw_ostream &OS,
1989 const PrintingPolicy &Policy) const;
1990 const char *getSpelling() const;
1991
1992
1993 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAHost; }
1994};
1995
1996class CUDAInvalidTargetAttr : public InheritableAttr {
1997public:
1998 static CUDAInvalidTargetAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1999 auto *A = new (Ctx) CUDAInvalidTargetAttr(Loc, Ctx, 0);
2000 A->setImplicit(true);
2001 return A;
2002 }
2003
2004 CUDAInvalidTargetAttr(SourceRange R, ASTContext &Ctx
2005 , unsigned SI
2006 )
2007 : InheritableAttr(attr::CUDAInvalidTarget, R, SI, false, false)
2008 {
2009 }
2010
2011 CUDAInvalidTargetAttr *clone(ASTContext &C) const;
2012 void printPretty(raw_ostream &OS,
2013 const PrintingPolicy &Policy) const;
2014 const char *getSpelling() const;
2015
2016
2017 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAInvalidTarget; }
2018};
2019
2020class CUDALaunchBoundsAttr : public InheritableAttr {
2021Expr * maxThreads;
2022
2023Expr * minBlocks;
2024
2025public:
2026 static CUDALaunchBoundsAttr *CreateImplicit(ASTContext &Ctx, Expr * MaxThreads, Expr * MinBlocks, SourceRange Loc = SourceRange()) {
2027 auto *A = new (Ctx) CUDALaunchBoundsAttr(Loc, Ctx, MaxThreads, MinBlocks, 0);
2028 A->setImplicit(true);
2029 return A;
2030 }
2031
2032 CUDALaunchBoundsAttr(SourceRange R, ASTContext &Ctx
2033 , Expr * MaxThreads
2034 , Expr * MinBlocks
2035 , unsigned SI
2036 )
2037 : InheritableAttr(attr::CUDALaunchBounds, R, SI, false, false)
2038 , maxThreads(MaxThreads)
2039 , minBlocks(MinBlocks)
2040 {
2041 }
2042
2043 CUDALaunchBoundsAttr(SourceRange R, ASTContext &Ctx
2044 , Expr * MaxThreads
2045 , unsigned SI
2046 )
2047 : InheritableAttr(attr::CUDALaunchBounds, R, SI, false, false)
2048 , maxThreads(MaxThreads)
2049 , minBlocks()
2050 {
2051 }
2052
2053 CUDALaunchBoundsAttr *clone(ASTContext &C) const;
2054 void printPretty(raw_ostream &OS,
2055 const PrintingPolicy &Policy) const;
2056 const char *getSpelling() const;
2057 Expr * getMaxThreads() const {
2058 return maxThreads;
2059 }
2060
2061 Expr * getMinBlocks() const {
2062 return minBlocks;
2063 }
2064
2065
2066
2067 static bool classof(const Attr *A) { return A->getKind() == attr::CUDALaunchBounds; }
2068};
2069
2070class CUDASharedAttr : public InheritableAttr {
2071public:
2072 static CUDASharedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2073 auto *A = new (Ctx) CUDASharedAttr(Loc, Ctx, 0);
2074 A->setImplicit(true);
2075 return A;
2076 }
2077
2078 CUDASharedAttr(SourceRange R, ASTContext &Ctx
2079 , unsigned SI
2080 )
2081 : InheritableAttr(attr::CUDAShared, R, SI, false, false)
2082 {
2083 }
2084
2085 CUDASharedAttr *clone(ASTContext &C) const;
2086 void printPretty(raw_ostream &OS,
2087 const PrintingPolicy &Policy) const;
2088 const char *getSpelling() const;
2089
2090
2091 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAShared; }
2092};
2093
2094class CXX11NoReturnAttr : public InheritableAttr {
2095public:
2096 static CXX11NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2097 auto *A = new (Ctx) CXX11NoReturnAttr(Loc, Ctx, 0);
2098 A->setImplicit(true);
2099 return A;
2100 }
2101
2102 CXX11NoReturnAttr(SourceRange R, ASTContext &Ctx
2103 , unsigned SI
2104 )
2105 : InheritableAttr(attr::CXX11NoReturn, R, SI, false, false)
2106 {
2107 }
2108
2109 CXX11NoReturnAttr *clone(ASTContext &C) const;
2110 void printPretty(raw_ostream &OS,
2111 const PrintingPolicy &Policy) const;
2112 const char *getSpelling() const;
2113
2114
2115 static bool classof(const Attr *A) { return A->getKind() == attr::CXX11NoReturn; }
2116};
2117
2118class CallableWhenAttr : public InheritableAttr {
2119public:
2120 enum ConsumedState {
2121 Unknown,
2122 Consumed,
2123 Unconsumed
2124 };
2125private:
2126 unsigned callableStates_Size;
2127 ConsumedState *callableStates_;
2128
2129public:
2130 static CallableWhenAttr *CreateImplicit(ASTContext &Ctx, ConsumedState *CallableStates, unsigned CallableStatesSize, SourceRange Loc = SourceRange()) {
2131 auto *A = new (Ctx) CallableWhenAttr(Loc, Ctx, CallableStates, CallableStatesSize, 0);
2132 A->setImplicit(true);
2133 return A;
2134 }
2135
2136 CallableWhenAttr(SourceRange R, ASTContext &Ctx
2137 , ConsumedState *CallableStates, unsigned CallableStatesSize
2138 , unsigned SI
2139 )
2140 : InheritableAttr(attr::CallableWhen, R, SI, false, false)
2141 , callableStates_Size(CallableStatesSize), callableStates_(new (Ctx, 16) ConsumedState[callableStates_Size])
2142 {
2143 std::copy(CallableStates, CallableStates + callableStates_Size, callableStates_);
2144 }
2145
2146 CallableWhenAttr(SourceRange R, ASTContext &Ctx
2147 , unsigned SI
2148 )
2149 : InheritableAttr(attr::CallableWhen, R, SI, false, false)
2150 , callableStates_Size(0), callableStates_(nullptr)
2151 {
2152 }
2153
2154 CallableWhenAttr *clone(ASTContext &C) const;
2155 void printPretty(raw_ostream &OS,
2156 const PrintingPolicy &Policy) const;
2157 const char *getSpelling() const;
2158 typedef ConsumedState* callableStates_iterator;
2159 callableStates_iterator callableStates_begin() const { return callableStates_; }
2160 callableStates_iterator callableStates_end() const { return callableStates_ + callableStates_Size; }
2161 unsigned callableStates_size() const { return callableStates_Size; }
2162 llvm::iterator_range<callableStates_iterator> callableStates() const { return llvm::make_range(callableStates_begin(), callableStates_end()); }
2163
2164
2165 static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) {
2166 Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val)
2167 .Case("unknown", CallableWhenAttr::Unknown)
2168 .Case("consumed", CallableWhenAttr::Consumed)
2169 .Case("unconsumed", CallableWhenAttr::Unconsumed)
2170 .Default(Optional<ConsumedState>());
2171 if (R) {
2172 Out = *R;
2173 return true;
2174 }
2175 return false;
2176 }
2177
2178 static const char *ConvertConsumedStateToStr(ConsumedState Val) {
2179 switch(Val) {
2180 case CallableWhenAttr::Unknown: return "unknown";
2181 case CallableWhenAttr::Consumed: return "consumed";
2182 case CallableWhenAttr::Unconsumed: return "unconsumed";
2183 }
2184 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 2184)
;
2185 }
2186
2187
2188 static bool classof(const Attr *A) { return A->getKind() == attr::CallableWhen; }
2189};
2190
2191class CallbackAttr : public InheritableAttr {
2192 unsigned encoding_Size;
2193 int *encoding_;
2194
2195public:
2196 static CallbackAttr *CreateImplicit(ASTContext &Ctx, int *Encoding, unsigned EncodingSize, SourceRange Loc = SourceRange()) {
2197 auto *A = new (Ctx) CallbackAttr(Loc, Ctx, Encoding, EncodingSize, 0);
2198 A->setImplicit(true);
2199 return A;
2200 }
2201
2202 CallbackAttr(SourceRange R, ASTContext &Ctx
2203 , int *Encoding, unsigned EncodingSize
2204 , unsigned SI
2205 )
2206 : InheritableAttr(attr::Callback, R, SI, false, false)
2207 , encoding_Size(EncodingSize), encoding_(new (Ctx, 16) int[encoding_Size])
2208 {
2209 std::copy(Encoding, Encoding + encoding_Size, encoding_);
2210 }
2211
2212 CallbackAttr(SourceRange R, ASTContext &Ctx
2213 , unsigned SI
2214 )
2215 : InheritableAttr(attr::Callback, R, SI, false, false)
2216 , encoding_Size(0), encoding_(nullptr)
2217 {
2218 }
2219
2220 CallbackAttr *clone(ASTContext &C) const;
2221 void printPretty(raw_ostream &OS,
2222 const PrintingPolicy &Policy) const;
2223 const char *getSpelling() const;
2224 typedef int* encoding_iterator;
2225 encoding_iterator encoding_begin() const { return encoding_; }
2226 encoding_iterator encoding_end() const { return encoding_ + encoding_Size; }
2227 unsigned encoding_size() const { return encoding_Size; }
2228 llvm::iterator_range<encoding_iterator> encoding() const { return llvm::make_range(encoding_begin(), encoding_end()); }
2229
2230
2231
2232
2233 static bool classof(const Attr *A) { return A->getKind() == attr::Callback; }
2234};
2235
2236class CapabilityAttr : public InheritableAttr {
2237unsigned nameLength;
2238char *name;
2239
2240public:
2241 enum Spelling {
2242 GNU_capability = 0,
2243 CXX11_clang_capability = 1,
2244 GNU_shared_capability = 2,
2245 CXX11_clang_shared_capability = 3
2246 };
2247
2248 static CapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, llvm::StringRef Name, SourceRange Loc = SourceRange()) {
2249 auto *A = new (Ctx) CapabilityAttr(Loc, Ctx, Name, S);
2250 A->setImplicit(true);
2251 return A;
2252 }
2253
2254 CapabilityAttr(SourceRange R, ASTContext &Ctx
2255 , llvm::StringRef Name
2256 , unsigned SI
2257 )
2258 : InheritableAttr(attr::Capability, R, SI, false, false)
2259 , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength])
2260 {
2261 if (!Name.empty())
2262 std::memcpy(name, Name.data(), nameLength);
2263 }
2264
2265 CapabilityAttr *clone(ASTContext &C) const;
2266 void printPretty(raw_ostream &OS,
2267 const PrintingPolicy &Policy) const;
2268 const char *getSpelling() const;
2269 Spelling getSemanticSpelling() const {
2270 switch (SpellingListIndex) {
2271 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 2271)
;
2272 case 0: return GNU_capability;
2273 case 1: return CXX11_clang_capability;
2274 case 2: return GNU_shared_capability;
2275 case 3: return CXX11_clang_shared_capability;
2276 }
2277 }
2278 bool isShared() const { return SpellingListIndex == 2 ||
2279 SpellingListIndex == 3; }
2280 llvm::StringRef getName() const {
2281 return llvm::StringRef(name, nameLength);
2282 }
2283 unsigned getNameLength() const {
2284 return nameLength;
2285 }
2286 void setName(ASTContext &C, llvm::StringRef S) {
2287 nameLength = S.size();
2288 this->name = new (C, 1) char [nameLength];
2289 if (!S.empty())
2290 std::memcpy(this->name, S.data(), nameLength);
2291 }
2292
2293
2294 bool isMutex() const { return getName().equals_lower("mutex"); }
2295 bool isRole() const { return getName().equals_lower("role"); }
2296
2297
2298 static bool classof(const Attr *A) { return A->getKind() == attr::Capability; }
2299};
2300
2301class CapturedRecordAttr : public InheritableAttr {
2302public:
2303 static CapturedRecordAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2304 auto *A = new (Ctx) CapturedRecordAttr(Loc, Ctx, 0);
2305 A->setImplicit(true);
2306 return A;
2307 }
2308
2309 CapturedRecordAttr(SourceRange R, ASTContext &Ctx
2310 , unsigned SI
2311 )
2312 : InheritableAttr(attr::CapturedRecord, R, SI, false, false)
2313 {
2314 }
2315
2316 CapturedRecordAttr *clone(ASTContext &C) const;
2317 void printPretty(raw_ostream &OS,
2318 const PrintingPolicy &Policy) const;
2319 const char *getSpelling() const;
2320
2321
2322 static bool classof(const Attr *A) { return A->getKind() == attr::CapturedRecord; }
2323};
2324
2325class CarriesDependencyAttr : public InheritableParamAttr {
2326public:
2327 static CarriesDependencyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2328 auto *A = new (Ctx) CarriesDependencyAttr(Loc, Ctx, 0);
2329 A->setImplicit(true);
2330 return A;
2331 }
2332
2333 CarriesDependencyAttr(SourceRange R, ASTContext &Ctx
2334 , unsigned SI
2335 )
2336 : InheritableParamAttr(attr::CarriesDependency, R, SI, false, false)
2337 {
2338 }
2339
2340 CarriesDependencyAttr *clone(ASTContext &C) const;
2341 void printPretty(raw_ostream &OS,
2342 const PrintingPolicy &Policy) const;
2343 const char *getSpelling() const;
2344
2345
2346 static bool classof(const Attr *A) { return A->getKind() == attr::CarriesDependency; }
2347};
2348
2349class CleanupAttr : public InheritableAttr {
2350FunctionDecl * functionDecl;
2351
2352public:
2353 static CleanupAttr *CreateImplicit(ASTContext &Ctx, FunctionDecl * FunctionDecl, SourceRange Loc = SourceRange()) {
2354 auto *A = new (Ctx) CleanupAttr(Loc, Ctx, FunctionDecl, 0);
2355 A->setImplicit(true);
2356 return A;
2357 }
2358
2359 CleanupAttr(SourceRange R, ASTContext &Ctx
2360 , FunctionDecl * FunctionDecl
2361 , unsigned SI
2362 )
2363 : InheritableAttr(attr::Cleanup, R, SI, false, false)
2364 , functionDecl(FunctionDecl)
2365 {
2366 }
2367
2368 CleanupAttr *clone(ASTContext &C) const;
2369 void printPretty(raw_ostream &OS,
2370 const PrintingPolicy &Policy) const;
2371 const char *getSpelling() const;
2372 FunctionDecl * getFunctionDecl() const {
2373 return functionDecl;
2374 }
2375
2376
2377
2378 static bool classof(const Attr *A) { return A->getKind() == attr::Cleanup; }
2379};
2380
2381class CodeSegAttr : public InheritableAttr {
2382unsigned nameLength;
2383char *name;
2384
2385public:
2386 static CodeSegAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, SourceRange Loc = SourceRange()) {
2387 auto *A = new (Ctx) CodeSegAttr(Loc, Ctx, Name, 0);
2388 A->setImplicit(true);
2389 return A;
2390 }
2391
2392 CodeSegAttr(SourceRange R, ASTContext &Ctx
2393 , llvm::StringRef Name
2394 , unsigned SI
2395 )
2396 : InheritableAttr(attr::CodeSeg, R, SI, false, false)
2397 , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength])
2398 {
2399 if (!Name.empty())
2400 std::memcpy(name, Name.data(), nameLength);
2401 }
2402
2403 CodeSegAttr *clone(ASTContext &C) const;
2404 void printPretty(raw_ostream &OS,
2405 const PrintingPolicy &Policy) const;
2406 const char *getSpelling() const;
2407 llvm::StringRef getName() const {
2408 return llvm::StringRef(name, nameLength);
2409 }
2410 unsigned getNameLength() const {
2411 return nameLength;
2412 }
2413 void setName(ASTContext &C, llvm::StringRef S) {
2414 nameLength = S.size();
2415 this->name = new (C, 1) char [nameLength];
2416 if (!S.empty())
2417 std::memcpy(this->name, S.data(), nameLength);
2418 }
2419
2420
2421
2422 static bool classof(const Attr *A) { return A->getKind() == attr::CodeSeg; }
2423};
2424
2425class ColdAttr : public InheritableAttr {
2426public:
2427 static ColdAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2428 auto *A = new (Ctx) ColdAttr(Loc, Ctx, 0);
2429 A->setImplicit(true);
2430 return A;
2431 }
2432
2433 ColdAttr(SourceRange R, ASTContext &Ctx
2434 , unsigned SI
2435 )
2436 : InheritableAttr(attr::Cold, R, SI, false, false)
2437 {
2438 }
2439
2440 ColdAttr *clone(ASTContext &C) const;
2441 void printPretty(raw_ostream &OS,
2442 const PrintingPolicy &Policy) const;
2443 const char *getSpelling() const;
2444
2445
2446 static bool classof(const Attr *A) { return A->getKind() == attr::Cold; }
2447};
2448
2449class CommonAttr : public InheritableAttr {
2450public:
2451 static CommonAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2452 auto *A = new (Ctx) CommonAttr(Loc, Ctx, 0);
2453 A->setImplicit(true);
2454 return A;
2455 }
2456
2457 CommonAttr(SourceRange R, ASTContext &Ctx
2458 , unsigned SI
2459 )
2460 : InheritableAttr(attr::Common, R, SI, false, false)
2461 {
2462 }
2463
2464 CommonAttr *clone(ASTContext &C) const;
2465 void printPretty(raw_ostream &OS,
2466 const PrintingPolicy &Policy) const;
2467 const char *getSpelling() const;
2468
2469
2470 static bool classof(const Attr *A) { return A->getKind() == attr::Common; }
2471};
2472
2473class ConstAttr : public InheritableAttr {
2474public:
2475 static ConstAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2476 auto *A = new (Ctx) ConstAttr(Loc, Ctx, 0);
2477 A->setImplicit(true);
2478 return A;
2479 }
2480
2481 ConstAttr(SourceRange R, ASTContext &Ctx
2482 , unsigned SI
2483 )
2484 : InheritableAttr(attr::Const, R, SI, false, false)
2485 {
2486 }
2487
2488 ConstAttr *clone(ASTContext &C) const;
2489 void printPretty(raw_ostream &OS,
2490 const PrintingPolicy &Policy) const;
2491 const char *getSpelling() const;
2492
2493
2494 static bool classof(const Attr *A) { return A->getKind() == attr::Const; }
2495};
2496
2497class ConstructorAttr : public InheritableAttr {
2498int priority;
2499
2500public:
2501 static ConstructorAttr *CreateImplicit(ASTContext &Ctx, int Priority, SourceRange Loc = SourceRange()) {
2502 auto *A = new (Ctx) ConstructorAttr(Loc, Ctx, Priority, 0);
2503 A->setImplicit(true);
2504 return A;
2505 }
2506
2507 ConstructorAttr(SourceRange R, ASTContext &Ctx
2508 , int Priority
2509 , unsigned SI
2510 )
2511 : InheritableAttr(attr::Constructor, R, SI, false, false)
2512 , priority(Priority)
2513 {
2514 }
2515
2516 ConstructorAttr(SourceRange R, ASTContext &Ctx
2517 , unsigned SI
2518 )
2519 : InheritableAttr(attr::Constructor, R, SI, false, false)
2520 , priority()
2521 {
2522 }
2523
2524 ConstructorAttr *clone(ASTContext &C) const;
2525 void printPretty(raw_ostream &OS,
2526 const PrintingPolicy &Policy) const;
2527 const char *getSpelling() const;
2528 int getPriority() const {
2529 return priority;
2530 }
2531
2532 static const int DefaultPriority = 65535;
2533
2534
2535
2536 static bool classof(const Attr *A) { return A->getKind() == attr::Constructor; }
2537};
2538
2539class ConsumableAttr : public InheritableAttr {
2540public:
2541 enum ConsumedState {
2542 Unknown,
2543 Consumed,
2544 Unconsumed
2545 };
2546private:
2547 ConsumedState defaultState;
2548
2549public:
2550 static ConsumableAttr *CreateImplicit(ASTContext &Ctx, ConsumedState DefaultState, SourceRange Loc = SourceRange()) {
2551 auto *A = new (Ctx) ConsumableAttr(Loc, Ctx, DefaultState, 0);
2552 A->setImplicit(true);
2553 return A;
2554 }
2555
2556 ConsumableAttr(SourceRange R, ASTContext &Ctx
2557 , ConsumedState DefaultState
2558 , unsigned SI
2559 )
2560 : InheritableAttr(attr::Consumable, R, SI, false, false)
2561 , defaultState(DefaultState)
2562 {
2563 }
2564
2565 ConsumableAttr *clone(ASTContext &C) const;
2566 void printPretty(raw_ostream &OS,
2567 const PrintingPolicy &Policy) const;
2568 const char *getSpelling() const;
2569 ConsumedState getDefaultState() const {
2570 return defaultState;
2571 }
2572
2573 static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) {
2574 Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val)
2575 .Case("unknown", ConsumableAttr::Unknown)
2576 .Case("consumed", ConsumableAttr::Consumed)
2577 .Case("unconsumed", ConsumableAttr::Unconsumed)
2578 .Default(Optional<ConsumedState>());
2579 if (R) {
2580 Out = *R;
2581 return true;
2582 }
2583 return false;
2584 }
2585
2586 static const char *ConvertConsumedStateToStr(ConsumedState Val) {
2587 switch(Val) {
2588 case ConsumableAttr::Unknown: return "unknown";
2589 case ConsumableAttr::Consumed: return "consumed";
2590 case ConsumableAttr::Unconsumed: return "unconsumed";
2591 }
2592 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 2592)
;
2593 }
2594
2595
2596 static bool classof(const Attr *A) { return A->getKind() == attr::Consumable; }
2597};
2598
2599class ConsumableAutoCastAttr : public InheritableAttr {
2600public:
2601 static ConsumableAutoCastAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2602 auto *A = new (Ctx) ConsumableAutoCastAttr(Loc, Ctx, 0);
2603 A->setImplicit(true);
2604 return A;
2605 }
2606
2607 ConsumableAutoCastAttr(SourceRange R, ASTContext &Ctx
2608 , unsigned SI
2609 )
2610 : InheritableAttr(attr::ConsumableAutoCast, R, SI, false, false)
2611 {
2612 }
2613
2614 ConsumableAutoCastAttr *clone(ASTContext &C) const;
2615 void printPretty(raw_ostream &OS,
2616 const PrintingPolicy &Policy) const;
2617 const char *getSpelling() const;
2618
2619
2620 static bool classof(const Attr *A) { return A->getKind() == attr::ConsumableAutoCast; }
2621};
2622
2623class ConsumableSetOnReadAttr : public InheritableAttr {
2624public:
2625 static ConsumableSetOnReadAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2626 auto *A = new (Ctx) ConsumableSetOnReadAttr(Loc, Ctx, 0);
2627 A->setImplicit(true);
2628 return A;
2629 }
2630
2631 ConsumableSetOnReadAttr(SourceRange R, ASTContext &Ctx
2632 , unsigned SI
2633 )
2634 : InheritableAttr(attr::ConsumableSetOnRead, R, SI, false, false)
2635 {
2636 }
2637
2638 ConsumableSetOnReadAttr *clone(ASTContext &C) const;
2639 void printPretty(raw_ostream &OS,
2640 const PrintingPolicy &Policy) const;
2641 const char *getSpelling() const;
2642
2643
2644 static bool classof(const Attr *A) { return A->getKind() == attr::ConsumableSetOnRead; }
2645};
2646
2647class ConvergentAttr : public InheritableAttr {
2648public:
2649 static ConvergentAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2650 auto *A = new (Ctx) ConvergentAttr(Loc, Ctx, 0);
2651 A->setImplicit(true);
2652 return A;
2653 }
2654
2655 ConvergentAttr(SourceRange R, ASTContext &Ctx
2656 , unsigned SI
2657 )
2658 : InheritableAttr(attr::Convergent, R, SI, false, false)
2659 {
2660 }
2661
2662 ConvergentAttr *clone(ASTContext &C) const;
2663 void printPretty(raw_ostream &OS,
2664 const PrintingPolicy &Policy) const;
2665 const char *getSpelling() const;
2666
2667
2668 static bool classof(const Attr *A) { return A->getKind() == attr::Convergent; }
2669};
2670
2671class DLLExportAttr : public InheritableAttr {
2672public:
2673 static DLLExportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2674 auto *A = new (Ctx) DLLExportAttr(Loc, Ctx, 0);
2675 A->setImplicit(true);
2676 return A;
2677 }
2678
2679 DLLExportAttr(SourceRange R, ASTContext &Ctx
2680 , unsigned SI
2681 )
2682 : InheritableAttr(attr::DLLExport, R, SI, false, false)
2683 {
2684 }
2685
2686 DLLExportAttr *clone(ASTContext &C) const;
2687 void printPretty(raw_ostream &OS,
2688 const PrintingPolicy &Policy) const;
2689 const char *getSpelling() const;
2690
2691
2692 static bool classof(const Attr *A) { return A->getKind() == attr::DLLExport; }
2693};
2694
2695class DLLExportStaticLocalAttr : public InheritableAttr {
2696public:
2697 static DLLExportStaticLocalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2698 auto *A = new (Ctx) DLLExportStaticLocalAttr(Loc, Ctx, 0);
2699 A->setImplicit(true);
2700 return A;
2701 }
2702
2703 DLLExportStaticLocalAttr(SourceRange R, ASTContext &Ctx
2704 , unsigned SI
2705 )
2706 : InheritableAttr(attr::DLLExportStaticLocal, R, SI, false, false)
2707 {
2708 }
2709
2710 DLLExportStaticLocalAttr *clone(ASTContext &C) const;
2711 void printPretty(raw_ostream &OS,
2712 const PrintingPolicy &Policy) const;
2713 const char *getSpelling() const;
2714
2715
2716 static bool classof(const Attr *A) { return A->getKind() == attr::DLLExportStaticLocal; }
2717};
2718
2719class DLLImportAttr : public InheritableAttr {
2720public:
2721 static DLLImportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2722 auto *A = new (Ctx) DLLImportAttr(Loc, Ctx, 0);
2723 A->setImplicit(true);
2724 return A;
2725 }
2726
2727 DLLImportAttr(SourceRange R, ASTContext &Ctx
2728 , unsigned SI
2729 )
2730 : InheritableAttr(attr::DLLImport, R, SI, false, false)
2731 {
2732 }
2733
2734 DLLImportAttr *clone(ASTContext &C) const;
2735 void printPretty(raw_ostream &OS,
2736 const PrintingPolicy &Policy) const;
2737 const char *getSpelling() const;
2738
2739private:
2740 bool PropagatedToBaseTemplate = false;
2741
2742public:
2743 void setPropagatedToBaseTemplate() { PropagatedToBaseTemplate = true; }
2744 bool wasPropagatedToBaseTemplate() { return PropagatedToBaseTemplate; }
2745
2746
2747 static bool classof(const Attr *A) { return A->getKind() == attr::DLLImport; }
2748};
2749
2750class DLLImportStaticLocalAttr : public InheritableAttr {
2751public:
2752 static DLLImportStaticLocalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2753 auto *A = new (Ctx) DLLImportStaticLocalAttr(Loc, Ctx, 0);
2754 A->setImplicit(true);
2755 return A;
2756 }
2757
2758 DLLImportStaticLocalAttr(SourceRange R, ASTContext &Ctx
2759 , unsigned SI
2760 )
2761 : InheritableAttr(attr::DLLImportStaticLocal, R, SI, false, false)
2762 {
2763 }
2764
2765 DLLImportStaticLocalAttr *clone(ASTContext &C) const;
2766 void printPretty(raw_ostream &OS,
2767 const PrintingPolicy &Policy) const;
2768 const char *getSpelling() const;
2769
2770
2771 static bool classof(const Attr *A) { return A->getKind() == attr::DLLImportStaticLocal; }
2772};
2773
2774class DeprecatedAttr : public InheritableAttr {
2775unsigned messageLength;
2776char *message;
2777
2778unsigned replacementLength;
2779char *replacement;
2780
2781public:
2782 static DeprecatedAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Message, llvm::StringRef Replacement, SourceRange Loc = SourceRange()) {
2783 auto *A = new (Ctx) DeprecatedAttr(Loc, Ctx, Message, Replacement, 0);
2784 A->setImplicit(true);
2785 return A;
2786 }
2787
2788 DeprecatedAttr(SourceRange R, ASTContext &Ctx
2789 , llvm::StringRef Message
2790 , llvm::StringRef Replacement
2791 , unsigned SI
2792 )
2793 : InheritableAttr(attr::Deprecated, R, SI, false, false)
2794 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2795 , replacementLength(Replacement.size()),replacement(new (Ctx, 1) char[replacementLength])
2796 {
2797 if (!Message.empty())
2798 std::memcpy(message, Message.data(), messageLength);
2799 if (!Replacement.empty())
2800 std::memcpy(replacement, Replacement.data(), replacementLength);
2801 }
2802
2803 DeprecatedAttr(SourceRange R, ASTContext &Ctx
2804 , unsigned SI
2805 )
2806 : InheritableAttr(attr::Deprecated, R, SI, false, false)
2807 , messageLength(0),message(nullptr)
2808 , replacementLength(0),replacement(nullptr)
2809 {
2810 }
2811
2812 DeprecatedAttr *clone(ASTContext &C) const;
2813 void printPretty(raw_ostream &OS,
2814 const PrintingPolicy &Policy) const;
2815 const char *getSpelling() const;
2816 llvm::StringRef getMessage() const {
2817 return llvm::StringRef(message, messageLength);
2818 }
2819 unsigned getMessageLength() const {
2820 return messageLength;
2821 }
2822 void setMessage(ASTContext &C, llvm::StringRef S) {
2823 messageLength = S.size();
2824 this->message = new (C, 1) char [messageLength];
2825 if (!S.empty())
2826 std::memcpy(this->message, S.data(), messageLength);
2827 }
2828
2829 llvm::StringRef getReplacement() const {
2830 return llvm::StringRef(replacement, replacementLength);
2831 }
2832 unsigned getReplacementLength() const {
2833 return replacementLength;
2834 }
2835 void setReplacement(ASTContext &C, llvm::StringRef S) {
2836 replacementLength = S.size();
2837 this->replacement = new (C, 1) char [replacementLength];
2838 if (!S.empty())
2839 std::memcpy(this->replacement, S.data(), replacementLength);
2840 }
2841
2842
2843
2844 static bool classof(const Attr *A) { return A->getKind() == attr::Deprecated; }
2845};
2846
2847class DestructorAttr : public InheritableAttr {
2848int priority;
2849
2850public:
2851 static DestructorAttr *CreateImplicit(ASTContext &Ctx, int Priority, SourceRange Loc = SourceRange()) {
2852 auto *A = new (Ctx) DestructorAttr(Loc, Ctx, Priority, 0);
2853 A->setImplicit(true);
2854 return A;
2855 }
2856
2857 DestructorAttr(SourceRange R, ASTContext &Ctx
2858 , int Priority
2859 , unsigned SI
2860 )
2861 : InheritableAttr(attr::Destructor, R, SI, false, false)
2862 , priority(Priority)
2863 {
2864 }
2865
2866 DestructorAttr(SourceRange R, ASTContext &Ctx
2867 , unsigned SI
2868 )
2869 : InheritableAttr(attr::Destructor, R, SI, false, false)
2870 , priority()
2871 {
2872 }
2873
2874 DestructorAttr *clone(ASTContext &C) const;
2875 void printPretty(raw_ostream &OS,
2876 const PrintingPolicy &Policy) const;
2877 const char *getSpelling() const;
2878 int getPriority() const {
2879 return priority;
2880 }
2881
2882 static const int DefaultPriority = 65535;
2883
2884
2885
2886 static bool classof(const Attr *A) { return A->getKind() == attr::Destructor; }
2887};
2888
2889class DiagnoseIfAttr : public InheritableAttr {
2890Expr * cond;
2891
2892unsigned messageLength;
2893char *message;
2894
2895public:
2896 enum DiagnosticType {
2897 DT_Error,
2898 DT_Warning
2899 };
2900private:
2901 DiagnosticType diagnosticType;
2902
2903bool argDependent;
2904
2905NamedDecl * parent;
2906
2907public:
2908 static DiagnoseIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, DiagnosticType DiagnosticType, bool ArgDependent, NamedDecl * Parent, SourceRange Loc = SourceRange()) {
2909 auto *A = new (Ctx) DiagnoseIfAttr(Loc, Ctx, Cond, Message, DiagnosticType, ArgDependent, Parent, 0);
2910 A->setImplicit(true);
2911 return A;
2912 }
2913
2914 static DiagnoseIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, DiagnosticType DiagnosticType, SourceRange Loc = SourceRange()) {
2915 auto *A = new (Ctx) DiagnoseIfAttr(Loc, Ctx, Cond, Message, DiagnosticType, 0);
2916 A->setImplicit(true);
2917 return A;
2918 }
2919
2920 DiagnoseIfAttr(SourceRange R, ASTContext &Ctx
2921 , Expr * Cond
2922 , llvm::StringRef Message
2923 , DiagnosticType DiagnosticType
2924 , bool ArgDependent
2925 , NamedDecl * Parent
2926 , unsigned SI
2927 )
2928 : InheritableAttr(attr::DiagnoseIf, R, SI, true, true)
2929 , cond(Cond)
2930 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2931 , diagnosticType(DiagnosticType)
2932 , argDependent(ArgDependent)
2933 , parent(Parent)
2934 {
2935 if (!Message.empty())
2936 std::memcpy(message, Message.data(), messageLength);
2937 }
2938
2939 DiagnoseIfAttr(SourceRange R, ASTContext &Ctx
2940 , Expr * Cond
2941 , llvm::StringRef Message
2942 , DiagnosticType DiagnosticType
2943 , unsigned SI
2944 )
2945 : InheritableAttr(attr::DiagnoseIf, R, SI, true, true)
2946 , cond(Cond)
2947 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2948 , diagnosticType(DiagnosticType)
2949 , argDependent()
2950 , parent()
2951 {
2952 if (!Message.empty())
2953 std::memcpy(message, Message.data(), messageLength);
2954 }
2955
2956 DiagnoseIfAttr *clone(ASTContext &C) const;
2957 void printPretty(raw_ostream &OS,
2958 const PrintingPolicy &Policy) const;
2959 const char *getSpelling() const;
2960 Expr * getCond() const {
2961 return cond;
2962 }
2963
2964 llvm::StringRef getMessage() const {
2965 return llvm::StringRef(message, messageLength);
2966 }
2967 unsigned getMessageLength() const {
2968 return messageLength;
2969 }
2970 void setMessage(ASTContext &C, llvm::StringRef S) {
2971 messageLength = S.size();
2972 this->message = new (C, 1) char [messageLength];
2973 if (!S.empty())
2974 std::memcpy(this->message, S.data(), messageLength);
2975 }
2976
2977 DiagnosticType getDiagnosticType() const {
2978 return diagnosticType;
2979 }
2980
2981 static bool ConvertStrToDiagnosticType(StringRef Val, DiagnosticType &Out) {
2982 Optional<DiagnosticType> R = llvm::StringSwitch<Optional<DiagnosticType>>(Val)
2983 .Case("error", DiagnoseIfAttr::DT_Error)
2984 .Case("warning", DiagnoseIfAttr::DT_Warning)
2985 .Default(Optional<DiagnosticType>());
2986 if (R) {
2987 Out = *R;
2988 return true;
2989 }
2990 return false;
2991 }
2992
2993 static const char *ConvertDiagnosticTypeToStr(DiagnosticType Val) {
2994 switch(Val) {
2995 case DiagnoseIfAttr::DT_Error: return "error";
2996 case DiagnoseIfAttr::DT_Warning: return "warning";
2997 }
2998 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 2998)
;
2999 }
3000 bool getArgDependent() const {
3001 return argDependent;
3002 }
3003
3004 NamedDecl * getParent() const {
3005 return parent;
3006 }
3007
3008
3009 bool isError() const { return diagnosticType == DT_Error; }
3010 bool isWarning() const { return diagnosticType == DT_Warning; }
3011
3012
3013 static bool classof(const Attr *A) { return A->getKind() == attr::DiagnoseIf; }
3014};
3015
3016class DisableTailCallsAttr : public InheritableAttr {
3017public:
3018 static DisableTailCallsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3019 auto *A = new (Ctx) DisableTailCallsAttr(Loc, Ctx, 0);
3020 A->setImplicit(true);
3021 return A;
3022 }
3023
3024 DisableTailCallsAttr(SourceRange R, ASTContext &Ctx
3025 , unsigned SI
3026 )
3027 : InheritableAttr(attr::DisableTailCalls, R, SI, false, false)
3028 {
3029 }
3030
3031 DisableTailCallsAttr *clone(ASTContext &C) const;
3032 void printPretty(raw_ostream &OS,
3033 const PrintingPolicy &Policy) const;
3034 const char *getSpelling() const;
3035
3036
3037 static bool classof(const Attr *A) { return A->getKind() == attr::DisableTailCalls; }
3038};
3039
3040class EmptyBasesAttr : public InheritableAttr {
3041public:
3042 static EmptyBasesAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3043 auto *A = new (Ctx) EmptyBasesAttr(Loc, Ctx, 0);
3044 A->setImplicit(true);
3045 return A;
3046 }
3047
3048 EmptyBasesAttr(SourceRange R, ASTContext &Ctx
3049 , unsigned SI
3050 )
3051 : InheritableAttr(attr::EmptyBases, R, SI, false, false)
3052 {
3053 }
3054
3055 EmptyBasesAttr *clone(ASTContext &C) const;
3056 void printPretty(raw_ostream &OS,
3057 const PrintingPolicy &Policy) const;
3058 const char *getSpelling() const;
3059
3060
3061 static bool classof(const Attr *A) { return A->getKind() == attr::EmptyBases; }
3062};
3063
3064class EnableIfAttr : public InheritableAttr {
3065Expr * cond;
3066
3067unsigned messageLength;
3068char *message;
3069
3070public:
3071 static EnableIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, SourceRange Loc = SourceRange()) {
3072 auto *A = new (Ctx) EnableIfAttr(Loc, Ctx, Cond, Message, 0);
3073 A->setImplicit(true);
3074 return A;
3075 }
3076
3077 EnableIfAttr(SourceRange R, ASTContext &Ctx
3078 , Expr * Cond
3079 , llvm::StringRef Message
3080 , unsigned SI
3081 )
3082 : InheritableAttr(attr::EnableIf, R, SI, false, false)
3083 , cond(Cond)
3084 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
3085 {
3086 if (!Message.empty())
3087 std::memcpy(message, Message.data(), messageLength);
3088 }
3089
3090 EnableIfAttr *clone(ASTContext &C) const;
3091 void printPretty(raw_ostream &OS,
3092 const PrintingPolicy &Policy) const;
3093 const char *getSpelling() const;
3094 Expr * getCond() const {
3095 return cond;
3096 }
3097
3098 llvm::StringRef getMessage() const {
3099 return llvm::StringRef(message, messageLength);
3100 }
3101 unsigned getMessageLength() const {
3102 return messageLength;
3103 }
3104 void setMessage(ASTContext &C, llvm::StringRef S) {
3105 messageLength = S.size();
3106 this->message = new (C, 1) char [messageLength];
3107 if (!S.empty())
3108 std::memcpy(this->message, S.data(), messageLength);
3109 }
3110
3111
3112
3113 static bool classof(const Attr *A) { return A->getKind() == attr::EnableIf; }
3114};
3115
3116class EnumExtensibilityAttr : public InheritableAttr {
3117public:
3118 enum Kind {
3119 Closed,
3120 Open
3121 };
3122private:
3123 Kind extensibility;
3124
3125public:
3126 static EnumExtensibilityAttr *CreateImplicit(ASTContext &Ctx, Kind Extensibility, SourceRange Loc = SourceRange()) {
3127 auto *A = new (Ctx) EnumExtensibilityAttr(Loc, Ctx, Extensibility, 0);
3128 A->setImplicit(true);
3129 return A;
3130 }
3131
3132 EnumExtensibilityAttr(SourceRange R, ASTContext &Ctx
3133 , Kind Extensibility
3134 , unsigned SI
3135 )
3136 : InheritableAttr(attr::EnumExtensibility, R, SI, false, false)
3137 , extensibility(Extensibility)
3138 {
3139 }
3140
3141 EnumExtensibilityAttr *clone(ASTContext &C) const;
3142 void printPretty(raw_ostream &OS,
3143 const PrintingPolicy &Policy) const;
3144 const char *getSpelling() const;
3145 Kind getExtensibility() const {
3146 return extensibility;
3147 }
3148
3149 static bool ConvertStrToKind(StringRef Val, Kind &Out) {
3150 Optional<Kind> R = llvm::StringSwitch<Optional<Kind>>(Val)
3151 .Case("closed", EnumExtensibilityAttr::Closed)
3152 .Case("open", EnumExtensibilityAttr::Open)
3153 .Default(Optional<Kind>());
3154 if (R) {
3155 Out = *R;
3156 return true;
3157 }
3158 return false;
3159 }
3160
3161 static const char *ConvertKindToStr(Kind Val) {
3162 switch(Val) {
3163 case EnumExtensibilityAttr::Closed: return "closed";
3164 case EnumExtensibilityAttr::Open: return "open";
3165 }
3166 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 3166)
;
3167 }
3168
3169
3170 static bool classof(const Attr *A) { return A->getKind() == attr::EnumExtensibility; }
3171};
3172
3173class ExcludeFromExplicitInstantiationAttr : public InheritableAttr {
3174public:
3175 static ExcludeFromExplicitInstantiationAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3176 auto *A = new (Ctx) ExcludeFromExplicitInstantiationAttr(Loc, Ctx, 0);
3177 A->setImplicit(true);
3178 return A;
3179 }
3180
3181 ExcludeFromExplicitInstantiationAttr(SourceRange R, ASTContext &Ctx
3182 , unsigned SI
3183 )
3184 : InheritableAttr(attr::ExcludeFromExplicitInstantiation, R, SI, false, false)
3185 {
3186 }
3187
3188 ExcludeFromExplicitInstantiationAttr *clone(ASTContext &C) const;
3189 void printPretty(raw_ostream &OS,
3190 const PrintingPolicy &Policy) const;
3191 const char *getSpelling() const;
3192
3193
3194 static bool classof(const Attr *A) { return A->getKind() == attr::ExcludeFromExplicitInstantiation; }
3195};
3196
3197class ExclusiveTrylockFunctionAttr : public InheritableAttr {
3198Expr * successValue;
3199
3200 unsigned args_Size;
3201 Expr * *args_;
3202
3203public:
3204 static ExclusiveTrylockFunctionAttr *CreateImplicit(ASTContext &Ctx, Expr * SuccessValue, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
3205 auto *A = new (Ctx) ExclusiveTrylockFunctionAttr(Loc, Ctx, SuccessValue, Args, ArgsSize, 0);
3206 A->setImplicit(true);
3207 return A;
3208 }
3209
3210 ExclusiveTrylockFunctionAttr(SourceRange R, ASTContext &Ctx
3211 , Expr * SuccessValue
3212 , Expr * *Args, unsigned ArgsSize
3213 , unsigned SI
3214 )
3215 : InheritableAttr(attr::ExclusiveTrylockFunction, R, SI, true, true)
3216 , successValue(SuccessValue)
3217 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
3218 {
3219 std::copy(Args, Args + args_Size, args_);
3220 }
3221
3222 ExclusiveTrylockFunctionAttr(SourceRange R, ASTContext &Ctx
3223 , Expr * SuccessValue
3224 , unsigned SI
3225 )
3226 : InheritableAttr(attr::ExclusiveTrylockFunction, R, SI, true, true)
3227 , successValue(SuccessValue)
3228 , args_Size(0), args_(nullptr)
3229 {
3230 }
3231
3232 ExclusiveTrylockFunctionAttr *clone(ASTContext &C) const;
3233 void printPretty(raw_ostream &OS,
3234 const PrintingPolicy &Policy) const;
3235 const char *getSpelling() const;
3236 Expr * getSuccessValue() const {
3237 return successValue;
3238 }
3239
3240 typedef Expr ** args_iterator;
3241 args_iterator args_begin() const { return args_; }
3242 args_iterator args_end() const { return args_ + args_Size; }
3243 unsigned args_size() const { return args_Size; }
3244 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
3245
3246
3247
3248
3249 static bool classof(const Attr *A) { return A->getKind() == attr::ExclusiveTrylockFunction; }
3250};
3251
3252class ExternalSourceSymbolAttr : public InheritableAttr {
3253unsigned languageLength;
3254char *language;
3255
3256unsigned definedInLength;
3257char *definedIn;
3258
3259bool generatedDeclaration;
3260
3261public:
3262 static ExternalSourceSymbolAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Language, llvm::StringRef DefinedIn, bool GeneratedDeclaration, SourceRange Loc = SourceRange()) {
3263 auto *A = new (Ctx) ExternalSourceSymbolAttr(Loc, Ctx, Language, DefinedIn, GeneratedDeclaration, 0);
3264 A->setImplicit(true);
3265 return A;
3266 }
3267
3268 ExternalSourceSymbolAttr(SourceRange R, ASTContext &Ctx
3269 , llvm::StringRef Language
3270 , llvm::StringRef DefinedIn
3271 , bool GeneratedDeclaration
3272 , unsigned SI
3273 )
3274 : InheritableAttr(attr::ExternalSourceSymbol, R, SI, false, false)
3275 , languageLength(Language.size()),language(new (Ctx, 1) char[languageLength])
3276 , definedInLength(DefinedIn.size()),definedIn(new (Ctx, 1) char[definedInLength])
3277 , generatedDeclaration(GeneratedDeclaration)
3278 {
3279 if (!Language.empty())
3280 std::memcpy(language, Language.data(), languageLength);
3281 if (!DefinedIn.empty())
3282 std::memcpy(definedIn, DefinedIn.data(), definedInLength);
3283 }
3284
3285 ExternalSourceSymbolAttr(SourceRange R, ASTContext &Ctx
3286 , unsigned SI
3287 )
3288 : InheritableAttr(attr::ExternalSourceSymbol, R, SI, false, false)
3289 , languageLength(0),language(nullptr)
3290 , definedInLength(0),definedIn(nullptr)
3291 , generatedDeclaration()
3292 {
3293 }
3294
3295 ExternalSourceSymbolAttr *clone(ASTContext &C) const;
3296 void printPretty(raw_ostream &OS,
3297 const PrintingPolicy &Policy) const;
3298 const char *getSpelling() const;
3299 llvm::StringRef getLanguage() const {
3300 return llvm::StringRef(language, languageLength);
3301 }
3302 unsigned getLanguageLength() const {
3303 return languageLength;
3304 }
3305 void setLanguage(ASTContext &C, llvm::StringRef S) {
3306 languageLength = S.size();
3307 this->language = new (C, 1) char [languageLength];
3308 if (!S.empty())
3309 std::memcpy(this->language, S.data(), languageLength);
3310 }
3311
3312 llvm::StringRef getDefinedIn() const {
3313 return llvm::StringRef(definedIn, definedInLength);
3314 }
3315 unsigned getDefinedInLength() const {
3316 return definedInLength;
3317 }
3318 void setDefinedIn(ASTContext &C, llvm::StringRef S) {
3319 definedInLength = S.size();
3320 this->definedIn = new (C, 1) char [definedInLength];
3321 if (!S.empty())
3322 std::memcpy(this->definedIn, S.data(), definedInLength);
3323 }
3324
3325 bool getGeneratedDeclaration() const {
3326 return generatedDeclaration;
3327 }
3328
3329
3330
3331 static bool classof(const Attr *A) { return A->getKind() == attr::ExternalSourceSymbol; }
3332};
3333
3334class FallThroughAttr : public StmtAttr {
3335public:
3336 static FallThroughAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3337 auto *A = new (Ctx) FallThroughAttr(Loc, Ctx, 0);
3338 A->setImplicit(true);
3339 return A;
3340 }
3341
3342 FallThroughAttr(SourceRange R, ASTContext &Ctx
3343 , unsigned SI
3344 )
3345 : StmtAttr(attr::FallThrough, R, SI, false)
3346 {
3347 }
3348
3349 FallThroughAttr *clone(ASTContext &C) const;
3350 void printPretty(raw_ostream &OS,
3351 const PrintingPolicy &Policy) const;
3352 const char *getSpelling() const;
3353
3354
3355 static bool classof(const Attr *A) { return A->getKind() == attr::FallThrough; }
3356};
3357
3358class FastCallAttr : public InheritableAttr {
3359public:
3360 static FastCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3361 auto *A = new (Ctx) FastCallAttr(Loc, Ctx, 0);
3362 A->setImplicit(true);
3363 return A;
3364 }
3365
3366 FastCallAttr(SourceRange R, ASTContext &Ctx
3367 , unsigned SI
3368 )
3369 : InheritableAttr(attr::FastCall, R, SI, false, false)
3370 {
3371 }
3372
3373 FastCallAttr *clone(ASTContext &C) const;
3374 void printPretty(raw_ostream &OS,
3375 const PrintingPolicy &Policy) const;
3376 const char *getSpelling() const;
3377
3378
3379 static bool classof(const Attr *A) { return A->getKind() == attr::FastCall; }
3380};
3381
3382class FinalAttr : public InheritableAttr {
3383public:
3384 enum Spelling {
3385 Keyword_final = 0,
3386 Keyword_sealed = 1
3387 };
3388
3389 static FinalAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
3390 auto *A = new (Ctx) FinalAttr(Loc, Ctx, S);
3391 A->setImplicit(true);
3392 return A;
3393 }
3394
3395 FinalAttr(SourceRange R, ASTContext &Ctx
3396 , unsigned SI
3397 )
3398 : InheritableAttr(attr::Final, R, SI, false, false)
3399 {
3400 }
3401
3402 FinalAttr *clone(ASTContext &C) const;
3403 void printPretty(raw_ostream &OS,
3404 const PrintingPolicy &Policy) const;
3405 const char *getSpelling() const;
3406 Spelling getSemanticSpelling() const {
3407 switch (SpellingListIndex) {
3408 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-9~svn362543/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 3408)
;
3409 case 0: return Keyword_final;
3410 case 1: return Keyword_sealed;
3411 }
3412 }
3413 bool isSpelledAsSealed() const { return SpellingListIndex == 1; }
3414
3415
3416 static bool classof(const Attr *A) { return A->getKind() == attr::Final; }
3417};
3418
3419class FlagEnumAttr : public InheritableAttr {
3420public:
3421 static FlagEnumAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3422 auto *A = new (Ctx) FlagEnumAttr(Loc, Ctx, 0);
3423 A->setImplicit(true);
3424 return A;
3425 }
3426
3427 FlagEnumAttr(SourceRange R, ASTContext &Ctx
3428 , unsigned SI
3429 )
3430 : InheritableAttr(attr::FlagEnum, R, SI, false, false)
3431 {
3432 }
3433
3434 FlagEnumAttr *clone(ASTContext &C) const;
3435 void printPretty(raw_ostream &OS,
3436 const PrintingPolicy &Policy) const;
3437 const char *getSpelling() const;
3438
3439
3440 static bool classof(const Attr *A) { return A->getKind() == attr::FlagEnum; }
3441};
3442
3443class FlattenAttr : public InheritableAttr {
3444public:
3445 static FlattenAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3446 auto *A = new (Ctx) FlattenAttr(Loc, Ctx, 0);
3447 A->setImplicit(true);
3448 return A;
3449 }
3450
3451 FlattenAttr(SourceRange R, ASTContext &Ctx
3452 , unsigned SI
3453 )
3454 : InheritableAttr(attr::Flatten, R, SI, false, false)
3455 {
3456 }
3457
3458 FlattenAttr *clone(ASTContext &C) const;
3459 void printPretty(raw_ostream &OS,
3460 const PrintingPolicy &Policy) const;
3461 const char *getSpelling() const;
3462
3463
3464 static bool classof(const Attr *A) { return A->getKind() == attr::Flatten; }
3465};
3466
3467class FormatAttr : public InheritableAttr {
3468IdentifierInfo * type;
3469
3470int formatIdx;
3471
3472int firstArg;
3473
3474public:
3475 static FormatAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Type, int FormatIdx, int FirstArg, SourceRange Loc = SourceRange()) {
3476 auto *A = new (Ctx) FormatAttr(Loc, Ctx, Type, FormatIdx, FirstArg, 0);
3477 A->setImplicit(true);
3478 return A;
3479 }
3480
3481 FormatAttr(SourceRange R, ASTContext &Ctx
3482 , IdentifierInfo * Type
3483 , int FormatIdx
3484 , int FirstArg
3485 , unsigned SI
3486 )
3487 : InheritableAttr(attr::Format, R, SI, false, false)
3488 , type(Type)
3489 , formatIdx(FormatIdx)
3490 , firstArg(FirstArg)
3491 {
3492 }
3493
3494 FormatAttr *clone(ASTContext &C) const;
3495 void printPretty(raw_ostream &OS,
3496 const PrintingPolicy &Policy) const;
3497 const char *getSpelling() const;
3498 IdentifierInfo * getType() const {
3499 return type;
3500 }
3501
3502 int getFormatIdx() const {
3503 return formatIdx;
3504 }
3505
3506 int getFirstArg() const {
3507 return firstArg;
3508 }
3509
3510
3511
3512 static bool classof(const Attr *A) { return A->getKind() == attr::Format; }
3513};
3514
3515class FormatArgAttr : public InheritableAttr {
3516ParamIdx formatIdx;
3517
3518public:
3519 static FormatArgAttr *CreateImplicit(ASTContext &Ctx, ParamIdx FormatIdx, SourceRange Loc = SourceRange()) {
3520 auto *A = new (Ctx) FormatArgAttr(Loc, Ctx, FormatIdx, 0);
3521 A->setImplicit(true);
3522 return A;
3523 }
3524
3525 FormatArgAttr(SourceRange R, ASTContext &Ctx
3526 , ParamIdx FormatIdx
3527 , unsigned SI
3528 )
3529 : InheritableAttr(attr::FormatArg, R, SI, false, false)
3530 , formatIdx(FormatIdx)
3531 {
3532 }
3533
3534 FormatArgAttr *clone(ASTContext &C) const;
3535 void printPretty(raw_ostream &OS,
3536 const PrintingPolicy &Policy) const;
3537 const char *getSpelling() const;
3538 ParamIdx getFormatIdx() const {
3539 return formatIdx;
3540 }
3541
3542
3543
3544 static bool classof(const Attr *A) { return A->getKind() == attr::FormatArg; }
3545};
3546
3547class GNUInlineAttr : public InheritableAttr {
3548public:
3549 static GNUInlineAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3550 auto *A = new (Ctx) GNUInlineAttr(Loc, Ctx, 0);
3551 A->setImplicit(true);
3552 return A;
3553 }
3554
3555 GNUInlineAttr(SourceRange R, ASTContext &Ctx
3556 , unsigned SI
3557 )
3558 : InheritableAttr(attr::GNUInline, R, SI, false, false)
3559 {
3560 }
3561
3562 GNUInlineAttr *clone(ASTContext &C) const;
3563 void printPretty(raw_ostream &OS,
3564 const PrintingPolicy &Policy) const;
3565 const char *getSpelling() const;
3566
3567
3568 static bool classof(const Attr *A) { return A->getKind() == attr::GNUInline; }
3569};
3570
3571class GuardedByAttr : public InheritableAttr {
3572Expr * arg;
3573
3574public:
3575 static GuardedByAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) {
3576 auto *A = new (Ctx) GuardedByAttr(Loc, Ctx, Arg, 0);
3577 A->setImplicit(true);
3578 return A;
3579 }
3580
3581 GuardedByAttr(SourceRange R, ASTContext &Ctx
3582 , Expr * Arg
3583 , unsigned SI
3584 )
3585 : InheritableAttr(attr::GuardedBy, R, SI, true, true)
3586 , arg(Arg)
3587 {
3588 }
3589
3590 GuardedByAttr *clone(ASTContext &C) const;
3591 void printPretty(raw_ostream &OS,
3592 const PrintingPolicy &Policy) const;
3593 const char *getSpelling() const;
3594 Expr * getArg() const {
3595 return arg;
3596 }
3597
3598
3599
3600 static bool classof(const Attr *A) { return A->getKind() == attr::GuardedBy; }
3601};
3602
3603class GuardedVarAttr : public InheritableAttr {
3604public:
3605 static GuardedVarAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3606 auto *A = new (Ctx) GuardedVarAttr(Loc, Ctx, 0);
3607 A->setImplicit(true);
3608 return A;
3609 }
3610
3611 GuardedVarAttr(SourceRange R, ASTContext &Ctx
3612 , unsigned SI
3613 )
3614 : InheritableAttr(attr::GuardedVar, R, SI, false, false)
3615 {
3616 }
3617
3618 GuardedVarAttr *clone(ASTContext &C) const;
3619 void printPretty(raw_ostream &OS,
3620 const PrintingPolicy &Policy) const;
3621 const char *getSpelling() const;
3622
3623
3624 static bool classof(const Attr *A) { return A->getKind() == attr::GuardedVar; }
3625};
3626
3627class HotAttr : public InheritableAttr {
3628public:
3629 static HotAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3630 auto *A = new (Ctx) HotAttr(Loc, Ctx, 0);
3631 A->setImplicit(true);
3632 return A;
3633 }
3634
3635 HotAttr(SourceRange R, ASTContext &Ctx
3636 , unsigned SI
3637 )
3638 : InheritableAttr(attr::Hot, R, SI, false, false)
3639 {
3640 }
3641
3642 HotAttr *clone(ASTContext &C) const;
3643 void printPretty(raw_ostream &OS,
3644 const PrintingPolicy &Policy) const;
3645 const char *getSpelling() const;
3646
3647
3648 static bool classof(const Attr *A) { return A->getKind() == attr::Hot; }
3649};
3650
3651class IBActionAttr : public InheritableAttr {
3652public:
3653 static IBActionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3654 auto *A = new (Ctx) IBActionAttr(Loc, Ctx, 0);
3655 A->setImplicit(true);
3656 return A;
3657 }
3658
3659 IBActionAttr(SourceRange R, ASTContext &Ctx
3660 , unsigned SI
3661 )
3662 : InheritableAttr(attr::IBAction, R, SI, false, false)
3663 {
3664 }
3665
3666 IBActionAttr *clone(ASTContext &C) const;
3667 void printPretty(raw_ostream &OS,
3668 const PrintingPolicy &Policy) const;
3669 const char *getSpelling() const;
3670
3671
3672 static bool classof(const Attr *A) { return A->getKind() == attr::IBAction; }
3673};
3674
3675class IBOutletAttr : public InheritableAttr {
3676public:
3677 static IBOutletAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3678 auto *A = new (Ctx) IBOutletAttr(Loc, Ctx, 0);
3679 A->setImplicit(true);
3680 return A;
3681 }
3682
3683 IBOutletAttr(SourceRange R, ASTContext &Ctx
3684 , unsigned SI
3685 )
3686 : InheritableAttr(attr::IBOutlet, R, SI, false, false)
3687 {
3688 }
3689
3690 IBOutletAttr *clone(ASTContext &C) const;
3691 void printPretty(raw_ostream &OS,
3692 const PrintingPolicy &Policy) const;
3693 const char *getSpelling() const;
3694
3695
3696 static bool classof(const Attr *A) { return A->getKind() == attr::IBOutlet; }
3697};
3698
3699class IBOutletCollectionAttr : public InheritableAttr {
3700TypeSourceInfo * interface_;
3701
3702public:
3703 static IBOutletCollectionAttr *CreateImplicit(ASTContext &Ctx, TypeSourceInfo * Interface, SourceRange Loc = SourceRange()) {
3704 auto *A = new (Ctx) IBOutletCollectionAttr(Loc, Ctx, Interface, 0);
3705 A->setImplicit(true);
3706 return A;
3707 }
3708
3709 IBOutletCollectionAttr(SourceRange R, ASTContext &Ctx
3710 , TypeSourceInfo * Interface
3711 , unsigned SI
3712 )
3713 : InheritableAttr(attr::IBOutletCollection, R, SI, false, false)
3714 , interface_(Interface)
3715 {
3716 }
3717
3718 IBOutletCollectionAttr(SourceRange R, ASTContext &Ctx
3719 , unsigned SI
3720 )
3721 : InheritableAttr(attr::IBOutletCollection, R, SI, false, false)
3722 , interface_()
3723 {
3724 }
3725
3726 IBOutletCollectionAttr *clone(ASTContext &C) const;
3727 void printPretty(raw_ostream &OS,
3728 const PrintingPolicy &Policy) const;
3729 const char *getSpelling() const;
3730 QualType getInterface() const {
3731 return interface_->getType();
3732 } TypeSourceInfo * getInterfaceLoc() const {
3733 return interface_;
3734 }
3735
3736
3737
3738 static bool classof(const Attr *A) { return A->getKind() == attr::IBOutletCollection; }
3739};
3740
3741class IFuncAttr : public Attr {
3742unsigned resolverLength;
3743char *resolver;
3744
3745public:
3746 static IFuncAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Resolver, SourceRange Loc = SourceRange()) {
3747 auto *A = new (Ctx) IFuncAttr(Loc, Ctx, Resolver, 0);
3748 A->setImplicit(true);
3749 return A;
3750 }
3751
3752 IFuncAttr(SourceRange R, ASTContext &Ctx
3753 , llvm::StringRef Resolver
3754 , unsigned SI
3755 )
3756 : Attr(attr::IFunc, R, SI, false)
3757 , resolverLength(Resolver.size()),resolver(new (Ctx, 1) char[resolverLength])
3758 {
3759 if (!Resolver.empty())
3760 std::memcpy(resolver, Resolver.data(), resolverLength);
3761 }
3762
3763 IFuncAttr *clone(ASTContext &C) const;
3764 void printPretty(raw_ostream &OS,
3765 const PrintingPolicy &Policy) const;
3766 const char *getSpelling() const;
3767 llvm::StringRef getResolver() const {
3768 return llvm::StringRef(resolver, resolverLength);
3769 }
3770 unsigned getResolverLength() const {
3771 return resolverLength;
3772 }
3773 void setResolver(ASTContext &C, llvm::StringRef S) {
3774 resolverLength = S.size();
3775 this->resolver = new (C, 1) char [resolverLength];
3776 if (!S.empty())
3777 std::memcpy(this->resolver, S.data(), resolverLength);
3778 }
3779
3780
3781
3782 static bool classof(const Attr *A) { return A->getKind() == attr::IFunc; }
3783};
3784
3785class InitPriorityAttr : public InheritableAttr {
3786unsigned priority;
3787
3788public:
3789 static InitPriorityAttr *CreateImplicit(ASTContext &Ctx, unsigned Priority, SourceRange Loc = SourceRange()) {
3790 auto *A = new (Ctx) InitPriorityAttr(Loc, Ctx, Priority, 0);
3791 A->setImplicit(true);
3792 return A;
3793 }
3794
3795 InitPriorityAttr(SourceRange R, ASTContext &Ctx
3796 , unsigned Priority
3797 , unsigned SI
3798 )
3799 : InheritableAttr(attr::InitPriority, R, SI, false, false)
3800 , priority(Priority)
3801 {
3802 }
3803
3804 InitPriorityAttr *clone(ASTContext &C) const;
3805 void printPretty(raw_ostream &OS,
3806 const PrintingPolicy &Policy) const;
3807 const char *getSpelling() const;
3808 unsigned getPriority() const {
3809 return priority;
3810 }
3811
3812
3813
3814 static bool classof(const Attr *A) { return A->getKind() == attr::InitPriority; }
3815};
3816
3817class InitSegAttr : public Attr {
3818unsigned sectionLength;
3819char *section;
3820
3821public:
3822 static InitSegAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Section, SourceRange Loc = SourceRange()) {
3823 auto *A = new (Ctx) InitSegAttr(Loc, Ctx, Section, 0);
3824 A->setImplicit(true);
3825 return A;
3826 }
3827
3828 InitSegAttr(SourceRange R, ASTContext &Ctx
3829 , llvm::StringRef Section
3830 , unsigned SI
3831 )
3832 : Attr(attr::InitSeg, R, SI, false)
3833 , sectionLength(Section.size()),section(new (Ctx, 1) char[sectionLength])
3834 {
3835 if (!Section.empty())
3836 std::memcpy(section, Section.data(), sectionLength);
3837 }
3838
3839 InitSegAttr *clone(ASTContext &C) const;
3840 void printPretty(raw_ostream &OS,
3841 const PrintingPolicy &Policy) const;
3842 const char *getSpelling() const;
3843 llvm::StringRef getSection() const {
3844 return llvm::StringRef(section, sectionLength);
3845 }
3846 unsigned getSectionLength() const {
3847 return sectionLength;
3848 }
3849 void setSection(ASTContext &C, llvm::StringRef S) {
3850 sectionLength = S.size();
3851 this->section = new (C, 1) char [sectionLength];
3852 if (!S.empty())
3853 std::memcpy(this->section, S.data(), sectionLength);
3854 }
3855
3856
3857 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3858 OS << " (" << getSection() << ')';
3859 }
3860
3861
3862 static bool classof(const Attr *A) { return A->getKind() == attr::InitSeg; }
3863};
3864
3865class IntelOclBiccAttr : public InheritableAttr {
3866public:
3867 static IntelOclBiccAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3868 auto *A = new (Ctx) IntelOclBiccAttr(Loc, Ctx, 0);
3869 A->setImplicit(true);
3870 return A;
3871 }
3872
3873 IntelOclBiccAttr(SourceRange R, ASTContext &Ctx
3874 , unsigned SI
3875 )
3876 : InheritableAttr(attr::IntelOclBicc, R, SI, false, false)
3877 {
3878 }
3879
3880 IntelOclBiccAttr *clone(ASTContext &C) const;
3881 void printPretty(raw_ostream &OS,
3882 const PrintingPolicy &Policy) const;
3883 const char *getSpelling() const;
3884
3885
3886 static bool classof(const Attr *A) { return A->getKind() == attr::IntelOclBicc; }
3887};
3888
3889class InternalLinkageAttr : public InheritableAttr {
3890public:
3891 static InternalLinkageAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3892 auto *A = new (Ctx) InternalLinkageAttr(Loc, Ctx, 0);
3893 A->setImplicit(true);
3894 return A;
3895 }
3896
3897 InternalLinkageAttr(SourceRange R, ASTContext &Ctx
3898 , unsigned SI
3899 )
3900 : InheritableAttr(attr::InternalLinkage, R, SI, false, false)
3901 {
3902 }
3903
3904 InternalLinkageAttr *clone(ASTContext &C) const;
3905 void printPretty(raw_ostream &OS,
3906 const PrintingPolicy &Policy) const;
3907 const char *getSpelling() const;
3908
3909
3910 static bool classof(const Attr *A) { return A->getKind() == attr::InternalLinkage; }
3911};
3912
3913class LTOVisibilityPublicAttr : public InheritableAttr {
3914public:
3915 static LTOVisibilityPublicAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3916 auto *A = new (Ctx) LTOVisibilityPublicAttr(Loc, Ctx, 0);
3917 A->setImplicit(true);
3918 return A;
3919 }
3920
3921 LTOVisibilityPublicAttr(SourceRange R, ASTContext &Ctx
3922 , unsigned SI
3923 )
3924 : InheritableAttr(attr::LTOVisibilityPublic, R, SI, false, false)
3925 {
3926 }
3927
3928 LTOVisibilityPublicAttr *clone(ASTContext &C) const;
3929 void printPretty(raw_ostream &OS,
3930 const PrintingPolicy &Policy) const;
3931 const char *getSpelling() const;
3932
3933
3934 static bool classof(const Attr *A) { return A->getKind() == attr::LTOVisibilityPublic; }
3935};
3936
3937class LayoutVersionAttr : public InheritableAttr {
3938unsigned version;
3939
3940public:
3941 static LayoutVersionAttr *CreateImplicit(ASTContext &Ctx, unsigned Version, SourceRange Loc = SourceRange()) {
3942 auto *A = new (Ctx) LayoutVersionAttr(Loc, Ctx, Version, 0);
3943 A->setImplicit(true);
3944 return A;
3945 }
3946
3947 LayoutVersionAttr(SourceRange R, ASTContext &Ctx
3948 , unsigned Version
3949 , unsigned SI
3950 )
3951 : InheritableAttr(attr::LayoutVersion, R, SI, false, false)
3952 , version(Version)
3953 {
3954 }
3955
3956 LayoutVersionAttr *clone(ASTContext &C) const;
3957 void printPretty(raw_ostream &OS,
3958 const PrintingPolicy &Policy) const;
3959 const char *getSpelling() const;
3960 unsigned getVersion() const {
3961 return version;
3962 }
3963
3964
3965
3966 static bool classof(const Attr *A) { return A->getKind() == attr::LayoutVersion; }
3967};
3968
3969class LifetimeBoundAttr : public InheritableAttr {
3970public:
3971 static LifetimeBoundAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3972 auto *A = new (Ctx) LifetimeBoundAttr(Loc, Ctx, 0);
3973 A->setImplicit(true);
3974 return A;
3975 }
3976
3977