1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | #ifndef LLVM_CLANG_AST_DECL_H |
14 | #define LLVM_CLANG_AST_DECL_H |
15 | |
16 | #include "clang/AST/APValue.h" |
17 | #include "clang/AST/ASTContextAllocate.h" |
18 | #include "clang/AST/DeclBase.h" |
19 | #include "clang/AST/DeclarationName.h" |
20 | #include "clang/AST/ExternalASTSource.h" |
21 | #include "clang/AST/NestedNameSpecifier.h" |
22 | #include "clang/AST/Redeclarable.h" |
23 | #include "clang/AST/Type.h" |
24 | #include "clang/Basic/AddressSpaces.h" |
25 | #include "clang/Basic/Diagnostic.h" |
26 | #include "clang/Basic/IdentifierTable.h" |
27 | #include "clang/Basic/LLVM.h" |
28 | #include "clang/Basic/Linkage.h" |
29 | #include "clang/Basic/OperatorKinds.h" |
30 | #include "clang/Basic/PartialDiagnostic.h" |
31 | #include "clang/Basic/PragmaKinds.h" |
32 | #include "clang/Basic/SourceLocation.h" |
33 | #include "clang/Basic/Specifiers.h" |
34 | #include "clang/Basic/Visibility.h" |
35 | #include "llvm/ADT/APSInt.h" |
36 | #include "llvm/ADT/ArrayRef.h" |
37 | #include "llvm/ADT/Optional.h" |
38 | #include "llvm/ADT/PointerIntPair.h" |
39 | #include "llvm/ADT/PointerUnion.h" |
40 | #include "llvm/ADT/StringRef.h" |
41 | #include "llvm/ADT/iterator_range.h" |
42 | #include "llvm/Support/Casting.h" |
43 | #include "llvm/Support/Compiler.h" |
44 | #include "llvm/Support/TrailingObjects.h" |
45 | #include <cassert> |
46 | #include <cstddef> |
47 | #include <cstdint> |
48 | #include <string> |
49 | #include <utility> |
50 | |
51 | namespace clang { |
52 | |
53 | class ASTContext; |
54 | struct ASTTemplateArgumentListInfo; |
55 | class Attr; |
56 | class CompoundStmt; |
57 | class DependentFunctionTemplateSpecializationInfo; |
58 | class EnumDecl; |
59 | class Expr; |
60 | class FunctionTemplateDecl; |
61 | class FunctionTemplateSpecializationInfo; |
62 | class LabelStmt; |
63 | class MemberSpecializationInfo; |
64 | class Module; |
65 | class NamespaceDecl; |
66 | class ParmVarDecl; |
67 | class RecordDecl; |
68 | class Stmt; |
69 | class StringLiteral; |
70 | class TagDecl; |
71 | class TemplateArgumentList; |
72 | class TemplateArgumentListInfo; |
73 | class TemplateParameterList; |
74 | class TypeAliasTemplateDecl; |
75 | class TypeLoc; |
76 | class UnresolvedSetImpl; |
77 | class VarTemplateDecl; |
78 | |
79 | |
80 | |
81 | |
82 | |
83 | |
84 | |
85 | |
86 | class alignas(8) TypeSourceInfo { |
87 | |
88 | |
89 | friend class ASTContext; |
90 | |
91 | QualType Ty; |
92 | |
93 | TypeSourceInfo(QualType ty) : Ty(ty) {} |
94 | |
95 | public: |
96 | |
97 | QualType getType() const { return Ty; } |
98 | |
99 | |
100 | TypeLoc getTypeLoc() const; |
101 | |
102 | |
103 | void overrideType(QualType T) { Ty = T; } |
104 | }; |
105 | |
106 | |
107 | class TranslationUnitDecl : public Decl, public DeclContext { |
108 | ASTContext &Ctx; |
109 | |
110 | |
111 | |
112 | NamespaceDecl *AnonymousNamespace = nullptr; |
113 | |
114 | explicit TranslationUnitDecl(ASTContext &ctx); |
115 | |
116 | virtual void anchor(); |
117 | |
118 | public: |
119 | ASTContext &getASTContext() const { return Ctx; } |
120 | |
121 | NamespaceDecl *getAnonymousNamespace() const { return AnonymousNamespace; } |
122 | void setAnonymousNamespace(NamespaceDecl *D) { AnonymousNamespace = D; } |
123 | |
124 | static TranslationUnitDecl *Create(ASTContext &C); |
125 | |
126 | |
127 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
128 | static bool classofKind(Kind K) { return K == TranslationUnit; } |
129 | static DeclContext *castToDeclContext(const TranslationUnitDecl *D) { |
130 | return static_cast<DeclContext *>(const_cast<TranslationUnitDecl*>(D)); |
131 | } |
132 | static TranslationUnitDecl *castFromDeclContext(const DeclContext *DC) { |
133 | return static_cast<TranslationUnitDecl *>(const_cast<DeclContext*>(DC)); |
134 | } |
135 | }; |
136 | |
137 | |
138 | |
139 | class final |
140 | : public Decl, |
141 | private llvm::TrailingObjects<PragmaCommentDecl, char> { |
142 | friend class ASTDeclReader; |
143 | friend class ASTDeclWriter; |
144 | friend TrailingObjects; |
145 | |
146 | PragmaMSCommentKind ; |
147 | |
148 | PragmaCommentDecl(TranslationUnitDecl *TU, SourceLocation , |
149 | PragmaMSCommentKind ) |
150 | : Decl(PragmaComment, TU, CommentLoc), CommentKind(CommentKind) {} |
151 | |
152 | virtual void (); |
153 | |
154 | public: |
155 | static PragmaCommentDecl *(const ASTContext &C, TranslationUnitDecl *DC, |
156 | SourceLocation , |
157 | PragmaMSCommentKind , |
158 | StringRef Arg); |
159 | static PragmaCommentDecl *(ASTContext &C, unsigned ID, |
160 | unsigned ArgSize); |
161 | |
162 | PragmaMSCommentKind () const { return CommentKind; } |
163 | |
164 | StringRef () const { return getTrailingObjects<char>(); } |
165 | |
166 | |
167 | static bool (const Decl *D) { return classofKind(D->getKind()); } |
168 | static bool (Kind K) { return K == PragmaComment; } |
169 | }; |
170 | |
171 | |
172 | |
173 | class PragmaDetectMismatchDecl final |
174 | : public Decl, |
175 | private llvm::TrailingObjects<PragmaDetectMismatchDecl, char> { |
176 | friend class ASTDeclReader; |
177 | friend class ASTDeclWriter; |
178 | friend TrailingObjects; |
179 | |
180 | size_t ValueStart; |
181 | |
182 | PragmaDetectMismatchDecl(TranslationUnitDecl *TU, SourceLocation Loc, |
183 | size_t ValueStart) |
184 | : Decl(PragmaDetectMismatch, TU, Loc), ValueStart(ValueStart) {} |
185 | |
186 | virtual void anchor(); |
187 | |
188 | public: |
189 | static PragmaDetectMismatchDecl *Create(const ASTContext &C, |
190 | TranslationUnitDecl *DC, |
191 | SourceLocation Loc, StringRef Name, |
192 | StringRef Value); |
193 | static PragmaDetectMismatchDecl * |
194 | CreateDeserialized(ASTContext &C, unsigned ID, unsigned NameValueSize); |
195 | |
196 | StringRef getName() const { return getTrailingObjects<char>(); } |
197 | StringRef getValue() const { return getTrailingObjects<char>() + ValueStart; } |
198 | |
199 | |
200 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
201 | static bool classofKind(Kind K) { return K == PragmaDetectMismatch; } |
202 | }; |
203 | |
204 | |
205 | |
206 | |
207 | |
208 | |
209 | |
210 | |
211 | |
212 | |
213 | |
214 | |
215 | |
216 | |
217 | |
218 | |
219 | |
220 | |
221 | class ExternCContextDecl : public Decl, public DeclContext { |
222 | explicit ExternCContextDecl(TranslationUnitDecl *TU) |
223 | : Decl(ExternCContext, TU, SourceLocation()), |
224 | DeclContext(ExternCContext) {} |
225 | |
226 | virtual void anchor(); |
227 | |
228 | public: |
229 | static ExternCContextDecl *Create(const ASTContext &C, |
230 | TranslationUnitDecl *TU); |
231 | |
232 | |
233 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
234 | static bool classofKind(Kind K) { return K == ExternCContext; } |
235 | static DeclContext *castToDeclContext(const ExternCContextDecl *D) { |
236 | return static_cast<DeclContext *>(const_cast<ExternCContextDecl*>(D)); |
237 | } |
238 | static ExternCContextDecl *castFromDeclContext(const DeclContext *DC) { |
239 | return static_cast<ExternCContextDecl *>(const_cast<DeclContext*>(DC)); |
240 | } |
241 | }; |
242 | |
243 | |
244 | |
245 | |
246 | |
247 | |
248 | class NamedDecl : public Decl { |
249 | |
250 | |
251 | |
252 | DeclarationName Name; |
253 | |
254 | virtual void anchor(); |
255 | |
256 | private: |
257 | NamedDecl *getUnderlyingDeclImpl() LLVM_READONLY; |
258 | |
259 | protected: |
260 | NamedDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N) |
261 | : Decl(DK, DC, L), Name(N) {} |
262 | |
263 | public: |
264 | |
265 | |
266 | |
267 | |
268 | |
269 | IdentifierInfo *getIdentifier() const { return Name.getAsIdentifierInfo(); } |
270 | |
271 | |
272 | |
273 | |
274 | |
275 | StringRef getName() const { |
276 | (0) . __assert_fail ("Name.isIdentifier() && \"Name is not a simple identifier\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 276, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Name.isIdentifier() && "Name is not a simple identifier"); |
277 | return getIdentifier() ? getIdentifier()->getName() : ""; |
278 | } |
279 | |
280 | |
281 | |
282 | |
283 | |
284 | |
285 | |
286 | |
287 | |
288 | |
289 | |
290 | |
291 | std::string getNameAsString() const { return Name.getAsString(); } |
292 | |
293 | virtual void printName(raw_ostream &os) const; |
294 | |
295 | |
296 | |
297 | DeclarationName getDeclName() const { return Name; } |
298 | |
299 | |
300 | void setDeclName(DeclarationName N) { Name = N; } |
301 | |
302 | |
303 | |
304 | |
305 | |
306 | |
307 | |
308 | |
309 | |
310 | void printQualifiedName(raw_ostream &OS) const; |
311 | void printQualifiedName(raw_ostream &OS, const PrintingPolicy &Policy) const; |
312 | |
313 | |
314 | std::string getQualifiedNameAsString() const; |
315 | |
316 | |
317 | |
318 | |
319 | |
320 | |
321 | |
322 | virtual void getNameForDiagnostic(raw_ostream &OS, |
323 | const PrintingPolicy &Policy, |
324 | bool Qualified) const; |
325 | |
326 | |
327 | |
328 | |
329 | |
330 | |
331 | |
332 | |
333 | |
334 | |
335 | |
336 | bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer = true) const; |
337 | |
338 | |
339 | bool hasLinkage() const; |
340 | |
341 | using Decl::isModulePrivate; |
342 | using Decl::setModulePrivate; |
343 | |
344 | |
345 | bool isCXXClassMember() const { |
346 | const DeclContext *DC = getDeclContext(); |
347 | |
348 | |
349 | |
350 | |
351 | if (isa<EnumDecl>(DC)) |
352 | DC = DC->getRedeclContext(); |
353 | |
354 | return DC->isRecord(); |
355 | } |
356 | |
357 | |
358 | |
359 | bool isCXXInstanceMember() const; |
360 | |
361 | |
362 | |
363 | |
364 | |
365 | |
366 | Linkage getLinkageInternal() const; |
367 | |
368 | |
369 | |
370 | Linkage getFormalLinkage() const { |
371 | return clang::getFormalLinkage(getLinkageInternal()); |
372 | } |
373 | |
374 | |
375 | bool hasExternalFormalLinkage() const { |
376 | return isExternalFormalLinkage(getLinkageInternal()); |
377 | } |
378 | |
379 | bool isExternallyVisible() const { |
380 | return clang::isExternallyVisible(getLinkageInternal()); |
381 | } |
382 | |
383 | |
384 | |
385 | bool isExternallyDeclarable() const { |
386 | return isExternallyVisible() && !getOwningModuleForLinkage(); |
387 | } |
388 | |
389 | |
390 | Visibility getVisibility() const { |
391 | return getLinkageAndVisibility().getVisibility(); |
392 | } |
393 | |
394 | |
395 | LinkageInfo getLinkageAndVisibility() const; |
396 | |
397 | |
398 | enum ExplicitVisibilityKind { |
399 | |
400 | |
401 | |
402 | VisibilityForType, |
403 | |
404 | |
405 | |
406 | |
407 | VisibilityForValue |
408 | }; |
409 | |
410 | |
411 | |
412 | Optional<Visibility> |
413 | getExplicitVisibility(ExplicitVisibilityKind kind) const; |
414 | |
415 | |
416 | |
417 | bool isLinkageValid() const; |
418 | |
419 | |
420 | |
421 | |
422 | |
423 | |
424 | |
425 | bool hasLinkageBeenComputed() const { |
426 | return hasCachedLinkage(); |
427 | } |
428 | |
429 | |
430 | |
431 | NamedDecl *getUnderlyingDecl() { |
432 | |
433 | if (this->getKind() != UsingShadow && |
434 | this->getKind() != ConstructorUsingShadow && |
435 | this->getKind() != ObjCCompatibleAlias && |
436 | this->getKind() != NamespaceAlias) |
437 | return this; |
438 | |
439 | return getUnderlyingDeclImpl(); |
440 | } |
441 | const NamedDecl *getUnderlyingDecl() const { |
442 | return const_cast<NamedDecl*>(this)->getUnderlyingDecl(); |
443 | } |
444 | |
445 | NamedDecl *getMostRecentDecl() { |
446 | return cast<NamedDecl>(static_cast<Decl *>(this)->getMostRecentDecl()); |
447 | } |
448 | const NamedDecl *getMostRecentDecl() const { |
449 | return const_cast<NamedDecl*>(this)->getMostRecentDecl(); |
450 | } |
451 | |
452 | ObjCStringFormatFamily getObjCFStringFormattingFamily() const; |
453 | |
454 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
455 | static bool classofKind(Kind K) { return K >= firstNamed && K <= lastNamed; } |
456 | }; |
457 | |
458 | inline raw_ostream &operator<<(raw_ostream &OS, const NamedDecl &ND) { |
459 | ND.printName(OS); |
460 | return OS; |
461 | } |
462 | |
463 | |
464 | |
465 | |
466 | |
467 | |
468 | class LabelDecl : public NamedDecl { |
469 | LabelStmt *TheStmt; |
470 | StringRef MSAsmName; |
471 | bool MSAsmNameResolved = false; |
472 | |
473 | |
474 | |
475 | |
476 | SourceLocation LocStart; |
477 | |
478 | LabelDecl(DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II, |
479 | LabelStmt *S, SourceLocation StartL) |
480 | : NamedDecl(Label, DC, IdentL, II), TheStmt(S), LocStart(StartL) {} |
481 | |
482 | void anchor() override; |
483 | |
484 | public: |
485 | static LabelDecl *Create(ASTContext &C, DeclContext *DC, |
486 | SourceLocation IdentL, IdentifierInfo *II); |
487 | static LabelDecl *Create(ASTContext &C, DeclContext *DC, |
488 | SourceLocation IdentL, IdentifierInfo *II, |
489 | SourceLocation GnuLabelL); |
490 | static LabelDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
491 | |
492 | LabelStmt *getStmt() const { return TheStmt; } |
493 | void setStmt(LabelStmt *T) { TheStmt = T; } |
494 | |
495 | bool isGnuLocal() const { return LocStart != getLocation(); } |
496 | void setLocStart(SourceLocation L) { LocStart = L; } |
497 | |
498 | SourceRange getSourceRange() const override LLVM_READONLY { |
499 | return SourceRange(LocStart, getLocation()); |
500 | } |
501 | |
502 | bool isMSAsmLabel() const { return !MSAsmName.empty(); } |
503 | bool isResolvedMSAsmLabel() const { return isMSAsmLabel() && MSAsmNameResolved; } |
504 | void setMSAsmLabel(StringRef Name); |
505 | StringRef getMSAsmLabel() const { return MSAsmName; } |
506 | void setMSAsmLabelResolved() { MSAsmNameResolved = true; } |
507 | |
508 | |
509 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
510 | static bool classofKind(Kind K) { return K == Label; } |
511 | }; |
512 | |
513 | |
514 | class NamespaceDecl : public NamedDecl, public DeclContext, |
515 | public Redeclarable<NamespaceDecl> |
516 | { |
517 | |
518 | |
519 | SourceLocation LocStart; |
520 | |
521 | |
522 | SourceLocation RBraceLoc; |
523 | |
524 | |
525 | |
526 | |
527 | |
528 | llvm::PointerIntPair<NamespaceDecl *, 1, bool> AnonOrFirstNamespaceAndInline; |
529 | |
530 | NamespaceDecl(ASTContext &C, DeclContext *DC, bool Inline, |
531 | SourceLocation StartLoc, SourceLocation IdLoc, |
532 | IdentifierInfo *Id, NamespaceDecl *PrevDecl); |
533 | |
534 | using redeclarable_base = Redeclarable<NamespaceDecl>; |
535 | |
536 | NamespaceDecl *getNextRedeclarationImpl() override; |
537 | NamespaceDecl *getPreviousDeclImpl() override; |
538 | NamespaceDecl *getMostRecentDeclImpl() override; |
539 | |
540 | public: |
541 | friend class ASTDeclReader; |
542 | friend class ASTDeclWriter; |
543 | |
544 | static NamespaceDecl *Create(ASTContext &C, DeclContext *DC, |
545 | bool Inline, SourceLocation StartLoc, |
546 | SourceLocation IdLoc, IdentifierInfo *Id, |
547 | NamespaceDecl *PrevDecl); |
548 | |
549 | static NamespaceDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
550 | |
551 | using redecl_range = redeclarable_base::redecl_range; |
552 | using redecl_iterator = redeclarable_base::redecl_iterator; |
553 | |
554 | using redeclarable_base::redecls_begin; |
555 | using redeclarable_base::redecls_end; |
556 | using redeclarable_base::redecls; |
557 | using redeclarable_base::getPreviousDecl; |
558 | using redeclarable_base::getMostRecentDecl; |
559 | using redeclarable_base::isFirstDecl; |
560 | |
561 | |
562 | |
563 | |
564 | |
565 | |
566 | |
567 | |
568 | |
569 | |
570 | bool isAnonymousNamespace() const { |
571 | return !getIdentifier(); |
572 | } |
573 | |
574 | |
575 | bool isInline() const { |
576 | return AnonOrFirstNamespaceAndInline.getInt(); |
577 | } |
578 | |
579 | |
580 | void setInline(bool Inline) { |
581 | AnonOrFirstNamespaceAndInline.setInt(Inline); |
582 | } |
583 | |
584 | |
585 | NamespaceDecl *getOriginalNamespace(); |
586 | |
587 | |
588 | const NamespaceDecl *getOriginalNamespace() const; |
589 | |
590 | |
591 | |
592 | |
593 | bool isOriginalNamespace() const; |
594 | |
595 | |
596 | |
597 | NamespaceDecl *getAnonymousNamespace() const { |
598 | return getOriginalNamespace()->AnonOrFirstNamespaceAndInline.getPointer(); |
599 | } |
600 | |
601 | void setAnonymousNamespace(NamespaceDecl *D) { |
602 | getOriginalNamespace()->AnonOrFirstNamespaceAndInline.setPointer(D); |
603 | } |
604 | |
605 | |
606 | NamespaceDecl *getCanonicalDecl() override { |
607 | return getOriginalNamespace(); |
608 | } |
609 | const NamespaceDecl *getCanonicalDecl() const { |
610 | return getOriginalNamespace(); |
611 | } |
612 | |
613 | SourceRange getSourceRange() const override LLVM_READONLY { |
614 | return SourceRange(LocStart, RBraceLoc); |
615 | } |
616 | |
617 | SourceLocation getBeginLoc() const LLVM_READONLY { return LocStart; } |
618 | SourceLocation getRBraceLoc() const { return RBraceLoc; } |
619 | void setLocStart(SourceLocation L) { LocStart = L; } |
620 | void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } |
621 | |
622 | |
623 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
624 | static bool classofKind(Kind K) { return K == Namespace; } |
625 | static DeclContext *castToDeclContext(const NamespaceDecl *D) { |
626 | return static_cast<DeclContext *>(const_cast<NamespaceDecl*>(D)); |
627 | } |
628 | static NamespaceDecl *castFromDeclContext(const DeclContext *DC) { |
629 | return static_cast<NamespaceDecl *>(const_cast<DeclContext*>(DC)); |
630 | } |
631 | }; |
632 | |
633 | |
634 | |
635 | |
636 | class ValueDecl : public NamedDecl { |
637 | QualType DeclType; |
638 | |
639 | void anchor() override; |
640 | |
641 | protected: |
642 | ValueDecl(Kind DK, DeclContext *DC, SourceLocation L, |
643 | DeclarationName N, QualType T) |
644 | : NamedDecl(DK, DC, L, N), DeclType(T) {} |
645 | |
646 | public: |
647 | QualType getType() const { return DeclType; } |
648 | void setType(QualType newType) { DeclType = newType; } |
649 | |
650 | |
651 | |
652 | bool isWeak() const; |
653 | |
654 | |
655 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
656 | static bool classofKind(Kind K) { return K >= firstValue && K <= lastValue; } |
657 | }; |
658 | |
659 | |
660 | |
661 | struct QualifierInfo { |
662 | NestedNameSpecifierLoc QualifierLoc; |
663 | |
664 | |
665 | |
666 | |
667 | |
668 | unsigned NumTemplParamLists = 0; |
669 | |
670 | |
671 | |
672 | |
673 | |
674 | |
675 | TemplateParameterList** TemplParamLists = nullptr; |
676 | |
677 | QualifierInfo() = default; |
678 | QualifierInfo(const QualifierInfo &) = delete; |
679 | QualifierInfo& operator=(const QualifierInfo &) = delete; |
680 | |
681 | |
682 | void setTemplateParameterListsInfo(ASTContext &Context, |
683 | ArrayRef<TemplateParameterList *> TPLists); |
684 | }; |
685 | |
686 | |
687 | |
688 | class DeclaratorDecl : public ValueDecl { |
689 | |
690 | |
691 | struct ExtInfo : public QualifierInfo { |
692 | TypeSourceInfo *TInfo; |
693 | }; |
694 | |
695 | llvm::PointerUnion<TypeSourceInfo *, ExtInfo *> DeclInfo; |
696 | |
697 | |
698 | |
699 | SourceLocation InnerLocStart; |
700 | |
701 | bool hasExtInfo() const { return DeclInfo.is<ExtInfo*>(); } |
702 | ExtInfo *getExtInfo() { return DeclInfo.get<ExtInfo*>(); } |
703 | const ExtInfo *getExtInfo() const { return DeclInfo.get<ExtInfo*>(); } |
704 | |
705 | protected: |
706 | DeclaratorDecl(Kind DK, DeclContext *DC, SourceLocation L, |
707 | DeclarationName N, QualType T, TypeSourceInfo *TInfo, |
708 | SourceLocation StartL) |
709 | : ValueDecl(DK, DC, L, N, T), DeclInfo(TInfo), InnerLocStart(StartL) {} |
710 | |
711 | public: |
712 | friend class ASTDeclReader; |
713 | friend class ASTDeclWriter; |
714 | |
715 | TypeSourceInfo *getTypeSourceInfo() const { |
716 | return hasExtInfo() |
717 | ? getExtInfo()->TInfo |
718 | : DeclInfo.get<TypeSourceInfo*>(); |
719 | } |
720 | |
721 | void setTypeSourceInfo(TypeSourceInfo *TI) { |
722 | if (hasExtInfo()) |
723 | getExtInfo()->TInfo = TI; |
724 | else |
725 | DeclInfo = TI; |
726 | } |
727 | |
728 | |
729 | SourceLocation getInnerLocStart() const { return InnerLocStart; } |
730 | void setInnerLocStart(SourceLocation L) { InnerLocStart = L; } |
731 | |
732 | |
733 | |
734 | SourceLocation getOuterLocStart() const; |
735 | |
736 | SourceRange getSourceRange() const override LLVM_READONLY; |
737 | |
738 | SourceLocation getBeginLoc() const LLVM_READONLY { |
739 | return getOuterLocStart(); |
740 | } |
741 | |
742 | |
743 | |
744 | NestedNameSpecifier *getQualifier() const { |
745 | return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier() |
746 | : nullptr; |
747 | } |
748 | |
749 | |
750 | |
751 | |
752 | NestedNameSpecifierLoc getQualifierLoc() const { |
753 | return hasExtInfo() ? getExtInfo()->QualifierLoc |
754 | : NestedNameSpecifierLoc(); |
755 | } |
756 | |
757 | void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc); |
758 | |
759 | unsigned getNumTemplateParameterLists() const { |
760 | return hasExtInfo() ? getExtInfo()->NumTemplParamLists : 0; |
761 | } |
762 | |
763 | TemplateParameterList *getTemplateParameterList(unsigned index) const { |
764 | assert(index < getNumTemplateParameterLists()); |
765 | return getExtInfo()->TemplParamLists[index]; |
766 | } |
767 | |
768 | void setTemplateParameterListsInfo(ASTContext &Context, |
769 | ArrayRef<TemplateParameterList *> TPLists); |
770 | |
771 | SourceLocation getTypeSpecStartLoc() const; |
772 | |
773 | |
774 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
775 | static bool classofKind(Kind K) { |
776 | return K >= firstDeclarator && K <= lastDeclarator; |
777 | } |
778 | }; |
779 | |
780 | |
781 | |
782 | |
783 | struct EvaluatedStmt { |
784 | |
785 | bool WasEvaluated : 1; |
786 | |
787 | |
788 | bool IsEvaluating : 1; |
789 | |
790 | |
791 | |
792 | bool CheckedICE : 1; |
793 | |
794 | |
795 | |
796 | bool CheckingICE : 1; |
797 | |
798 | |
799 | |
800 | |
801 | bool IsICE : 1; |
802 | |
803 | Stmt *Value; |
804 | APValue Evaluated; |
805 | |
806 | EvaluatedStmt() : WasEvaluated(false), IsEvaluating(false), CheckedICE(false), |
807 | CheckingICE(false), IsICE(false) {} |
808 | |
809 | }; |
810 | |
811 | |
812 | class VarDecl : public DeclaratorDecl, public Redeclarable<VarDecl> { |
813 | public: |
814 | |
815 | enum InitializationStyle { |
816 | |
817 | CInit, |
818 | |
819 | |
820 | CallInit, |
821 | |
822 | |
823 | ListInit |
824 | }; |
825 | |
826 | |
827 | enum TLSKind { |
828 | |
829 | TLS_None, |
830 | |
831 | |
832 | TLS_Static, |
833 | |
834 | |
835 | TLS_Dynamic |
836 | }; |
837 | |
838 | |
839 | |
840 | |
841 | static const char *getStorageClassSpecifierString(StorageClass SC); |
842 | |
843 | protected: |
844 | |
845 | |
846 | |
847 | |
848 | |
849 | |
850 | |
851 | using InitType = llvm::PointerUnion<Stmt *, EvaluatedStmt *>; |
852 | |
853 | |
854 | |
855 | mutable InitType Init; |
856 | |
857 | private: |
858 | friend class ASTDeclReader; |
859 | friend class ASTNodeImporter; |
860 | friend class StmtIteratorBase; |
861 | |
862 | class VarDeclBitfields { |
863 | friend class ASTDeclReader; |
864 | friend class VarDecl; |
865 | |
866 | unsigned SClass : 3; |
867 | unsigned TSCSpec : 2; |
868 | unsigned InitStyle : 2; |
869 | |
870 | |
871 | |
872 | unsigned ARCPseudoStrong : 1; |
873 | }; |
874 | enum { NumVarDeclBits = 8 }; |
875 | |
876 | protected: |
877 | enum { NumParameterIndexBits = 8 }; |
878 | |
879 | enum DefaultArgKind { |
880 | DAK_None, |
881 | DAK_Unparsed, |
882 | DAK_Uninstantiated, |
883 | DAK_Normal |
884 | }; |
885 | |
886 | class ParmVarDeclBitfields { |
887 | friend class ASTDeclReader; |
888 | friend class ParmVarDecl; |
889 | |
890 | unsigned : NumVarDeclBits; |
891 | |
892 | |
893 | |
894 | unsigned HasInheritedDefaultArg : 1; |
895 | |
896 | |
897 | |
898 | |
899 | |
900 | unsigned DefaultArgKind : 2; |
901 | |
902 | |
903 | unsigned IsKNRPromoted : 1; |
904 | |
905 | |
906 | unsigned IsObjCMethodParam : 1; |
907 | |
908 | |
909 | |
910 | |
911 | |
912 | unsigned ScopeDepthOrObjCQuals : 7; |
913 | |
914 | |
915 | |
916 | unsigned ParameterIndex : NumParameterIndexBits; |
917 | }; |
918 | |
919 | class NonParmVarDeclBitfields { |
920 | friend class ASTDeclReader; |
921 | friend class ImplicitParamDecl; |
922 | friend class VarDecl; |
923 | |
924 | unsigned : NumVarDeclBits; |
925 | |
926 | |
927 | |
928 | |
929 | unsigned IsThisDeclarationADemotedDefinition : 1; |
930 | |
931 | |
932 | |
933 | unsigned ExceptionVar : 1; |
934 | |
935 | |
936 | |
937 | |
938 | unsigned NRVOVariable : 1; |
939 | |
940 | |
941 | |
942 | unsigned CXXForRangeDecl : 1; |
943 | |
944 | |
945 | unsigned ObjCForDecl : 1; |
946 | |
947 | |
948 | unsigned IsInline : 1; |
949 | |
950 | |
951 | unsigned IsInlineSpecified : 1; |
952 | |
953 | |
954 | unsigned IsConstexpr : 1; |
955 | |
956 | |
957 | |
958 | unsigned IsInitCapture : 1; |
959 | |
960 | |
961 | |
962 | |
963 | unsigned PreviousDeclInSameBlockScope : 1; |
964 | |
965 | |
966 | |
967 | unsigned ImplicitParamKind : 3; |
968 | |
969 | unsigned EscapingByref : 1; |
970 | }; |
971 | |
972 | union { |
973 | unsigned AllBits; |
974 | VarDeclBitfields VarDeclBits; |
975 | ParmVarDeclBitfields ParmVarDeclBits; |
976 | NonParmVarDeclBitfields NonParmVarDeclBits; |
977 | }; |
978 | |
979 | VarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, |
980 | SourceLocation IdLoc, IdentifierInfo *Id, QualType T, |
981 | TypeSourceInfo *TInfo, StorageClass SC); |
982 | |
983 | using redeclarable_base = Redeclarable<VarDecl>; |
984 | |
985 | VarDecl *getNextRedeclarationImpl() override { |
986 | return getNextRedeclaration(); |
987 | } |
988 | |
989 | VarDecl *getPreviousDeclImpl() override { |
990 | return getPreviousDecl(); |
991 | } |
992 | |
993 | VarDecl *getMostRecentDeclImpl() override { |
994 | return getMostRecentDecl(); |
995 | } |
996 | |
997 | public: |
998 | using redecl_range = redeclarable_base::redecl_range; |
999 | using redecl_iterator = redeclarable_base::redecl_iterator; |
1000 | |
1001 | using redeclarable_base::redecls_begin; |
1002 | using redeclarable_base::redecls_end; |
1003 | using redeclarable_base::redecls; |
1004 | using redeclarable_base::getPreviousDecl; |
1005 | using redeclarable_base::getMostRecentDecl; |
1006 | using redeclarable_base::isFirstDecl; |
1007 | |
1008 | static VarDecl *Create(ASTContext &C, DeclContext *DC, |
1009 | SourceLocation StartLoc, SourceLocation IdLoc, |
1010 | IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, |
1011 | StorageClass S); |
1012 | |
1013 | static VarDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
1014 | |
1015 | SourceRange getSourceRange() const override LLVM_READONLY; |
1016 | |
1017 | |
1018 | |
1019 | StorageClass getStorageClass() const { |
1020 | return (StorageClass) VarDeclBits.SClass; |
1021 | } |
1022 | void setStorageClass(StorageClass SC); |
1023 | |
1024 | void setTSCSpec(ThreadStorageClassSpecifier TSC) { |
1025 | VarDeclBits.TSCSpec = TSC; |
1026 | (0) . __assert_fail ("VarDeclBits.TSCSpec == TSC && \"truncation\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1026, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(VarDeclBits.TSCSpec == TSC && "truncation"); |
1027 | } |
1028 | ThreadStorageClassSpecifier getTSCSpec() const { |
1029 | return static_cast<ThreadStorageClassSpecifier>(VarDeclBits.TSCSpec); |
1030 | } |
1031 | TLSKind getTLSKind() const; |
1032 | |
1033 | |
1034 | |
1035 | bool hasLocalStorage() const { |
1036 | if (getStorageClass() == SC_None) { |
1037 | |
1038 | |
1039 | |
1040 | |
1041 | if (getType().getAddressSpace() == LangAS::opencl_constant) |
1042 | return false; |
1043 | |
1044 | return !isFileVarDecl() && getTSCSpec() == TSCS_unspecified; |
1045 | } |
1046 | |
1047 | |
1048 | if (getStorageClass() == SC_Register && !isLocalVarDeclOrParm()) |
1049 | return false; |
1050 | |
1051 | |
1052 | |
1053 | |
1054 | return getStorageClass() >= SC_Auto; |
1055 | } |
1056 | |
1057 | |
1058 | |
1059 | bool isStaticLocal() const { |
1060 | return (getStorageClass() == SC_Static || |
1061 | |
1062 | (getStorageClass() == SC_None && getTSCSpec() == TSCS_thread_local)) |
1063 | && !isFileVarDecl(); |
1064 | } |
1065 | |
1066 | |
1067 | |
1068 | bool hasExternalStorage() const { |
1069 | return getStorageClass() == SC_Extern || |
1070 | getStorageClass() == SC_PrivateExtern; |
1071 | } |
1072 | |
1073 | |
1074 | |
1075 | |
1076 | |
1077 | bool hasGlobalStorage() const { return !hasLocalStorage(); } |
1078 | |
1079 | |
1080 | StorageDuration getStorageDuration() const { |
1081 | return hasLocalStorage() ? SD_Automatic : |
1082 | getTSCSpec() ? SD_Thread : SD_Static; |
1083 | } |
1084 | |
1085 | |
1086 | LanguageLinkage getLanguageLinkage() const; |
1087 | |
1088 | |
1089 | bool isExternC() const; |
1090 | |
1091 | |
1092 | |
1093 | bool isInExternCContext() const; |
1094 | |
1095 | |
1096 | |
1097 | bool isInExternCXXContext() const; |
1098 | |
1099 | |
1100 | |
1101 | |
1102 | |
1103 | |
1104 | bool isLocalVarDecl() const { |
1105 | if (getKind() != Decl::Var && getKind() != Decl::Decomposition) |
1106 | return false; |
1107 | if (const DeclContext *DC = getLexicalDeclContext()) |
1108 | return DC->getRedeclContext()->isFunctionOrMethod(); |
1109 | return false; |
1110 | } |
1111 | |
1112 | |
1113 | bool isLocalVarDeclOrParm() const { |
1114 | return isLocalVarDecl() || getKind() == Decl::ParmVar; |
1115 | } |
1116 | |
1117 | |
1118 | bool isFunctionOrMethodVarDecl() const { |
1119 | if (getKind() != Decl::Var && getKind() != Decl::Decomposition) |
1120 | return false; |
1121 | const DeclContext *DC = getLexicalDeclContext()->getRedeclContext(); |
1122 | return DC->isFunctionOrMethod() && DC->getDeclKind() != Decl::Block; |
1123 | } |
1124 | |
1125 | |
1126 | |
1127 | |
1128 | |
1129 | |
1130 | |
1131 | |
1132 | |
1133 | |
1134 | bool isStaticDataMember() const { |
1135 | |
1136 | return getKind() != Decl::ParmVar && getDeclContext()->isRecord(); |
1137 | } |
1138 | |
1139 | VarDecl *getCanonicalDecl() override; |
1140 | const VarDecl *getCanonicalDecl() const { |
1141 | return const_cast<VarDecl*>(this)->getCanonicalDecl(); |
1142 | } |
1143 | |
1144 | enum DefinitionKind { |
1145 | |
1146 | DeclarationOnly, |
1147 | |
1148 | |
1149 | TentativeDefinition, |
1150 | |
1151 | |
1152 | Definition |
1153 | }; |
1154 | |
1155 | |
1156 | |
1157 | |
1158 | DefinitionKind isThisDeclarationADefinition(ASTContext &) const; |
1159 | DefinitionKind isThisDeclarationADefinition() const { |
1160 | return isThisDeclarationADefinition(getASTContext()); |
1161 | } |
1162 | |
1163 | |
1164 | DefinitionKind hasDefinition(ASTContext &) const; |
1165 | DefinitionKind hasDefinition() const { |
1166 | return hasDefinition(getASTContext()); |
1167 | } |
1168 | |
1169 | |
1170 | |
1171 | VarDecl *getActingDefinition(); |
1172 | const VarDecl *getActingDefinition() const { |
1173 | return const_cast<VarDecl*>(this)->getActingDefinition(); |
1174 | } |
1175 | |
1176 | |
1177 | VarDecl *getDefinition(ASTContext &); |
1178 | const VarDecl *getDefinition(ASTContext &C) const { |
1179 | return const_cast<VarDecl*>(this)->getDefinition(C); |
1180 | } |
1181 | VarDecl *getDefinition() { |
1182 | return getDefinition(getASTContext()); |
1183 | } |
1184 | const VarDecl *getDefinition() const { |
1185 | return const_cast<VarDecl*>(this)->getDefinition(); |
1186 | } |
1187 | |
1188 | |
1189 | |
1190 | bool isOutOfLine() const override; |
1191 | |
1192 | |
1193 | bool isFileVarDecl() const { |
1194 | Kind K = getKind(); |
1195 | if (K == ParmVar || K == ImplicitParam) |
1196 | return false; |
1197 | |
1198 | if (getLexicalDeclContext()->getRedeclContext()->isFileContext()) |
1199 | return true; |
1200 | |
1201 | if (isStaticDataMember()) |
1202 | return true; |
1203 | |
1204 | return false; |
1205 | } |
1206 | |
1207 | |
1208 | |
1209 | const Expr *getAnyInitializer() const { |
1210 | const VarDecl *D; |
1211 | return getAnyInitializer(D); |
1212 | } |
1213 | |
1214 | |
1215 | |
1216 | const Expr *getAnyInitializer(const VarDecl *&D) const; |
1217 | |
1218 | bool hasInit() const; |
1219 | const Expr *getInit() const { |
1220 | return const_cast<VarDecl *>(this)->getInit(); |
1221 | } |
1222 | Expr *getInit(); |
1223 | |
1224 | |
1225 | Stmt **getInitAddress(); |
1226 | |
1227 | void setInit(Expr *I); |
1228 | |
1229 | |
1230 | |
1231 | |
1232 | |
1233 | bool isUsableInConstantExpressions(ASTContext &C) const; |
1234 | |
1235 | EvaluatedStmt *ensureEvaluatedStmt() const; |
1236 | |
1237 | |
1238 | |
1239 | |
1240 | |
1241 | APValue *evaluateValue() const; |
1242 | APValue *evaluateValue(SmallVectorImpl<PartialDiagnosticAt> &Notes) const; |
1243 | |
1244 | |
1245 | |
1246 | |
1247 | APValue *getEvaluatedValue() const; |
1248 | |
1249 | |
1250 | |
1251 | bool isInitKnownICE() const; |
1252 | |
1253 | |
1254 | |
1255 | |
1256 | |
1257 | |
1258 | bool isInitICE() const; |
1259 | |
1260 | |
1261 | |
1262 | bool checkInitIsICE() const; |
1263 | |
1264 | void setInitStyle(InitializationStyle Style) { |
1265 | VarDeclBits.InitStyle = Style; |
1266 | } |
1267 | |
1268 | |
1269 | |
1270 | |
1271 | |
1272 | |
1273 | |
1274 | |
1275 | |
1276 | |
1277 | |
1278 | InitializationStyle getInitStyle() const { |
1279 | return static_cast<InitializationStyle>(VarDeclBits.InitStyle); |
1280 | } |
1281 | |
1282 | |
1283 | bool isDirectInit() const { |
1284 | return getInitStyle() != CInit; |
1285 | } |
1286 | |
1287 | |
1288 | bool isThisDeclarationADemotedDefinition() const { |
1289 | return isa<ParmVarDecl>(this) ? false : |
1290 | NonParmVarDeclBits.IsThisDeclarationADemotedDefinition; |
1291 | } |
1292 | |
1293 | |
1294 | |
1295 | |
1296 | |
1297 | |
1298 | void demoteThisDefinitionToDeclaration() { |
1299 | (0) . __assert_fail ("isThisDeclarationADefinition() && \"Not a definition!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1299, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isThisDeclarationADefinition() && "Not a definition!"); |
1300 | (0) . __assert_fail ("!isa(this) && \"Cannot demote ParmVarDecls!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1300, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<ParmVarDecl>(this) && "Cannot demote ParmVarDecls!"); |
1301 | NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1; |
1302 | } |
1303 | |
1304 | |
1305 | |
1306 | bool isExceptionVariable() const { |
1307 | return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.ExceptionVar; |
1308 | } |
1309 | void setExceptionVariable(bool EV) { |
1310 | (this)", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1310, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<ParmVarDecl>(this)); |
1311 | NonParmVarDeclBits.ExceptionVar = EV; |
1312 | } |
1313 | |
1314 | |
1315 | |
1316 | |
1317 | |
1318 | |
1319 | |
1320 | |
1321 | |
1322 | |
1323 | |
1324 | bool isNRVOVariable() const { |
1325 | return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.NRVOVariable; |
1326 | } |
1327 | void setNRVOVariable(bool NRVO) { |
1328 | (this)", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1328, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<ParmVarDecl>(this)); |
1329 | NonParmVarDeclBits.NRVOVariable = NRVO; |
1330 | } |
1331 | |
1332 | |
1333 | |
1334 | bool isCXXForRangeDecl() const { |
1335 | return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.CXXForRangeDecl; |
1336 | } |
1337 | void setCXXForRangeDecl(bool FRD) { |
1338 | (this)", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1338, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<ParmVarDecl>(this)); |
1339 | NonParmVarDeclBits.CXXForRangeDecl = FRD; |
1340 | } |
1341 | |
1342 | |
1343 | |
1344 | bool isObjCForDecl() const { |
1345 | return NonParmVarDeclBits.ObjCForDecl; |
1346 | } |
1347 | |
1348 | void setObjCForDecl(bool FRD) { |
1349 | NonParmVarDeclBits.ObjCForDecl = FRD; |
1350 | } |
1351 | |
1352 | |
1353 | |
1354 | |
1355 | |
1356 | |
1357 | |
1358 | |
1359 | bool isARCPseudoStrong() const { return VarDeclBits.ARCPseudoStrong; } |
1360 | void setARCPseudoStrong(bool PS) { VarDeclBits.ARCPseudoStrong = PS; } |
1361 | |
1362 | |
1363 | bool isInline() const { |
1364 | return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.IsInline; |
1365 | } |
1366 | bool isInlineSpecified() const { |
1367 | return isa<ParmVarDecl>(this) ? false |
1368 | : NonParmVarDeclBits.IsInlineSpecified; |
1369 | } |
1370 | void setInlineSpecified() { |
1371 | (this)", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1371, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<ParmVarDecl>(this)); |
1372 | NonParmVarDeclBits.IsInline = true; |
1373 | NonParmVarDeclBits.IsInlineSpecified = true; |
1374 | } |
1375 | void setImplicitlyInline() { |
1376 | (this)", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1376, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<ParmVarDecl>(this)); |
1377 | NonParmVarDeclBits.IsInline = true; |
1378 | } |
1379 | |
1380 | |
1381 | bool isConstexpr() const { |
1382 | return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.IsConstexpr; |
1383 | } |
1384 | void setConstexpr(bool IC) { |
1385 | (this)", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1385, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<ParmVarDecl>(this)); |
1386 | NonParmVarDeclBits.IsConstexpr = IC; |
1387 | } |
1388 | |
1389 | |
1390 | bool isInitCapture() const { |
1391 | return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.IsInitCapture; |
1392 | } |
1393 | void setInitCapture(bool IC) { |
1394 | (this)", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1394, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<ParmVarDecl>(this)); |
1395 | NonParmVarDeclBits.IsInitCapture = IC; |
1396 | } |
1397 | |
1398 | |
1399 | |
1400 | bool isPreviousDeclInSameBlockScope() const { |
1401 | return isa<ParmVarDecl>(this) |
1402 | ? false |
1403 | : NonParmVarDeclBits.PreviousDeclInSameBlockScope; |
1404 | } |
1405 | void setPreviousDeclInSameBlockScope(bool Same) { |
1406 | (this)", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1406, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<ParmVarDecl>(this)); |
1407 | NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same; |
1408 | } |
1409 | |
1410 | |
1411 | |
1412 | |
1413 | bool isEscapingByref() const; |
1414 | |
1415 | |
1416 | |
1417 | bool isNonEscapingByref() const; |
1418 | |
1419 | void setEscapingByref() { |
1420 | NonParmVarDeclBits.EscapingByref = true; |
1421 | } |
1422 | |
1423 | |
1424 | |
1425 | VarDecl *getTemplateInstantiationPattern() const; |
1426 | |
1427 | |
1428 | |
1429 | |
1430 | VarDecl *getInstantiatedFromStaticDataMember() const; |
1431 | |
1432 | |
1433 | |
1434 | |
1435 | TemplateSpecializationKind getTemplateSpecializationKind() const; |
1436 | |
1437 | |
1438 | |
1439 | |
1440 | SourceLocation getPointOfInstantiation() const; |
1441 | |
1442 | |
1443 | |
1444 | |
1445 | MemberSpecializationInfo *getMemberSpecializationInfo() const; |
1446 | |
1447 | |
1448 | |
1449 | void setTemplateSpecializationKind(TemplateSpecializationKind TSK, |
1450 | SourceLocation PointOfInstantiation = SourceLocation()); |
1451 | |
1452 | |
1453 | |
1454 | void setInstantiationOfStaticDataMember(VarDecl *VD, |
1455 | TemplateSpecializationKind TSK); |
1456 | |
1457 | |
1458 | |
1459 | |
1460 | |
1461 | |
1462 | |
1463 | |
1464 | |
1465 | |
1466 | |
1467 | |
1468 | VarTemplateDecl *getDescribedVarTemplate() const; |
1469 | |
1470 | void setDescribedVarTemplate(VarTemplateDecl *Template); |
1471 | |
1472 | |
1473 | |
1474 | |
1475 | bool isKnownToBeDefined() const; |
1476 | |
1477 | |
1478 | bool isNoDestroy(const ASTContext &) const; |
1479 | |
1480 | |
1481 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
1482 | static bool classofKind(Kind K) { return K >= firstVar && K <= lastVar; } |
1483 | }; |
1484 | |
1485 | class ImplicitParamDecl : public VarDecl { |
1486 | void anchor() override; |
1487 | |
1488 | public: |
1489 | |
1490 | |
1491 | |
1492 | enum ImplicitParamKind : unsigned { |
1493 | |
1494 | ObjCSelf, |
1495 | |
1496 | |
1497 | ObjCCmd, |
1498 | |
1499 | |
1500 | CXXThis, |
1501 | |
1502 | |
1503 | CXXVTT, |
1504 | |
1505 | |
1506 | CapturedContext, |
1507 | |
1508 | |
1509 | Other, |
1510 | }; |
1511 | |
1512 | |
1513 | static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC, |
1514 | SourceLocation IdLoc, IdentifierInfo *Id, |
1515 | QualType T, ImplicitParamKind ParamKind); |
1516 | static ImplicitParamDecl *Create(ASTContext &C, QualType T, |
1517 | ImplicitParamKind ParamKind); |
1518 | |
1519 | static ImplicitParamDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
1520 | |
1521 | ImplicitParamDecl(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, |
1522 | IdentifierInfo *Id, QualType Type, |
1523 | ImplicitParamKind ParamKind) |
1524 | : VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type, |
1525 | , SC_None) { |
1526 | NonParmVarDeclBits.ImplicitParamKind = ParamKind; |
1527 | setImplicit(); |
1528 | } |
1529 | |
1530 | ImplicitParamDecl(ASTContext &C, QualType Type, ImplicitParamKind ParamKind) |
1531 | : VarDecl(ImplicitParam, C, , SourceLocation(), |
1532 | SourceLocation(), , Type, |
1533 | , SC_None) { |
1534 | NonParmVarDeclBits.ImplicitParamKind = ParamKind; |
1535 | setImplicit(); |
1536 | } |
1537 | |
1538 | |
1539 | ImplicitParamKind getParameterKind() const { |
1540 | return static_cast<ImplicitParamKind>(NonParmVarDeclBits.ImplicitParamKind); |
1541 | } |
1542 | |
1543 | |
1544 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
1545 | static bool classofKind(Kind K) { return K == ImplicitParam; } |
1546 | }; |
1547 | |
1548 | |
1549 | class ParmVarDecl : public VarDecl { |
1550 | public: |
1551 | enum { MaxFunctionScopeDepth = 255 }; |
1552 | enum { MaxFunctionScopeIndex = 255 }; |
1553 | |
1554 | protected: |
1555 | ParmVarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, |
1556 | SourceLocation IdLoc, IdentifierInfo *Id, QualType T, |
1557 | TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg) |
1558 | : VarDecl(DK, C, DC, StartLoc, IdLoc, Id, T, TInfo, S) { |
1559 | assert(ParmVarDeclBits.HasInheritedDefaultArg == false); |
1560 | assert(ParmVarDeclBits.DefaultArgKind == DAK_None); |
1561 | assert(ParmVarDeclBits.IsKNRPromoted == false); |
1562 | assert(ParmVarDeclBits.IsObjCMethodParam == false); |
1563 | setDefaultArg(DefArg); |
1564 | } |
1565 | |
1566 | public: |
1567 | static ParmVarDecl *Create(ASTContext &C, DeclContext *DC, |
1568 | SourceLocation StartLoc, |
1569 | SourceLocation IdLoc, IdentifierInfo *Id, |
1570 | QualType T, TypeSourceInfo *TInfo, |
1571 | StorageClass S, Expr *DefArg); |
1572 | |
1573 | static ParmVarDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
1574 | |
1575 | SourceRange getSourceRange() const override LLVM_READONLY; |
1576 | |
1577 | void setObjCMethodScopeInfo(unsigned parameterIndex) { |
1578 | ParmVarDeclBits.IsObjCMethodParam = true; |
1579 | setParameterIndex(parameterIndex); |
1580 | } |
1581 | |
1582 | void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex) { |
1583 | assert(!ParmVarDeclBits.IsObjCMethodParam); |
1584 | |
1585 | ParmVarDeclBits.ScopeDepthOrObjCQuals = scopeDepth; |
1586 | (0) . __assert_fail ("ParmVarDeclBits.ScopeDepthOrObjCQuals == scopeDepth && \"truncation!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1587, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(ParmVarDeclBits.ScopeDepthOrObjCQuals == scopeDepth |
1587 | (0) . __assert_fail ("ParmVarDeclBits.ScopeDepthOrObjCQuals == scopeDepth && \"truncation!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1587, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> && "truncation!"); |
1588 | |
1589 | setParameterIndex(parameterIndex); |
1590 | } |
1591 | |
1592 | bool isObjCMethodParameter() const { |
1593 | return ParmVarDeclBits.IsObjCMethodParam; |
1594 | } |
1595 | |
1596 | unsigned getFunctionScopeDepth() const { |
1597 | if (ParmVarDeclBits.IsObjCMethodParam) return 0; |
1598 | return ParmVarDeclBits.ScopeDepthOrObjCQuals; |
1599 | } |
1600 | |
1601 | |
1602 | unsigned getFunctionScopeIndex() const { |
1603 | return getParameterIndex(); |
1604 | } |
1605 | |
1606 | ObjCDeclQualifier getObjCDeclQualifier() const { |
1607 | if (!ParmVarDeclBits.IsObjCMethodParam) return OBJC_TQ_None; |
1608 | return ObjCDeclQualifier(ParmVarDeclBits.ScopeDepthOrObjCQuals); |
1609 | } |
1610 | void setObjCDeclQualifier(ObjCDeclQualifier QTVal) { |
1611 | assert(ParmVarDeclBits.IsObjCMethodParam); |
1612 | ParmVarDeclBits.ScopeDepthOrObjCQuals = QTVal; |
1613 | } |
1614 | |
1615 | |
1616 | |
1617 | |
1618 | |
1619 | |
1620 | |
1621 | |
1622 | |
1623 | bool isKNRPromoted() const { |
1624 | return ParmVarDeclBits.IsKNRPromoted; |
1625 | } |
1626 | void setKNRPromoted(bool promoted) { |
1627 | ParmVarDeclBits.IsKNRPromoted = promoted; |
1628 | } |
1629 | |
1630 | Expr *getDefaultArg(); |
1631 | const Expr *getDefaultArg() const { |
1632 | return const_cast<ParmVarDecl *>(this)->getDefaultArg(); |
1633 | } |
1634 | |
1635 | void setDefaultArg(Expr *defarg); |
1636 | |
1637 | |
1638 | |
1639 | SourceRange getDefaultArgRange() const; |
1640 | void setUninstantiatedDefaultArg(Expr *arg); |
1641 | Expr *getUninstantiatedDefaultArg(); |
1642 | const Expr *getUninstantiatedDefaultArg() const { |
1643 | return const_cast<ParmVarDecl *>(this)->getUninstantiatedDefaultArg(); |
1644 | } |
1645 | |
1646 | |
1647 | |
1648 | bool hasDefaultArg() const; |
1649 | |
1650 | |
1651 | |
1652 | |
1653 | |
1654 | |
1655 | |
1656 | |
1657 | |
1658 | |
1659 | bool hasUnparsedDefaultArg() const { |
1660 | return ParmVarDeclBits.DefaultArgKind == DAK_Unparsed; |
1661 | } |
1662 | |
1663 | bool hasUninstantiatedDefaultArg() const { |
1664 | return ParmVarDeclBits.DefaultArgKind == DAK_Uninstantiated; |
1665 | } |
1666 | |
1667 | |
1668 | |
1669 | |
1670 | |
1671 | void setUnparsedDefaultArg() { |
1672 | ParmVarDeclBits.DefaultArgKind = DAK_Unparsed; |
1673 | } |
1674 | |
1675 | bool hasInheritedDefaultArg() const { |
1676 | return ParmVarDeclBits.HasInheritedDefaultArg; |
1677 | } |
1678 | |
1679 | void setHasInheritedDefaultArg(bool I = true) { |
1680 | ParmVarDeclBits.HasInheritedDefaultArg = I; |
1681 | } |
1682 | |
1683 | QualType getOriginalType() const; |
1684 | |
1685 | |
1686 | |
1687 | bool isParameterPack() const; |
1688 | |
1689 | |
1690 | |
1691 | |
1692 | |
1693 | void setOwningFunction(DeclContext *FD) { setDeclContext(FD); } |
1694 | |
1695 | |
1696 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
1697 | static bool classofKind(Kind K) { return K == ParmVar; } |
1698 | |
1699 | private: |
1700 | enum { ParameterIndexSentinel = (1 << NumParameterIndexBits) - 1 }; |
1701 | |
1702 | void setParameterIndex(unsigned parameterIndex) { |
1703 | if (parameterIndex >= ParameterIndexSentinel) { |
1704 | setParameterIndexLarge(parameterIndex); |
1705 | return; |
1706 | } |
1707 | |
1708 | ParmVarDeclBits.ParameterIndex = parameterIndex; |
1709 | (0) . __assert_fail ("ParmVarDeclBits.ParameterIndex == parameterIndex && \"truncation!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 1709, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(ParmVarDeclBits.ParameterIndex == parameterIndex && "truncation!"); |
1710 | } |
1711 | unsigned getParameterIndex() const { |
1712 | unsigned d = ParmVarDeclBits.ParameterIndex; |
1713 | return d == ParameterIndexSentinel ? getParameterIndexLarge() : d; |
1714 | } |
1715 | |
1716 | void setParameterIndexLarge(unsigned parameterIndex); |
1717 | unsigned getParameterIndexLarge() const; |
1718 | }; |
1719 | |
1720 | enum class MultiVersionKind { |
1721 | None, |
1722 | Target, |
1723 | CPUSpecific, |
1724 | CPUDispatch |
1725 | }; |
1726 | |
1727 | |
1728 | |
1729 | |
1730 | |
1731 | |
1732 | |
1733 | |
1734 | |
1735 | |
1736 | |
1737 | class FunctionDecl : public DeclaratorDecl, |
1738 | public DeclContext, |
1739 | public Redeclarable<FunctionDecl> { |
1740 | |
1741 | |
1742 | public: |
1743 | |
1744 | enum TemplatedKind { |
1745 | TK_NonTemplate, |
1746 | TK_FunctionTemplate, |
1747 | TK_MemberSpecialization, |
1748 | TK_FunctionTemplateSpecialization, |
1749 | TK_DependentFunctionTemplateSpecialization |
1750 | }; |
1751 | |
1752 | private: |
1753 | |
1754 | |
1755 | |
1756 | ParmVarDecl **ParamInfo = nullptr; |
1757 | |
1758 | LazyDeclStmtPtr Body; |
1759 | |
1760 | unsigned ODRHash; |
1761 | |
1762 | |
1763 | |
1764 | |
1765 | |
1766 | |
1767 | |
1768 | |
1769 | SourceLocation EndRangeLoc; |
1770 | |
1771 | |
1772 | |
1773 | |
1774 | |
1775 | |
1776 | |
1777 | |
1778 | |
1779 | |
1780 | |
1781 | |
1782 | |
1783 | llvm::PointerUnion4<FunctionTemplateDecl *, |
1784 | MemberSpecializationInfo *, |
1785 | FunctionTemplateSpecializationInfo *, |
1786 | DependentFunctionTemplateSpecializationInfo *> |
1787 | TemplateOrSpecialization; |
1788 | |
1789 | |
1790 | |
1791 | DeclarationNameLoc DNLoc; |
1792 | |
1793 | |
1794 | |
1795 | |
1796 | |
1797 | |
1798 | |
1799 | |
1800 | |
1801 | |
1802 | |
1803 | |
1804 | |
1805 | |
1806 | |
1807 | |
1808 | |
1809 | |
1810 | |
1811 | |
1812 | |
1813 | |
1814 | void setFunctionTemplateSpecialization(ASTContext &C, |
1815 | FunctionTemplateDecl *Template, |
1816 | const TemplateArgumentList *TemplateArgs, |
1817 | void *InsertPos, |
1818 | TemplateSpecializationKind TSK, |
1819 | const TemplateArgumentListInfo *TemplateArgsAsWritten, |
1820 | SourceLocation PointOfInstantiation); |
1821 | |
1822 | |
1823 | |
1824 | void setInstantiationOfMemberFunction(ASTContext &C, FunctionDecl *FD, |
1825 | TemplateSpecializationKind TSK); |
1826 | |
1827 | void setParams(ASTContext &C, ArrayRef<ParmVarDecl *> NewParamInfo); |
1828 | |
1829 | |
1830 | |
1831 | |
1832 | bool isDeletedBit() const { return FunctionDeclBits.IsDeleted; } |
1833 | |
1834 | |
1835 | bool hasODRHash() const { return FunctionDeclBits.HasODRHash; } |
1836 | |
1837 | |
1838 | void setHasODRHash(bool B = true) { FunctionDeclBits.HasODRHash = B; } |
1839 | |
1840 | protected: |
1841 | FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, |
1842 | const DeclarationNameInfo &NameInfo, QualType T, |
1843 | TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified, |
1844 | bool isConstexprSpecified); |
1845 | |
1846 | using redeclarable_base = Redeclarable<FunctionDecl>; |
1847 | |
1848 | FunctionDecl *getNextRedeclarationImpl() override { |
1849 | return getNextRedeclaration(); |
1850 | } |
1851 | |
1852 | FunctionDecl *getPreviousDeclImpl() override { |
1853 | return getPreviousDecl(); |
1854 | } |
1855 | |
1856 | FunctionDecl *getMostRecentDeclImpl() override { |
1857 | return getMostRecentDecl(); |
1858 | } |
1859 | |
1860 | public: |
1861 | friend class ASTDeclReader; |
1862 | friend class ASTDeclWriter; |
1863 | |
1864 | using redecl_range = redeclarable_base::redecl_range; |
1865 | using redecl_iterator = redeclarable_base::redecl_iterator; |
1866 | |
1867 | using redeclarable_base::redecls_begin; |
1868 | using redeclarable_base::redecls_end; |
1869 | using redeclarable_base::redecls; |
1870 | using redeclarable_base::getPreviousDecl; |
1871 | using redeclarable_base::getMostRecentDecl; |
1872 | using redeclarable_base::isFirstDecl; |
1873 | |
1874 | static FunctionDecl *Create(ASTContext &C, DeclContext *DC, |
1875 | SourceLocation StartLoc, SourceLocation NLoc, |
1876 | DeclarationName N, QualType T, |
1877 | TypeSourceInfo *TInfo, |
1878 | StorageClass SC, |
1879 | bool isInlineSpecified = false, |
1880 | bool hasWrittenPrototype = true, |
1881 | bool isConstexprSpecified = false) { |
1882 | DeclarationNameInfo NameInfo(N, NLoc); |
1883 | return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo, |
1884 | SC, |
1885 | isInlineSpecified, hasWrittenPrototype, |
1886 | isConstexprSpecified); |
1887 | } |
1888 | |
1889 | static FunctionDecl *Create(ASTContext &C, DeclContext *DC, |
1890 | SourceLocation StartLoc, |
1891 | const DeclarationNameInfo &NameInfo, |
1892 | QualType T, TypeSourceInfo *TInfo, |
1893 | StorageClass SC, |
1894 | bool isInlineSpecified, |
1895 | bool hasWrittenPrototype, |
1896 | bool isConstexprSpecified = false); |
1897 | |
1898 | static FunctionDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
1899 | |
1900 | DeclarationNameInfo getNameInfo() const { |
1901 | return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc); |
1902 | } |
1903 | |
1904 | void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, |
1905 | bool Qualified) const override; |
1906 | |
1907 | void setRangeEnd(SourceLocation E) { EndRangeLoc = E; } |
1908 | |
1909 | SourceRange getSourceRange() const override LLVM_READONLY; |
1910 | |
1911 | |
1912 | |
1913 | |
1914 | |
1915 | |
1916 | |
1917 | |
1918 | |
1919 | |
1920 | |
1921 | |
1922 | |
1923 | |
1924 | |
1925 | |
1926 | |
1927 | |
1928 | |
1929 | |
1930 | bool hasBody(const FunctionDecl *&Definition) const; |
1931 | |
1932 | bool hasBody() const override { |
1933 | const FunctionDecl* Definition; |
1934 | return hasBody(Definition); |
1935 | } |
1936 | |
1937 | |
1938 | |
1939 | bool hasTrivialBody() const; |
1940 | |
1941 | |
1942 | |
1943 | |
1944 | |
1945 | |
1946 | bool isDefined(const FunctionDecl *&Definition) const; |
1947 | |
1948 | virtual bool isDefined() const { |
1949 | const FunctionDecl* Definition; |
1950 | return isDefined(Definition); |
1951 | } |
1952 | |
1953 | |
1954 | FunctionDecl *getDefinition() { |
1955 | const FunctionDecl *Definition; |
1956 | if (isDefined(Definition)) |
1957 | return const_cast<FunctionDecl *>(Definition); |
1958 | return nullptr; |
1959 | } |
1960 | const FunctionDecl *getDefinition() const { |
1961 | return const_cast<FunctionDecl *>(this)->getDefinition(); |
1962 | } |
1963 | |
1964 | |
1965 | |
1966 | |
1967 | |
1968 | |
1969 | |
1970 | Stmt *getBody(const FunctionDecl *&Definition) const; |
1971 | |
1972 | Stmt *getBody() const override { |
1973 | const FunctionDecl* Definition; |
1974 | return getBody(Definition); |
1975 | } |
1976 | |
1977 | |
1978 | |
1979 | |
1980 | |
1981 | |
1982 | bool isThisDeclarationADefinition() const { |
1983 | return isDeletedAsWritten() || isDefaulted() || Body || hasSkippedBody() || |
1984 | isLateTemplateParsed() || willHaveBody() || hasDefiningAttr(); |
1985 | } |
1986 | |
1987 | |
1988 | bool doesThisDeclarationHaveABody() const { |
1989 | return Body || isLateTemplateParsed(); |
1990 | } |
1991 | |
1992 | void setBody(Stmt *B); |
1993 | void setLazyBody(uint64_t Offset) { Body = Offset; } |
1994 | |
1995 | |
1996 | bool isVariadic() const; |
1997 | |
1998 | |
1999 | bool isVirtualAsWritten() const { |
2000 | return FunctionDeclBits.IsVirtualAsWritten; |
2001 | } |
2002 | |
2003 | |
2004 | void setVirtualAsWritten(bool V) { FunctionDeclBits.IsVirtualAsWritten = V; } |
2005 | |
2006 | |
2007 | |
2008 | bool isPure() const { return FunctionDeclBits.IsPure; } |
2009 | void setPure(bool P = true); |
2010 | |
2011 | |
2012 | bool isLateTemplateParsed() const { |
2013 | return FunctionDeclBits.IsLateTemplateParsed; |
2014 | } |
2015 | |
2016 | |
2017 | void setLateTemplateParsed(bool ILT = true) { |
2018 | FunctionDeclBits.IsLateTemplateParsed = ILT; |
2019 | } |
2020 | |
2021 | |
2022 | |
2023 | |
2024 | |
2025 | bool isTrivial() const { return FunctionDeclBits.IsTrivial; } |
2026 | void setTrivial(bool IT) { FunctionDeclBits.IsTrivial = IT; } |
2027 | |
2028 | bool isTrivialForCall() const { return FunctionDeclBits.IsTrivialForCall; } |
2029 | void setTrivialForCall(bool IT) { FunctionDeclBits.IsTrivialForCall = IT; } |
2030 | |
2031 | |
2032 | |
2033 | bool isDefaulted() const { return FunctionDeclBits.IsDefaulted; } |
2034 | void setDefaulted(bool D = true) { FunctionDeclBits.IsDefaulted = D; } |
2035 | |
2036 | |
2037 | |
2038 | bool isExplicitlyDefaulted() const { |
2039 | return FunctionDeclBits.IsExplicitlyDefaulted; |
2040 | } |
2041 | |
2042 | |
2043 | |
2044 | void setExplicitlyDefaulted(bool ED = true) { |
2045 | FunctionDeclBits.IsExplicitlyDefaulted = ED; |
2046 | } |
2047 | |
2048 | |
2049 | |
2050 | |
2051 | bool hasImplicitReturnZero() const { |
2052 | return FunctionDeclBits.HasImplicitReturnZero; |
2053 | } |
2054 | |
2055 | |
2056 | |
2057 | |
2058 | void setHasImplicitReturnZero(bool IRZ) { |
2059 | FunctionDeclBits.HasImplicitReturnZero = IRZ; |
2060 | } |
2061 | |
2062 | |
2063 | |
2064 | |
2065 | |
2066 | bool hasPrototype() const { |
2067 | return hasWrittenPrototype() || hasInheritedPrototype(); |
2068 | } |
2069 | |
2070 | |
2071 | bool hasWrittenPrototype() const { |
2072 | return FunctionDeclBits.HasWrittenPrototype; |
2073 | } |
2074 | |
2075 | |
2076 | void setHasWrittenPrototype(bool P = true) { |
2077 | FunctionDeclBits.HasWrittenPrototype = P; |
2078 | } |
2079 | |
2080 | |
2081 | |
2082 | bool hasInheritedPrototype() const { |
2083 | return FunctionDeclBits.HasInheritedPrototype; |
2084 | } |
2085 | |
2086 | |
2087 | |
2088 | void setHasInheritedPrototype(bool P = true) { |
2089 | FunctionDeclBits.HasInheritedPrototype = P; |
2090 | } |
2091 | |
2092 | |
2093 | bool isConstexpr() const { return FunctionDeclBits.IsConstexpr; } |
2094 | void setConstexpr(bool IC) { FunctionDeclBits.IsConstexpr = IC; } |
2095 | |
2096 | |
2097 | |
2098 | |
2099 | |
2100 | |
2101 | |
2102 | bool instantiationIsPending() const { |
2103 | return FunctionDeclBits.InstantiationIsPending; |
2104 | } |
2105 | |
2106 | |
2107 | |
2108 | void setInstantiationIsPending(bool IC) { |
2109 | FunctionDeclBits.InstantiationIsPending = IC; |
2110 | } |
2111 | |
2112 | |
2113 | bool usesSEHTry() const { return FunctionDeclBits.UsesSEHTry; } |
2114 | void setUsesSEHTry(bool UST) { FunctionDeclBits.UsesSEHTry = UST; } |
2115 | |
2116 | |
2117 | |
2118 | |
2119 | |
2120 | |
2121 | |
2122 | |
2123 | |
2124 | |
2125 | |
2126 | |
2127 | |
2128 | |
2129 | |
2130 | |
2131 | |
2132 | |
2133 | |
2134 | |
2135 | bool isDeleted() const { |
2136 | return getCanonicalDecl()->FunctionDeclBits.IsDeleted; |
2137 | } |
2138 | |
2139 | bool isDeletedAsWritten() const { |
2140 | return FunctionDeclBits.IsDeleted && !isDefaulted(); |
2141 | } |
2142 | |
2143 | void setDeletedAsWritten(bool D = true) { FunctionDeclBits.IsDeleted = D; } |
2144 | |
2145 | |
2146 | |
2147 | bool isMain() const; |
2148 | |
2149 | |
2150 | |
2151 | bool isMSVCRTEntryPoint() const; |
2152 | |
2153 | |
2154 | |
2155 | |
2156 | |
2157 | |
2158 | |
2159 | |
2160 | |
2161 | |
2162 | |
2163 | |
2164 | |
2165 | |
2166 | bool isReservedGlobalPlacementOperator() const; |
2167 | |
2168 | |
2169 | |
2170 | |
2171 | |
2172 | |
2173 | |
2174 | |
2175 | |
2176 | |
2177 | |
2178 | |
2179 | |
2180 | |
2181 | |
2182 | |
2183 | |
2184 | |
2185 | |
2186 | bool isReplaceableGlobalAllocationFunction(bool *IsAligned = nullptr) const; |
2187 | |
2188 | |
2189 | bool isDestroyingOperatorDelete() const; |
2190 | |
2191 | |
2192 | LanguageLinkage getLanguageLinkage() const; |
2193 | |
2194 | |
2195 | |
2196 | bool isExternC() const; |
2197 | |
2198 | |
2199 | |
2200 | bool isInExternCContext() const; |
2201 | |
2202 | |
2203 | |
2204 | bool isInExternCXXContext() const; |
2205 | |
2206 | |
2207 | bool isGlobal() const; |
2208 | |
2209 | |
2210 | |
2211 | bool isNoReturn() const; |
2212 | |
2213 | |
2214 | bool hasSkippedBody() const { return FunctionDeclBits.HasSkippedBody; } |
2215 | void setHasSkippedBody(bool Skipped = true) { |
2216 | FunctionDeclBits.HasSkippedBody = Skipped; |
2217 | } |
2218 | |
2219 | |
2220 | bool willHaveBody() const { return FunctionDeclBits.WillHaveBody; } |
2221 | void setWillHaveBody(bool V = true) { FunctionDeclBits.WillHaveBody = V; } |
2222 | |
2223 | |
2224 | bool isMultiVersion() const { |
2225 | return getCanonicalDecl()->FunctionDeclBits.IsMultiVersion; |
2226 | } |
2227 | |
2228 | |
2229 | |
2230 | void setIsMultiVersion(bool V = true) { |
2231 | getCanonicalDecl()->FunctionDeclBits.IsMultiVersion = V; |
2232 | } |
2233 | |
2234 | |
2235 | |
2236 | |
2237 | MultiVersionKind getMultiVersionKind() const; |
2238 | |
2239 | |
2240 | |
2241 | |
2242 | bool isCPUDispatchMultiVersion() const; |
2243 | |
2244 | |
2245 | bool isCPUSpecificMultiVersion() const; |
2246 | |
2247 | |
2248 | |
2249 | bool isTargetMultiVersion() const; |
2250 | |
2251 | void setPreviousDeclaration(FunctionDecl * PrevDecl); |
2252 | |
2253 | FunctionDecl *getCanonicalDecl() override; |
2254 | const FunctionDecl *getCanonicalDecl() const { |
2255 | return const_cast<FunctionDecl*>(this)->getCanonicalDecl(); |
2256 | } |
2257 | |
2258 | unsigned getBuiltinID(bool ConsiderWrapperFunctions = false) const; |
2259 | |
2260 | |
2261 | ArrayRef<ParmVarDecl *> parameters() const { |
2262 | return {ParamInfo, getNumParams()}; |
2263 | } |
2264 | MutableArrayRef<ParmVarDecl *> parameters() { |
2265 | return {ParamInfo, getNumParams()}; |
2266 | } |
2267 | |
2268 | |
2269 | using param_iterator = MutableArrayRef<ParmVarDecl *>::iterator; |
2270 | using param_const_iterator = ArrayRef<ParmVarDecl *>::const_iterator; |
2271 | |
2272 | bool param_empty() const { return parameters().empty(); } |
2273 | param_iterator param_begin() { return parameters().begin(); } |
2274 | param_iterator param_end() { return parameters().end(); } |
2275 | param_const_iterator param_begin() const { return parameters().begin(); } |
2276 | param_const_iterator param_end() const { return parameters().end(); } |
2277 | size_t param_size() const { return parameters().size(); } |
2278 | |
2279 | |
2280 | |
2281 | |
2282 | unsigned getNumParams() const; |
2283 | |
2284 | const ParmVarDecl *getParamDecl(unsigned i) const { |
2285 | (0) . __assert_fail ("i < getNumParams() && \"Illegal param #\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 2285, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(i < getNumParams() && "Illegal param #"); |
2286 | return ParamInfo[i]; |
2287 | } |
2288 | ParmVarDecl *getParamDecl(unsigned i) { |
2289 | (0) . __assert_fail ("i < getNumParams() && \"Illegal param #\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 2289, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(i < getNumParams() && "Illegal param #"); |
2290 | return ParamInfo[i]; |
2291 | } |
2292 | void setParams(ArrayRef<ParmVarDecl *> NewParamInfo) { |
2293 | setParams(getASTContext(), NewParamInfo); |
2294 | } |
2295 | |
2296 | |
2297 | |
2298 | |
2299 | unsigned getMinRequiredArguments() const; |
2300 | |
2301 | QualType getReturnType() const { |
2302 | return getType()->castAs<FunctionType>()->getReturnType(); |
2303 | } |
2304 | |
2305 | |
2306 | |
2307 | |
2308 | SourceRange getReturnTypeSourceRange() const; |
2309 | |
2310 | |
2311 | |
2312 | QualType getDeclaredReturnType() const { |
2313 | auto *TSI = getTypeSourceInfo(); |
2314 | QualType T = TSI ? TSI->getType() : getType(); |
2315 | return T->castAs<FunctionType>()->getReturnType(); |
2316 | } |
2317 | |
2318 | |
2319 | |
2320 | SourceRange getExceptionSpecSourceRange() const; |
2321 | |
2322 | |
2323 | QualType getCallResultType() const { |
2324 | return getType()->castAs<FunctionType>()->getCallResultType( |
2325 | getASTContext()); |
2326 | } |
2327 | |
2328 | |
2329 | |
2330 | StorageClass getStorageClass() const { |
2331 | return static_cast<StorageClass>(FunctionDeclBits.SClass); |
2332 | } |
2333 | |
2334 | |
2335 | void setStorageClass(StorageClass SClass) { |
2336 | FunctionDeclBits.SClass = SClass; |
2337 | } |
2338 | |
2339 | |
2340 | |
2341 | bool isInlineSpecified() const { return FunctionDeclBits.IsInlineSpecified; } |
2342 | |
2343 | |
2344 | void setInlineSpecified(bool I) { |
2345 | FunctionDeclBits.IsInlineSpecified = I; |
2346 | FunctionDeclBits.IsInline = I; |
2347 | } |
2348 | |
2349 | |
2350 | void setImplicitlyInline(bool I = true) { FunctionDeclBits.IsInline = I; } |
2351 | |
2352 | |
2353 | |
2354 | |
2355 | bool isInlined() const { return FunctionDeclBits.IsInline; } |
2356 | |
2357 | |
2358 | bool isExplicitSpecified() const { |
2359 | return FunctionDeclBits.IsExplicitSpecified; |
2360 | } |
2361 | |
2362 | |
2363 | void setExplicitSpecified(bool ExpSpec = true) { |
2364 | FunctionDeclBits.IsExplicitSpecified = ExpSpec; |
2365 | } |
2366 | |
2367 | bool isInlineDefinitionExternallyVisible() const; |
2368 | |
2369 | bool isMSExternInline() const; |
2370 | |
2371 | bool doesDeclarationForceExternallyVisibleDefinition() const; |
2372 | |
2373 | |
2374 | |
2375 | bool isOverloadedOperator() const { |
2376 | return getOverloadedOperator() != OO_None; |
2377 | } |
2378 | |
2379 | OverloadedOperatorKind getOverloadedOperator() const; |
2380 | |
2381 | const IdentifierInfo *getLiteralIdentifier() const; |
2382 | |
2383 | |
2384 | |
2385 | |
2386 | |
2387 | |
2388 | |
2389 | |
2390 | |
2391 | |
2392 | |
2393 | |
2394 | |
2395 | |
2396 | |
2397 | |
2398 | |
2399 | |
2400 | |
2401 | |
2402 | |
2403 | |
2404 | FunctionDecl *getInstantiatedFromMemberFunction() const; |
2405 | |
2406 | |
2407 | TemplatedKind getTemplatedKind() const; |
2408 | |
2409 | |
2410 | |
2411 | |
2412 | MemberSpecializationInfo *getMemberSpecializationInfo() const; |
2413 | |
2414 | |
2415 | |
2416 | void setInstantiationOfMemberFunction(FunctionDecl *FD, |
2417 | TemplateSpecializationKind TSK) { |
2418 | setInstantiationOfMemberFunction(getASTContext(), FD, TSK); |
2419 | } |
2420 | |
2421 | |
2422 | |
2423 | |
2424 | |
2425 | |
2426 | |
2427 | |
2428 | |
2429 | |
2430 | |
2431 | |
2432 | |
2433 | FunctionTemplateDecl *getDescribedFunctionTemplate() const; |
2434 | |
2435 | void setDescribedFunctionTemplate(FunctionTemplateDecl *Template); |
2436 | |
2437 | |
2438 | |
2439 | bool isFunctionTemplateSpecialization() const { |
2440 | return getPrimaryTemplate() != nullptr; |
2441 | } |
2442 | |
2443 | |
2444 | |
2445 | FunctionDecl *getClassScopeSpecializationPattern() const; |
2446 | |
2447 | |
2448 | |
2449 | |
2450 | FunctionTemplateSpecializationInfo *getTemplateSpecializationInfo() const; |
2451 | |
2452 | |
2453 | |
2454 | |
2455 | bool isImplicitlyInstantiable() const; |
2456 | |
2457 | |
2458 | |
2459 | bool isTemplateInstantiation() const; |
2460 | |
2461 | |
2462 | |
2463 | |
2464 | FunctionDecl *getTemplateInstantiationPattern() const; |
2465 | |
2466 | |
2467 | |
2468 | |
2469 | |
2470 | |
2471 | FunctionTemplateDecl *getPrimaryTemplate() const; |
2472 | |
2473 | |
2474 | |
2475 | |
2476 | |
2477 | |
2478 | const TemplateArgumentList *getTemplateSpecializationArgs() const; |
2479 | |
2480 | |
2481 | |
2482 | |
2483 | |
2484 | |
2485 | |
2486 | |
2487 | const ASTTemplateArgumentListInfo* |
2488 | getTemplateSpecializationArgsAsWritten() const; |
2489 | |
2490 | |
2491 | |
2492 | |
2493 | |
2494 | |
2495 | |
2496 | |
2497 | |
2498 | |
2499 | |
2500 | |
2501 | |
2502 | |
2503 | |
2504 | |
2505 | |
2506 | |
2507 | |
2508 | |
2509 | void setFunctionTemplateSpecialization(FunctionTemplateDecl *Template, |
2510 | const TemplateArgumentList *TemplateArgs, |
2511 | void *InsertPos, |
2512 | TemplateSpecializationKind TSK = TSK_ImplicitInstantiation, |
2513 | const TemplateArgumentListInfo *TemplateArgsAsWritten = nullptr, |
2514 | SourceLocation PointOfInstantiation = SourceLocation()) { |
2515 | setFunctionTemplateSpecialization(getASTContext(), Template, TemplateArgs, |
2516 | InsertPos, TSK, TemplateArgsAsWritten, |
2517 | PointOfInstantiation); |
2518 | } |
2519 | |
2520 | |
2521 | |
2522 | void setDependentTemplateSpecialization(ASTContext &Context, |
2523 | const UnresolvedSetImpl &Templates, |
2524 | const TemplateArgumentListInfo &TemplateArgs); |
2525 | |
2526 | DependentFunctionTemplateSpecializationInfo * |
2527 | getDependentSpecializationInfo() const; |
2528 | |
2529 | |
2530 | |
2531 | TemplateSpecializationKind getTemplateSpecializationKind() const; |
2532 | |
2533 | |
2534 | |
2535 | void setTemplateSpecializationKind(TemplateSpecializationKind TSK, |
2536 | SourceLocation PointOfInstantiation = SourceLocation()); |
2537 | |
2538 | |
2539 | |
2540 | |
2541 | |
2542 | |
2543 | |
2544 | SourceLocation getPointOfInstantiation() const; |
2545 | |
2546 | |
2547 | |
2548 | bool isOutOfLine() const override; |
2549 | |
2550 | |
2551 | |
2552 | |
2553 | |
2554 | unsigned getMemoryFunctionKind() const; |
2555 | |
2556 | |
2557 | |
2558 | unsigned getODRHash(); |
2559 | |
2560 | |
2561 | |
2562 | unsigned getODRHash() const; |
2563 | |
2564 | |
2565 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
2566 | static bool classofKind(Kind K) { |
2567 | return K >= firstFunction && K <= lastFunction; |
2568 | } |
2569 | static DeclContext *castToDeclContext(const FunctionDecl *D) { |
2570 | return static_cast<DeclContext *>(const_cast<FunctionDecl*>(D)); |
2571 | } |
2572 | static FunctionDecl *castFromDeclContext(const DeclContext *DC) { |
2573 | return static_cast<FunctionDecl *>(const_cast<DeclContext*>(DC)); |
2574 | } |
2575 | }; |
2576 | |
2577 | |
2578 | class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> { |
2579 | unsigned BitField : 1; |
2580 | unsigned Mutable : 1; |
2581 | mutable unsigned CachedFieldIndex : 30; |
2582 | |
2583 | |
2584 | |
2585 | |
2586 | |
2587 | enum InitStorageKind { |
2588 | |
2589 | |
2590 | |
2591 | ISK_NoInit = (unsigned) ICIS_NoInit, |
2592 | |
2593 | |
2594 | |
2595 | ISK_InClassCopyInit = (unsigned) ICIS_CopyInit, |
2596 | |
2597 | |
2598 | |
2599 | ISK_InClassListInit = (unsigned) ICIS_ListInit, |
2600 | |
2601 | |
2602 | |
2603 | ISK_CapturedVLAType, |
2604 | }; |
2605 | |
2606 | |
2607 | |
2608 | struct InitAndBitWidth { |
2609 | Expr *Init; |
2610 | Expr *BitWidth; |
2611 | }; |
2612 | |
2613 | |
2614 | |
2615 | |
2616 | |
2617 | |
2618 | |
2619 | |
2620 | |
2621 | |
2622 | llvm::PointerIntPair<void *, 2, InitStorageKind> InitStorage; |
2623 | |
2624 | protected: |
2625 | FieldDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc, |
2626 | SourceLocation IdLoc, IdentifierInfo *Id, |
2627 | QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, |
2628 | InClassInitStyle InitStyle) |
2629 | : DeclaratorDecl(DK, DC, IdLoc, Id, T, TInfo, StartLoc), |
2630 | BitField(false), Mutable(Mutable), CachedFieldIndex(0), |
2631 | InitStorage(nullptr, (InitStorageKind) InitStyle) { |
2632 | if (BW) |
2633 | setBitWidth(BW); |
2634 | } |
2635 | |
2636 | public: |
2637 | friend class ASTDeclReader; |
2638 | friend class ASTDeclWriter; |
2639 | |
2640 | static FieldDecl *Create(const ASTContext &C, DeclContext *DC, |
2641 | SourceLocation StartLoc, SourceLocation IdLoc, |
2642 | IdentifierInfo *Id, QualType T, |
2643 | TypeSourceInfo *TInfo, Expr *BW, bool Mutable, |
2644 | InClassInitStyle InitStyle); |
2645 | |
2646 | static FieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
2647 | |
2648 | |
2649 | |
2650 | unsigned getFieldIndex() const; |
2651 | |
2652 | |
2653 | bool isMutable() const { return Mutable; } |
2654 | |
2655 | |
2656 | bool isBitField() const { return BitField; } |
2657 | |
2658 | |
2659 | bool isUnnamedBitfield() const { return isBitField() && !getDeclName(); } |
2660 | |
2661 | |
2662 | |
2663 | |
2664 | |
2665 | bool isAnonymousStructOrUnion() const; |
2666 | |
2667 | Expr *getBitWidth() const { |
2668 | if (!BitField) |
2669 | return nullptr; |
2670 | void *Ptr = InitStorage.getPointer(); |
2671 | if (getInClassInitStyle()) |
2672 | return static_cast<InitAndBitWidth*>(Ptr)->BitWidth; |
2673 | return static_cast<Expr*>(Ptr); |
2674 | } |
2675 | |
2676 | unsigned getBitWidthValue(const ASTContext &Ctx) const; |
2677 | |
2678 | |
2679 | |
2680 | void setBitWidth(Expr *Width) { |
2681 | (0) . __assert_fail ("!hasCapturedVLAType() && !BitField && \"bit width or captured type already set\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 2682, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!hasCapturedVLAType() && !BitField && |
2682 | (0) . __assert_fail ("!hasCapturedVLAType() && !BitField && \"bit width or captured type already set\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 2682, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "bit width or captured type already set"); |
2683 | (0) . __assert_fail ("Width && \"no bit width specified\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 2683, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Width && "no bit width specified"); |
2684 | InitStorage.setPointer( |
2685 | InitStorage.getInt() |
2686 | ? new (getASTContext()) |
2687 | InitAndBitWidth{getInClassInitializer(), Width} |
2688 | : static_cast<void*>(Width)); |
2689 | BitField = true; |
2690 | } |
2691 | |
2692 | |
2693 | |
2694 | void removeBitWidth() { |
2695 | (0) . __assert_fail ("isBitField() && \"no bitfield width to remove\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 2695, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isBitField() && "no bitfield width to remove"); |
2696 | InitStorage.setPointer(getInClassInitializer()); |
2697 | BitField = false; |
2698 | } |
2699 | |
2700 | |
2701 | |
2702 | |
2703 | bool isZeroLengthBitField(const ASTContext &Ctx) const; |
2704 | |
2705 | |
2706 | InClassInitStyle getInClassInitStyle() const { |
2707 | InitStorageKind storageKind = InitStorage.getInt(); |
2708 | return (storageKind == ISK_CapturedVLAType |
2709 | ? ICIS_NoInit : (InClassInitStyle) storageKind); |
2710 | } |
2711 | |
2712 | |
2713 | bool hasInClassInitializer() const { |
2714 | return getInClassInitStyle() != ICIS_NoInit; |
2715 | } |
2716 | |
2717 | |
2718 | |
2719 | |
2720 | Expr *getInClassInitializer() const { |
2721 | if (!hasInClassInitializer()) |
2722 | return nullptr; |
2723 | void *Ptr = InitStorage.getPointer(); |
2724 | if (BitField) |
2725 | return static_cast<InitAndBitWidth*>(Ptr)->Init; |
2726 | return static_cast<Expr*>(Ptr); |
2727 | } |
2728 | |
2729 | |
2730 | void setInClassInitializer(Expr *Init) { |
2731 | assert(hasInClassInitializer() && !getInClassInitializer()); |
2732 | if (BitField) |
2733 | static_cast<InitAndBitWidth*>(InitStorage.getPointer())->Init = Init; |
2734 | else |
2735 | InitStorage.setPointer(Init); |
2736 | } |
2737 | |
2738 | |
2739 | void removeInClassInitializer() { |
2740 | (0) . __assert_fail ("hasInClassInitializer() && \"no initializer to remove\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 2740, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(hasInClassInitializer() && "no initializer to remove"); |
2741 | InitStorage.setPointerAndInt(getBitWidth(), ISK_NoInit); |
2742 | } |
2743 | |
2744 | |
2745 | |
2746 | bool hasCapturedVLAType() const { |
2747 | return InitStorage.getInt() == ISK_CapturedVLAType; |
2748 | } |
2749 | |
2750 | |
2751 | const VariableArrayType *getCapturedVLAType() const { |
2752 | return hasCapturedVLAType() ? static_cast<const VariableArrayType *>( |
2753 | InitStorage.getPointer()) |
2754 | : nullptr; |
2755 | } |
2756 | |
2757 | |
2758 | void setCapturedVLAType(const VariableArrayType *VLAType); |
2759 | |
2760 | |
2761 | |
2762 | const RecordDecl *getParent() const { |
2763 | return cast<RecordDecl>(getDeclContext()); |
2764 | } |
2765 | |
2766 | RecordDecl *getParent() { |
2767 | return cast<RecordDecl>(getDeclContext()); |
2768 | } |
2769 | |
2770 | SourceRange getSourceRange() const override LLVM_READONLY; |
2771 | |
2772 | |
2773 | FieldDecl *getCanonicalDecl() override { return getFirstDecl(); } |
2774 | const FieldDecl *getCanonicalDecl() const { return getFirstDecl(); } |
2775 | |
2776 | |
2777 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
2778 | static bool classofKind(Kind K) { return K >= firstField && K <= lastField; } |
2779 | }; |
2780 | |
2781 | |
2782 | |
2783 | |
2784 | |
2785 | class EnumConstantDecl : public ValueDecl, public Mergeable<EnumConstantDecl> { |
2786 | Stmt *Init; |
2787 | llvm::APSInt Val; |
2788 | |
2789 | protected: |
2790 | EnumConstantDecl(DeclContext *DC, SourceLocation L, |
2791 | IdentifierInfo *Id, QualType T, Expr *E, |
2792 | const llvm::APSInt &V) |
2793 | : ValueDecl(EnumConstant, DC, L, Id, T), Init((Stmt*)E), Val(V) {} |
2794 | |
2795 | public: |
2796 | friend class StmtIteratorBase; |
2797 | |
2798 | static EnumConstantDecl *Create(ASTContext &C, EnumDecl *DC, |
2799 | SourceLocation L, IdentifierInfo *Id, |
2800 | QualType T, Expr *E, |
2801 | const llvm::APSInt &V); |
2802 | static EnumConstantDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
2803 | |
2804 | const Expr *getInitExpr() const { return (const Expr*) Init; } |
2805 | Expr *getInitExpr() { return (Expr*) Init; } |
2806 | const llvm::APSInt &getInitVal() const { return Val; } |
2807 | |
2808 | void setInitExpr(Expr *E) { Init = (Stmt*) E; } |
2809 | void setInitVal(const llvm::APSInt &V) { Val = V; } |
2810 | |
2811 | SourceRange getSourceRange() const override LLVM_READONLY; |
2812 | |
2813 | |
2814 | EnumConstantDecl *getCanonicalDecl() override { return getFirstDecl(); } |
2815 | const EnumConstantDecl *getCanonicalDecl() const { return getFirstDecl(); } |
2816 | |
2817 | |
2818 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
2819 | static bool classofKind(Kind K) { return K == EnumConstant; } |
2820 | }; |
2821 | |
2822 | |
2823 | |
2824 | class IndirectFieldDecl : public ValueDecl, |
2825 | public Mergeable<IndirectFieldDecl> { |
2826 | NamedDecl **Chaining; |
2827 | unsigned ChainingSize; |
2828 | |
2829 | IndirectFieldDecl(ASTContext &C, DeclContext *DC, SourceLocation L, |
2830 | DeclarationName N, QualType T, |
2831 | MutableArrayRef<NamedDecl *> CH); |
2832 | |
2833 | void anchor() override; |
2834 | |
2835 | public: |
2836 | friend class ASTDeclReader; |
2837 | |
2838 | static IndirectFieldDecl *Create(ASTContext &C, DeclContext *DC, |
2839 | SourceLocation L, IdentifierInfo *Id, |
2840 | QualType T, llvm::MutableArrayRef<NamedDecl *> CH); |
2841 | |
2842 | static IndirectFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
2843 | |
2844 | using chain_iterator = ArrayRef<NamedDecl *>::const_iterator; |
2845 | |
2846 | ArrayRef<NamedDecl *> chain() const { |
2847 | return llvm::makeArrayRef(Chaining, ChainingSize); |
2848 | } |
2849 | chain_iterator chain_begin() const { return chain().begin(); } |
2850 | chain_iterator chain_end() const { return chain().end(); } |
2851 | |
2852 | unsigned getChainingSize() const { return ChainingSize; } |
2853 | |
2854 | FieldDecl *getAnonField() const { |
2855 | = 2", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 2855, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(chain().size() >= 2); |
2856 | return cast<FieldDecl>(chain().back()); |
2857 | } |
2858 | |
2859 | VarDecl *getVarDecl() const { |
2860 | = 2", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 2860, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(chain().size() >= 2); |
2861 | return dyn_cast<VarDecl>(chain().front()); |
2862 | } |
2863 | |
2864 | IndirectFieldDecl *getCanonicalDecl() override { return getFirstDecl(); } |
2865 | const IndirectFieldDecl *getCanonicalDecl() const { return getFirstDecl(); } |
2866 | |
2867 | |
2868 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
2869 | static bool classofKind(Kind K) { return K == IndirectField; } |
2870 | }; |
2871 | |
2872 | |
2873 | class TypeDecl : public NamedDecl { |
2874 | friend class ASTContext; |
2875 | |
2876 | |
2877 | |
2878 | |
2879 | |
2880 | mutable const Type *TypeForDecl = nullptr; |
2881 | |
2882 | |
2883 | SourceLocation LocStart; |
2884 | |
2885 | void anchor() override; |
2886 | |
2887 | protected: |
2888 | TypeDecl(Kind DK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, |
2889 | SourceLocation StartL = SourceLocation()) |
2890 | : NamedDecl(DK, DC, L, Id), LocStart(StartL) {} |
2891 | |
2892 | public: |
2893 | |
2894 | |
2895 | |
2896 | |
2897 | const Type *getTypeForDecl() const { return TypeForDecl; } |
2898 | void setTypeForDecl(const Type *TD) { TypeForDecl = TD; } |
2899 | |
2900 | SourceLocation getBeginLoc() const LLVM_READONLY { return LocStart; } |
2901 | void setLocStart(SourceLocation L) { LocStart = L; } |
2902 | SourceRange getSourceRange() const override LLVM_READONLY { |
2903 | if (LocStart.isValid()) |
2904 | return SourceRange(LocStart, getLocation()); |
2905 | else |
2906 | return SourceRange(getLocation()); |
2907 | } |
2908 | |
2909 | |
2910 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
2911 | static bool classofKind(Kind K) { return K >= firstType && K <= lastType; } |
2912 | }; |
2913 | |
2914 | |
2915 | class TypedefNameDecl : public TypeDecl, public Redeclarable<TypedefNameDecl> { |
2916 | struct alignas(8) ModedTInfo { |
2917 | TypeSourceInfo *first; |
2918 | QualType second; |
2919 | }; |
2920 | |
2921 | |
2922 | |
2923 | mutable llvm::PointerIntPair< |
2924 | llvm::PointerUnion<TypeSourceInfo *, ModedTInfo *>, 2> |
2925 | MaybeModedTInfo; |
2926 | |
2927 | void anchor() override; |
2928 | |
2929 | protected: |
2930 | TypedefNameDecl(Kind DK, ASTContext &C, DeclContext *DC, |
2931 | SourceLocation StartLoc, SourceLocation IdLoc, |
2932 | IdentifierInfo *Id, TypeSourceInfo *TInfo) |
2933 | : TypeDecl(DK, DC, IdLoc, Id, StartLoc), redeclarable_base(C), |
2934 | MaybeModedTInfo(TInfo, 0) {} |
2935 | |
2936 | using redeclarable_base = Redeclarable<TypedefNameDecl>; |
2937 | |
2938 | TypedefNameDecl *getNextRedeclarationImpl() override { |
2939 | return getNextRedeclaration(); |
2940 | } |
2941 | |
2942 | TypedefNameDecl *getPreviousDeclImpl() override { |
2943 | return getPreviousDecl(); |
2944 | } |
2945 | |
2946 | TypedefNameDecl *getMostRecentDeclImpl() override { |
2947 | return getMostRecentDecl(); |
2948 | } |
2949 | |
2950 | public: |
2951 | using redecl_range = redeclarable_base::redecl_range; |
2952 | using redecl_iterator = redeclarable_base::redecl_iterator; |
2953 | |
2954 | using redeclarable_base::redecls_begin; |
2955 | using redeclarable_base::redecls_end; |
2956 | using redeclarable_base::redecls; |
2957 | using redeclarable_base::getPreviousDecl; |
2958 | using redeclarable_base::getMostRecentDecl; |
2959 | using redeclarable_base::isFirstDecl; |
2960 | |
2961 | bool isModed() const { |
2962 | return MaybeModedTInfo.getPointer().is<ModedTInfo *>(); |
2963 | } |
2964 | |
2965 | TypeSourceInfo *getTypeSourceInfo() const { |
2966 | return isModed() ? MaybeModedTInfo.getPointer().get<ModedTInfo *>()->first |
2967 | : MaybeModedTInfo.getPointer().get<TypeSourceInfo *>(); |
2968 | } |
2969 | |
2970 | QualType getUnderlyingType() const { |
2971 | return isModed() ? MaybeModedTInfo.getPointer().get<ModedTInfo *>()->second |
2972 | : MaybeModedTInfo.getPointer() |
2973 | .get<TypeSourceInfo *>() |
2974 | ->getType(); |
2975 | } |
2976 | |
2977 | void setTypeSourceInfo(TypeSourceInfo *newType) { |
2978 | MaybeModedTInfo.setPointer(newType); |
2979 | } |
2980 | |
2981 | void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy) { |
2982 | MaybeModedTInfo.setPointer(new (getASTContext(), 8) |
2983 | ModedTInfo({unmodedTSI, modedTy})); |
2984 | } |
2985 | |
2986 | |
2987 | TypedefNameDecl *getCanonicalDecl() override { return getFirstDecl(); } |
2988 | const TypedefNameDecl *getCanonicalDecl() const { return getFirstDecl(); } |
2989 | |
2990 | |
2991 | |
2992 | |
2993 | |
2994 | |
2995 | TagDecl *getAnonDeclWithTypedefName(bool AnyRedecl = false) const; |
2996 | |
2997 | |
2998 | |
2999 | bool isTransparentTag() const { |
3000 | if (MaybeModedTInfo.getInt()) |
3001 | return MaybeModedTInfo.getInt() & 0x2; |
3002 | return isTransparentTagSlow(); |
3003 | } |
3004 | |
3005 | |
3006 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
3007 | static bool classofKind(Kind K) { |
3008 | return K >= firstTypedefName && K <= lastTypedefName; |
3009 | } |
3010 | |
3011 | private: |
3012 | bool isTransparentTagSlow() const; |
3013 | }; |
3014 | |
3015 | |
3016 | |
3017 | class TypedefDecl : public TypedefNameDecl { |
3018 | TypedefDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, |
3019 | SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo) |
3020 | : TypedefNameDecl(Typedef, C, DC, StartLoc, IdLoc, Id, TInfo) {} |
3021 | |
3022 | public: |
3023 | static TypedefDecl *Create(ASTContext &C, DeclContext *DC, |
3024 | SourceLocation StartLoc, SourceLocation IdLoc, |
3025 | IdentifierInfo *Id, TypeSourceInfo *TInfo); |
3026 | static TypedefDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
3027 | |
3028 | SourceRange getSourceRange() const override LLVM_READONLY; |
3029 | |
3030 | |
3031 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
3032 | static bool classofKind(Kind K) { return K == Typedef; } |
3033 | }; |
3034 | |
3035 | |
3036 | |
3037 | class TypeAliasDecl : public TypedefNameDecl { |
3038 | |
3039 | TypeAliasTemplateDecl *Template; |
3040 | |
3041 | TypeAliasDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, |
3042 | SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo) |
3043 | : TypedefNameDecl(TypeAlias, C, DC, StartLoc, IdLoc, Id, TInfo), |
3044 | Template(nullptr) {} |
3045 | |
3046 | public: |
3047 | static TypeAliasDecl *Create(ASTContext &C, DeclContext *DC, |
3048 | SourceLocation StartLoc, SourceLocation IdLoc, |
3049 | IdentifierInfo *Id, TypeSourceInfo *TInfo); |
3050 | static TypeAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
3051 | |
3052 | SourceRange getSourceRange() const override LLVM_READONLY; |
3053 | |
3054 | TypeAliasTemplateDecl *getDescribedAliasTemplate() const { return Template; } |
3055 | void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT) { Template = TAT; } |
3056 | |
3057 | |
3058 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
3059 | static bool classofKind(Kind K) { return K == TypeAlias; } |
3060 | }; |
3061 | |
3062 | |
3063 | class TagDecl : public TypeDecl, |
3064 | public DeclContext, |
3065 | public Redeclarable<TagDecl> { |
3066 | |
3067 | |
3068 | public: |
3069 | |
3070 | using TagKind = TagTypeKind; |
3071 | |
3072 | private: |
3073 | SourceRange BraceRange; |
3074 | |
3075 | |
3076 | |
3077 | using ExtInfo = QualifierInfo; |
3078 | |
3079 | |
3080 | |
3081 | |
3082 | |
3083 | |
3084 | |
3085 | |
3086 | |
3087 | llvm::PointerUnion<TypedefNameDecl *, ExtInfo *> TypedefNameDeclOrQualifier; |
3088 | |
3089 | bool hasExtInfo() const { return TypedefNameDeclOrQualifier.is<ExtInfo *>(); } |
3090 | ExtInfo *getExtInfo() { return TypedefNameDeclOrQualifier.get<ExtInfo *>(); } |
3091 | const ExtInfo *getExtInfo() const { |
3092 | return TypedefNameDeclOrQualifier.get<ExtInfo *>(); |
3093 | } |
3094 | |
3095 | protected: |
3096 | TagDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC, |
3097 | SourceLocation L, IdentifierInfo *Id, TagDecl *PrevDecl, |
3098 | SourceLocation StartL); |
3099 | |
3100 | using redeclarable_base = Redeclarable<TagDecl>; |
3101 | |
3102 | TagDecl *getNextRedeclarationImpl() override { |
3103 | return getNextRedeclaration(); |
3104 | } |
3105 | |
3106 | TagDecl *getPreviousDeclImpl() override { |
3107 | return getPreviousDecl(); |
3108 | } |
3109 | |
3110 | TagDecl *getMostRecentDeclImpl() override { |
3111 | return getMostRecentDecl(); |
3112 | } |
3113 | |
3114 | |
3115 | |
3116 | |
3117 | void completeDefinition(); |
3118 | |
3119 | |
3120 | void setBeingDefined(bool V = true) { TagDeclBits.IsBeingDefined = V; } |
3121 | |
3122 | |
3123 | |
3124 | |
3125 | |
3126 | void setMayHaveOutOfDateDef(bool V = true) { |
3127 | TagDeclBits.MayHaveOutOfDateDef = V; |
3128 | } |
3129 | |
3130 | public: |
3131 | friend class ASTDeclReader; |
3132 | friend class ASTDeclWriter; |
3133 | |
3134 | using redecl_range = redeclarable_base::redecl_range; |
3135 | using redecl_iterator = redeclarable_base::redecl_iterator; |
3136 | |
3137 | using redeclarable_base::redecls_begin; |
3138 | using redeclarable_base::redecls_end; |
3139 | using redeclarable_base::redecls; |
3140 | using redeclarable_base::getPreviousDecl; |
3141 | using redeclarable_base::getMostRecentDecl; |
3142 | using redeclarable_base::isFirstDecl; |
3143 | |
3144 | SourceRange getBraceRange() const { return BraceRange; } |
3145 | void setBraceRange(SourceRange R) { BraceRange = R; } |
3146 | |
3147 | |
3148 | |
3149 | SourceLocation getInnerLocStart() const { return getBeginLoc(); } |
3150 | |
3151 | |
3152 | |
3153 | SourceLocation getOuterLocStart() const; |
3154 | SourceRange getSourceRange() const override LLVM_READONLY; |
3155 | |
3156 | TagDecl *getCanonicalDecl() override; |
3157 | const TagDecl *getCanonicalDecl() const { |
3158 | return const_cast<TagDecl*>(this)->getCanonicalDecl(); |
3159 | } |
3160 | |
3161 | |
3162 | |
3163 | bool isThisDeclarationADefinition() const { |
3164 | return isCompleteDefinition(); |
3165 | } |
3166 | |
3167 | |
3168 | bool isCompleteDefinition() const { return TagDeclBits.IsCompleteDefinition; } |
3169 | |
3170 | |
3171 | void setCompleteDefinition(bool V = true) { |
3172 | TagDeclBits.IsCompleteDefinition = V; |
3173 | } |
3174 | |
3175 | |
3176 | |
3177 | bool isCompleteDefinitionRequired() const { |
3178 | return TagDeclBits.IsCompleteDefinitionRequired; |
3179 | } |
3180 | |
3181 | |
3182 | |
3183 | void setCompleteDefinitionRequired(bool V = true) { |
3184 | TagDeclBits.IsCompleteDefinitionRequired = V; |
3185 | } |
3186 | |
3187 | |
3188 | bool isBeingDefined() const { return TagDeclBits.IsBeingDefined; } |
3189 | |
3190 | |
3191 | |
3192 | bool isEmbeddedInDeclarator() const { |
3193 | return TagDeclBits.IsEmbeddedInDeclarator; |
3194 | } |
3195 | |
3196 | |
3197 | |
3198 | void setEmbeddedInDeclarator(bool isInDeclarator) { |
3199 | TagDeclBits.IsEmbeddedInDeclarator = isInDeclarator; |
3200 | } |
3201 | |
3202 | |
3203 | bool isFreeStanding() const { return TagDeclBits.IsFreeStanding; } |
3204 | |
3205 | |
3206 | void setFreeStanding(bool isFreeStanding = true) { |
3207 | TagDeclBits.IsFreeStanding = isFreeStanding; |
3208 | } |
3209 | |
3210 | |
3211 | |
3212 | |
3213 | |
3214 | bool mayHaveOutOfDateDef() const { return TagDeclBits.MayHaveOutOfDateDef; } |
3215 | |
3216 | |
3217 | |
3218 | |
3219 | bool isDependentType() const { return isDependentContext(); } |
3220 | |
3221 | |
3222 | |
3223 | |
3224 | |
3225 | |
3226 | void startDefinition(); |
3227 | |
3228 | |
3229 | |
3230 | |
3231 | |
3232 | |
3233 | |
3234 | |
3235 | |
3236 | TagDecl *getDefinition() const; |
3237 | |
3238 | StringRef getKindName() const { |
3239 | return TypeWithKeyword::getTagTypeKindName(getTagKind()); |
3240 | } |
3241 | |
3242 | TagKind getTagKind() const { |
3243 | return static_cast<TagKind>(TagDeclBits.TagDeclKind); |
3244 | } |
3245 | |
3246 | void setTagKind(TagKind TK) { TagDeclBits.TagDeclKind = TK; } |
3247 | |
3248 | bool isStruct() const { return getTagKind() == TTK_Struct; } |
3249 | bool isInterface() const { return getTagKind() == TTK_Interface; } |
3250 | bool isClass() const { return getTagKind() == TTK_Class; } |
3251 | bool isUnion() const { return getTagKind() == TTK_Union; } |
3252 | bool isEnum() const { return getTagKind() == TTK_Enum; } |
3253 | |
3254 | |
3255 | |
3256 | |
3257 | |
3258 | |
3259 | |
3260 | |
3261 | |
3262 | |
3263 | |
3264 | |
3265 | |
3266 | |
3267 | |
3268 | |
3269 | bool hasNameForLinkage() const { |
3270 | return (getDeclName() || getTypedefNameForAnonDecl()); |
3271 | } |
3272 | |
3273 | TypedefNameDecl *getTypedefNameForAnonDecl() const { |
3274 | return hasExtInfo() ? nullptr |
3275 | : TypedefNameDeclOrQualifier.get<TypedefNameDecl *>(); |
3276 | } |
3277 | |
3278 | void setTypedefNameForAnonDecl(TypedefNameDecl *TDD); |
3279 | |
3280 | |
3281 | |
3282 | NestedNameSpecifier *getQualifier() const { |
3283 | return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier() |
3284 | : nullptr; |
3285 | } |
3286 | |
3287 | |
3288 | |
3289 | |
3290 | NestedNameSpecifierLoc getQualifierLoc() const { |
3291 | return hasExtInfo() ? getExtInfo()->QualifierLoc |
3292 | : NestedNameSpecifierLoc(); |
3293 | } |
3294 | |
3295 | void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc); |
3296 | |
3297 | unsigned getNumTemplateParameterLists() const { |
3298 | return hasExtInfo() ? getExtInfo()->NumTemplParamLists : 0; |
3299 | } |
3300 | |
3301 | TemplateParameterList *getTemplateParameterList(unsigned i) const { |
3302 | assert(i < getNumTemplateParameterLists()); |
3303 | return getExtInfo()->TemplParamLists[i]; |
3304 | } |
3305 | |
3306 | void setTemplateParameterListsInfo(ASTContext &Context, |
3307 | ArrayRef<TemplateParameterList *> TPLists); |
3308 | |
3309 | |
3310 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
3311 | static bool classofKind(Kind K) { return K >= firstTag && K <= lastTag; } |
3312 | |
3313 | static DeclContext *castToDeclContext(const TagDecl *D) { |
3314 | return static_cast<DeclContext *>(const_cast<TagDecl*>(D)); |
3315 | } |
3316 | |
3317 | static TagDecl *castFromDeclContext(const DeclContext *DC) { |
3318 | return static_cast<TagDecl *>(const_cast<DeclContext*>(DC)); |
3319 | } |
3320 | }; |
3321 | |
3322 | |
3323 | |
3324 | |
3325 | class EnumDecl : public TagDecl { |
3326 | |
3327 | |
3328 | |
3329 | |
3330 | |
3331 | |
3332 | |
3333 | |
3334 | |
3335 | |
3336 | |
3337 | |
3338 | |
3339 | |
3340 | |
3341 | |
3342 | |
3343 | llvm::PointerUnion<const Type *, TypeSourceInfo *> IntegerType; |
3344 | |
3345 | |
3346 | |
3347 | |
3348 | |
3349 | QualType PromotionType; |
3350 | |
3351 | |
3352 | |
3353 | |
3354 | MemberSpecializationInfo *SpecializationInfo = nullptr; |
3355 | |
3356 | |
3357 | |
3358 | |
3359 | unsigned ODRHash; |
3360 | |
3361 | EnumDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, |
3362 | SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, |
3363 | bool Scoped, bool ScopedUsingClassTag, bool Fixed); |
3364 | |
3365 | void anchor() override; |
3366 | |
3367 | void setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED, |
3368 | TemplateSpecializationKind TSK); |
3369 | |
3370 | |
3371 | |
3372 | void setNumPositiveBits(unsigned Num) { |
3373 | EnumDeclBits.NumPositiveBits = Num; |
3374 | (0) . __assert_fail ("EnumDeclBits.NumPositiveBits == Num && \"can't store this bitcount\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 3374, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(EnumDeclBits.NumPositiveBits == Num && "can't store this bitcount"); |
3375 | } |
3376 | |
3377 | |
3378 | |
3379 | void setNumNegativeBits(unsigned Num) { EnumDeclBits.NumNegativeBits = Num; } |
3380 | |
3381 | |
3382 | |
3383 | void setScoped(bool Scoped = true) { EnumDeclBits.IsScoped = Scoped; } |
3384 | |
3385 | |
3386 | |
3387 | |
3388 | |
3389 | void setScopedUsingClassTag(bool ScopedUCT = true) { |
3390 | EnumDeclBits.IsScopedUsingClassTag = ScopedUCT; |
3391 | } |
3392 | |
3393 | |
3394 | |
3395 | void setFixed(bool Fixed = true) { EnumDeclBits.IsFixed = Fixed; } |
3396 | |
3397 | |
3398 | bool hasODRHash() const { return EnumDeclBits.HasODRHash; } |
3399 | void setHasODRHash(bool Hash = true) { EnumDeclBits.HasODRHash = Hash; } |
3400 | |
3401 | public: |
3402 | friend class ASTDeclReader; |
3403 | |
3404 | EnumDecl *getCanonicalDecl() override { |
3405 | return cast<EnumDecl>(TagDecl::getCanonicalDecl()); |
3406 | } |
3407 | const EnumDecl *getCanonicalDecl() const { |
3408 | return const_cast<EnumDecl*>(this)->getCanonicalDecl(); |
3409 | } |
3410 | |
3411 | EnumDecl *getPreviousDecl() { |
3412 | return cast_or_null<EnumDecl>( |
3413 | static_cast<TagDecl *>(this)->getPreviousDecl()); |
3414 | } |
3415 | const EnumDecl *getPreviousDecl() const { |
3416 | return const_cast<EnumDecl*>(this)->getPreviousDecl(); |
3417 | } |
3418 | |
3419 | EnumDecl *getMostRecentDecl() { |
3420 | return cast<EnumDecl>(static_cast<TagDecl *>(this)->getMostRecentDecl()); |
3421 | } |
3422 | const EnumDecl *getMostRecentDecl() const { |
3423 | return const_cast<EnumDecl*>(this)->getMostRecentDecl(); |
3424 | } |
3425 | |
3426 | EnumDecl *getDefinition() const { |
3427 | return cast_or_null<EnumDecl>(TagDecl::getDefinition()); |
3428 | } |
3429 | |
3430 | static EnumDecl *Create(ASTContext &C, DeclContext *DC, |
3431 | SourceLocation StartLoc, SourceLocation IdLoc, |
3432 | IdentifierInfo *Id, EnumDecl *PrevDecl, |
3433 | bool IsScoped, bool IsScopedUsingClassTag, |
3434 | bool IsFixed); |
3435 | static EnumDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
3436 | |
3437 | |
3438 | |
3439 | |
3440 | |
3441 | |
3442 | void completeDefinition(QualType NewType, |
3443 | QualType PromotionType, |
3444 | unsigned NumPositiveBits, |
3445 | unsigned NumNegativeBits); |
3446 | |
3447 | |
3448 | using enumerator_iterator = specific_decl_iterator<EnumConstantDecl>; |
3449 | using enumerator_range = |
3450 | llvm::iterator_range<specific_decl_iterator<EnumConstantDecl>>; |
3451 | |
3452 | enumerator_range enumerators() const { |
3453 | return enumerator_range(enumerator_begin(), enumerator_end()); |
3454 | } |
3455 | |
3456 | enumerator_iterator enumerator_begin() const { |
3457 | const EnumDecl *E = getDefinition(); |
3458 | if (!E) |
3459 | E = this; |
3460 | return enumerator_iterator(E->decls_begin()); |
3461 | } |
3462 | |
3463 | enumerator_iterator enumerator_end() const { |
3464 | const EnumDecl *E = getDefinition(); |
3465 | if (!E) |
3466 | E = this; |
3467 | return enumerator_iterator(E->decls_end()); |
3468 | } |
3469 | |
3470 | |
3471 | QualType getPromotionType() const { return PromotionType; } |
3472 | |
3473 | |
3474 | void setPromotionType(QualType T) { PromotionType = T; } |
3475 | |
3476 | |
3477 | |
3478 | |
3479 | QualType getIntegerType() const { |
3480 | if (!IntegerType) |
3481 | return QualType(); |
3482 | if (const Type *T = IntegerType.dyn_cast<const Type*>()) |
3483 | return QualType(T, 0); |
3484 | return IntegerType.get<TypeSourceInfo*>()->getType().getUnqualifiedType(); |
3485 | } |
3486 | |
3487 | |
3488 | void setIntegerType(QualType T) { IntegerType = T.getTypePtrOrNull(); } |
3489 | |
3490 | |
3491 | void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo) { IntegerType = TInfo; } |
3492 | |
3493 | |
3494 | |
3495 | TypeSourceInfo *getIntegerTypeSourceInfo() const { |
3496 | return IntegerType.dyn_cast<TypeSourceInfo*>(); |
3497 | } |
3498 | |
3499 | |
3500 | |
3501 | SourceRange getIntegerTypeRange() const LLVM_READONLY; |
3502 | |
3503 | |
3504 | |
3505 | unsigned getNumPositiveBits() const { return EnumDeclBits.NumPositiveBits; } |
3506 | |
3507 | |
3508 | |
3509 | |
3510 | |
3511 | |
3512 | |
3513 | |
3514 | |
3515 | |
3516 | unsigned getNumNegativeBits() const { return EnumDeclBits.NumNegativeBits; } |
3517 | |
3518 | |
3519 | bool isScoped() const { return EnumDeclBits.IsScoped; } |
3520 | |
3521 | |
3522 | bool isScopedUsingClassTag() const { |
3523 | return EnumDeclBits.IsScopedUsingClassTag; |
3524 | } |
3525 | |
3526 | |
3527 | |
3528 | bool isFixed() const { return EnumDeclBits.IsFixed; } |
3529 | |
3530 | unsigned getODRHash(); |
3531 | |
3532 | |
3533 | bool isComplete() const { |
3534 | |
3535 | |
3536 | return isCompleteDefinition() || IntegerType; |
3537 | } |
3538 | |
3539 | |
3540 | |
3541 | bool isClosed() const; |
3542 | |
3543 | |
3544 | |
3545 | bool isClosedFlag() const; |
3546 | |
3547 | |
3548 | |
3549 | bool isClosedNonFlag() const; |
3550 | |
3551 | |
3552 | |
3553 | EnumDecl *getTemplateInstantiationPattern() const; |
3554 | |
3555 | |
3556 | |
3557 | |
3558 | EnumDecl *getInstantiatedFromMemberEnum() const; |
3559 | |
3560 | |
3561 | |
3562 | |
3563 | TemplateSpecializationKind getTemplateSpecializationKind() const; |
3564 | |
3565 | |
3566 | |
3567 | void setTemplateSpecializationKind(TemplateSpecializationKind TSK, |
3568 | SourceLocation PointOfInstantiation = SourceLocation()); |
3569 | |
3570 | |
3571 | |
3572 | |
3573 | MemberSpecializationInfo *getMemberSpecializationInfo() const { |
3574 | return SpecializationInfo; |
3575 | } |
3576 | |
3577 | |
3578 | |
3579 | void setInstantiationOfMemberEnum(EnumDecl *ED, |
3580 | TemplateSpecializationKind TSK) { |
3581 | setInstantiationOfMemberEnum(getASTContext(), ED, TSK); |
3582 | } |
3583 | |
3584 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
3585 | static bool classofKind(Kind K) { return K == Enum; } |
3586 | }; |
3587 | |
3588 | |
3589 | |
3590 | |
3591 | |
3592 | class RecordDecl : public TagDecl { |
3593 | |
3594 | |
3595 | public: |
3596 | friend class DeclContext; |
3597 | |
3598 | |
3599 | |
3600 | |
3601 | enum ArgPassingKind : unsigned { |
3602 | |
3603 | APK_CanPassInRegs, |
3604 | |
3605 | |
3606 | |
3607 | |
3608 | |
3609 | |
3610 | |
3611 | |
3612 | APK_CannotPassInRegs, |
3613 | |
3614 | |
3615 | |
3616 | |
3617 | APK_CanNeverPassInRegs |
3618 | }; |
3619 | |
3620 | protected: |
3621 | RecordDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC, |
3622 | SourceLocation StartLoc, SourceLocation IdLoc, |
3623 | IdentifierInfo *Id, RecordDecl *PrevDecl); |
3624 | |
3625 | public: |
3626 | static RecordDecl *Create(const ASTContext &C, TagKind TK, DeclContext *DC, |
3627 | SourceLocation StartLoc, SourceLocation IdLoc, |
3628 | IdentifierInfo *Id, RecordDecl* PrevDecl = nullptr); |
3629 | static RecordDecl *CreateDeserialized(const ASTContext &C, unsigned ID); |
3630 | |
3631 | RecordDecl *getPreviousDecl() { |
3632 | return cast_or_null<RecordDecl>( |
3633 | static_cast<TagDecl *>(this)->getPreviousDecl()); |
3634 | } |
3635 | const RecordDecl *getPreviousDecl() const { |
3636 | return const_cast<RecordDecl*>(this)->getPreviousDecl(); |
3637 | } |
3638 | |
3639 | RecordDecl *getMostRecentDecl() { |
3640 | return cast<RecordDecl>(static_cast<TagDecl *>(this)->getMostRecentDecl()); |
3641 | } |
3642 | const RecordDecl *getMostRecentDecl() const { |
3643 | return const_cast<RecordDecl*>(this)->getMostRecentDecl(); |
3644 | } |
3645 | |
3646 | bool hasFlexibleArrayMember() const { |
3647 | return RecordDeclBits.HasFlexibleArrayMember; |
3648 | } |
3649 | |
3650 | void setHasFlexibleArrayMember(bool V) { |
3651 | RecordDeclBits.HasFlexibleArrayMember = V; |
3652 | } |
3653 | |
3654 | |
3655 | |
3656 | |
3657 | |
3658 | |
3659 | |
3660 | |
3661 | |
3662 | |
3663 | |
3664 | |
3665 | bool isAnonymousStructOrUnion() const { |
3666 | return RecordDeclBits.AnonymousStructOrUnion; |
3667 | } |
3668 | |
3669 | void setAnonymousStructOrUnion(bool Anon) { |
3670 | RecordDeclBits.AnonymousStructOrUnion = Anon; |
3671 | } |
3672 | |
3673 | bool hasObjectMember() const { return RecordDeclBits.HasObjectMember; } |
3674 | void setHasObjectMember(bool val) { RecordDeclBits.HasObjectMember = val; } |
3675 | |
3676 | bool hasVolatileMember() const { return RecordDeclBits.HasVolatileMember; } |
3677 | |
3678 | void setHasVolatileMember(bool val) { |
3679 | RecordDeclBits.HasVolatileMember = val; |
3680 | } |
3681 | |
3682 | bool hasLoadedFieldsFromExternalStorage() const { |
3683 | return RecordDeclBits.LoadedFieldsFromExternalStorage; |
3684 | } |
3685 | |
3686 | void setHasLoadedFieldsFromExternalStorage(bool val) const { |
3687 | RecordDeclBits.LoadedFieldsFromExternalStorage = val; |
3688 | } |
3689 | |
3690 | |
3691 | bool isNonTrivialToPrimitiveDefaultInitialize() const { |
3692 | return RecordDeclBits.NonTrivialToPrimitiveDefaultInitialize; |
3693 | } |
3694 | |
3695 | void setNonTrivialToPrimitiveDefaultInitialize(bool V) { |
3696 | RecordDeclBits.NonTrivialToPrimitiveDefaultInitialize = V; |
3697 | } |
3698 | |
3699 | bool isNonTrivialToPrimitiveCopy() const { |
3700 | return RecordDeclBits.NonTrivialToPrimitiveCopy; |
3701 | } |
3702 | |
3703 | void setNonTrivialToPrimitiveCopy(bool V) { |
3704 | RecordDeclBits.NonTrivialToPrimitiveCopy = V; |
3705 | } |
3706 | |
3707 | bool isNonTrivialToPrimitiveDestroy() const { |
3708 | return RecordDeclBits.NonTrivialToPrimitiveDestroy; |
3709 | } |
3710 | |
3711 | void setNonTrivialToPrimitiveDestroy(bool V) { |
3712 | RecordDeclBits.NonTrivialToPrimitiveDestroy = V; |
3713 | } |
3714 | |
3715 | |
3716 | |
3717 | |
3718 | bool canPassInRegisters() const { |
3719 | return getArgPassingRestrictions() == APK_CanPassInRegs; |
3720 | } |
3721 | |
3722 | ArgPassingKind getArgPassingRestrictions() const { |
3723 | return static_cast<ArgPassingKind>(RecordDeclBits.ArgPassingRestrictions); |
3724 | } |
3725 | |
3726 | void setArgPassingRestrictions(ArgPassingKind Kind) { |
3727 | RecordDeclBits.ArgPassingRestrictions = Kind; |
3728 | } |
3729 | |
3730 | bool isParamDestroyedInCallee() const { |
3731 | return RecordDeclBits.ParamDestroyedInCallee; |
3732 | } |
3733 | |
3734 | void setParamDestroyedInCallee(bool V) { |
3735 | RecordDeclBits.ParamDestroyedInCallee = V; |
3736 | } |
3737 | |
3738 | |
3739 | |
3740 | |
3741 | |
3742 | |
3743 | |
3744 | |
3745 | |
3746 | |
3747 | |
3748 | |
3749 | |
3750 | |
3751 | bool isInjectedClassName() const; |
3752 | |
3753 | |
3754 | |
3755 | bool isLambda() const; |
3756 | |
3757 | |
3758 | |
3759 | bool isCapturedRecord() const; |
3760 | |
3761 | |
3762 | |
3763 | void setCapturedRecord(); |
3764 | |
3765 | |
3766 | |
3767 | |
3768 | |
3769 | |
3770 | |
3771 | |
3772 | |
3773 | RecordDecl *getDefinition() const { |
3774 | return cast_or_null<RecordDecl>(TagDecl::getDefinition()); |
3775 | } |
3776 | |
3777 | |
3778 | |
3779 | |
3780 | using field_iterator = specific_decl_iterator<FieldDecl>; |
3781 | using field_range = llvm::iterator_range<specific_decl_iterator<FieldDecl>>; |
3782 | |
3783 | field_range fields() const { return field_range(field_begin(), field_end()); } |
3784 | field_iterator field_begin() const; |
3785 | |
3786 | field_iterator field_end() const { |
3787 | return field_iterator(decl_iterator()); |
3788 | } |
3789 | |
3790 | |
3791 | bool field_empty() const { |
3792 | return field_begin() == field_end(); |
3793 | } |
3794 | |
3795 | |
3796 | virtual void completeDefinition(); |
3797 | |
3798 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
3799 | static bool classofKind(Kind K) { |
3800 | return K >= firstRecord && K <= lastRecord; |
3801 | } |
3802 | |
3803 | |
3804 | |
3805 | |
3806 | bool isMsStruct(const ASTContext &C) const; |
3807 | |
3808 | |
3809 | |
3810 | |
3811 | bool (bool = false) const; |
3812 | |
3813 | |
3814 | |
3815 | const FieldDecl *findFirstNamedDataMember() const; |
3816 | |
3817 | private: |
3818 | |
3819 | void LoadFieldsFromExternalStorage() const; |
3820 | }; |
3821 | |
3822 | class FileScopeAsmDecl : public Decl { |
3823 | StringLiteral *AsmString; |
3824 | SourceLocation RParenLoc; |
3825 | |
3826 | FileScopeAsmDecl(DeclContext *DC, StringLiteral *asmstring, |
3827 | SourceLocation StartL, SourceLocation EndL) |
3828 | : Decl(FileScopeAsm, DC, StartL), AsmString(asmstring), RParenLoc(EndL) {} |
3829 | |
3830 | virtual void anchor(); |
3831 | |
3832 | public: |
3833 | static FileScopeAsmDecl *Create(ASTContext &C, DeclContext *DC, |
3834 | StringLiteral *Str, SourceLocation AsmLoc, |
3835 | SourceLocation RParenLoc); |
3836 | |
3837 | static FileScopeAsmDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
3838 | |
3839 | SourceLocation getAsmLoc() const { return getLocation(); } |
3840 | SourceLocation getRParenLoc() const { return RParenLoc; } |
3841 | void setRParenLoc(SourceLocation L) { RParenLoc = L; } |
3842 | SourceRange getSourceRange() const override LLVM_READONLY { |
3843 | return SourceRange(getAsmLoc(), getRParenLoc()); |
3844 | } |
3845 | |
3846 | const StringLiteral *getAsmString() const { return AsmString; } |
3847 | StringLiteral *getAsmString() { return AsmString; } |
3848 | void setAsmString(StringLiteral *Asm) { AsmString = Asm; } |
3849 | |
3850 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
3851 | static bool classofKind(Kind K) { return K == FileScopeAsm; } |
3852 | }; |
3853 | |
3854 | |
3855 | |
3856 | |
3857 | class BlockDecl : public Decl, public DeclContext { |
3858 | |
3859 | |
3860 | public: |
3861 | |
3862 | |
3863 | class Capture { |
3864 | enum { |
3865 | flag_isByRef = 0x1, |
3866 | flag_isNested = 0x2 |
3867 | }; |
3868 | |
3869 | |
3870 | llvm::PointerIntPair<VarDecl*, 2> VariableAndFlags; |
3871 | |
3872 | |
3873 | |
3874 | |
3875 | Expr *CopyExpr; |
3876 | |
3877 | public: |
3878 | Capture(VarDecl *variable, bool byRef, bool nested, Expr *copy) |
3879 | : VariableAndFlags(variable, |
3880 | (byRef ? flag_isByRef : 0) | (nested ? flag_isNested : 0)), |
3881 | CopyExpr(copy) {} |
3882 | |
3883 | |
3884 | VarDecl *getVariable() const { return VariableAndFlags.getPointer(); } |
3885 | |
3886 | |
3887 | |
3888 | bool isByRef() const { return VariableAndFlags.getInt() & flag_isByRef; } |
3889 | |
3890 | bool isEscapingByref() const { |
3891 | return getVariable()->isEscapingByref(); |
3892 | } |
3893 | |
3894 | bool isNonEscapingByref() const { |
3895 | return getVariable()->isNonEscapingByref(); |
3896 | } |
3897 | |
3898 | |
3899 | |
3900 | bool isNested() const { return VariableAndFlags.getInt() & flag_isNested; } |
3901 | |
3902 | bool hasCopyExpr() const { return CopyExpr != nullptr; } |
3903 | Expr *getCopyExpr() const { return CopyExpr; } |
3904 | void setCopyExpr(Expr *e) { CopyExpr = e; } |
3905 | }; |
3906 | |
3907 | private: |
3908 | |
3909 | |
3910 | |
3911 | ParmVarDecl **ParamInfo = nullptr; |
3912 | unsigned NumParams = 0; |
3913 | |
3914 | Stmt *Body = nullptr; |
3915 | TypeSourceInfo *SignatureAsWritten = nullptr; |
3916 | |
3917 | const Capture *Captures = nullptr; |
3918 | unsigned NumCaptures = 0; |
3919 | |
3920 | unsigned ManglingNumber = 0; |
3921 | Decl *ManglingContextDecl = nullptr; |
3922 | |
3923 | protected: |
3924 | BlockDecl(DeclContext *DC, SourceLocation CaretLoc); |
3925 | |
3926 | public: |
3927 | static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L); |
3928 | static BlockDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
3929 | |
3930 | SourceLocation getCaretLocation() const { return getLocation(); } |
3931 | |
3932 | bool isVariadic() const { return BlockDeclBits.IsVariadic; } |
3933 | void setIsVariadic(bool value) { BlockDeclBits.IsVariadic = value; } |
3934 | |
3935 | CompoundStmt *getCompoundBody() const { return (CompoundStmt*) Body; } |
3936 | Stmt *getBody() const override { return (Stmt*) Body; } |
3937 | void setBody(CompoundStmt *B) { Body = (Stmt*) B; } |
3938 | |
3939 | void setSignatureAsWritten(TypeSourceInfo *Sig) { SignatureAsWritten = Sig; } |
3940 | TypeSourceInfo *getSignatureAsWritten() const { return SignatureAsWritten; } |
3941 | |
3942 | |
3943 | ArrayRef<ParmVarDecl *> parameters() const { |
3944 | return {ParamInfo, getNumParams()}; |
3945 | } |
3946 | MutableArrayRef<ParmVarDecl *> parameters() { |
3947 | return {ParamInfo, getNumParams()}; |
3948 | } |
3949 | |
3950 | |
3951 | using param_iterator = MutableArrayRef<ParmVarDecl *>::iterator; |
3952 | using param_const_iterator = ArrayRef<ParmVarDecl *>::const_iterator; |
3953 | |
3954 | bool param_empty() const { return parameters().empty(); } |
3955 | param_iterator param_begin() { return parameters().begin(); } |
3956 | param_iterator param_end() { return parameters().end(); } |
3957 | param_const_iterator param_begin() const { return parameters().begin(); } |
3958 | param_const_iterator param_end() const { return parameters().end(); } |
3959 | size_t param_size() const { return parameters().size(); } |
3960 | |
3961 | unsigned getNumParams() const { return NumParams; } |
3962 | |
3963 | const ParmVarDecl *getParamDecl(unsigned i) const { |
3964 | (0) . __assert_fail ("i < getNumParams() && \"Illegal param #\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 3964, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(i < getNumParams() && "Illegal param #"); |
3965 | return ParamInfo[i]; |
3966 | } |
3967 | ParmVarDecl *getParamDecl(unsigned i) { |
3968 | (0) . __assert_fail ("i < getNumParams() && \"Illegal param #\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 3968, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(i < getNumParams() && "Illegal param #"); |
3969 | return ParamInfo[i]; |
3970 | } |
3971 | |
3972 | void setParams(ArrayRef<ParmVarDecl *> NewParamInfo); |
3973 | |
3974 | |
3975 | |
3976 | bool hasCaptures() const { return NumCaptures || capturesCXXThis(); } |
3977 | |
3978 | |
3979 | |
3980 | unsigned getNumCaptures() const { return NumCaptures; } |
3981 | |
3982 | using capture_const_iterator = ArrayRef<Capture>::const_iterator; |
3983 | |
3984 | ArrayRef<Capture> captures() const { return {Captures, NumCaptures}; } |
3985 | |
3986 | capture_const_iterator capture_begin() const { return captures().begin(); } |
3987 | capture_const_iterator capture_end() const { return captures().end(); } |
3988 | |
3989 | bool capturesCXXThis() const { return BlockDeclBits.CapturesCXXThis; } |
3990 | void setCapturesCXXThis(bool B = true) { BlockDeclBits.CapturesCXXThis = B; } |
3991 | |
3992 | bool blockMissingReturnType() const { |
3993 | return BlockDeclBits.BlockMissingReturnType; |
3994 | } |
3995 | |
3996 | void setBlockMissingReturnType(bool val = true) { |
3997 | BlockDeclBits.BlockMissingReturnType = val; |
3998 | } |
3999 | |
4000 | bool isConversionFromLambda() const { |
4001 | return BlockDeclBits.IsConversionFromLambda; |
4002 | } |
4003 | |
4004 | void setIsConversionFromLambda(bool val = true) { |
4005 | BlockDeclBits.IsConversionFromLambda = val; |
4006 | } |
4007 | |
4008 | bool doesNotEscape() const { return BlockDeclBits.DoesNotEscape; } |
4009 | void setDoesNotEscape(bool B = true) { BlockDeclBits.DoesNotEscape = B; } |
4010 | |
4011 | bool canAvoidCopyToHeap() const { |
4012 | return BlockDeclBits.CanAvoidCopyToHeap; |
4013 | } |
4014 | void setCanAvoidCopyToHeap(bool B = true) { |
4015 | BlockDeclBits.CanAvoidCopyToHeap = B; |
4016 | } |
4017 | |
4018 | bool capturesVariable(const VarDecl *var) const; |
4019 | |
4020 | void setCaptures(ASTContext &Context, ArrayRef<Capture> Captures, |
4021 | bool CapturesCXXThis); |
4022 | |
4023 | unsigned getBlockManglingNumber() const { |
4024 | return ManglingNumber; |
4025 | } |
4026 | |
4027 | Decl *getBlockManglingContextDecl() const { |
4028 | return ManglingContextDecl; |
4029 | } |
4030 | |
4031 | void setBlockMangling(unsigned Number, Decl *Ctx) { |
4032 | ManglingNumber = Number; |
4033 | ManglingContextDecl = Ctx; |
4034 | } |
4035 | |
4036 | SourceRange getSourceRange() const override LLVM_READONLY; |
4037 | |
4038 | |
4039 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
4040 | static bool classofKind(Kind K) { return K == Block; } |
4041 | static DeclContext *castToDeclContext(const BlockDecl *D) { |
4042 | return static_cast<DeclContext *>(const_cast<BlockDecl*>(D)); |
4043 | } |
4044 | static BlockDecl *castFromDeclContext(const DeclContext *DC) { |
4045 | return static_cast<BlockDecl *>(const_cast<DeclContext*>(DC)); |
4046 | } |
4047 | }; |
4048 | |
4049 | |
4050 | class CapturedDecl final |
4051 | : public Decl, |
4052 | public DeclContext, |
4053 | private llvm::TrailingObjects<CapturedDecl, ImplicitParamDecl *> { |
4054 | protected: |
4055 | size_t numTrailingObjects(OverloadToken<ImplicitParamDecl>) { |
4056 | return NumParams; |
4057 | } |
4058 | |
4059 | private: |
4060 | |
4061 | unsigned NumParams; |
4062 | |
4063 | |
4064 | unsigned ContextParam; |
4065 | |
4066 | |
4067 | llvm::PointerIntPair<Stmt *, 1, bool> BodyAndNothrow; |
4068 | |
4069 | explicit CapturedDecl(DeclContext *DC, unsigned NumParams); |
4070 | |
4071 | ImplicitParamDecl *const *getParams() const { |
4072 | return getTrailingObjects<ImplicitParamDecl *>(); |
4073 | } |
4074 | |
4075 | ImplicitParamDecl **getParams() { |
4076 | return getTrailingObjects<ImplicitParamDecl *>(); |
4077 | } |
4078 | |
4079 | public: |
4080 | friend class ASTDeclReader; |
4081 | friend class ASTDeclWriter; |
4082 | friend TrailingObjects; |
4083 | |
4084 | static CapturedDecl *Create(ASTContext &C, DeclContext *DC, |
4085 | unsigned NumParams); |
4086 | static CapturedDecl *CreateDeserialized(ASTContext &C, unsigned ID, |
4087 | unsigned NumParams); |
4088 | |
4089 | Stmt *getBody() const override; |
4090 | void setBody(Stmt *B); |
4091 | |
4092 | bool isNothrow() const; |
4093 | void setNothrow(bool Nothrow = true); |
4094 | |
4095 | unsigned getNumParams() const { return NumParams; } |
4096 | |
4097 | ImplicitParamDecl *getParam(unsigned i) const { |
4098 | assert(i < NumParams); |
4099 | return getParams()[i]; |
4100 | } |
4101 | void setParam(unsigned i, ImplicitParamDecl *P) { |
4102 | assert(i < NumParams); |
4103 | getParams()[i] = P; |
4104 | } |
4105 | |
4106 | |
4107 | ArrayRef<ImplicitParamDecl *> parameters() const { |
4108 | return {getParams(), getNumParams()}; |
4109 | } |
4110 | MutableArrayRef<ImplicitParamDecl *> parameters() { |
4111 | return {getParams(), getNumParams()}; |
4112 | } |
4113 | |
4114 | |
4115 | ImplicitParamDecl *getContextParam() const { |
4116 | assert(ContextParam < NumParams); |
4117 | return getParam(ContextParam); |
4118 | } |
4119 | void setContextParam(unsigned i, ImplicitParamDecl *P) { |
4120 | assert(i < NumParams); |
4121 | ContextParam = i; |
4122 | setParam(i, P); |
4123 | } |
4124 | unsigned getContextParamPosition() const { return ContextParam; } |
4125 | |
4126 | using param_iterator = ImplicitParamDecl *const *; |
4127 | using param_range = llvm::iterator_range<param_iterator>; |
4128 | |
4129 | |
4130 | param_iterator param_begin() const { return getParams(); } |
4131 | |
4132 | param_iterator param_end() const { return getParams() + NumParams; } |
4133 | |
4134 | |
4135 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
4136 | static bool classofKind(Kind K) { return K == Captured; } |
4137 | static DeclContext *castToDeclContext(const CapturedDecl *D) { |
4138 | return static_cast<DeclContext *>(const_cast<CapturedDecl *>(D)); |
4139 | } |
4140 | static CapturedDecl *castFromDeclContext(const DeclContext *DC) { |
4141 | return static_cast<CapturedDecl *>(const_cast<DeclContext *>(DC)); |
4142 | } |
4143 | }; |
4144 | |
4145 | |
4146 | |
4147 | |
4148 | |
4149 | |
4150 | |
4151 | |
4152 | |
4153 | |
4154 | |
4155 | class ImportDecl final : public Decl, |
4156 | llvm::TrailingObjects<ImportDecl, SourceLocation> { |
4157 | friend class ASTContext; |
4158 | friend class ASTDeclReader; |
4159 | friend class ASTReader; |
4160 | friend TrailingObjects; |
4161 | |
4162 | |
4163 | |
4164 | |
4165 | |
4166 | |
4167 | |
4168 | llvm::PointerIntPair<Module *, 1, bool> ImportedAndComplete; |
4169 | |
4170 | |
4171 | |
4172 | ImportDecl *NextLocalImport = nullptr; |
4173 | |
4174 | ImportDecl(DeclContext *DC, SourceLocation StartLoc, Module *Imported, |
4175 | ArrayRef<SourceLocation> IdentifierLocs); |
4176 | |
4177 | ImportDecl(DeclContext *DC, SourceLocation StartLoc, Module *Imported, |
4178 | SourceLocation EndLoc); |
4179 | |
4180 | ImportDecl(EmptyShell Empty) : Decl(Import, Empty) {} |
4181 | |
4182 | public: |
4183 | |
4184 | static ImportDecl *Create(ASTContext &C, DeclContext *DC, |
4185 | SourceLocation StartLoc, Module *Imported, |
4186 | ArrayRef<SourceLocation> IdentifierLocs); |
4187 | |
4188 | |
4189 | |
4190 | static ImportDecl *CreateImplicit(ASTContext &C, DeclContext *DC, |
4191 | SourceLocation StartLoc, Module *Imported, |
4192 | SourceLocation EndLoc); |
4193 | |
4194 | |
4195 | static ImportDecl *CreateDeserialized(ASTContext &C, unsigned ID, |
4196 | unsigned NumLocations); |
4197 | |
4198 | |
4199 | Module *getImportedModule() const { return ImportedAndComplete.getPointer(); } |
4200 | |
4201 | |
4202 | |
4203 | |
4204 | |
4205 | |
4206 | ArrayRef<SourceLocation> getIdentifierLocs() const; |
4207 | |
4208 | SourceRange getSourceRange() const override LLVM_READONLY; |
4209 | |
4210 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
4211 | static bool classofKind(Kind K) { return K == Import; } |
4212 | }; |
4213 | |
4214 | |
4215 | |
4216 | |
4217 | |
4218 | |
4219 | |
4220 | class ExportDecl final : public Decl, public DeclContext { |
4221 | virtual void anchor(); |
4222 | |
4223 | private: |
4224 | friend class ASTDeclReader; |
4225 | |
4226 | |
4227 | SourceLocation RBraceLoc; |
4228 | |
4229 | ExportDecl(DeclContext *DC, SourceLocation ExportLoc) |
4230 | : Decl(Export, DC, ExportLoc), DeclContext(Export), |
4231 | RBraceLoc(SourceLocation()) {} |
4232 | |
4233 | public: |
4234 | static ExportDecl *Create(ASTContext &C, DeclContext *DC, |
4235 | SourceLocation ExportLoc); |
4236 | static ExportDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
4237 | |
4238 | SourceLocation getExportLoc() const { return getLocation(); } |
4239 | SourceLocation getRBraceLoc() const { return RBraceLoc; } |
4240 | void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } |
4241 | |
4242 | SourceLocation getEndLoc() const LLVM_READONLY { |
4243 | if (RBraceLoc.isValid()) |
4244 | return RBraceLoc; |
4245 | |
4246 | |
4247 | return decls_empty() ? getLocation() : decls_begin()->getEndLoc(); |
4248 | } |
4249 | |
4250 | SourceRange getSourceRange() const override LLVM_READONLY { |
4251 | return SourceRange(getLocation(), getEndLoc()); |
4252 | } |
4253 | |
4254 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
4255 | static bool classofKind(Kind K) { return K == Export; } |
4256 | static DeclContext *castToDeclContext(const ExportDecl *D) { |
4257 | return static_cast<DeclContext *>(const_cast<ExportDecl*>(D)); |
4258 | } |
4259 | static ExportDecl *castFromDeclContext(const DeclContext *DC) { |
4260 | return static_cast<ExportDecl *>(const_cast<DeclContext*>(DC)); |
4261 | } |
4262 | }; |
4263 | |
4264 | |
4265 | class EmptyDecl : public Decl { |
4266 | EmptyDecl(DeclContext *DC, SourceLocation L) : Decl(Empty, DC, L) {} |
4267 | |
4268 | virtual void anchor(); |
4269 | |
4270 | public: |
4271 | static EmptyDecl *Create(ASTContext &C, DeclContext *DC, |
4272 | SourceLocation L); |
4273 | static EmptyDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
4274 | |
4275 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
4276 | static bool classofKind(Kind K) { return K == Empty; } |
4277 | }; |
4278 | |
4279 | |
4280 | |
4281 | inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, |
4282 | const NamedDecl* ND) { |
4283 | DB.AddTaggedVal(reinterpret_cast<intptr_t>(ND), |
4284 | DiagnosticsEngine::ak_nameddecl); |
4285 | return DB; |
4286 | } |
4287 | inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, |
4288 | const NamedDecl* ND) { |
4289 | PD.AddTaggedVal(reinterpret_cast<intptr_t>(ND), |
4290 | DiagnosticsEngine::ak_nameddecl); |
4291 | return PD; |
4292 | } |
4293 | |
4294 | template<typename decl_type> |
4295 | void Redeclarable<decl_type>::setPreviousDecl(decl_type *PrevDecl) { |
4296 | |
4297 | |
4298 | (0) . __assert_fail ("RedeclLink.isFirst() && \"setPreviousDecl on a decl already in a redeclaration chain\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 4299, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(RedeclLink.isFirst() && |
4299 | (0) . __assert_fail ("RedeclLink.isFirst() && \"setPreviousDecl on a decl already in a redeclaration chain\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 4299, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "setPreviousDecl on a decl already in a redeclaration chain"); |
4300 | |
4301 | if (PrevDecl) { |
4302 | |
4303 | |
4304 | |
4305 | First = PrevDecl->getFirstDecl(); |
4306 | (0) . __assert_fail ("First->RedeclLink.isFirst() && \"Expected first\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 4306, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(First->RedeclLink.isFirst() && "Expected first"); |
4307 | decl_type *MostRecent = First->getNextRedeclaration(); |
4308 | RedeclLink = PreviousDeclLink(cast<decl_type>(MostRecent)); |
4309 | |
4310 | |
4311 | |
4312 | static_cast<decl_type*>(this)->IdentifierNamespace |= |
4313 | MostRecent->getIdentifierNamespace() & |
4314 | (Decl::IDNS_Ordinary | Decl::IDNS_Tag | Decl::IDNS_Type); |
4315 | } else { |
4316 | |
4317 | First = static_cast<decl_type*>(this); |
4318 | } |
4319 | |
4320 | |
4321 | First->RedeclLink.setLatest(static_cast<decl_type*>(this)); |
4322 | |
4323 | (static_cast(this)) || cast(static_cast(this))->isLinkageValid()", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 4324, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<NamedDecl>(static_cast<decl_type*>(this)) || |
4324 | (static_cast(this)) || cast(static_cast(this))->isLinkageValid()", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Decl.h", 4324, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> cast<NamedDecl>(static_cast<decl_type*>(this))->isLinkageValid()); |
4325 | } |
4326 | |
4327 | |
4328 | |
4329 | |
4330 | |
4331 | |
4332 | |
4333 | inline bool IsEnumDeclComplete(EnumDecl *ED) { |
4334 | return ED->isComplete(); |
4335 | } |
4336 | |
4337 | |
4338 | |
4339 | |
4340 | |
4341 | inline bool IsEnumDeclScoped(EnumDecl *ED) { |
4342 | return ED->isScoped(); |
4343 | } |
4344 | |
4345 | } |
4346 | |
4347 | #endif |
4348 | |