1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | #ifndef LLVM_CLANG_AST_TYPE_H |
18 | #define LLVM_CLANG_AST_TYPE_H |
19 | |
20 | #include "clang/AST/NestedNameSpecifier.h" |
21 | #include "clang/AST/TemplateName.h" |
22 | #include "clang/Basic/AddressSpaces.h" |
23 | #include "clang/Basic/AttrKinds.h" |
24 | #include "clang/Basic/Diagnostic.h" |
25 | #include "clang/Basic/ExceptionSpecificationType.h" |
26 | #include "clang/Basic/LLVM.h" |
27 | #include "clang/Basic/Linkage.h" |
28 | #include "clang/Basic/PartialDiagnostic.h" |
29 | #include "clang/Basic/SourceLocation.h" |
30 | #include "clang/Basic/Specifiers.h" |
31 | #include "clang/Basic/Visibility.h" |
32 | #include "llvm/ADT/APInt.h" |
33 | #include "llvm/ADT/APSInt.h" |
34 | #include "llvm/ADT/ArrayRef.h" |
35 | #include "llvm/ADT/FoldingSet.h" |
36 | #include "llvm/ADT/None.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/Twine.h" |
42 | #include "llvm/ADT/iterator_range.h" |
43 | #include "llvm/Support/Casting.h" |
44 | #include "llvm/Support/Compiler.h" |
45 | #include "llvm/Support/ErrorHandling.h" |
46 | #include "llvm/Support/PointerLikeTypeTraits.h" |
47 | #include "llvm/Support/type_traits.h" |
48 | #include "llvm/Support/TrailingObjects.h" |
49 | #include <cassert> |
50 | #include <cstddef> |
51 | #include <cstdint> |
52 | #include <cstring> |
53 | #include <string> |
54 | #include <type_traits> |
55 | #include <utility> |
56 | |
57 | namespace clang { |
58 | |
59 | class ExtQuals; |
60 | class QualType; |
61 | class TagDecl; |
62 | class Type; |
63 | |
64 | enum { |
65 | TypeAlignmentInBits = 4, |
66 | TypeAlignment = 1 << TypeAlignmentInBits |
67 | }; |
68 | |
69 | } |
70 | |
71 | namespace llvm { |
72 | |
73 | template <typename T> |
74 | struct PointerLikeTypeTraits; |
75 | template<> |
76 | struct PointerLikeTypeTraits< ::clang::Type*> { |
77 | static inline void *getAsVoidPointer(::clang::Type *P) { return P; } |
78 | |
79 | static inline ::clang::Type *getFromVoidPointer(void *P) { |
80 | return static_cast< ::clang::Type*>(P); |
81 | } |
82 | |
83 | enum { NumLowBitsAvailable = clang::TypeAlignmentInBits }; |
84 | }; |
85 | |
86 | template<> |
87 | struct PointerLikeTypeTraits< ::clang::ExtQuals*> { |
88 | static inline void *getAsVoidPointer(::clang::ExtQuals *P) { return P; } |
89 | |
90 | static inline ::clang::ExtQuals *getFromVoidPointer(void *P) { |
91 | return static_cast< ::clang::ExtQuals*>(P); |
92 | } |
93 | |
94 | enum { NumLowBitsAvailable = clang::TypeAlignmentInBits }; |
95 | }; |
96 | |
97 | } |
98 | |
99 | namespace clang { |
100 | |
101 | class ASTContext; |
102 | template <typename> class CanQual; |
103 | class CXXRecordDecl; |
104 | class DeclContext; |
105 | class EnumDecl; |
106 | class Expr; |
107 | class ExtQualsTypeCommonBase; |
108 | class FunctionDecl; |
109 | class IdentifierInfo; |
110 | class NamedDecl; |
111 | class ObjCInterfaceDecl; |
112 | class ObjCProtocolDecl; |
113 | class ObjCTypeParamDecl; |
114 | struct PrintingPolicy; |
115 | class RecordDecl; |
116 | class Stmt; |
117 | class TagDecl; |
118 | class TemplateArgument; |
119 | class TemplateArgumentListInfo; |
120 | class TemplateArgumentLoc; |
121 | class TemplateTypeParmDecl; |
122 | class TypedefNameDecl; |
123 | class UnresolvedUsingTypenameDecl; |
124 | |
125 | using CanQualType = CanQual<Type>; |
126 | |
127 | |
128 | #define TYPE(Class, Base) class Class##Type; |
129 | #include "clang/AST/TypeNodes.def" |
130 | |
131 | |
132 | |
133 | |
134 | |
135 | |
136 | |
137 | class Qualifiers { |
138 | public: |
139 | enum TQ { |
140 | Const = 0x1, |
141 | Restrict = 0x2, |
142 | Volatile = 0x4, |
143 | CVRMask = Const | Volatile | Restrict |
144 | }; |
145 | |
146 | enum GC { |
147 | GCNone = 0, |
148 | Weak, |
149 | Strong |
150 | }; |
151 | |
152 | enum ObjCLifetime { |
153 | |
154 | OCL_None, |
155 | |
156 | |
157 | |
158 | OCL_ExplicitNone, |
159 | |
160 | |
161 | |
162 | |
163 | |
164 | |
165 | OCL_Strong, |
166 | |
167 | |
168 | OCL_Weak, |
169 | |
170 | |
171 | OCL_Autoreleasing |
172 | }; |
173 | |
174 | enum { |
175 | |
176 | |
177 | MaxAddressSpace = 0x7fffffu, |
178 | |
179 | |
180 | FastWidth = 3, |
181 | |
182 | |
183 | FastMask = (1 << FastWidth) - 1 |
184 | }; |
185 | |
186 | |
187 | |
188 | static Qualifiers removeCommonQualifiers(Qualifiers &L, Qualifiers &R) { |
189 | |
190 | if (!(L.Mask & ~CVRMask) && !(R.Mask & ~CVRMask)) { |
191 | Qualifiers Q; |
192 | Q.Mask = L.Mask & R.Mask; |
193 | L.Mask &= ~Q.Mask; |
194 | R.Mask &= ~Q.Mask; |
195 | return Q; |
196 | } |
197 | |
198 | Qualifiers Q; |
199 | unsigned CommonCRV = L.getCVRQualifiers() & R.getCVRQualifiers(); |
200 | Q.addCVRQualifiers(CommonCRV); |
201 | L.removeCVRQualifiers(CommonCRV); |
202 | R.removeCVRQualifiers(CommonCRV); |
203 | |
204 | if (L.getObjCGCAttr() == R.getObjCGCAttr()) { |
205 | Q.setObjCGCAttr(L.getObjCGCAttr()); |
206 | L.removeObjCGCAttr(); |
207 | R.removeObjCGCAttr(); |
208 | } |
209 | |
210 | if (L.getObjCLifetime() == R.getObjCLifetime()) { |
211 | Q.setObjCLifetime(L.getObjCLifetime()); |
212 | L.removeObjCLifetime(); |
213 | R.removeObjCLifetime(); |
214 | } |
215 | |
216 | if (L.getAddressSpace() == R.getAddressSpace()) { |
217 | Q.setAddressSpace(L.getAddressSpace()); |
218 | L.removeAddressSpace(); |
219 | R.removeAddressSpace(); |
220 | } |
221 | return Q; |
222 | } |
223 | |
224 | static Qualifiers fromFastMask(unsigned Mask) { |
225 | Qualifiers Qs; |
226 | Qs.addFastQualifiers(Mask); |
227 | return Qs; |
228 | } |
229 | |
230 | static Qualifiers fromCVRMask(unsigned CVR) { |
231 | Qualifiers Qs; |
232 | Qs.addCVRQualifiers(CVR); |
233 | return Qs; |
234 | } |
235 | |
236 | static Qualifiers fromCVRUMask(unsigned CVRU) { |
237 | Qualifiers Qs; |
238 | Qs.addCVRUQualifiers(CVRU); |
239 | return Qs; |
240 | } |
241 | |
242 | |
243 | static Qualifiers fromOpaqueValue(unsigned opaque) { |
244 | Qualifiers Qs; |
245 | Qs.Mask = opaque; |
246 | return Qs; |
247 | } |
248 | |
249 | |
250 | unsigned getAsOpaqueValue() const { |
251 | return Mask; |
252 | } |
253 | |
254 | bool hasConst() const { return Mask & Const; } |
255 | bool hasOnlyConst() const { return Mask == Const; } |
256 | void removeConst() { Mask &= ~Const; } |
257 | void addConst() { Mask |= Const; } |
258 | |
259 | bool hasVolatile() const { return Mask & Volatile; } |
260 | bool hasOnlyVolatile() const { return Mask == Volatile; } |
261 | void removeVolatile() { Mask &= ~Volatile; } |
262 | void addVolatile() { Mask |= Volatile; } |
263 | |
264 | bool hasRestrict() const { return Mask & Restrict; } |
265 | bool hasOnlyRestrict() const { return Mask == Restrict; } |
266 | void removeRestrict() { Mask &= ~Restrict; } |
267 | void addRestrict() { Mask |= Restrict; } |
268 | |
269 | bool hasCVRQualifiers() const { return getCVRQualifiers(); } |
270 | unsigned getCVRQualifiers() const { return Mask & CVRMask; } |
271 | unsigned getCVRUQualifiers() const { return Mask & (CVRMask | UMask); } |
272 | |
273 | void setCVRQualifiers(unsigned mask) { |
274 | (0) . __assert_fail ("!(mask & ~CVRMask) && \"bitmask contains non-CVR bits\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 274, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!(mask & ~CVRMask) && "bitmask contains non-CVR bits"); |
275 | Mask = (Mask & ~CVRMask) | mask; |
276 | } |
277 | void removeCVRQualifiers(unsigned mask) { |
278 | (0) . __assert_fail ("!(mask & ~CVRMask) && \"bitmask contains non-CVR bits\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 278, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!(mask & ~CVRMask) && "bitmask contains non-CVR bits"); |
279 | Mask &= ~mask; |
280 | } |
281 | void removeCVRQualifiers() { |
282 | removeCVRQualifiers(CVRMask); |
283 | } |
284 | void addCVRQualifiers(unsigned mask) { |
285 | (0) . __assert_fail ("!(mask & ~CVRMask) && \"bitmask contains non-CVR bits\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 285, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!(mask & ~CVRMask) && "bitmask contains non-CVR bits"); |
286 | Mask |= mask; |
287 | } |
288 | void addCVRUQualifiers(unsigned mask) { |
289 | (0) . __assert_fail ("!(mask & ~CVRMask & ~UMask) && \"bitmask contains non-CVRU bits\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 289, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!(mask & ~CVRMask & ~UMask) && "bitmask contains non-CVRU bits"); |
290 | Mask |= mask; |
291 | } |
292 | |
293 | bool hasUnaligned() const { return Mask & UMask; } |
294 | void setUnaligned(bool flag) { |
295 | Mask = (Mask & ~UMask) | (flag ? UMask : 0); |
296 | } |
297 | void removeUnaligned() { Mask &= ~UMask; } |
298 | void addUnaligned() { Mask |= UMask; } |
299 | |
300 | bool hasObjCGCAttr() const { return Mask & GCAttrMask; } |
301 | GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >> GCAttrShift); } |
302 | void setObjCGCAttr(GC type) { |
303 | Mask = (Mask & ~GCAttrMask) | (type << GCAttrShift); |
304 | } |
305 | void removeObjCGCAttr() { setObjCGCAttr(GCNone); } |
306 | void addObjCGCAttr(GC type) { |
307 | assert(type); |
308 | setObjCGCAttr(type); |
309 | } |
310 | Qualifiers withoutObjCGCAttr() const { |
311 | Qualifiers qs = *this; |
312 | qs.removeObjCGCAttr(); |
313 | return qs; |
314 | } |
315 | Qualifiers withoutObjCLifetime() const { |
316 | Qualifiers qs = *this; |
317 | qs.removeObjCLifetime(); |
318 | return qs; |
319 | } |
320 | Qualifiers withoutAddressSpace() const { |
321 | Qualifiers qs = *this; |
322 | qs.removeAddressSpace(); |
323 | return qs; |
324 | } |
325 | |
326 | bool hasObjCLifetime() const { return Mask & LifetimeMask; } |
327 | ObjCLifetime getObjCLifetime() const { |
328 | return ObjCLifetime((Mask & LifetimeMask) >> LifetimeShift); |
329 | } |
330 | void setObjCLifetime(ObjCLifetime type) { |
331 | Mask = (Mask & ~LifetimeMask) | (type << LifetimeShift); |
332 | } |
333 | void removeObjCLifetime() { setObjCLifetime(OCL_None); } |
334 | void addObjCLifetime(ObjCLifetime type) { |
335 | assert(type); |
336 | assert(!hasObjCLifetime()); |
337 | Mask |= (type << LifetimeShift); |
338 | } |
339 | |
340 | |
341 | bool hasNonTrivialObjCLifetime() const { |
342 | ObjCLifetime lifetime = getObjCLifetime(); |
343 | return (lifetime > OCL_ExplicitNone); |
344 | } |
345 | |
346 | |
347 | bool hasStrongOrWeakObjCLifetime() const { |
348 | ObjCLifetime lifetime = getObjCLifetime(); |
349 | return (lifetime == OCL_Strong || lifetime == OCL_Weak); |
350 | } |
351 | |
352 | bool hasAddressSpace() const { return Mask & AddressSpaceMask; } |
353 | LangAS getAddressSpace() const { |
354 | return static_cast<LangAS>(Mask >> AddressSpaceShift); |
355 | } |
356 | bool hasTargetSpecificAddressSpace() const { |
357 | return isTargetAddressSpace(getAddressSpace()); |
358 | } |
359 | |
360 | unsigned getAddressSpaceAttributePrintValue() const { |
361 | auto Addr = getAddressSpace(); |
362 | |
363 | |
364 | |
365 | assert(Addr == LangAS::Default || hasTargetSpecificAddressSpace()); |
366 | if (Addr != LangAS::Default) |
367 | return toTargetAddressSpace(Addr); |
368 | |
369 | |
370 | |
371 | return 0; |
372 | } |
373 | void setAddressSpace(LangAS space) { |
374 | assert((unsigned)space <= MaxAddressSpace); |
375 | Mask = (Mask & ~AddressSpaceMask) |
376 | | (((uint32_t) space) << AddressSpaceShift); |
377 | } |
378 | void removeAddressSpace() { setAddressSpace(LangAS::Default); } |
379 | void addAddressSpace(LangAS space) { |
380 | assert(space != LangAS::Default); |
381 | setAddressSpace(space); |
382 | } |
383 | |
384 | |
385 | |
386 | bool hasFastQualifiers() const { return getFastQualifiers(); } |
387 | unsigned getFastQualifiers() const { return Mask & FastMask; } |
388 | void setFastQualifiers(unsigned mask) { |
389 | (0) . __assert_fail ("!(mask & ~FastMask) && \"bitmask contains non-fast qualifier bits\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 389, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!(mask & ~FastMask) && "bitmask contains non-fast qualifier bits"); |
390 | Mask = (Mask & ~FastMask) | mask; |
391 | } |
392 | void removeFastQualifiers(unsigned mask) { |
393 | (0) . __assert_fail ("!(mask & ~FastMask) && \"bitmask contains non-fast qualifier bits\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 393, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!(mask & ~FastMask) && "bitmask contains non-fast qualifier bits"); |
394 | Mask &= ~mask; |
395 | } |
396 | void removeFastQualifiers() { |
397 | removeFastQualifiers(FastMask); |
398 | } |
399 | void addFastQualifiers(unsigned mask) { |
400 | (0) . __assert_fail ("!(mask & ~FastMask) && \"bitmask contains non-fast qualifier bits\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 400, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!(mask & ~FastMask) && "bitmask contains non-fast qualifier bits"); |
401 | Mask |= mask; |
402 | } |
403 | |
404 | |
405 | |
406 | bool hasNonFastQualifiers() const { return Mask & ~FastMask; } |
407 | Qualifiers getNonFastQualifiers() const { |
408 | Qualifiers Quals = *this; |
409 | Quals.setFastQualifiers(0); |
410 | return Quals; |
411 | } |
412 | |
413 | |
414 | bool hasQualifiers() const { return Mask; } |
415 | bool empty() const { return !Mask; } |
416 | |
417 | |
418 | void addQualifiers(Qualifiers Q) { |
419 | |
420 | |
421 | if (!(Q.Mask & ~CVRMask)) |
422 | Mask |= Q.Mask; |
423 | else { |
424 | Mask |= (Q.Mask & CVRMask); |
425 | if (Q.hasAddressSpace()) |
426 | addAddressSpace(Q.getAddressSpace()); |
427 | if (Q.hasObjCGCAttr()) |
428 | addObjCGCAttr(Q.getObjCGCAttr()); |
429 | if (Q.hasObjCLifetime()) |
430 | addObjCLifetime(Q.getObjCLifetime()); |
431 | } |
432 | } |
433 | |
434 | |
435 | void removeQualifiers(Qualifiers Q) { |
436 | |
437 | |
438 | if (!(Q.Mask & ~CVRMask)) |
439 | Mask &= ~Q.Mask; |
440 | else { |
441 | Mask &= ~(Q.Mask & CVRMask); |
442 | if (getObjCGCAttr() == Q.getObjCGCAttr()) |
443 | removeObjCGCAttr(); |
444 | if (getObjCLifetime() == Q.getObjCLifetime()) |
445 | removeObjCLifetime(); |
446 | if (getAddressSpace() == Q.getAddressSpace()) |
447 | removeAddressSpace(); |
448 | } |
449 | } |
450 | |
451 | |
452 | |
453 | void addConsistentQualifiers(Qualifiers qs) { |
454 | assert(getAddressSpace() == qs.getAddressSpace() || |
455 | !hasAddressSpace() || !qs.hasAddressSpace()); |
456 | assert(getObjCGCAttr() == qs.getObjCGCAttr() || |
457 | !hasObjCGCAttr() || !qs.hasObjCGCAttr()); |
458 | assert(getObjCLifetime() == qs.getObjCLifetime() || |
459 | !hasObjCLifetime() || !qs.hasObjCLifetime()); |
460 | Mask |= qs.Mask; |
461 | } |
462 | |
463 | |
464 | |
465 | |
466 | |
467 | |
468 | |
469 | |
470 | bool isAddressSpaceSupersetOf(Qualifiers other) const { |
471 | return |
472 | |
473 | getAddressSpace() == other.getAddressSpace() || |
474 | |
475 | |
476 | (getAddressSpace() == LangAS::opencl_generic && |
477 | other.getAddressSpace() != LangAS::opencl_constant); |
478 | } |
479 | |
480 | |
481 | |
482 | |
483 | bool compatiblyIncludes(Qualifiers other) const { |
484 | return isAddressSpaceSupersetOf(other) && |
485 | |
486 | |
487 | (getObjCGCAttr() == other.getObjCGCAttr() || !hasObjCGCAttr() || |
488 | !other.hasObjCGCAttr()) && |
489 | |
490 | getObjCLifetime() == other.getObjCLifetime() && |
491 | |
492 | (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask)) && |
493 | |
494 | (!other.hasUnaligned() || hasUnaligned()); |
495 | } |
496 | |
497 | |
498 | |
499 | |
500 | |
501 | |
502 | |
503 | |
504 | bool compatiblyIncludesObjCLifetime(Qualifiers other) const { |
505 | if (getObjCLifetime() == other.getObjCLifetime()) |
506 | return true; |
507 | |
508 | if (getObjCLifetime() == OCL_Weak || other.getObjCLifetime() == OCL_Weak) |
509 | return false; |
510 | |
511 | if (getObjCLifetime() == OCL_None || other.getObjCLifetime() == OCL_None) |
512 | return true; |
513 | |
514 | return hasConst(); |
515 | } |
516 | |
517 | |
518 | |
519 | bool isStrictSupersetOf(Qualifiers Other) const; |
520 | |
521 | bool operator==(Qualifiers Other) const { return Mask == Other.Mask; } |
522 | bool operator!=(Qualifiers Other) const { return Mask != Other.Mask; } |
523 | |
524 | explicit operator bool() const { return hasQualifiers(); } |
525 | |
526 | Qualifiers &operator+=(Qualifiers R) { |
527 | addQualifiers(R); |
528 | return *this; |
529 | } |
530 | |
531 | |
532 | |
533 | friend Qualifiers operator+(Qualifiers L, Qualifiers R) { |
534 | L += R; |
535 | return L; |
536 | } |
537 | |
538 | Qualifiers &operator-=(Qualifiers R) { |
539 | removeQualifiers(R); |
540 | return *this; |
541 | } |
542 | |
543 | |
544 | friend Qualifiers operator-(Qualifiers L, Qualifiers R) { |
545 | L -= R; |
546 | return L; |
547 | } |
548 | |
549 | std::string getAsString() const; |
550 | std::string getAsString(const PrintingPolicy &Policy) const; |
551 | |
552 | bool isEmptyWhenPrinted(const PrintingPolicy &Policy) const; |
553 | void print(raw_ostream &OS, const PrintingPolicy &Policy, |
554 | bool appendSpaceIfNonEmpty = false) const; |
555 | |
556 | void Profile(llvm::FoldingSetNodeID &ID) const { |
557 | ID.AddInteger(Mask); |
558 | } |
559 | |
560 | private: |
561 | |
562 | |
563 | uint32_t Mask = 0; |
564 | |
565 | static const uint32_t UMask = 0x8; |
566 | static const uint32_t UShift = 3; |
567 | static const uint32_t GCAttrMask = 0x30; |
568 | static const uint32_t GCAttrShift = 4; |
569 | static const uint32_t LifetimeMask = 0x1C0; |
570 | static const uint32_t LifetimeShift = 6; |
571 | static const uint32_t AddressSpaceMask = |
572 | ~(CVRMask | UMask | GCAttrMask | LifetimeMask); |
573 | static const uint32_t AddressSpaceShift = 9; |
574 | }; |
575 | |
576 | |
577 | |
578 | struct SplitQualType { |
579 | |
580 | const Type *Ty = nullptr; |
581 | |
582 | |
583 | Qualifiers Quals; |
584 | |
585 | SplitQualType() = default; |
586 | SplitQualType(const Type *ty, Qualifiers qs) : Ty(ty), Quals(qs) {} |
587 | |
588 | SplitQualType getSingleStepDesugaredType() const; |
589 | |
590 | |
591 | std::pair<const Type *,Qualifiers> asPair() const { |
592 | return std::pair<const Type *, Qualifiers>(Ty, Quals); |
593 | } |
594 | |
595 | friend bool operator==(SplitQualType a, SplitQualType b) { |
596 | return a.Ty == b.Ty && a.Quals == b.Quals; |
597 | } |
598 | friend bool operator!=(SplitQualType a, SplitQualType b) { |
599 | return a.Ty != b.Ty || a.Quals != b.Quals; |
600 | } |
601 | }; |
602 | |
603 | |
604 | |
605 | |
606 | |
607 | |
608 | enum class ObjCSubstitutionContext { |
609 | |
610 | Ordinary, |
611 | |
612 | |
613 | Result, |
614 | |
615 | |
616 | Parameter, |
617 | |
618 | |
619 | Property, |
620 | |
621 | |
622 | Superclass, |
623 | }; |
624 | |
625 | |
626 | |
627 | |
628 | |
629 | |
630 | |
631 | |
632 | |
633 | |
634 | |
635 | |
636 | |
637 | |
638 | |
639 | class QualType { |
640 | friend class QualifierCollector; |
641 | |
642 | |
643 | llvm::PointerIntPair<llvm::PointerUnion<const Type *, const ExtQuals *>, |
644 | Qualifiers::FastWidth> Value; |
645 | |
646 | const ExtQuals *getExtQualsUnsafe() const { |
647 | return Value.getPointer().get<const ExtQuals*>(); |
648 | } |
649 | |
650 | const Type *getTypePtrUnsafe() const { |
651 | return Value.getPointer().get<const Type*>(); |
652 | } |
653 | |
654 | const ExtQualsTypeCommonBase *getCommonPtr() const { |
655 | (0) . __assert_fail ("!isNull() && \"Cannot retrieve a NULL type pointer\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 655, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isNull() && "Cannot retrieve a NULL type pointer"); |
656 | auto CommonPtrVal = reinterpret_cast<uintptr_t>(Value.getOpaqueValue()); |
657 | CommonPtrVal &= ~(uintptr_t)((1 << TypeAlignmentInBits) - 1); |
658 | return reinterpret_cast<ExtQualsTypeCommonBase*>(CommonPtrVal); |
659 | } |
660 | |
661 | public: |
662 | QualType() = default; |
663 | QualType(const Type *Ptr, unsigned Quals) : Value(Ptr, Quals) {} |
664 | QualType(const ExtQuals *Ptr, unsigned Quals) : Value(Ptr, Quals) {} |
665 | |
666 | unsigned getLocalFastQualifiers() const { return Value.getInt(); } |
667 | void setLocalFastQualifiers(unsigned Quals) { Value.setInt(Quals); } |
668 | |
669 | |
670 | |
671 | |
672 | |
673 | const Type *getTypePtr() const; |
674 | |
675 | const Type *getTypePtrOrNull() const; |
676 | |
677 | |
678 | const IdentifierInfo *getBaseTypeIdentifier() const; |
679 | |
680 | |
681 | |
682 | SplitQualType split() const; |
683 | |
684 | void *getAsOpaquePtr() const { return Value.getOpaqueValue(); } |
685 | |
686 | static QualType getFromOpaquePtr(const void *Ptr) { |
687 | QualType T; |
688 | T.Value.setFromOpaqueValue(const_cast<void*>(Ptr)); |
689 | return T; |
690 | } |
691 | |
692 | const Type &operator*() const { |
693 | return *getTypePtr(); |
694 | } |
695 | |
696 | const Type *operator->() const { |
697 | return getTypePtr(); |
698 | } |
699 | |
700 | bool isCanonical() const; |
701 | bool isCanonicalAsParam() const; |
702 | |
703 | |
704 | bool isNull() const { |
705 | return Value.getPointer().isNull(); |
706 | } |
707 | |
708 | |
709 | |
710 | |
711 | bool isLocalConstQualified() const { |
712 | return (getLocalFastQualifiers() & Qualifiers::Const); |
713 | } |
714 | |
715 | |
716 | bool isConstQualified() const; |
717 | |
718 | |
719 | |
720 | |
721 | bool isLocalRestrictQualified() const { |
722 | return (getLocalFastQualifiers() & Qualifiers::Restrict); |
723 | } |
724 | |
725 | |
726 | bool isRestrictQualified() const; |
727 | |
728 | |
729 | |
730 | |
731 | bool isLocalVolatileQualified() const { |
732 | return (getLocalFastQualifiers() & Qualifiers::Volatile); |
733 | } |
734 | |
735 | |
736 | bool isVolatileQualified() const; |
737 | |
738 | |
739 | |
740 | |
741 | bool hasLocalQualifiers() const { |
742 | return getLocalFastQualifiers() || hasLocalNonFastQualifiers(); |
743 | } |
744 | |
745 | |
746 | bool hasQualifiers() const; |
747 | |
748 | |
749 | |
750 | |
751 | bool hasLocalNonFastQualifiers() const { |
752 | return Value.getPointer().is<const ExtQuals*>(); |
753 | } |
754 | |
755 | |
756 | |
757 | |
758 | Qualifiers getLocalQualifiers() const; |
759 | |
760 | |
761 | Qualifiers getQualifiers() const; |
762 | |
763 | |
764 | |
765 | |
766 | unsigned getLocalCVRQualifiers() const { |
767 | return getLocalFastQualifiers(); |
768 | } |
769 | |
770 | |
771 | |
772 | unsigned getCVRQualifiers() const; |
773 | |
774 | bool isConstant(const ASTContext& Ctx) const { |
775 | return QualType::isConstant(*this, Ctx); |
776 | } |
777 | |
778 | |
779 | bool isPODType(const ASTContext &Context) const; |
780 | |
781 | |
782 | |
783 | bool isCXX98PODType(const ASTContext &Context) const; |
784 | |
785 | |
786 | |
787 | |
788 | |
789 | bool isCXX11PODType(const ASTContext &Context) const; |
790 | |
791 | |
792 | bool isTrivialType(const ASTContext &Context) const; |
793 | |
794 | |
795 | bool isTriviallyCopyableType(const ASTContext &Context) const; |
796 | |
797 | |
798 | |
799 | bool mayBeDynamicClass() const; |
800 | |
801 | |
802 | bool mayBeNotDynamicClass() const; |
803 | |
804 | |
805 | |
806 | |
807 | |
808 | void addConst() { |
809 | addFastQualifiers(Qualifiers::Const); |
810 | } |
811 | QualType withConst() const { |
812 | return withFastQualifiers(Qualifiers::Const); |
813 | } |
814 | |
815 | |
816 | void addVolatile() { |
817 | addFastQualifiers(Qualifiers::Volatile); |
818 | } |
819 | QualType withVolatile() const { |
820 | return withFastQualifiers(Qualifiers::Volatile); |
821 | } |
822 | |
823 | |
824 | void addRestrict() { |
825 | addFastQualifiers(Qualifiers::Restrict); |
826 | } |
827 | QualType withRestrict() const { |
828 | return withFastQualifiers(Qualifiers::Restrict); |
829 | } |
830 | |
831 | QualType withCVRQualifiers(unsigned CVR) const { |
832 | return withFastQualifiers(CVR); |
833 | } |
834 | |
835 | void addFastQualifiers(unsigned TQs) { |
836 | (0) . __assert_fail ("!(TQs & ~Qualifiers..FastMask) && \"non-fast qualifier bits set in mask!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 837, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!(TQs & ~Qualifiers::FastMask) |
837 | (0) . __assert_fail ("!(TQs & ~Qualifiers..FastMask) && \"non-fast qualifier bits set in mask!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 837, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> && "non-fast qualifier bits set in mask!"); |
838 | Value.setInt(Value.getInt() | TQs); |
839 | } |
840 | |
841 | void removeLocalConst(); |
842 | void removeLocalVolatile(); |
843 | void removeLocalRestrict(); |
844 | void removeLocalCVRQualifiers(unsigned Mask); |
845 | |
846 | void removeLocalFastQualifiers() { Value.setInt(0); } |
847 | void removeLocalFastQualifiers(unsigned Mask) { |
848 | (0) . __assert_fail ("!(Mask & ~Qualifiers..FastMask) && \"mask has non-fast qualifiers\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 848, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!(Mask & ~Qualifiers::FastMask) && "mask has non-fast qualifiers"); |
849 | Value.setInt(Value.getInt() & ~Mask); |
850 | } |
851 | |
852 | |
853 | |
854 | QualType withFastQualifiers(unsigned TQs) const { |
855 | QualType T = *this; |
856 | T.addFastQualifiers(TQs); |
857 | return T; |
858 | } |
859 | |
860 | |
861 | |
862 | QualType withExactLocalFastQualifiers(unsigned TQs) const { |
863 | return withoutLocalFastQualifiers().withFastQualifiers(TQs); |
864 | } |
865 | |
866 | |
867 | QualType withoutLocalFastQualifiers() const { |
868 | QualType T = *this; |
869 | T.removeLocalFastQualifiers(); |
870 | return T; |
871 | } |
872 | |
873 | QualType getCanonicalType() const; |
874 | |
875 | |
876 | |
877 | |
878 | QualType getLocalUnqualifiedType() const { return QualType(getTypePtr(), 0); } |
879 | |
880 | |
881 | |
882 | |
883 | |
884 | |
885 | |
886 | |
887 | |
888 | |
889 | |
890 | |
891 | |
892 | |
893 | |
894 | |
895 | |
896 | |
897 | |
898 | inline QualType getUnqualifiedType() const; |
899 | |
900 | |
901 | |
902 | |
903 | |
904 | |
905 | |
906 | |
907 | |
908 | |
909 | inline SplitQualType getSplitUnqualifiedType() const; |
910 | |
911 | |
912 | |
913 | bool isMoreQualifiedThan(QualType Other) const; |
914 | |
915 | |
916 | |
917 | bool isAtLeastAsQualifiedAs(QualType Other) const; |
918 | |
919 | QualType getNonReferenceType() const; |
920 | |
921 | |
922 | |
923 | |
924 | |
925 | |
926 | |
927 | |
928 | |
929 | QualType getNonLValueExprType(const ASTContext &Context) const; |
930 | |
931 | |
932 | |
933 | |
934 | |
935 | |
936 | |
937 | |
938 | |
939 | QualType getDesugaredType(const ASTContext &Context) const { |
940 | return getDesugaredType(*this, Context); |
941 | } |
942 | |
943 | SplitQualType getSplitDesugaredType() const { |
944 | return getSplitDesugaredType(*this); |
945 | } |
946 | |
947 | |
948 | |
949 | |
950 | |
951 | |
952 | QualType getSingleStepDesugaredType(const ASTContext &Context) const { |
953 | return getSingleStepDesugaredTypeImpl(*this, Context); |
954 | } |
955 | |
956 | |
957 | |
958 | QualType IgnoreParens() const { |
959 | if (isa<ParenType>(*this)) |
960 | return QualType::IgnoreParens(*this); |
961 | return *this; |
962 | } |
963 | |
964 | |
965 | friend bool operator==(const QualType &LHS, const QualType &RHS) { |
966 | return LHS.Value == RHS.Value; |
967 | } |
968 | friend bool operator!=(const QualType &LHS, const QualType &RHS) { |
969 | return LHS.Value != RHS.Value; |
970 | } |
971 | |
972 | static std::string getAsString(SplitQualType split, |
973 | const PrintingPolicy &Policy) { |
974 | return getAsString(split.Ty, split.Quals, Policy); |
975 | } |
976 | static std::string getAsString(const Type *ty, Qualifiers qs, |
977 | const PrintingPolicy &Policy); |
978 | |
979 | std::string getAsString() const; |
980 | std::string getAsString(const PrintingPolicy &Policy) const; |
981 | |
982 | void print(raw_ostream &OS, const PrintingPolicy &Policy, |
983 | const Twine &PlaceHolder = Twine(), |
984 | unsigned Indentation = 0) const; |
985 | |
986 | static void print(SplitQualType split, raw_ostream &OS, |
987 | const PrintingPolicy &policy, const Twine &PlaceHolder, |
988 | unsigned Indentation = 0) { |
989 | return print(split.Ty, split.Quals, OS, policy, PlaceHolder, Indentation); |
990 | } |
991 | |
992 | static void print(const Type *ty, Qualifiers qs, |
993 | raw_ostream &OS, const PrintingPolicy &policy, |
994 | const Twine &PlaceHolder, |
995 | unsigned Indentation = 0); |
996 | |
997 | void getAsStringInternal(std::string &Str, |
998 | const PrintingPolicy &Policy) const; |
999 | |
1000 | static void getAsStringInternal(SplitQualType split, std::string &out, |
1001 | const PrintingPolicy &policy) { |
1002 | return getAsStringInternal(split.Ty, split.Quals, out, policy); |
1003 | } |
1004 | |
1005 | static void getAsStringInternal(const Type *ty, Qualifiers qs, |
1006 | std::string &out, |
1007 | const PrintingPolicy &policy); |
1008 | |
1009 | class StreamedQualTypeHelper { |
1010 | const QualType &T; |
1011 | const PrintingPolicy &Policy; |
1012 | const Twine &PlaceHolder; |
1013 | unsigned Indentation; |
1014 | |
1015 | public: |
1016 | StreamedQualTypeHelper(const QualType &T, const PrintingPolicy &Policy, |
1017 | const Twine &PlaceHolder, unsigned Indentation) |
1018 | : T(T), Policy(Policy), PlaceHolder(PlaceHolder), |
1019 | Indentation(Indentation) {} |
1020 | |
1021 | friend raw_ostream &operator<<(raw_ostream &OS, |
1022 | const StreamedQualTypeHelper &SQT) { |
1023 | SQT.T.print(OS, SQT.Policy, SQT.PlaceHolder, SQT.Indentation); |
1024 | return OS; |
1025 | } |
1026 | }; |
1027 | |
1028 | StreamedQualTypeHelper stream(const PrintingPolicy &Policy, |
1029 | const Twine &PlaceHolder = Twine(), |
1030 | unsigned Indentation = 0) const { |
1031 | return StreamedQualTypeHelper(*this, Policy, PlaceHolder, Indentation); |
1032 | } |
1033 | |
1034 | void dump(const char *s) const; |
1035 | void dump() const; |
1036 | void dump(llvm::raw_ostream &OS) const; |
1037 | |
1038 | void Profile(llvm::FoldingSetNodeID &ID) const { |
1039 | ID.AddPointer(getAsOpaquePtr()); |
1040 | } |
1041 | |
1042 | |
1043 | inline LangAS getAddressSpace() const; |
1044 | |
1045 | |
1046 | inline Qualifiers::GC getObjCGCAttr() const; |
1047 | |
1048 | |
1049 | bool isObjCGCWeak() const { |
1050 | return getObjCGCAttr() == Qualifiers::Weak; |
1051 | } |
1052 | |
1053 | |
1054 | bool isObjCGCStrong() const { |
1055 | return getObjCGCAttr() == Qualifiers::Strong; |
1056 | } |
1057 | |
1058 | |
1059 | Qualifiers::ObjCLifetime getObjCLifetime() const { |
1060 | return getQualifiers().getObjCLifetime(); |
1061 | } |
1062 | |
1063 | bool hasNonTrivialObjCLifetime() const { |
1064 | return getQualifiers().hasNonTrivialObjCLifetime(); |
1065 | } |
1066 | |
1067 | bool hasStrongOrWeakObjCLifetime() const { |
1068 | return getQualifiers().hasStrongOrWeakObjCLifetime(); |
1069 | } |
1070 | |
1071 | |
1072 | bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const; |
1073 | |
1074 | enum PrimitiveDefaultInitializeKind { |
1075 | |
1076 | |
1077 | |
1078 | PDIK_Trivial, |
1079 | |
1080 | |
1081 | |
1082 | PDIK_ARCStrong, |
1083 | |
1084 | |
1085 | |
1086 | PDIK_ARCWeak, |
1087 | |
1088 | |
1089 | PDIK_Struct |
1090 | }; |
1091 | |
1092 | |
1093 | |
1094 | |
1095 | |
1096 | |
1097 | PrimitiveDefaultInitializeKind |
1098 | isNonTrivialToPrimitiveDefaultInitialize() const; |
1099 | |
1100 | enum PrimitiveCopyKind { |
1101 | |
1102 | |
1103 | |
1104 | PCK_Trivial, |
1105 | |
1106 | |
1107 | |
1108 | |
1109 | PCK_VolatileTrivial, |
1110 | |
1111 | |
1112 | |
1113 | PCK_ARCStrong, |
1114 | |
1115 | |
1116 | |
1117 | PCK_ARCWeak, |
1118 | |
1119 | |
1120 | |
1121 | |
1122 | |
1123 | |
1124 | |
1125 | PCK_Struct |
1126 | }; |
1127 | |
1128 | |
1129 | |
1130 | |
1131 | |
1132 | bool isNonTrivialPrimitiveCType(const ASTContext &Ctx) const; |
1133 | |
1134 | |
1135 | |
1136 | |
1137 | PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const; |
1138 | |
1139 | |
1140 | |
1141 | |
1142 | |
1143 | |
1144 | |
1145 | PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const; |
1146 | |
1147 | enum DestructionKind { |
1148 | DK_none, |
1149 | DK_cxx_destructor, |
1150 | DK_objc_strong_lifetime, |
1151 | DK_objc_weak_lifetime, |
1152 | DK_nontrivial_c_struct |
1153 | }; |
1154 | |
1155 | |
1156 | |
1157 | |
1158 | |
1159 | DestructionKind isDestructedType() const { |
1160 | return isDestructedTypeImpl(*this); |
1161 | } |
1162 | |
1163 | |
1164 | |
1165 | |
1166 | |
1167 | |
1168 | |
1169 | |
1170 | |
1171 | |
1172 | |
1173 | bool isCForbiddenLValueType() const; |
1174 | |
1175 | |
1176 | |
1177 | |
1178 | |
1179 | |
1180 | |
1181 | |
1182 | |
1183 | |
1184 | |
1185 | |
1186 | |
1187 | |
1188 | |
1189 | QualType substObjCTypeArgs(ASTContext &ctx, |
1190 | ArrayRef<QualType> typeArgs, |
1191 | ObjCSubstitutionContext context) const; |
1192 | |
1193 | |
1194 | |
1195 | |
1196 | |
1197 | |
1198 | |
1199 | |
1200 | |
1201 | |
1202 | |
1203 | |
1204 | |
1205 | |
1206 | |
1207 | |
1208 | |
1209 | |
1210 | |
1211 | |
1212 | |
1213 | QualType substObjCMemberType(QualType objectType, |
1214 | const DeclContext *dc, |
1215 | ObjCSubstitutionContext context) const; |
1216 | |
1217 | |
1218 | QualType stripObjCKindOfType(const ASTContext &ctx) const; |
1219 | |
1220 | |
1221 | QualType getAtomicUnqualifiedType() const; |
1222 | |
1223 | private: |
1224 | |
1225 | |
1226 | |
1227 | static bool isConstant(QualType T, const ASTContext& Ctx); |
1228 | static QualType getDesugaredType(QualType T, const ASTContext &Context); |
1229 | static SplitQualType getSplitDesugaredType(QualType T); |
1230 | static SplitQualType getSplitUnqualifiedTypeImpl(QualType type); |
1231 | static QualType getSingleStepDesugaredTypeImpl(QualType type, |
1232 | const ASTContext &C); |
1233 | static QualType IgnoreParens(QualType T); |
1234 | static DestructionKind isDestructedTypeImpl(QualType type); |
1235 | }; |
1236 | |
1237 | } |
1238 | |
1239 | namespace llvm { |
1240 | |
1241 | |
1242 | |
1243 | template<> struct simplify_type< ::clang::QualType> { |
1244 | using SimpleType = const ::clang::Type *; |
1245 | |
1246 | static SimpleType getSimplifiedValue(::clang::QualType Val) { |
1247 | return Val.getTypePtr(); |
1248 | } |
1249 | }; |
1250 | |
1251 | |
1252 | template<> |
1253 | struct PointerLikeTypeTraits<clang::QualType> { |
1254 | static inline void *getAsVoidPointer(clang::QualType P) { |
1255 | return P.getAsOpaquePtr(); |
1256 | } |
1257 | |
1258 | static inline clang::QualType getFromVoidPointer(void *P) { |
1259 | return clang::QualType::getFromOpaquePtr(P); |
1260 | } |
1261 | |
1262 | |
1263 | enum { NumLowBitsAvailable = 0 }; |
1264 | }; |
1265 | |
1266 | } |
1267 | |
1268 | namespace clang { |
1269 | |
1270 | |
1271 | |
1272 | |
1273 | class ExtQualsTypeCommonBase { |
1274 | friend class ExtQuals; |
1275 | friend class QualType; |
1276 | friend class Type; |
1277 | |
1278 | |
1279 | |
1280 | |
1281 | |
1282 | |
1283 | const Type *const BaseType; |
1284 | |
1285 | |
1286 | QualType CanonicalType; |
1287 | |
1288 | ExtQualsTypeCommonBase(const Type *baseType, QualType canon) |
1289 | : BaseType(baseType), CanonicalType(canon) {} |
1290 | }; |
1291 | |
1292 | |
1293 | |
1294 | |
1295 | |
1296 | |
1297 | |
1298 | |
1299 | |
1300 | |
1301 | |
1302 | class ExtQuals : public ExtQualsTypeCommonBase, public llvm::FoldingSetNode { |
1303 | |
1304 | |
1305 | |
1306 | |
1307 | |
1308 | |
1309 | |
1310 | |
1311 | |
1312 | |
1313 | |
1314 | |
1315 | |
1316 | |
1317 | |
1318 | Qualifiers Quals; |
1319 | |
1320 | ExtQuals *this_() { return this; } |
1321 | |
1322 | public: |
1323 | ExtQuals(const Type *baseType, QualType canon, Qualifiers quals) |
1324 | : ExtQualsTypeCommonBase(baseType, |
1325 | canon.isNull() ? QualType(this_(), 0) : canon), |
1326 | Quals(quals) { |
1327 | (0) . __assert_fail ("Quals.hasNonFastQualifiers() && \"ExtQuals created with no fast qualifiers\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 1328, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Quals.hasNonFastQualifiers() |
1328 | (0) . __assert_fail ("Quals.hasNonFastQualifiers() && \"ExtQuals created with no fast qualifiers\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 1328, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> && "ExtQuals created with no fast qualifiers"); |
1329 | (0) . __assert_fail ("!Quals.hasFastQualifiers() && \"ExtQuals created with fast qualifiers\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 1330, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!Quals.hasFastQualifiers() |
1330 | (0) . __assert_fail ("!Quals.hasFastQualifiers() && \"ExtQuals created with fast qualifiers\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 1330, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> && "ExtQuals created with fast qualifiers"); |
1331 | } |
1332 | |
1333 | Qualifiers getQualifiers() const { return Quals; } |
1334 | |
1335 | bool hasObjCGCAttr() const { return Quals.hasObjCGCAttr(); } |
1336 | Qualifiers::GC getObjCGCAttr() const { return Quals.getObjCGCAttr(); } |
1337 | |
1338 | bool hasObjCLifetime() const { return Quals.hasObjCLifetime(); } |
1339 | Qualifiers::ObjCLifetime getObjCLifetime() const { |
1340 | return Quals.getObjCLifetime(); |
1341 | } |
1342 | |
1343 | bool hasAddressSpace() const { return Quals.hasAddressSpace(); } |
1344 | LangAS getAddressSpace() const { return Quals.getAddressSpace(); } |
1345 | |
1346 | const Type *getBaseType() const { return BaseType; } |
1347 | |
1348 | public: |
1349 | void Profile(llvm::FoldingSetNodeID &ID) const { |
1350 | Profile(ID, getBaseType(), Quals); |
1351 | } |
1352 | |
1353 | static void Profile(llvm::FoldingSetNodeID &ID, |
1354 | const Type *BaseType, |
1355 | Qualifiers Quals) { |
1356 | (0) . __assert_fail ("!Quals.hasFastQualifiers() && \"fast qualifiers in ExtQuals hash!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 1356, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!Quals.hasFastQualifiers() && "fast qualifiers in ExtQuals hash!"); |
1357 | ID.AddPointer(BaseType); |
1358 | Quals.Profile(ID); |
1359 | } |
1360 | }; |
1361 | |
1362 | |
1363 | |
1364 | |
1365 | enum RefQualifierKind { |
1366 | |
1367 | RQ_None = 0, |
1368 | |
1369 | |
1370 | RQ_LValue, |
1371 | |
1372 | |
1373 | RQ_RValue |
1374 | }; |
1375 | |
1376 | |
1377 | enum class AutoTypeKeyword { |
1378 | |
1379 | Auto, |
1380 | |
1381 | |
1382 | DecltypeAuto, |
1383 | |
1384 | |
1385 | GNUAutoType |
1386 | }; |
1387 | |
1388 | |
1389 | |
1390 | |
1391 | |
1392 | |
1393 | |
1394 | |
1395 | |
1396 | |
1397 | |
1398 | |
1399 | |
1400 | |
1401 | |
1402 | |
1403 | |
1404 | |
1405 | |
1406 | |
1407 | |
1408 | |
1409 | |
1410 | |
1411 | |
1412 | |
1413 | |
1414 | class Type : public ExtQualsTypeCommonBase { |
1415 | public: |
1416 | enum TypeClass { |
1417 | #define TYPE(Class, Base) Class, |
1418 | #define LAST_TYPE(Class) TypeLast = Class, |
1419 | #define ABSTRACT_TYPE(Class, Base) |
1420 | #include "clang/AST/TypeNodes.def" |
1421 | TagFirst = Record, TagLast = Enum |
1422 | }; |
1423 | |
1424 | private: |
1425 | |
1426 | class TypeBitfields { |
1427 | friend class Type; |
1428 | template <class T> friend class TypePropertyCache; |
1429 | |
1430 | |
1431 | unsigned TC : 8; |
1432 | |
1433 | |
1434 | unsigned Dependent : 1; |
1435 | |
1436 | |
1437 | |
1438 | unsigned InstantiationDependent : 1; |
1439 | |
1440 | |
1441 | unsigned VariablyModified : 1; |
1442 | |
1443 | |
1444 | |
1445 | unsigned ContainsUnexpandedParameterPack : 1; |
1446 | |
1447 | |
1448 | |
1449 | mutable unsigned CacheValid : 1; |
1450 | |
1451 | |
1452 | mutable unsigned CachedLinkage : 3; |
1453 | |
1454 | |
1455 | mutable unsigned CachedLocalOrUnnamed : 1; |
1456 | |
1457 | |
1458 | mutable unsigned FromAST : 1; |
1459 | |
1460 | bool isCacheValid() const { |
1461 | return CacheValid; |
1462 | } |
1463 | |
1464 | Linkage getLinkage() const { |
1465 | (0) . __assert_fail ("isCacheValid() && \"getting linkage from invalid cache\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 1465, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isCacheValid() && "getting linkage from invalid cache"); |
1466 | return static_cast<Linkage>(CachedLinkage); |
1467 | } |
1468 | |
1469 | bool hasLocalOrUnnamedType() const { |
1470 | (0) . __assert_fail ("isCacheValid() && \"getting linkage from invalid cache\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 1470, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isCacheValid() && "getting linkage from invalid cache"); |
1471 | return CachedLocalOrUnnamed; |
1472 | } |
1473 | }; |
1474 | enum { NumTypeBits = 18 }; |
1475 | |
1476 | protected: |
1477 | |
1478 | |
1479 | |
1480 | class ArrayTypeBitfields { |
1481 | friend class ArrayType; |
1482 | |
1483 | unsigned : NumTypeBits; |
1484 | |
1485 | |
1486 | |
1487 | unsigned IndexTypeQuals : 3; |
1488 | |
1489 | |
1490 | |
1491 | |
1492 | unsigned SizeModifier : 3; |
1493 | }; |
1494 | |
1495 | class BuiltinTypeBitfields { |
1496 | friend class BuiltinType; |
1497 | |
1498 | unsigned : NumTypeBits; |
1499 | |
1500 | |
1501 | unsigned Kind : 8; |
1502 | }; |
1503 | |
1504 | |
1505 | |
1506 | |
1507 | class FunctionTypeBitfields { |
1508 | friend class FunctionProtoType; |
1509 | friend class FunctionType; |
1510 | |
1511 | unsigned : NumTypeBits; |
1512 | |
1513 | |
1514 | |
1515 | unsigned ExtInfo : 12; |
1516 | |
1517 | |
1518 | |
1519 | |
1520 | unsigned RefQualifier : 2; |
1521 | |
1522 | |
1523 | |
1524 | |
1525 | |
1526 | |
1527 | |
1528 | unsigned FastTypeQuals : Qualifiers::FastWidth; |
1529 | |
1530 | unsigned HasExtQuals : 1; |
1531 | |
1532 | |
1533 | |
1534 | |
1535 | |
1536 | unsigned NumParams : 16; |
1537 | |
1538 | |
1539 | unsigned ExceptionSpecType : 4; |
1540 | |
1541 | |
1542 | unsigned HasExtParameterInfos : 1; |
1543 | |
1544 | |
1545 | unsigned Variadic : 1; |
1546 | |
1547 | |
1548 | unsigned HasTrailingReturn : 1; |
1549 | }; |
1550 | |
1551 | class ObjCObjectTypeBitfields { |
1552 | friend class ObjCObjectType; |
1553 | |
1554 | unsigned : NumTypeBits; |
1555 | |
1556 | |
1557 | unsigned NumTypeArgs : 7; |
1558 | |
1559 | |
1560 | unsigned NumProtocols : 6; |
1561 | |
1562 | |
1563 | unsigned IsKindOf : 1; |
1564 | }; |
1565 | |
1566 | class ReferenceTypeBitfields { |
1567 | friend class ReferenceType; |
1568 | |
1569 | unsigned : NumTypeBits; |
1570 | |
1571 | |
1572 | |
1573 | |
1574 | |
1575 | |
1576 | |
1577 | |
1578 | |
1579 | |
1580 | |
1581 | |
1582 | unsigned SpelledAsLValue : 1; |
1583 | |
1584 | |
1585 | |
1586 | unsigned InnerRef : 1; |
1587 | }; |
1588 | |
1589 | class TypeWithKeywordBitfields { |
1590 | friend class TypeWithKeyword; |
1591 | |
1592 | unsigned : NumTypeBits; |
1593 | |
1594 | |
1595 | unsigned Keyword : 8; |
1596 | }; |
1597 | |
1598 | enum { NumTypeWithKeywordBits = 8 }; |
1599 | |
1600 | class ElaboratedTypeBitfields { |
1601 | friend class ElaboratedType; |
1602 | |
1603 | unsigned : NumTypeBits; |
1604 | unsigned : NumTypeWithKeywordBits; |
1605 | |
1606 | |
1607 | unsigned HasOwnedTagDecl : 1; |
1608 | }; |
1609 | |
1610 | class VectorTypeBitfields { |
1611 | friend class VectorType; |
1612 | friend class DependentVectorType; |
1613 | |
1614 | unsigned : NumTypeBits; |
1615 | |
1616 | |
1617 | |
1618 | unsigned VecKind : 3; |
1619 | |
1620 | |
1621 | unsigned NumElements : 29 - NumTypeBits; |
1622 | |
1623 | enum { MaxNumElements = (1 << (29 - NumTypeBits)) - 1 }; |
1624 | }; |
1625 | |
1626 | class AttributedTypeBitfields { |
1627 | friend class AttributedType; |
1628 | |
1629 | unsigned : NumTypeBits; |
1630 | |
1631 | |
1632 | unsigned AttrKind : 32 - NumTypeBits; |
1633 | }; |
1634 | |
1635 | class AutoTypeBitfields { |
1636 | friend class AutoType; |
1637 | |
1638 | unsigned : NumTypeBits; |
1639 | |
1640 | |
1641 | |
1642 | unsigned Keyword : 2; |
1643 | }; |
1644 | |
1645 | class SubstTemplateTypeParmPackTypeBitfields { |
1646 | friend class SubstTemplateTypeParmPackType; |
1647 | |
1648 | unsigned : NumTypeBits; |
1649 | |
1650 | |
1651 | |
1652 | |
1653 | |
1654 | |
1655 | |
1656 | |
1657 | unsigned NumArgs; |
1658 | }; |
1659 | |
1660 | class TemplateSpecializationTypeBitfields { |
1661 | friend class TemplateSpecializationType; |
1662 | |
1663 | unsigned : NumTypeBits; |
1664 | |
1665 | |
1666 | unsigned TypeAlias : 1; |
1667 | |
1668 | |
1669 | |
1670 | |
1671 | |
1672 | |
1673 | |
1674 | |
1675 | unsigned NumArgs; |
1676 | }; |
1677 | |
1678 | class DependentTemplateSpecializationTypeBitfields { |
1679 | friend class DependentTemplateSpecializationType; |
1680 | |
1681 | unsigned : NumTypeBits; |
1682 | unsigned : NumTypeWithKeywordBits; |
1683 | |
1684 | |
1685 | |
1686 | |
1687 | |
1688 | |
1689 | |
1690 | |
1691 | unsigned NumArgs; |
1692 | }; |
1693 | |
1694 | class PackExpansionTypeBitfields { |
1695 | friend class PackExpansionType; |
1696 | |
1697 | unsigned : NumTypeBits; |
1698 | |
1699 | |
1700 | |
1701 | |
1702 | |
1703 | |
1704 | |
1705 | |
1706 | |
1707 | |
1708 | |
1709 | |
1710 | unsigned NumExpansions; |
1711 | }; |
1712 | |
1713 | union { |
1714 | TypeBitfields TypeBits; |
1715 | ArrayTypeBitfields ArrayTypeBits; |
1716 | AttributedTypeBitfields AttributedTypeBits; |
1717 | AutoTypeBitfields AutoTypeBits; |
1718 | BuiltinTypeBitfields BuiltinTypeBits; |
1719 | FunctionTypeBitfields FunctionTypeBits; |
1720 | ObjCObjectTypeBitfields ObjCObjectTypeBits; |
1721 | ReferenceTypeBitfields ReferenceTypeBits; |
1722 | TypeWithKeywordBitfields TypeWithKeywordBits; |
1723 | ElaboratedTypeBitfields ElaboratedTypeBits; |
1724 | VectorTypeBitfields VectorTypeBits; |
1725 | SubstTemplateTypeParmPackTypeBitfields SubstTemplateTypeParmPackTypeBits; |
1726 | TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits; |
1727 | DependentTemplateSpecializationTypeBitfields |
1728 | DependentTemplateSpecializationTypeBits; |
1729 | PackExpansionTypeBitfields PackExpansionTypeBits; |
1730 | |
1731 | static_assert(sizeof(TypeBitfields) <= 8, |
1732 | "TypeBitfields is larger than 8 bytes!"); |
1733 | static_assert(sizeof(ArrayTypeBitfields) <= 8, |
1734 | "ArrayTypeBitfields is larger than 8 bytes!"); |
1735 | static_assert(sizeof(AttributedTypeBitfields) <= 8, |
1736 | "AttributedTypeBitfields is larger than 8 bytes!"); |
1737 | static_assert(sizeof(AutoTypeBitfields) <= 8, |
1738 | "AutoTypeBitfields is larger than 8 bytes!"); |
1739 | static_assert(sizeof(BuiltinTypeBitfields) <= 8, |
1740 | "BuiltinTypeBitfields is larger than 8 bytes!"); |
1741 | static_assert(sizeof(FunctionTypeBitfields) <= 8, |
1742 | "FunctionTypeBitfields is larger than 8 bytes!"); |
1743 | static_assert(sizeof(ObjCObjectTypeBitfields) <= 8, |
1744 | "ObjCObjectTypeBitfields is larger than 8 bytes!"); |
1745 | static_assert(sizeof(ReferenceTypeBitfields) <= 8, |
1746 | "ReferenceTypeBitfields is larger than 8 bytes!"); |
1747 | static_assert(sizeof(TypeWithKeywordBitfields) <= 8, |
1748 | "TypeWithKeywordBitfields is larger than 8 bytes!"); |
1749 | static_assert(sizeof(ElaboratedTypeBitfields) <= 8, |
1750 | "ElaboratedTypeBitfields is larger than 8 bytes!"); |
1751 | static_assert(sizeof(VectorTypeBitfields) <= 8, |
1752 | "VectorTypeBitfields is larger than 8 bytes!"); |
1753 | static_assert(sizeof(SubstTemplateTypeParmPackTypeBitfields) <= 8, |
1754 | "SubstTemplateTypeParmPackTypeBitfields is larger" |
1755 | " than 8 bytes!"); |
1756 | static_assert(sizeof(TemplateSpecializationTypeBitfields) <= 8, |
1757 | "TemplateSpecializationTypeBitfields is larger" |
1758 | " than 8 bytes!"); |
1759 | static_assert(sizeof(DependentTemplateSpecializationTypeBitfields) <= 8, |
1760 | "DependentTemplateSpecializationTypeBitfields is larger" |
1761 | " than 8 bytes!"); |
1762 | static_assert(sizeof(PackExpansionTypeBitfields) <= 8, |
1763 | "PackExpansionTypeBitfields is larger than 8 bytes"); |
1764 | }; |
1765 | |
1766 | private: |
1767 | template <class T> friend class TypePropertyCache; |
1768 | |
1769 | |
1770 | void setFromAST(bool V = true) const { |
1771 | TypeBits.FromAST = V; |
1772 | } |
1773 | |
1774 | protected: |
1775 | friend class ASTContext; |
1776 | |
1777 | Type(TypeClass tc, QualType canon, bool Dependent, |
1778 | bool InstantiationDependent, bool VariablyModified, |
1779 | bool ContainsUnexpandedParameterPack) |
1780 | : ExtQualsTypeCommonBase(this, |
1781 | canon.isNull() ? QualType(this_(), 0) : canon) { |
1782 | TypeBits.TC = tc; |
1783 | TypeBits.Dependent = Dependent; |
1784 | TypeBits.InstantiationDependent = Dependent || InstantiationDependent; |
1785 | TypeBits.VariablyModified = VariablyModified; |
1786 | TypeBits.ContainsUnexpandedParameterPack = ContainsUnexpandedParameterPack; |
1787 | TypeBits.CacheValid = false; |
1788 | TypeBits.CachedLocalOrUnnamed = false; |
1789 | TypeBits.CachedLinkage = NoLinkage; |
1790 | TypeBits.FromAST = false; |
1791 | } |
1792 | |
1793 | |
1794 | Type *this_() { return this; } |
1795 | |
1796 | void setDependent(bool D = true) { |
1797 | TypeBits.Dependent = D; |
1798 | if (D) |
1799 | TypeBits.InstantiationDependent = true; |
1800 | } |
1801 | |
1802 | void setInstantiationDependent(bool D = true) { |
1803 | TypeBits.InstantiationDependent = D; } |
1804 | |
1805 | void setVariablyModified(bool VM = true) { TypeBits.VariablyModified = VM; } |
1806 | |
1807 | void setContainsUnexpandedParameterPack(bool PP = true) { |
1808 | TypeBits.ContainsUnexpandedParameterPack = PP; |
1809 | } |
1810 | |
1811 | public: |
1812 | friend class ASTReader; |
1813 | friend class ASTWriter; |
1814 | |
1815 | Type(const Type &) = delete; |
1816 | Type &operator=(const Type &) = delete; |
1817 | |
1818 | TypeClass getTypeClass() const { return static_cast<TypeClass>(TypeBits.TC); } |
1819 | |
1820 | |
1821 | bool isFromAST() const { return TypeBits.FromAST; } |
1822 | |
1823 | |
1824 | |
1825 | |
1826 | |
1827 | |
1828 | |
1829 | |
1830 | |
1831 | |
1832 | |
1833 | |
1834 | |
1835 | |
1836 | |
1837 | |
1838 | bool containsUnexpandedParameterPack() const { |
1839 | return TypeBits.ContainsUnexpandedParameterPack; |
1840 | } |
1841 | |
1842 | |
1843 | |
1844 | bool isCanonicalUnqualified() const { |
1845 | return CanonicalType == QualType(this, 0); |
1846 | } |
1847 | |
1848 | |
1849 | |
1850 | |
1851 | QualType getLocallyUnqualifiedSingleStepDesugaredType() const; |
1852 | |
1853 | |
1854 | |
1855 | |
1856 | |
1857 | |
1858 | |
1859 | |
1860 | |
1861 | |
1862 | |
1863 | |
1864 | bool isIncompleteType(NamedDecl **Def = nullptr) const; |
1865 | |
1866 | |
1867 | |
1868 | bool isIncompleteOrObjectType() const { |
1869 | return !isFunctionType(); |
1870 | } |
1871 | |
1872 | |
1873 | bool isObjectType() const { |
1874 | |
1875 | |
1876 | |
1877 | return !isReferenceType() && !isFunctionType() && !isVoidType(); |
1878 | } |
1879 | |
1880 | |
1881 | |
1882 | bool isLiteralType(const ASTContext &Ctx) const; |
1883 | |
1884 | |
1885 | |
1886 | bool isStandardLayoutType() const; |
1887 | |
1888 | |
1889 | |
1890 | |
1891 | |
1892 | bool isBuiltinType() const; |
1893 | |
1894 | |
1895 | bool isSpecificBuiltinType(unsigned K) const; |
1896 | |
1897 | |
1898 | |
1899 | |
1900 | bool isPlaceholderType() const; |
1901 | const BuiltinType *getAsPlaceholderType() const; |
1902 | |
1903 | |
1904 | bool isSpecificPlaceholderType(unsigned K) const; |
1905 | |
1906 | |
1907 | |
1908 | bool isNonOverloadPlaceholderType() const; |
1909 | |
1910 | |
1911 | |
1912 | bool isIntegerType() const; |
1913 | bool isEnumeralType() const; |
1914 | |
1915 | |
1916 | bool isScopedEnumeralType() const; |
1917 | bool isBooleanType() const; |
1918 | bool isCharType() const; |
1919 | bool isWideCharType() const; |
1920 | bool isChar8Type() const; |
1921 | bool isChar16Type() const; |
1922 | bool isChar32Type() const; |
1923 | bool isAnyCharacterType() const; |
1924 | bool isIntegralType(const ASTContext &Ctx) const; |
1925 | |
1926 | |
1927 | bool isIntegralOrEnumerationType() const; |
1928 | |
1929 | |
1930 | bool isIntegralOrUnscopedEnumerationType() const; |
1931 | |
1932 | |
1933 | bool isRealFloatingType() const; |
1934 | |
1935 | |
1936 | bool isComplexType() const; |
1937 | bool isAnyComplexType() const; |
1938 | bool isFloatingType() const; |
1939 | bool isHalfType() const; |
1940 | bool isFloat16Type() const; |
1941 | bool isFloat128Type() const; |
1942 | bool isRealType() const; |
1943 | bool isArithmeticType() const; |
1944 | bool isVoidType() const; |
1945 | bool isScalarType() const; |
1946 | bool isAggregateType() const; |
1947 | bool isFundamentalType() const; |
1948 | bool isCompoundType() const; |
1949 | |
1950 | |
1951 | |
1952 | bool isFunctionType() const; |
1953 | bool isFunctionNoProtoType() const { return getAs<FunctionNoProtoType>(); } |
1954 | bool isFunctionProtoType() const { return getAs<FunctionProtoType>(); } |
1955 | bool isPointerType() const; |
1956 | bool isAnyPointerType() const; |
1957 | bool isBlockPointerType() const; |
1958 | bool isVoidPointerType() const; |
1959 | bool isReferenceType() const; |
1960 | bool isLValueReferenceType() const; |
1961 | bool isRValueReferenceType() const; |
1962 | bool isFunctionPointerType() const; |
1963 | bool isMemberPointerType() const; |
1964 | bool isMemberFunctionPointerType() const; |
1965 | bool isMemberDataPointerType() const; |
1966 | bool isArrayType() const; |
1967 | bool isConstantArrayType() const; |
1968 | bool isIncompleteArrayType() const; |
1969 | bool isVariableArrayType() const; |
1970 | bool isDependentSizedArrayType() const; |
1971 | bool isRecordType() const; |
1972 | bool isClassType() const; |
1973 | bool isStructureType() const; |
1974 | bool isObjCBoxableRecordType() const; |
1975 | bool isInterfaceType() const; |
1976 | bool isStructureOrClassType() const; |
1977 | bool isUnionType() const; |
1978 | bool isComplexIntegerType() const; |
1979 | bool isVectorType() const; |
1980 | bool isExtVectorType() const; |
1981 | bool isDependentAddressSpaceType() const; |
1982 | bool isObjCObjectPointerType() const; |
1983 | bool isObjCRetainableType() const; |
1984 | bool isObjCLifetimeType() const; |
1985 | bool isObjCIndirectLifetimeType() const; |
1986 | bool isObjCNSObjectType() const; |
1987 | bool isObjCIndependentClassType() const; |
1988 | |
1989 | |
1990 | bool isObjCObjectType() const; |
1991 | bool isObjCQualifiedInterfaceType() const; |
1992 | bool isObjCQualifiedIdType() const; |
1993 | bool isObjCQualifiedClassType() const; |
1994 | bool isObjCObjectOrInterfaceType() const; |
1995 | bool isObjCIdType() const; |
1996 | bool isDecltypeType() const; |
1997 | |
1998 | |
1999 | |
2000 | |
2001 | |
2002 | |
2003 | bool isObjCInertUnsafeUnretainedType() const { |
2004 | return hasAttr(attr::ObjCInertUnsafeUnretained); |
2005 | } |
2006 | |
2007 | |
2008 | |
2009 | |
2010 | |
2011 | |
2012 | |
2013 | |
2014 | bool isObjCIdOrObjectKindOfType(const ASTContext &ctx, |
2015 | const ObjCObjectType *&bound) const; |
2016 | |
2017 | bool isObjCClassType() const; |
2018 | |
2019 | |
2020 | |
2021 | |
2022 | |
2023 | |
2024 | |
2025 | bool isObjCClassOrClassKindOfType() const; |
2026 | |
2027 | bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const; |
2028 | bool isObjCSelType() const; |
2029 | bool isObjCBuiltinType() const; |
2030 | bool isObjCARCBridgableType() const; |
2031 | bool isCARCBridgableType() const; |
2032 | bool isTemplateTypeParmType() const; |
2033 | bool isNullPtrType() const; |
2034 | bool isAlignValT() const; |
2035 | bool isStdByteType() const; |
2036 | bool isAtomicType() const; |
2037 | |
2038 | #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ |
2039 | bool is##Id##Type() const; |
2040 | #include "clang/Basic/OpenCLImageTypes.def" |
2041 | |
2042 | bool isImageType() const; |
2043 | |
2044 | bool isSamplerT() const; |
2045 | bool isEventT() const; |
2046 | bool isClkEventT() const; |
2047 | bool isQueueT() const; |
2048 | bool isReserveIDT() const; |
2049 | |
2050 | #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ |
2051 | bool is##Id##Type() const; |
2052 | #include "clang/Basic/OpenCLExtensionTypes.def" |
2053 | |
2054 | bool isOCLIntelSubgroupAVCType() const; |
2055 | bool isOCLExtOpaqueType() const; |
2056 | |
2057 | bool isPipeType() const; |
2058 | bool isOpenCLSpecificType() const; |
2059 | |
2060 | |
2061 | |
2062 | |
2063 | bool isObjCARCImplicitlyUnretainedType() const; |
2064 | |
2065 | |
2066 | Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const; |
2067 | |
2068 | enum ScalarTypeKind { |
2069 | STK_CPointer, |
2070 | STK_BlockPointer, |
2071 | STK_ObjCObjectPointer, |
2072 | STK_MemberPointer, |
2073 | STK_Bool, |
2074 | STK_Integral, |
2075 | STK_Floating, |
2076 | STK_IntegralComplex, |
2077 | STK_FloatingComplex, |
2078 | STK_FixedPoint |
2079 | }; |
2080 | |
2081 | |
2082 | ScalarTypeKind getScalarTypeKind() const; |
2083 | |
2084 | |
2085 | |
2086 | bool isDependentType() const { return TypeBits.Dependent; } |
2087 | |
2088 | |
2089 | |
2090 | |
2091 | |
2092 | bool isInstantiationDependentType() const { |
2093 | return TypeBits.InstantiationDependent; |
2094 | } |
2095 | |
2096 | |
2097 | |
2098 | |
2099 | bool isUndeducedType() const; |
2100 | |
2101 | |
2102 | bool isVariablyModifiedType() const { return TypeBits.VariablyModified; } |
2103 | |
2104 | |
2105 | |
2106 | bool hasSizedVLAType() const; |
2107 | |
2108 | |
2109 | bool hasUnnamedOrLocalType() const; |
2110 | |
2111 | bool isOverloadableType() const; |
2112 | |
2113 | |
2114 | bool isElaboratedTypeSpecifier() const; |
2115 | |
2116 | bool canDecayToPointerType() const; |
2117 | |
2118 | |
2119 | |
2120 | |
2121 | bool hasPointerRepresentation() const; |
2122 | |
2123 | |
2124 | |
2125 | bool hasObjCPointerRepresentation() const; |
2126 | |
2127 | |
2128 | |
2129 | bool hasIntegerRepresentation() const; |
2130 | |
2131 | |
2132 | |
2133 | bool hasSignedIntegerRepresentation() const; |
2134 | |
2135 | |
2136 | |
2137 | bool hasUnsignedIntegerRepresentation() const; |
2138 | |
2139 | |
2140 | |
2141 | bool hasFloatingRepresentation() const; |
2142 | |
2143 | |
2144 | |
2145 | |
2146 | const RecordType *getAsStructureType() const; |
2147 | |
2148 | const RecordType *getAsUnionType() const; |
2149 | const ComplexType *getAsComplexIntegerType() const; |
2150 | const ObjCObjectType *getAsObjCInterfaceType() const; |
2151 | |
2152 | |
2153 | |
2154 | const ObjCObjectPointerType *getAsObjCInterfacePointerType() const; |
2155 | const ObjCObjectPointerType *getAsObjCQualifiedIdType() const; |
2156 | const ObjCObjectPointerType *getAsObjCQualifiedClassType() const; |
2157 | const ObjCObjectType *getAsObjCQualifiedInterfaceType() const; |
2158 | |
2159 | |
2160 | |
2161 | |
2162 | CXXRecordDecl *getAsCXXRecordDecl() const; |
2163 | |
2164 | |
2165 | RecordDecl *getAsRecordDecl() const; |
2166 | |
2167 | |
2168 | |
2169 | |
2170 | TagDecl *getAsTagDecl() const; |
2171 | |
2172 | |
2173 | |
2174 | |
2175 | |
2176 | |
2177 | const CXXRecordDecl *getPointeeCXXRecordDecl() const; |
2178 | |
2179 | |
2180 | |
2181 | |
2182 | DeducedType *getContainedDeducedType() const; |
2183 | |
2184 | |
2185 | |
2186 | |
2187 | AutoType *getContainedAutoType() const { |
2188 | return dyn_cast_or_null<AutoType>(getContainedDeducedType()); |
2189 | } |
2190 | |
2191 | |
2192 | |
2193 | |
2194 | bool hasAutoForTrailingReturnType() const; |
2195 | |
2196 | |
2197 | |
2198 | |
2199 | |
2200 | |
2201 | |
2202 | template <typename T> const T *getAs() const; |
2203 | |
2204 | |
2205 | |
2206 | |
2207 | |
2208 | |
2209 | template <typename T> const T *getAsAdjusted() const; |
2210 | |
2211 | |
2212 | |
2213 | const ArrayType *getAsArrayTypeUnsafe() const; |
2214 | |
2215 | |
2216 | |
2217 | |
2218 | |
2219 | |
2220 | |
2221 | template <typename T> const T *castAs() const; |
2222 | |
2223 | |
2224 | |
2225 | const ArrayType *castAsArrayTypeUnsafe() const; |
2226 | |
2227 | |
2228 | |
2229 | bool hasAttr(attr::Kind AK) const; |
2230 | |
2231 | |
2232 | |
2233 | |
2234 | const Type *getBaseElementTypeUnsafe() const; |
2235 | |
2236 | |
2237 | |
2238 | |
2239 | const Type *getArrayElementTypeNoTypeQual() const; |
2240 | |
2241 | |
2242 | |
2243 | |
2244 | const Type *getPointeeOrArrayElementType() const; |
2245 | |
2246 | |
2247 | |
2248 | QualType getPointeeType() const; |
2249 | |
2250 | |
2251 | |
2252 | const Type *getUnqualifiedDesugaredType() const; |
2253 | |
2254 | |
2255 | bool isPromotableIntegerType() const; |
2256 | |
2257 | |
2258 | |
2259 | |
2260 | bool isSignedIntegerType() const; |
2261 | |
2262 | |
2263 | |
2264 | |
2265 | bool isUnsignedIntegerType() const; |
2266 | |
2267 | |
2268 | |
2269 | bool isSignedIntegerOrEnumerationType() const; |
2270 | |
2271 | |
2272 | |
2273 | bool isUnsignedIntegerOrEnumerationType() const; |
2274 | |
2275 | |
2276 | |
2277 | bool isFixedPointType() const; |
2278 | |
2279 | |
2280 | bool isFixedPointOrIntegerType() const; |
2281 | |
2282 | |
2283 | |
2284 | bool isSaturatedFixedPointType() const; |
2285 | |
2286 | |
2287 | |
2288 | bool isUnsaturatedFixedPointType() const; |
2289 | |
2290 | |
2291 | |
2292 | bool isSignedFixedPointType() const; |
2293 | |
2294 | |
2295 | |
2296 | bool isUnsignedFixedPointType() const; |
2297 | |
2298 | |
2299 | |
2300 | |
2301 | bool isConstantSizeType() const; |
2302 | |
2303 | |
2304 | |
2305 | bool isSpecifierType() const; |
2306 | |
2307 | |
2308 | Linkage getLinkage() const; |
2309 | |
2310 | |
2311 | Visibility getVisibility() const { |
2312 | return getLinkageAndVisibility().getVisibility(); |
2313 | } |
2314 | |
2315 | |
2316 | bool isVisibilityExplicit() const { |
2317 | return getLinkageAndVisibility().isVisibilityExplicit(); |
2318 | } |
2319 | |
2320 | |
2321 | LinkageInfo getLinkageAndVisibility() const; |
2322 | |
2323 | |
2324 | |
2325 | bool isLinkageValid() const; |
2326 | |
2327 | |
2328 | |
2329 | |
2330 | |
2331 | |
2332 | Optional<NullabilityKind> getNullability(const ASTContext &context) const; |
2333 | |
2334 | |
2335 | |
2336 | |
2337 | |
2338 | |
2339 | bool canHaveNullability(bool ResultIfUnknown = true) const; |
2340 | |
2341 | |
2342 | |
2343 | |
2344 | |
2345 | |
2346 | |
2347 | |
2348 | |
2349 | |
2350 | |
2351 | |
2352 | |
2353 | |
2354 | |
2355 | |
2356 | Optional<ArrayRef<QualType>> |
2357 | getObjCSubstitutions(const DeclContext *dc) const; |
2358 | |
2359 | |
2360 | |
2361 | bool acceptsObjCTypeParams() const; |
2362 | |
2363 | const char *getTypeClassName() const; |
2364 | |
2365 | QualType getCanonicalTypeInternal() const { |
2366 | return CanonicalType; |
2367 | } |
2368 | |
2369 | CanQualType getCanonicalTypeUnqualified() const; |
2370 | void dump() const; |
2371 | void dump(llvm::raw_ostream &OS) const; |
2372 | }; |
2373 | |
2374 | |
2375 | |
2376 | template <> const TypedefType *Type::getAs() const; |
2377 | |
2378 | |
2379 | |
2380 | |
2381 | template <> const TemplateSpecializationType *Type::getAs() const; |
2382 | |
2383 | |
2384 | |
2385 | template <> const AttributedType *Type::getAs() const; |
2386 | |
2387 | |
2388 | |
2389 | #define TYPE(Class, Base) |
2390 | #define LEAF_TYPE(Class) \ |
2391 | template <> inline const Class##Type *Type::getAs() const { \ |
2392 | return dyn_cast<Class##Type>(CanonicalType); \ |
2393 | } \ |
2394 | template <> inline const Class##Type *Type::castAs() const { \ |
2395 | return cast<Class##Type>(CanonicalType); \ |
2396 | } |
2397 | #include "clang/AST/TypeNodes.def" |
2398 | |
2399 | |
2400 | |
2401 | class BuiltinType : public Type { |
2402 | public: |
2403 | enum Kind { |
2404 | |
2405 | #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) Id, |
2406 | #include "clang/Basic/OpenCLImageTypes.def" |
2407 | |
2408 | #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) Id, |
2409 | #include "clang/Basic/OpenCLExtensionTypes.def" |
2410 | |
2411 | #define BUILTIN_TYPE(Id, SingletonId) Id, |
2412 | #define LAST_BUILTIN_TYPE(Id) LastKind = Id |
2413 | #include "clang/AST/BuiltinTypes.def" |
2414 | }; |
2415 | |
2416 | private: |
2417 | friend class ASTContext; |
2418 | |
2419 | BuiltinType(Kind K) |
2420 | : Type(Builtin, QualType(), (K == Dependent), |
2421 | (K == Dependent), |
2422 | , |
2423 | ) { |
2424 | BuiltinTypeBits.Kind = K; |
2425 | } |
2426 | |
2427 | public: |
2428 | Kind getKind() const { return static_cast<Kind>(BuiltinTypeBits.Kind); } |
2429 | StringRef getName(const PrintingPolicy &Policy) const; |
2430 | |
2431 | const char *getNameAsCString(const PrintingPolicy &Policy) const { |
2432 | |
2433 | StringRef str = getName(Policy); |
2434 | assert(!str.empty() && str.data()[str.size()] == '\0'); |
2435 | return str.data(); |
2436 | } |
2437 | |
2438 | bool isSugared() const { return false; } |
2439 | QualType desugar() const { return QualType(this, 0); } |
2440 | |
2441 | bool isInteger() const { |
2442 | return getKind() >= Bool && getKind() <= Int128; |
2443 | } |
2444 | |
2445 | bool isSignedInteger() const { |
2446 | return getKind() >= Char_S && getKind() <= Int128; |
2447 | } |
2448 | |
2449 | bool isUnsignedInteger() const { |
2450 | return getKind() >= Bool && getKind() <= UInt128; |
2451 | } |
2452 | |
2453 | bool isFloatingPoint() const { |
2454 | return getKind() >= Half && getKind() <= Float128; |
2455 | } |
2456 | |
2457 | |
2458 | static bool isPlaceholderTypeKind(Kind K) { |
2459 | return K >= Overload; |
2460 | } |
2461 | |
2462 | |
2463 | |
2464 | |
2465 | bool isPlaceholderType() const { |
2466 | return isPlaceholderTypeKind(getKind()); |
2467 | } |
2468 | |
2469 | |
2470 | |
2471 | |
2472 | |
2473 | |
2474 | |
2475 | |
2476 | |
2477 | |
2478 | bool isNonOverloadPlaceholderType() const { |
2479 | return getKind() > Overload; |
2480 | } |
2481 | |
2482 | static bool classof(const Type *T) { return T->getTypeClass() == Builtin; } |
2483 | }; |
2484 | |
2485 | |
2486 | |
2487 | class ComplexType : public Type, public llvm::FoldingSetNode { |
2488 | friend class ASTContext; |
2489 | |
2490 | QualType ElementType; |
2491 | |
2492 | ComplexType(QualType Element, QualType CanonicalPtr) |
2493 | : Type(Complex, CanonicalPtr, Element->isDependentType(), |
2494 | Element->isInstantiationDependentType(), |
2495 | Element->isVariablyModifiedType(), |
2496 | Element->containsUnexpandedParameterPack()), |
2497 | ElementType(Element) {} |
2498 | |
2499 | public: |
2500 | QualType getElementType() const { return ElementType; } |
2501 | |
2502 | bool isSugared() const { return false; } |
2503 | QualType desugar() const { return QualType(this, 0); } |
2504 | |
2505 | void Profile(llvm::FoldingSetNodeID &ID) { |
2506 | Profile(ID, getElementType()); |
2507 | } |
2508 | |
2509 | static void Profile(llvm::FoldingSetNodeID &ID, QualType Element) { |
2510 | ID.AddPointer(Element.getAsOpaquePtr()); |
2511 | } |
2512 | |
2513 | static bool classof(const Type *T) { return T->getTypeClass() == Complex; } |
2514 | }; |
2515 | |
2516 | |
2517 | class ParenType : public Type, public llvm::FoldingSetNode { |
2518 | friend class ASTContext; |
2519 | |
2520 | QualType Inner; |
2521 | |
2522 | ParenType(QualType InnerType, QualType CanonType) |
2523 | : Type(Paren, CanonType, InnerType->isDependentType(), |
2524 | InnerType->isInstantiationDependentType(), |
2525 | InnerType->isVariablyModifiedType(), |
2526 | InnerType->containsUnexpandedParameterPack()), |
2527 | Inner(InnerType) {} |
2528 | |
2529 | public: |
2530 | QualType getInnerType() const { return Inner; } |
2531 | |
2532 | bool isSugared() const { return true; } |
2533 | QualType desugar() const { return getInnerType(); } |
2534 | |
2535 | void Profile(llvm::FoldingSetNodeID &ID) { |
2536 | Profile(ID, getInnerType()); |
2537 | } |
2538 | |
2539 | static void Profile(llvm::FoldingSetNodeID &ID, QualType Inner) { |
2540 | Inner.Profile(ID); |
2541 | } |
2542 | |
2543 | static bool classof(const Type *T) { return T->getTypeClass() == Paren; } |
2544 | }; |
2545 | |
2546 | |
2547 | class PointerType : public Type, public llvm::FoldingSetNode { |
2548 | friend class ASTContext; |
2549 | |
2550 | QualType PointeeType; |
2551 | |
2552 | PointerType(QualType Pointee, QualType CanonicalPtr) |
2553 | : Type(Pointer, CanonicalPtr, Pointee->isDependentType(), |
2554 | Pointee->isInstantiationDependentType(), |
2555 | Pointee->isVariablyModifiedType(), |
2556 | Pointee->containsUnexpandedParameterPack()), |
2557 | PointeeType(Pointee) {} |
2558 | |
2559 | public: |
2560 | QualType getPointeeType() const { return PointeeType; } |
2561 | |
2562 | |
2563 | |
2564 | |
2565 | |
2566 | |
2567 | |
2568 | |
2569 | |
2570 | bool isAddressSpaceOverlapping(const PointerType &other) const { |
2571 | Qualifiers thisQuals = PointeeType.getQualifiers(); |
2572 | Qualifiers otherQuals = other.getPointeeType().getQualifiers(); |
2573 | |
2574 | return thisQuals.isAddressSpaceSupersetOf(otherQuals) || |
2575 | otherQuals.isAddressSpaceSupersetOf(thisQuals); |
2576 | } |
2577 | |
2578 | bool isSugared() const { return false; } |
2579 | QualType desugar() const { return QualType(this, 0); } |
2580 | |
2581 | void Profile(llvm::FoldingSetNodeID &ID) { |
2582 | Profile(ID, getPointeeType()); |
2583 | } |
2584 | |
2585 | static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee) { |
2586 | ID.AddPointer(Pointee.getAsOpaquePtr()); |
2587 | } |
2588 | |
2589 | static bool classof(const Type *T) { return T->getTypeClass() == Pointer; } |
2590 | }; |
2591 | |
2592 | |
2593 | |
2594 | |
2595 | class AdjustedType : public Type, public llvm::FoldingSetNode { |
2596 | QualType OriginalTy; |
2597 | QualType AdjustedTy; |
2598 | |
2599 | protected: |
2600 | friend class ASTContext; |
2601 | |
2602 | AdjustedType(TypeClass TC, QualType OriginalTy, QualType AdjustedTy, |
2603 | QualType CanonicalPtr) |
2604 | : Type(TC, CanonicalPtr, OriginalTy->isDependentType(), |
2605 | OriginalTy->isInstantiationDependentType(), |
2606 | OriginalTy->isVariablyModifiedType(), |
2607 | OriginalTy->containsUnexpandedParameterPack()), |
2608 | OriginalTy(OriginalTy), AdjustedTy(AdjustedTy) {} |
2609 | |
2610 | public: |
2611 | QualType getOriginalType() const { return OriginalTy; } |
2612 | QualType getAdjustedType() const { return AdjustedTy; } |
2613 | |
2614 | bool isSugared() const { return true; } |
2615 | QualType desugar() const { return AdjustedTy; } |
2616 | |
2617 | void Profile(llvm::FoldingSetNodeID &ID) { |
2618 | Profile(ID, OriginalTy, AdjustedTy); |
2619 | } |
2620 | |
2621 | static void Profile(llvm::FoldingSetNodeID &ID, QualType Orig, QualType New) { |
2622 | ID.AddPointer(Orig.getAsOpaquePtr()); |
2623 | ID.AddPointer(New.getAsOpaquePtr()); |
2624 | } |
2625 | |
2626 | static bool classof(const Type *T) { |
2627 | return T->getTypeClass() == Adjusted || T->getTypeClass() == Decayed; |
2628 | } |
2629 | }; |
2630 | |
2631 | |
2632 | class DecayedType : public AdjustedType { |
2633 | friend class ASTContext; |
2634 | |
2635 | inline |
2636 | DecayedType(QualType OriginalType, QualType Decayed, QualType Canonical); |
2637 | |
2638 | public: |
2639 | QualType getDecayedType() const { return getAdjustedType(); } |
2640 | |
2641 | inline QualType getPointeeType() const; |
2642 | |
2643 | static bool classof(const Type *T) { return T->getTypeClass() == Decayed; } |
2644 | }; |
2645 | |
2646 | |
2647 | |
2648 | |
2649 | class BlockPointerType : public Type, public llvm::FoldingSetNode { |
2650 | friend class ASTContext; |
2651 | |
2652 | |
2653 | QualType PointeeType; |
2654 | |
2655 | BlockPointerType(QualType Pointee, QualType CanonicalCls) |
2656 | : Type(BlockPointer, CanonicalCls, Pointee->isDependentType(), |
2657 | Pointee->isInstantiationDependentType(), |
2658 | Pointee->isVariablyModifiedType(), |
2659 | Pointee->containsUnexpandedParameterPack()), |
2660 | PointeeType(Pointee) {} |
2661 | |
2662 | public: |
2663 | |
2664 | QualType getPointeeType() const { return PointeeType; } |
2665 | |
2666 | bool isSugared() const { return false; } |
2667 | QualType desugar() const { return QualType(this, 0); } |
2668 | |
2669 | void Profile(llvm::FoldingSetNodeID &ID) { |
2670 | Profile(ID, getPointeeType()); |
2671 | } |
2672 | |
2673 | static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee) { |
2674 | ID.AddPointer(Pointee.getAsOpaquePtr()); |
2675 | } |
2676 | |
2677 | static bool classof(const Type *T) { |
2678 | return T->getTypeClass() == BlockPointer; |
2679 | } |
2680 | }; |
2681 | |
2682 | |
2683 | class ReferenceType : public Type, public llvm::FoldingSetNode { |
2684 | QualType PointeeType; |
2685 | |
2686 | protected: |
2687 | ReferenceType(TypeClass tc, QualType Referencee, QualType CanonicalRef, |
2688 | bool SpelledAsLValue) |
2689 | : Type(tc, CanonicalRef, Referencee->isDependentType(), |
2690 | Referencee->isInstantiationDependentType(), |
2691 | Referencee->isVariablyModifiedType(), |
2692 | Referencee->containsUnexpandedParameterPack()), |
2693 | PointeeType(Referencee) { |
2694 | ReferenceTypeBits.SpelledAsLValue = SpelledAsLValue; |
2695 | ReferenceTypeBits.InnerRef = Referencee->isReferenceType(); |
2696 | } |
2697 | |
2698 | public: |
2699 | bool isSpelledAsLValue() const { return ReferenceTypeBits.SpelledAsLValue; } |
2700 | bool isInnerRef() const { return ReferenceTypeBits.InnerRef; } |
2701 | |
2702 | QualType getPointeeTypeAsWritten() const { return PointeeType; } |
2703 | |
2704 | QualType getPointeeType() const { |
2705 | |
2706 | const ReferenceType *T = this; |
2707 | while (T->isInnerRef()) |
2708 | T = T->PointeeType->castAs<ReferenceType>(); |
2709 | return T->PointeeType; |
2710 | } |
2711 | |
2712 | void Profile(llvm::FoldingSetNodeID &ID) { |
2713 | Profile(ID, PointeeType, isSpelledAsLValue()); |
2714 | } |
2715 | |
2716 | static void Profile(llvm::FoldingSetNodeID &ID, |
2717 | QualType Referencee, |
2718 | bool SpelledAsLValue) { |
2719 | ID.AddPointer(Referencee.getAsOpaquePtr()); |
2720 | ID.AddBoolean(SpelledAsLValue); |
2721 | } |
2722 | |
2723 | static bool classof(const Type *T) { |
2724 | return T->getTypeClass() == LValueReference || |
2725 | T->getTypeClass() == RValueReference; |
2726 | } |
2727 | }; |
2728 | |
2729 | |
2730 | class LValueReferenceType : public ReferenceType { |
2731 | friend class ASTContext; |
2732 | |
2733 | LValueReferenceType(QualType Referencee, QualType CanonicalRef, |
2734 | bool SpelledAsLValue) |
2735 | : ReferenceType(LValueReference, Referencee, CanonicalRef, |
2736 | SpelledAsLValue) {} |
2737 | |
2738 | public: |
2739 | bool isSugared() const { return false; } |
2740 | QualType desugar() const { return QualType(this, 0); } |
2741 | |
2742 | static bool classof(const Type *T) { |
2743 | return T->getTypeClass() == LValueReference; |
2744 | } |
2745 | }; |
2746 | |
2747 | |
2748 | class RValueReferenceType : public ReferenceType { |
2749 | friend class ASTContext; |
2750 | |
2751 | RValueReferenceType(QualType Referencee, QualType CanonicalRef) |
2752 | : ReferenceType(RValueReference, Referencee, CanonicalRef, false) {} |
2753 | |
2754 | public: |
2755 | bool isSugared() const { return false; } |
2756 | QualType desugar() const { return QualType(this, 0); } |
2757 | |
2758 | static bool classof(const Type *T) { |
2759 | return T->getTypeClass() == RValueReference; |
2760 | } |
2761 | }; |
2762 | |
2763 | |
2764 | |
2765 | |
2766 | class MemberPointerType : public Type, public llvm::FoldingSetNode { |
2767 | friend class ASTContext; |
2768 | |
2769 | QualType PointeeType; |
2770 | |
2771 | |
2772 | |
2773 | const Type *Class; |
2774 | |
2775 | MemberPointerType(QualType Pointee, const Type *Cls, QualType CanonicalPtr) |
2776 | : Type(MemberPointer, CanonicalPtr, |
2777 | Cls->isDependentType() || Pointee->isDependentType(), |
2778 | (Cls->isInstantiationDependentType() || |
2779 | Pointee->isInstantiationDependentType()), |
2780 | Pointee->isVariablyModifiedType(), |
2781 | (Cls->containsUnexpandedParameterPack() || |
2782 | Pointee->containsUnexpandedParameterPack())), |
2783 | PointeeType(Pointee), Class(Cls) {} |
2784 | |
2785 | public: |
2786 | QualType getPointeeType() const { return PointeeType; } |
2787 | |
2788 | |
2789 | |
2790 | bool isMemberFunctionPointer() const { |
2791 | return PointeeType->isFunctionProtoType(); |
2792 | } |
2793 | |
2794 | |
2795 | |
2796 | bool isMemberDataPointer() const { |
2797 | return !PointeeType->isFunctionProtoType(); |
2798 | } |
2799 | |
2800 | const Type *getClass() const { return Class; } |
2801 | CXXRecordDecl *getMostRecentCXXRecordDecl() const; |
2802 | |
2803 | bool isSugared() const { return false; } |
2804 | QualType desugar() const { return QualType(this, 0); } |
2805 | |
2806 | void Profile(llvm::FoldingSetNodeID &ID) { |
2807 | Profile(ID, getPointeeType(), getClass()); |
2808 | } |
2809 | |
2810 | static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee, |
2811 | const Type *Class) { |
2812 | ID.AddPointer(Pointee.getAsOpaquePtr()); |
2813 | ID.AddPointer(Class); |
2814 | } |
2815 | |
2816 | static bool classof(const Type *T) { |
2817 | return T->getTypeClass() == MemberPointer; |
2818 | } |
2819 | }; |
2820 | |
2821 | |
2822 | class ArrayType : public Type, public llvm::FoldingSetNode { |
2823 | public: |
2824 | |
2825 | |
2826 | |
2827 | |
2828 | enum ArraySizeModifier { |
2829 | Normal, Static, Star |
2830 | }; |
2831 | |
2832 | private: |
2833 | |
2834 | QualType ElementType; |
2835 | |
2836 | protected: |
2837 | friend class ASTContext; |
2838 | |
2839 | |
2840 | |
2841 | |
2842 | |
2843 | |
2844 | ArrayType(TypeClass tc, QualType et, QualType can, |
2845 | ArraySizeModifier sm, unsigned tq, |
2846 | bool ContainsUnexpandedParameterPack) |
2847 | : Type(tc, can, et->isDependentType() || tc == DependentSizedArray, |
2848 | et->isInstantiationDependentType() || tc == DependentSizedArray, |
2849 | (tc == VariableArray || et->isVariablyModifiedType()), |
2850 | ContainsUnexpandedParameterPack), |
2851 | ElementType(et) { |
2852 | ArrayTypeBits.IndexTypeQuals = tq; |
2853 | ArrayTypeBits.SizeModifier = sm; |
2854 | } |
2855 | |
2856 | public: |
2857 | QualType getElementType() const { return ElementType; } |
2858 | |
2859 | ArraySizeModifier getSizeModifier() const { |
2860 | return ArraySizeModifier(ArrayTypeBits.SizeModifier); |
2861 | } |
2862 | |
2863 | Qualifiers getIndexTypeQualifiers() const { |
2864 | return Qualifiers::fromCVRMask(getIndexTypeCVRQualifiers()); |
2865 | } |
2866 | |
2867 | unsigned getIndexTypeCVRQualifiers() const { |
2868 | return ArrayTypeBits.IndexTypeQuals; |
2869 | } |
2870 | |
2871 | static bool classof(const Type *T) { |
2872 | return T->getTypeClass() == ConstantArray || |
2873 | T->getTypeClass() == VariableArray || |
2874 | T->getTypeClass() == IncompleteArray || |
2875 | T->getTypeClass() == DependentSizedArray; |
2876 | } |
2877 | }; |
2878 | |
2879 | |
2880 | |
2881 | |
2882 | class ConstantArrayType : public ArrayType { |
2883 | llvm::APInt Size; |
2884 | |
2885 | ConstantArrayType(QualType et, QualType can, const llvm::APInt &size, |
2886 | ArraySizeModifier sm, unsigned tq) |
2887 | : ArrayType(ConstantArray, et, can, sm, tq, |
2888 | et->containsUnexpandedParameterPack()), |
2889 | Size(size) {} |
2890 | |
2891 | protected: |
2892 | friend class ASTContext; |
2893 | |
2894 | ConstantArrayType(TypeClass tc, QualType et, QualType can, |
2895 | const llvm::APInt &size, ArraySizeModifier sm, unsigned tq) |
2896 | : ArrayType(tc, et, can, sm, tq, et->containsUnexpandedParameterPack()), |
2897 | Size(size) {} |
2898 | |
2899 | public: |
2900 | const llvm::APInt &getSize() const { return Size; } |
2901 | bool isSugared() const { return false; } |
2902 | QualType desugar() const { return QualType(this, 0); } |
2903 | |
2904 | |
2905 | |
2906 | static unsigned getNumAddressingBits(const ASTContext &Context, |
2907 | QualType ElementType, |
2908 | const llvm::APInt &NumElements); |
2909 | |
2910 | |
2911 | |
2912 | static unsigned getMaxSizeBits(const ASTContext &Context); |
2913 | |
2914 | void Profile(llvm::FoldingSetNodeID &ID) { |
2915 | Profile(ID, getElementType(), getSize(), |
2916 | getSizeModifier(), getIndexTypeCVRQualifiers()); |
2917 | } |
2918 | |
2919 | static void Profile(llvm::FoldingSetNodeID &ID, QualType ET, |
2920 | const llvm::APInt &ArraySize, ArraySizeModifier SizeMod, |
2921 | unsigned TypeQuals) { |
2922 | ID.AddPointer(ET.getAsOpaquePtr()); |
2923 | ID.AddInteger(ArraySize.getZExtValue()); |
2924 | ID.AddInteger(SizeMod); |
2925 | ID.AddInteger(TypeQuals); |
2926 | } |
2927 | |
2928 | static bool classof(const Type *T) { |
2929 | return T->getTypeClass() == ConstantArray; |
2930 | } |
2931 | }; |
2932 | |
2933 | |
2934 | |
2935 | |
2936 | class IncompleteArrayType : public ArrayType { |
2937 | friend class ASTContext; |
2938 | |
2939 | IncompleteArrayType(QualType et, QualType can, |
2940 | ArraySizeModifier sm, unsigned tq) |
2941 | : ArrayType(IncompleteArray, et, can, sm, tq, |
2942 | et->containsUnexpandedParameterPack()) {} |
2943 | |
2944 | public: |
2945 | friend class StmtIteratorBase; |
2946 | |
2947 | bool isSugared() const { return false; } |
2948 | QualType desugar() const { return QualType(this, 0); } |
2949 | |
2950 | static bool classof(const Type *T) { |
2951 | return T->getTypeClass() == IncompleteArray; |
2952 | } |
2953 | |
2954 | void Profile(llvm::FoldingSetNodeID &ID) { |
2955 | Profile(ID, getElementType(), getSizeModifier(), |
2956 | getIndexTypeCVRQualifiers()); |
2957 | } |
2958 | |
2959 | static void Profile(llvm::FoldingSetNodeID &ID, QualType ET, |
2960 | ArraySizeModifier SizeMod, unsigned TypeQuals) { |
2961 | ID.AddPointer(ET.getAsOpaquePtr()); |
2962 | ID.AddInteger(SizeMod); |
2963 | ID.AddInteger(TypeQuals); |
2964 | } |
2965 | }; |
2966 | |
2967 | |
2968 | |
2969 | |
2970 | |
2971 | |
2972 | |
2973 | |
2974 | |
2975 | |
2976 | |
2977 | |
2978 | |
2979 | |
2980 | |
2981 | class VariableArrayType : public ArrayType { |
2982 | friend class ASTContext; |
2983 | |
2984 | |
2985 | |
2986 | Stmt *SizeExpr; |
2987 | |
2988 | |
2989 | SourceRange Brackets; |
2990 | |
2991 | VariableArrayType(QualType et, QualType can, Expr *e, |
2992 | ArraySizeModifier sm, unsigned tq, |
2993 | SourceRange brackets) |
2994 | : ArrayType(VariableArray, et, can, sm, tq, |
2995 | et->containsUnexpandedParameterPack()), |
2996 | SizeExpr((Stmt*) e), Brackets(brackets) {} |
2997 | |
2998 | public: |
2999 | friend class StmtIteratorBase; |
3000 | |
3001 | Expr *getSizeExpr() const { |
3002 | |
3003 | |
3004 | return (Expr*) SizeExpr; |
3005 | } |
3006 | |
3007 | SourceRange getBracketsRange() const { return Brackets; } |
3008 | SourceLocation getLBracketLoc() const { return Brackets.getBegin(); } |
3009 | SourceLocation getRBracketLoc() const { return Brackets.getEnd(); } |
3010 | |
3011 | bool isSugared() const { return false; } |
3012 | QualType desugar() const { return QualType(this, 0); } |
3013 | |
3014 | static bool classof(const Type *T) { |
3015 | return T->getTypeClass() == VariableArray; |
3016 | } |
3017 | |
3018 | void Profile(llvm::FoldingSetNodeID &ID) { |
3019 | llvm_unreachable("Cannot unique VariableArrayTypes."); |
3020 | } |
3021 | }; |
3022 | |
3023 | |
3024 | |
3025 | |
3026 | |
3027 | |
3028 | |
3029 | |
3030 | |
3031 | |
3032 | |
3033 | |
3034 | |
3035 | |
3036 | class DependentSizedArrayType : public ArrayType { |
3037 | friend class ASTContext; |
3038 | |
3039 | const ASTContext &Context; |
3040 | |
3041 | |
3042 | |
3043 | |
3044 | |
3045 | |
3046 | Stmt *SizeExpr; |
3047 | |
3048 | |
3049 | SourceRange Brackets; |
3050 | |
3051 | DependentSizedArrayType(const ASTContext &Context, QualType et, QualType can, |
3052 | Expr *e, ArraySizeModifier sm, unsigned tq, |
3053 | SourceRange brackets); |
3054 | |
3055 | public: |
3056 | friend class StmtIteratorBase; |
3057 | |
3058 | Expr *getSizeExpr() const { |
3059 | |
3060 | |
3061 | return (Expr*) SizeExpr; |
3062 | } |
3063 | |
3064 | SourceRange getBracketsRange() const { return Brackets; } |
3065 | SourceLocation getLBracketLoc() const { return Brackets.getBegin(); } |
3066 | SourceLocation getRBracketLoc() const { return Brackets.getEnd(); } |
3067 | |
3068 | bool isSugared() const { return false; } |
3069 | QualType desugar() const { return QualType(this, 0); } |
3070 | |
3071 | static bool classof(const Type *T) { |
3072 | return T->getTypeClass() == DependentSizedArray; |
3073 | } |
3074 | |
3075 | void Profile(llvm::FoldingSetNodeID &ID) { |
3076 | Profile(ID, Context, getElementType(), |
3077 | getSizeModifier(), getIndexTypeCVRQualifiers(), getSizeExpr()); |
3078 | } |
3079 | |
3080 | static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, |
3081 | QualType ET, ArraySizeModifier SizeMod, |
3082 | unsigned TypeQuals, Expr *E); |
3083 | }; |
3084 | |
3085 | |
3086 | |
3087 | |
3088 | |
3089 | |
3090 | |
3091 | |
3092 | |
3093 | |
3094 | |
3095 | |
3096 | class DependentAddressSpaceType : public Type, public llvm::FoldingSetNode { |
3097 | friend class ASTContext; |
3098 | |
3099 | const ASTContext &Context; |
3100 | Expr *AddrSpaceExpr; |
3101 | QualType PointeeType; |
3102 | SourceLocation loc; |
3103 | |
3104 | DependentAddressSpaceType(const ASTContext &Context, QualType PointeeType, |
3105 | QualType can, Expr *AddrSpaceExpr, |
3106 | SourceLocation loc); |
3107 | |
3108 | public: |
3109 | Expr *getAddrSpaceExpr() const { return AddrSpaceExpr; } |
3110 | QualType getPointeeType() const { return PointeeType; } |
3111 | SourceLocation getAttributeLoc() const { return loc; } |
3112 | |
3113 | bool isSugared() const { return false; } |
3114 | QualType desugar() const { return QualType(this, 0); } |
3115 | |
3116 | static bool classof(const Type *T) { |
3117 | return T->getTypeClass() == DependentAddressSpace; |
3118 | } |
3119 | |
3120 | void Profile(llvm::FoldingSetNodeID &ID) { |
3121 | Profile(ID, Context, getPointeeType(), getAddrSpaceExpr()); |
3122 | } |
3123 | |
3124 | static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, |
3125 | QualType PointeeType, Expr *AddrSpaceExpr); |
3126 | }; |
3127 | |
3128 | |
3129 | |
3130 | |
3131 | |
3132 | |
3133 | |
3134 | |
3135 | |
3136 | |
3137 | |
3138 | class DependentSizedExtVectorType : public Type, public llvm::FoldingSetNode { |
3139 | friend class ASTContext; |
3140 | |
3141 | const ASTContext &Context; |
3142 | Expr *SizeExpr; |
3143 | |
3144 | |
3145 | QualType ElementType; |
3146 | |
3147 | SourceLocation loc; |
3148 | |
3149 | DependentSizedExtVectorType(const ASTContext &Context, QualType ElementType, |
3150 | QualType can, Expr *SizeExpr, SourceLocation loc); |
3151 | |
3152 | public: |
3153 | Expr *getSizeExpr() const { return SizeExpr; } |
3154 | QualType getElementType() const { return ElementType; } |
3155 | SourceLocation getAttributeLoc() const { return loc; } |
3156 | |
3157 | bool isSugared() const { return false; } |
3158 | QualType desugar() const { return QualType(this, 0); } |
3159 | |
3160 | static bool classof(const Type *T) { |
3161 | return T->getTypeClass() == DependentSizedExtVector; |
3162 | } |
3163 | |
3164 | void Profile(llvm::FoldingSetNodeID &ID) { |
3165 | Profile(ID, Context, getElementType(), getSizeExpr()); |
3166 | } |
3167 | |
3168 | static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, |
3169 | QualType ElementType, Expr *SizeExpr); |
3170 | }; |
3171 | |
3172 | |
3173 | |
3174 | |
3175 | |
3176 | |
3177 | |
3178 | class VectorType : public Type, public llvm::FoldingSetNode { |
3179 | public: |
3180 | enum VectorKind { |
3181 | |
3182 | GenericVector, |
3183 | |
3184 | |
3185 | AltiVecVector, |
3186 | |
3187 | |
3188 | AltiVecPixel, |
3189 | |
3190 | |
3191 | AltiVecBool, |
3192 | |
3193 | |
3194 | NeonVector, |
3195 | |
3196 | |
3197 | NeonPolyVector |
3198 | }; |
3199 | |
3200 | protected: |
3201 | friend class ASTContext; |
3202 | |
3203 | |
3204 | QualType ElementType; |
3205 | |
3206 | VectorType(QualType vecType, unsigned nElements, QualType canonType, |
3207 | VectorKind vecKind); |
3208 | |
3209 | VectorType(TypeClass tc, QualType vecType, unsigned nElements, |
3210 | QualType canonType, VectorKind vecKind); |
3211 | |
3212 | public: |
3213 | QualType getElementType() const { return ElementType; } |
3214 | unsigned getNumElements() const { return VectorTypeBits.NumElements; } |
3215 | |
3216 | static bool isVectorSizeTooLarge(unsigned NumElements) { |
3217 | return NumElements > VectorTypeBitfields::MaxNumElements; |
3218 | } |
3219 | |
3220 | bool isSugared() const { return false; } |
3221 | QualType desugar() const { return QualType(this, 0); } |
3222 | |
3223 | VectorKind getVectorKind() const { |
3224 | return VectorKind(VectorTypeBits.VecKind); |
3225 | } |
3226 | |
3227 | void Profile(llvm::FoldingSetNodeID &ID) { |
3228 | Profile(ID, getElementType(), getNumElements(), |
3229 | getTypeClass(), getVectorKind()); |
3230 | } |
3231 | |
3232 | static void Profile(llvm::FoldingSetNodeID &ID, QualType ElementType, |
3233 | unsigned NumElements, TypeClass TypeClass, |
3234 | VectorKind VecKind) { |
3235 | ID.AddPointer(ElementType.getAsOpaquePtr()); |
3236 | ID.AddInteger(NumElements); |
3237 | ID.AddInteger(TypeClass); |
3238 | ID.AddInteger(VecKind); |
3239 | } |
3240 | |
3241 | static bool classof(const Type *T) { |
3242 | return T->getTypeClass() == Vector || T->getTypeClass() == ExtVector; |
3243 | } |
3244 | }; |
3245 | |
3246 | |
3247 | |
3248 | |
3249 | |
3250 | |
3251 | |
3252 | |
3253 | |
3254 | |
3255 | class DependentVectorType : public Type, public llvm::FoldingSetNode { |
3256 | friend class ASTContext; |
3257 | |
3258 | const ASTContext &Context; |
3259 | QualType ElementType; |
3260 | Expr *SizeExpr; |
3261 | SourceLocation Loc; |
3262 | |
3263 | DependentVectorType(const ASTContext &Context, QualType ElementType, |
3264 | QualType CanonType, Expr *SizeExpr, |
3265 | SourceLocation Loc, VectorType::VectorKind vecKind); |
3266 | |
3267 | public: |
3268 | Expr *getSizeExpr() const { return SizeExpr; } |
3269 | QualType getElementType() const { return ElementType; } |
3270 | SourceLocation getAttributeLoc() const { return Loc; } |
3271 | VectorType::VectorKind getVectorKind() const { |
3272 | return VectorType::VectorKind(VectorTypeBits.VecKind); |
3273 | } |
3274 | |
3275 | bool isSugared() const { return false; } |
3276 | QualType desugar() const { return QualType(this, 0); } |
3277 | |
3278 | static bool classof(const Type *T) { |
3279 | return T->getTypeClass() == DependentVector; |
3280 | } |
3281 | |
3282 | void Profile(llvm::FoldingSetNodeID &ID) { |
3283 | Profile(ID, Context, getElementType(), getSizeExpr(), getVectorKind()); |
3284 | } |
3285 | |
3286 | static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, |
3287 | QualType ElementType, const Expr *SizeExpr, |
3288 | VectorType::VectorKind VecKind); |
3289 | }; |
3290 | |
3291 | |
3292 | |
3293 | |
3294 | |
3295 | |
3296 | |
3297 | class ExtVectorType : public VectorType { |
3298 | friend class ASTContext; |
3299 | |
3300 | ExtVectorType(QualType vecType, unsigned nElements, QualType canonType) |
3301 | : VectorType(ExtVector, vecType, nElements, canonType, GenericVector) {} |
3302 | |
3303 | public: |
3304 | static int getPointAccessorIdx(char c) { |
3305 | switch (c) { |
3306 | default: return -1; |
3307 | case 'x': case 'r': return 0; |
3308 | case 'y': case 'g': return 1; |
3309 | case 'z': case 'b': return 2; |
3310 | case 'w': case 'a': return 3; |
3311 | } |
3312 | } |
3313 | |
3314 | static int getNumericAccessorIdx(char c) { |
3315 | switch (c) { |
3316 | default: return -1; |
3317 | case '0': return 0; |
3318 | case '1': return 1; |
3319 | case '2': return 2; |
3320 | case '3': return 3; |
3321 | case '4': return 4; |
3322 | case '5': return 5; |
3323 | case '6': return 6; |
3324 | case '7': return 7; |
3325 | case '8': return 8; |
3326 | case '9': return 9; |
3327 | case 'A': |
3328 | case 'a': return 10; |
3329 | case 'B': |
3330 | case 'b': return 11; |
3331 | case 'C': |
3332 | case 'c': return 12; |
3333 | case 'D': |
3334 | case 'd': return 13; |
3335 | case 'E': |
3336 | case 'e': return 14; |
3337 | case 'F': |
3338 | case 'f': return 15; |
3339 | } |
3340 | } |
3341 | |
3342 | static int getAccessorIdx(char c, bool isNumericAccessor) { |
3343 | if (isNumericAccessor) |
3344 | return getNumericAccessorIdx(c); |
3345 | else |
3346 | return getPointAccessorIdx(c); |
3347 | } |
3348 | |
3349 | bool isAccessorWithinNumElements(char c, bool isNumericAccessor) const { |
3350 | if (int idx = getAccessorIdx(c, isNumericAccessor)+1) |
3351 | return unsigned(idx-1) < getNumElements(); |
3352 | return false; |
3353 | } |
3354 | |
3355 | bool isSugared() const { return false; } |
3356 | QualType desugar() const { return QualType(this, 0); } |
3357 | |
3358 | static bool classof(const Type *T) { |
3359 | return T->getTypeClass() == ExtVector; |
3360 | } |
3361 | }; |
3362 | |
3363 | |
3364 | |
3365 | class FunctionType : public Type { |
3366 | |
3367 | QualType ResultType; |
3368 | |
3369 | public: |
3370 | |
3371 | |
3372 | |
3373 | |
3374 | |
3375 | |
3376 | |
3377 | |
3378 | |
3379 | |
3380 | |
3381 | |
3382 | |
3383 | |
3384 | |
3385 | |
3386 | |
3387 | |
3388 | |
3389 | |
3390 | |
3391 | class ExtParameterInfo { |
3392 | enum { |
3393 | ABIMask = 0x0F, |
3394 | IsConsumed = 0x10, |
3395 | HasPassObjSize = 0x20, |
3396 | IsNoEscape = 0x40, |
3397 | }; |
3398 | unsigned char Data = 0; |
3399 | |
3400 | public: |
3401 | ExtParameterInfo() = default; |
3402 | |
3403 | |
3404 | ParameterABI getABI() const { return ParameterABI(Data & ABIMask); } |
3405 | ExtParameterInfo withABI(ParameterABI kind) const { |
3406 | ExtParameterInfo copy = *this; |
3407 | copy.Data = (copy.Data & ~ABIMask) | unsigned(kind); |
3408 | return copy; |
3409 | } |
3410 | |
3411 | |
3412 | |
3413 | bool isConsumed() const { return (Data & IsConsumed); } |
3414 | ExtParameterInfo withIsConsumed(bool consumed) const { |
3415 | ExtParameterInfo copy = *this; |
3416 | if (consumed) |
3417 | copy.Data |= IsConsumed; |
3418 | else |
3419 | copy.Data &= ~IsConsumed; |
3420 | return copy; |
3421 | } |
3422 | |
3423 | bool hasPassObjectSize() const { return Data & HasPassObjSize; } |
3424 | ExtParameterInfo withHasPassObjectSize() const { |
3425 | ExtParameterInfo Copy = *this; |
3426 | Copy.Data |= HasPassObjSize; |
3427 | return Copy; |
3428 | } |
3429 | |
3430 | bool isNoEscape() const { return Data & IsNoEscape; } |
3431 | ExtParameterInfo withIsNoEscape(bool NoEscape) const { |
3432 | ExtParameterInfo Copy = *this; |
3433 | if (NoEscape) |
3434 | Copy.Data |= IsNoEscape; |
3435 | else |
3436 | Copy.Data &= ~IsNoEscape; |
3437 | return Copy; |
3438 | } |
3439 | |
3440 | unsigned char getOpaqueValue() const { return Data; } |
3441 | static ExtParameterInfo getFromOpaqueValue(unsigned char data) { |
3442 | ExtParameterInfo result; |
3443 | result.Data = data; |
3444 | return result; |
3445 | } |
3446 | |
3447 | friend bool operator==(ExtParameterInfo lhs, ExtParameterInfo rhs) { |
3448 | return lhs.Data == rhs.Data; |
3449 | } |
3450 | |
3451 | friend bool operator!=(ExtParameterInfo lhs, ExtParameterInfo rhs) { |
3452 | return lhs.Data != rhs.Data; |
3453 | } |
3454 | }; |
3455 | |
3456 | |
3457 | |
3458 | |
3459 | |
3460 | |
3461 | |
3462 | |
3463 | |
3464 | |
3465 | |
3466 | |
3467 | |
3468 | |
3469 | |
3470 | |
3471 | |
3472 | |
3473 | |
3474 | |
3475 | |
3476 | class ExtInfo { |
3477 | friend class FunctionType; |
3478 | |
3479 | |
3480 | |
3481 | |
3482 | |
3483 | |
3484 | |
3485 | |
3486 | |
3487 | enum { CallConvMask = 0x1F }; |
3488 | enum { NoReturnMask = 0x20 }; |
3489 | enum { ProducesResultMask = 0x40 }; |
3490 | enum { NoCallerSavedRegsMask = 0x80 }; |
3491 | enum { NoCfCheckMask = 0x800 }; |
3492 | enum { |
3493 | RegParmMask = ~(CallConvMask | NoReturnMask | ProducesResultMask | |
3494 | NoCallerSavedRegsMask | NoCfCheckMask), |
3495 | RegParmOffset = 8 |
3496 | }; |
3497 | uint16_t Bits = CC_C; |
3498 | |
3499 | ExtInfo(unsigned Bits) : Bits(static_cast<uint16_t>(Bits)) {} |
3500 | |
3501 | public: |
3502 | |
3503 | |
3504 | ExtInfo(bool noReturn, bool hasRegParm, unsigned regParm, CallingConv cc, |
3505 | bool producesResult, bool noCallerSavedRegs, bool NoCfCheck) { |
3506 | (0) . __assert_fail ("(!hasRegParm || regParm < 7) && \"Invalid regparm value\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 3506, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert((!hasRegParm || regParm < 7) && "Invalid regparm value"); |
3507 | Bits = ((unsigned)cc) | (noReturn ? NoReturnMask : 0) | |
3508 | (producesResult ? ProducesResultMask : 0) | |
3509 | (noCallerSavedRegs ? NoCallerSavedRegsMask : 0) | |
3510 | (hasRegParm ? ((regParm + 1) << RegParmOffset) : 0) | |
3511 | (NoCfCheck ? NoCfCheckMask : 0); |
3512 | } |
3513 | |
3514 | |
3515 | |
3516 | ExtInfo() = default; |
3517 | |
3518 | |
3519 | |
3520 | ExtInfo(CallingConv CC) : Bits(CC) {} |
3521 | |
3522 | bool getNoReturn() const { return Bits & NoReturnMask; } |
3523 | bool getProducesResult() const { return Bits & ProducesResultMask; } |
3524 | bool getNoCallerSavedRegs() const { return Bits & NoCallerSavedRegsMask; } |
3525 | bool getNoCfCheck() const { return Bits & NoCfCheckMask; } |
3526 | bool getHasRegParm() const { return (Bits >> RegParmOffset) != 0; } |
3527 | |
3528 | unsigned getRegParm() const { |
3529 | unsigned RegParm = (Bits & RegParmMask) >> RegParmOffset; |
3530 | if (RegParm > 0) |
3531 | --RegParm; |
3532 | return RegParm; |
3533 | } |
3534 | |
3535 | CallingConv getCC() const { return CallingConv(Bits & CallConvMask); } |
3536 | |
3537 | bool operator==(ExtInfo Other) const { |
3538 | return Bits == Other.Bits; |
3539 | } |
3540 | bool operator!=(ExtInfo Other) const { |
3541 | return Bits != Other.Bits; |
3542 | } |
3543 | |
3544 | |
3545 | |
3546 | |
3547 | ExtInfo withNoReturn(bool noReturn) const { |
3548 | if (noReturn) |
3549 | return ExtInfo(Bits | NoReturnMask); |
3550 | else |
3551 | return ExtInfo(Bits & ~NoReturnMask); |
3552 | } |
3553 | |
3554 | ExtInfo withProducesResult(bool producesResult) const { |
3555 | if (producesResult) |
3556 | return ExtInfo(Bits | ProducesResultMask); |
3557 | else |
3558 | return ExtInfo(Bits & ~ProducesResultMask); |
3559 | } |
3560 | |
3561 | ExtInfo withNoCallerSavedRegs(bool noCallerSavedRegs) const { |
3562 | if (noCallerSavedRegs) |
3563 | return ExtInfo(Bits | NoCallerSavedRegsMask); |
3564 | else |
3565 | return ExtInfo(Bits & ~NoCallerSavedRegsMask); |
3566 | } |
3567 | |
3568 | ExtInfo withNoCfCheck(bool noCfCheck) const { |
3569 | if (noCfCheck) |
3570 | return ExtInfo(Bits | NoCfCheckMask); |
3571 | else |
3572 | return ExtInfo(Bits & ~NoCfCheckMask); |
3573 | } |
3574 | |
3575 | ExtInfo withRegParm(unsigned RegParm) const { |
3576 | (0) . __assert_fail ("RegParm < 7 && \"Invalid regparm value\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 3576, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(RegParm < 7 && "Invalid regparm value"); |
3577 | return ExtInfo((Bits & ~RegParmMask) | |
3578 | ((RegParm + 1) << RegParmOffset)); |
3579 | } |
3580 | |
3581 | ExtInfo withCallingConv(CallingConv cc) const { |
3582 | return ExtInfo((Bits & ~CallConvMask) | (unsigned) cc); |
3583 | } |
3584 | |
3585 | void Profile(llvm::FoldingSetNodeID &ID) const { |
3586 | ID.AddInteger(Bits); |
3587 | } |
3588 | }; |
3589 | |
3590 | |
3591 | |
3592 | |
3593 | struct ExceptionType { QualType Type; }; |
3594 | |
3595 | |
3596 | |
3597 | |
3598 | |
3599 | struct alignas(void *) { |
3600 | |
3601 | |
3602 | |
3603 | unsigned ; |
3604 | }; |
3605 | |
3606 | protected: |
3607 | FunctionType(TypeClass tc, QualType res, |
3608 | QualType Canonical, bool Dependent, |
3609 | bool InstantiationDependent, |
3610 | bool VariablyModified, bool ContainsUnexpandedParameterPack, |
3611 | ExtInfo Info) |
3612 | : Type(tc, Canonical, Dependent, InstantiationDependent, VariablyModified, |
3613 | ContainsUnexpandedParameterPack), |
3614 | ResultType(res) { |
3615 | FunctionTypeBits.ExtInfo = Info.Bits; |
3616 | } |
3617 | |
3618 | Qualifiers getFastTypeQuals() const { |
3619 | return Qualifiers::fromFastMask(FunctionTypeBits.FastTypeQuals); |
3620 | } |
3621 | |
3622 | public: |
3623 | QualType getReturnType() const { return ResultType; } |
3624 | |
3625 | bool getHasRegParm() const { return getExtInfo().getHasRegParm(); } |
3626 | unsigned getRegParmType() const { return getExtInfo().getRegParm(); } |
3627 | |
3628 | |
3629 | |
3630 | |
3631 | bool getNoReturnAttr() const { return getExtInfo().getNoReturn(); } |
3632 | |
3633 | CallingConv getCallConv() const { return getExtInfo().getCC(); } |
3634 | ExtInfo getExtInfo() const { return ExtInfo(FunctionTypeBits.ExtInfo); } |
3635 | |
3636 | static_assert((~Qualifiers::FastMask & Qualifiers::CVRMask) == 0, |
3637 | "Const, volatile and restrict are assumed to be a subset of " |
3638 | "the fast qualifiers."); |
3639 | |
3640 | bool isConst() const { return getFastTypeQuals().hasConst(); } |
3641 | bool isVolatile() const { return getFastTypeQuals().hasVolatile(); } |
3642 | bool isRestrict() const { return getFastTypeQuals().hasRestrict(); } |
3643 | |
3644 | |
3645 | |
3646 | QualType getCallResultType(const ASTContext &Context) const { |
3647 | return getReturnType().getNonLValueExprType(Context); |
3648 | } |
3649 | |
3650 | static StringRef getNameForCallConv(CallingConv CC); |
3651 | |
3652 | static bool classof(const Type *T) { |
3653 | return T->getTypeClass() == FunctionNoProto || |
3654 | T->getTypeClass() == FunctionProto; |
3655 | } |
3656 | }; |
3657 | |
3658 | |
3659 | |
3660 | class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { |
3661 | friend class ASTContext; |
3662 | |
3663 | FunctionNoProtoType(QualType Result, QualType Canonical, ExtInfo Info) |
3664 | : FunctionType(FunctionNoProto, Result, Canonical, |
3665 | , , |
3666 | Result->isVariablyModifiedType(), |
3667 | , Info) {} |
3668 | |
3669 | public: |
3670 | |
3671 | |
3672 | bool isSugared() const { return false; } |
3673 | QualType desugar() const { return QualType(this, 0); } |
3674 | |
3675 | void Profile(llvm::FoldingSetNodeID &ID) { |
3676 | Profile(ID, getReturnType(), getExtInfo()); |
3677 | } |
3678 | |
3679 | static void Profile(llvm::FoldingSetNodeID &ID, QualType ResultType, |
3680 | ExtInfo Info) { |
3681 | Info.Profile(ID); |
3682 | ID.AddPointer(ResultType.getAsOpaquePtr()); |
3683 | } |
3684 | |
3685 | static bool classof(const Type *T) { |
3686 | return T->getTypeClass() == FunctionNoProto; |
3687 | } |
3688 | }; |
3689 | |
3690 | |
3691 | |
3692 | |
3693 | |
3694 | |
3695 | |
3696 | |
3697 | class FunctionProtoType final |
3698 | : public FunctionType, |
3699 | public llvm::FoldingSetNode, |
3700 | private llvm::TrailingObjects< |
3701 | FunctionProtoType, QualType, FunctionType::FunctionTypeExtraBitfields, |
3702 | FunctionType::ExceptionType, Expr *, FunctionDecl *, |
3703 | FunctionType::ExtParameterInfo, Qualifiers> { |
3704 | friend class ASTContext; |
3705 | friend TrailingObjects; |
3706 | |
3707 | |
3708 | |
3709 | |
3710 | |
3711 | |
3712 | |
3713 | |
3714 | |
3715 | |
3716 | |
3717 | |
3718 | |
3719 | |
3720 | |
3721 | |
3722 | |
3723 | |
3724 | |
3725 | |
3726 | |
3727 | |
3728 | |
3729 | |
3730 | |
3731 | |
3732 | |
3733 | |
3734 | |
3735 | |
3736 | |
3737 | |
3738 | |
3739 | |
3740 | |
3741 | |
3742 | |
3743 | |
3744 | |
3745 | |
3746 | public: |
3747 | |
3748 | |
3749 | |
3750 | |
3751 | struct ExceptionSpecInfo { |
3752 | |
3753 | ExceptionSpecificationType Type = EST_None; |
3754 | |
3755 | |
3756 | ArrayRef<QualType> Exceptions; |
3757 | |
3758 | |
3759 | Expr *NoexceptExpr = nullptr; |
3760 | |
3761 | |
3762 | |
3763 | FunctionDecl *SourceDecl = nullptr; |
3764 | |
3765 | |
3766 | |
3767 | FunctionDecl *SourceTemplate = nullptr; |
3768 | |
3769 | ExceptionSpecInfo() = default; |
3770 | |
3771 | ExceptionSpecInfo(ExceptionSpecificationType EST) : Type(EST) {} |
3772 | }; |
3773 | |
3774 | |
3775 | |
3776 | |
3777 | struct ExtProtoInfo { |
3778 | FunctionType::ExtInfo ExtInfo; |
3779 | bool Variadic : 1; |
3780 | bool HasTrailingReturn : 1; |
3781 | Qualifiers TypeQuals; |
3782 | RefQualifierKind RefQualifier = RQ_None; |
3783 | ExceptionSpecInfo ExceptionSpec; |
3784 | const ExtParameterInfo *ExtParameterInfos = nullptr; |
3785 | |
3786 | ExtProtoInfo() : Variadic(false), HasTrailingReturn(false) {} |
3787 | |
3788 | ExtProtoInfo(CallingConv CC) |
3789 | : ExtInfo(CC), Variadic(false), HasTrailingReturn(false) {} |
3790 | |
3791 | ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &ESI) { |
3792 | ExtProtoInfo Result(*this); |
3793 | Result.ExceptionSpec = ESI; |
3794 | return Result; |
3795 | } |
3796 | }; |
3797 | |
3798 | private: |
3799 | unsigned numTrailingObjects(OverloadToken<QualType>) const { |
3800 | return getNumParams(); |
3801 | } |
3802 | |
3803 | unsigned numTrailingObjects(OverloadToken<FunctionTypeExtraBitfields>) const { |
3804 | return hasExtraBitfields(); |
3805 | } |
3806 | |
3807 | unsigned numTrailingObjects(OverloadToken<ExceptionType>) const { |
3808 | return getExceptionSpecSize().NumExceptionType; |
3809 | } |
3810 | |
3811 | unsigned numTrailingObjects(OverloadToken<Expr *>) const { |
3812 | return getExceptionSpecSize().NumExprPtr; |
3813 | } |
3814 | |
3815 | unsigned numTrailingObjects(OverloadToken<FunctionDecl *>) const { |
3816 | return getExceptionSpecSize().NumFunctionDeclPtr; |
3817 | } |
3818 | |
3819 | unsigned numTrailingObjects(OverloadToken<ExtParameterInfo>) const { |
3820 | return hasExtParameterInfos() ? getNumParams() : 0; |
3821 | } |
3822 | |
3823 | |
3824 | |
3825 | static bool containsAnyUnexpandedParameterPack(const QualType *ArgArray, |
3826 | unsigned numArgs) { |
3827 | for (unsigned Idx = 0; Idx < numArgs; ++Idx) |
3828 | if (ArgArray[Idx]->containsUnexpandedParameterPack()) |
3829 | return true; |
3830 | |
3831 | return false; |
3832 | } |
3833 | |
3834 | FunctionProtoType(QualType result, ArrayRef<QualType> params, |
3835 | QualType canonical, const ExtProtoInfo &epi); |
3836 | |
3837 | |
3838 | |
3839 | |
3840 | struct ExceptionSpecSizeHolder { |
3841 | unsigned NumExceptionType; |
3842 | unsigned NumExprPtr; |
3843 | unsigned NumFunctionDeclPtr; |
3844 | }; |
3845 | |
3846 | |
3847 | |
3848 | static ExceptionSpecSizeHolder |
3849 | getExceptionSpecSize(ExceptionSpecificationType EST, unsigned NumExceptions) { |
3850 | switch (EST) { |
3851 | case EST_None: |
3852 | case EST_DynamicNone: |
3853 | case EST_MSAny: |
3854 | case EST_BasicNoexcept: |
3855 | case EST_Unparsed: |
3856 | return {0, 0, 0}; |
3857 | |
3858 | case EST_Dynamic: |
3859 | return {NumExceptions, 0, 0}; |
3860 | |
3861 | case EST_DependentNoexcept: |
3862 | case EST_NoexceptFalse: |
3863 | case EST_NoexceptTrue: |
3864 | return {0, 1, 0}; |
3865 | |
3866 | case EST_Uninstantiated: |
3867 | return {0, 0, 2}; |
3868 | |
3869 | case EST_Unevaluated: |
3870 | return {0, 0, 1}; |
3871 | } |
3872 | llvm_unreachable("bad exception specification kind"); |
3873 | } |
3874 | |
3875 | |
3876 | |
3877 | ExceptionSpecSizeHolder getExceptionSpecSize() const { |
3878 | return getExceptionSpecSize(getExceptionSpecType(), getNumExceptions()); |
3879 | } |
3880 | |
3881 | |
3882 | static bool (ExceptionSpecificationType EST) { |
3883 | |
3884 | |
3885 | return EST == EST_Dynamic; |
3886 | } |
3887 | |
3888 | |
3889 | bool () const { |
3890 | return hasExtraBitfields(getExceptionSpecType()); |
3891 | } |
3892 | |
3893 | bool hasExtQualifiers() const { |
3894 | return FunctionTypeBits.HasExtQuals; |
3895 | } |
3896 | |
3897 | public: |
3898 | unsigned getNumParams() const { return FunctionTypeBits.NumParams; } |
3899 | |
3900 | QualType getParamType(unsigned i) const { |
3901 | (0) . __assert_fail ("i < getNumParams() && \"invalid parameter index\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 3901, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(i < getNumParams() && "invalid parameter index"); |
3902 | return param_type_begin()[i]; |
3903 | } |
3904 | |
3905 | ArrayRef<QualType> getParamTypes() const { |
3906 | return llvm::makeArrayRef(param_type_begin(), param_type_end()); |
3907 | } |
3908 | |
3909 | ExtProtoInfo getExtProtoInfo() const { |
3910 | ExtProtoInfo EPI; |
3911 | EPI.ExtInfo = getExtInfo(); |
3912 | EPI.Variadic = isVariadic(); |
3913 | EPI.HasTrailingReturn = hasTrailingReturn(); |
3914 | EPI.ExceptionSpec.Type = getExceptionSpecType(); |
3915 | EPI.TypeQuals = getMethodQuals(); |
3916 | EPI.RefQualifier = getRefQualifier(); |
3917 | if (EPI.ExceptionSpec.Type == EST_Dynamic) { |
3918 | EPI.ExceptionSpec.Exceptions = exceptions(); |
3919 | } else if (isComputedNoexcept(EPI.ExceptionSpec.Type)) { |
3920 | EPI.ExceptionSpec.NoexceptExpr = getNoexceptExpr(); |
3921 | } else if (EPI.ExceptionSpec.Type == EST_Uninstantiated) { |
3922 | EPI.ExceptionSpec.SourceDecl = getExceptionSpecDecl(); |
3923 | EPI.ExceptionSpec.SourceTemplate = getExceptionSpecTemplate(); |
3924 | } else if (EPI.ExceptionSpec.Type == EST_Unevaluated) { |
3925 | EPI.ExceptionSpec.SourceDecl = getExceptionSpecDecl(); |
3926 | } |
3927 | EPI.ExtParameterInfos = getExtParameterInfosOrNull(); |
3928 | return EPI; |
3929 | } |
3930 | |
3931 | |
3932 | ExceptionSpecificationType getExceptionSpecType() const { |
3933 | return static_cast<ExceptionSpecificationType>( |
3934 | FunctionTypeBits.ExceptionSpecType); |
3935 | } |
3936 | |
3937 | |
3938 | bool hasExceptionSpec() const { return getExceptionSpecType() != EST_None; } |
3939 | |
3940 | |
3941 | bool hasDynamicExceptionSpec() const { |
3942 | return isDynamicExceptionSpec(getExceptionSpecType()); |
3943 | } |
3944 | |
3945 | |
3946 | bool hasNoexceptExceptionSpec() const { |
3947 | return isNoexceptExceptionSpec(getExceptionSpecType()); |
3948 | } |
3949 | |
3950 | |
3951 | bool hasDependentExceptionSpec() const; |
3952 | |
3953 | |
3954 | |
3955 | bool hasInstantiationDependentExceptionSpec() const; |
3956 | |
3957 | |
3958 | unsigned getNumExceptions() const { |
3959 | return getExceptionSpecType() == EST_Dynamic |
3960 | ? getTrailingObjects<FunctionTypeExtraBitfields>() |
3961 | ->NumExceptionType |
3962 | : 0; |
3963 | } |
3964 | |
3965 | |
3966 | QualType getExceptionType(unsigned i) const { |
3967 | (0) . __assert_fail ("i < getNumExceptions() && \"Invalid exception number!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 3967, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(i < getNumExceptions() && "Invalid exception number!"); |
3968 | return exception_begin()[i]; |
3969 | } |
3970 | |
3971 | |
3972 | |
3973 | Expr *getNoexceptExpr() const { |
3974 | if (!isComputedNoexcept(getExceptionSpecType())) |
3975 | return nullptr; |
3976 | return *getTrailingObjects<Expr *>(); |
3977 | } |
3978 | |
3979 | |
3980 | |
3981 | |
3982 | |
3983 | FunctionDecl *getExceptionSpecDecl() const { |
3984 | if (getExceptionSpecType() != EST_Uninstantiated && |
3985 | getExceptionSpecType() != EST_Unevaluated) |
3986 | return nullptr; |
3987 | return getTrailingObjects<FunctionDecl *>()[0]; |
3988 | } |
3989 | |
3990 | |
3991 | |
3992 | |
3993 | |
3994 | FunctionDecl *getExceptionSpecTemplate() const { |
3995 | if (getExceptionSpecType() != EST_Uninstantiated) |
3996 | return nullptr; |
3997 | return getTrailingObjects<FunctionDecl *>()[1]; |
3998 | } |
3999 | |
4000 | |
4001 | |
4002 | CanThrowResult canThrow() const; |
4003 | |
4004 | |
4005 | |
4006 | |
4007 | bool isNothrow(bool ResultIfDependent = false) const { |
4008 | return ResultIfDependent ? canThrow() != CT_Can : canThrow() == CT_Cannot; |
4009 | } |
4010 | |
4011 | |
4012 | bool isVariadic() const { return FunctionTypeBits.Variadic; } |
4013 | |
4014 | |
4015 | |
4016 | |
4017 | |
4018 | |
4019 | |
4020 | bool isTemplateVariadic() const; |
4021 | |
4022 | |
4023 | bool hasTrailingReturn() const { return FunctionTypeBits.HasTrailingReturn; } |
4024 | |
4025 | Qualifiers getMethodQuals() const { |
4026 | if (hasExtQualifiers()) |
4027 | return *getTrailingObjects<Qualifiers>(); |
4028 | else |
4029 | return getFastTypeQuals(); |
4030 | } |
4031 | |
4032 | |
4033 | RefQualifierKind getRefQualifier() const { |
4034 | return static_cast<RefQualifierKind>(FunctionTypeBits.RefQualifier); |
4035 | } |
4036 | |
4037 | using param_type_iterator = const QualType *; |
4038 | using param_type_range = llvm::iterator_range<param_type_iterator>; |
4039 | |
4040 | param_type_range param_types() const { |
4041 | return param_type_range(param_type_begin(), param_type_end()); |
4042 | } |
4043 | |
4044 | param_type_iterator param_type_begin() const { |
4045 | return getTrailingObjects<QualType>(); |
4046 | } |
4047 | |
4048 | param_type_iterator param_type_end() const { |
4049 | return param_type_begin() + getNumParams(); |
4050 | } |
4051 | |
4052 | using exception_iterator = const QualType *; |
4053 | |
4054 | ArrayRef<QualType> exceptions() const { |
4055 | return llvm::makeArrayRef(exception_begin(), exception_end()); |
4056 | } |
4057 | |
4058 | exception_iterator exception_begin() const { |
4059 | return reinterpret_cast<exception_iterator>( |
4060 | getTrailingObjects<ExceptionType>()); |
4061 | } |
4062 | |
4063 | exception_iterator exception_end() const { |
4064 | return exception_begin() + getNumExceptions(); |
4065 | } |
4066 | |
4067 | |
4068 | |
4069 | bool hasExtParameterInfos() const { |
4070 | return FunctionTypeBits.HasExtParameterInfos; |
4071 | } |
4072 | |
4073 | ArrayRef<ExtParameterInfo> getExtParameterInfos() const { |
4074 | assert(hasExtParameterInfos()); |
4075 | return ArrayRef<ExtParameterInfo>(getTrailingObjects<ExtParameterInfo>(), |
4076 | getNumParams()); |
4077 | } |
4078 | |
4079 | |
4080 | |
4081 | |
4082 | const ExtParameterInfo *getExtParameterInfosOrNull() const { |
4083 | if (!hasExtParameterInfos()) |
4084 | return nullptr; |
4085 | return getTrailingObjects<ExtParameterInfo>(); |
4086 | } |
4087 | |
4088 | ExtParameterInfo getExtParameterInfo(unsigned I) const { |
4089 | (0) . __assert_fail ("I < getNumParams() && \"parameter index out of range\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 4089, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(I < getNumParams() && "parameter index out of range"); |
4090 | if (hasExtParameterInfos()) |
4091 | return getTrailingObjects<ExtParameterInfo>()[I]; |
4092 | return ExtParameterInfo(); |
4093 | } |
4094 | |
4095 | ParameterABI getParameterABI(unsigned I) const { |
4096 | (0) . __assert_fail ("I < getNumParams() && \"parameter index out of range\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 4096, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(I < getNumParams() && "parameter index out of range"); |
4097 | if (hasExtParameterInfos()) |
4098 | return getTrailingObjects<ExtParameterInfo>()[I].getABI(); |
4099 | return ParameterABI::Ordinary; |
4100 | } |
4101 | |
4102 | bool isParamConsumed(unsigned I) const { |
4103 | (0) . __assert_fail ("I < getNumParams() && \"parameter index out of range\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 4103, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(I < getNumParams() && "parameter index out of range"); |
4104 | if (hasExtParameterInfos()) |
4105 | return getTrailingObjects<ExtParameterInfo>()[I].isConsumed(); |
4106 | return false; |
4107 | } |
4108 | |
4109 | bool isSugared() const { return false; } |
4110 | QualType desugar() const { return QualType(this, 0); } |
4111 | |
4112 | void printExceptionSpecification(raw_ostream &OS, |
4113 | const PrintingPolicy &Policy) const; |
4114 | |
4115 | static bool classof(const Type *T) { |
4116 | return T->getTypeClass() == FunctionProto; |
4117 | } |
4118 | |
4119 | void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx); |
4120 | static void Profile(llvm::FoldingSetNodeID &ID, QualType Result, |
4121 | param_type_iterator ArgTys, unsigned NumArgs, |
4122 | const ExtProtoInfo &EPI, const ASTContext &Context, |
4123 | bool Canonical); |
4124 | }; |
4125 | |
4126 | |
4127 | |
4128 | |
4129 | |
4130 | |
4131 | class UnresolvedUsingType : public Type { |
4132 | friend class ASTContext; |
4133 | |
4134 | UnresolvedUsingTypenameDecl *Decl; |
4135 | |
4136 | UnresolvedUsingType(const UnresolvedUsingTypenameDecl *D) |
4137 | : Type(UnresolvedUsing, QualType(), true, true, false, |
4138 | ), |
4139 | Decl(const_cast<UnresolvedUsingTypenameDecl*>(D)) {} |
4140 | |
4141 | public: |
4142 | UnresolvedUsingTypenameDecl *getDecl() const { return Decl; } |
4143 | |
4144 | bool isSugared() const { return false; } |
4145 | QualType desugar() const { return QualType(this, 0); } |
4146 | |
4147 | static bool classof(const Type *T) { |
4148 | return T->getTypeClass() == UnresolvedUsing; |
4149 | } |
4150 | |
4151 | void Profile(llvm::FoldingSetNodeID &ID) { |
4152 | return Profile(ID, Decl); |
4153 | } |
4154 | |
4155 | static void Profile(llvm::FoldingSetNodeID &ID, |
4156 | UnresolvedUsingTypenameDecl *D) { |
4157 | ID.AddPointer(D); |
4158 | } |
4159 | }; |
4160 | |
4161 | class TypedefType : public Type { |
4162 | TypedefNameDecl *Decl; |
4163 | |
4164 | protected: |
4165 | friend class ASTContext; |
4166 | |
4167 | TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType can) |
4168 | : Type(tc, can, can->isDependentType(), |
4169 | can->isInstantiationDependentType(), |
4170 | can->isVariablyModifiedType(), |
4171 | ), |
4172 | Decl(const_cast<TypedefNameDecl*>(D)) { |
4173 | (0) . __assert_fail ("!isa(can) && \"Invalid canonical type\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 4173, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<TypedefType>(can) && "Invalid canonical type"); |
4174 | } |
4175 | |
4176 | public: |
4177 | TypedefNameDecl *getDecl() const { return Decl; } |
4178 | |
4179 | bool isSugared() const { return true; } |
4180 | QualType desugar() const; |
4181 | |
4182 | static bool classof(const Type *T) { return T->getTypeClass() == Typedef; } |
4183 | }; |
4184 | |
4185 | |
4186 | class TypeOfExprType : public Type { |
4187 | Expr *TOExpr; |
4188 | |
4189 | protected: |
4190 | friend class ASTContext; |
4191 | |
4192 | TypeOfExprType(Expr *E, QualType can = QualType()); |
4193 | |
4194 | public: |
4195 | Expr *getUnderlyingExpr() const { return TOExpr; } |
4196 | |
4197 | |
4198 | QualType desugar() const; |
4199 | |
4200 | |
4201 | bool isSugared() const; |
4202 | |
4203 | static bool classof(const Type *T) { return T->getTypeClass() == TypeOfExpr; } |
4204 | }; |
4205 | |
4206 | |
4207 | |
4208 | |
4209 | |
4210 | |
4211 | |
4212 | class DependentTypeOfExprType |
4213 | : public TypeOfExprType, public llvm::FoldingSetNode { |
4214 | const ASTContext &Context; |
4215 | |
4216 | public: |
4217 | DependentTypeOfExprType(const ASTContext &Context, Expr *E) |
4218 | : TypeOfExprType(E), Context(Context) {} |
4219 | |
4220 | void Profile(llvm::FoldingSetNodeID &ID) { |
4221 | Profile(ID, Context, getUnderlyingExpr()); |
4222 | } |
4223 | |
4224 | static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, |
4225 | Expr *E); |
4226 | }; |
4227 | |
4228 | |
4229 | class TypeOfType : public Type { |
4230 | friend class ASTContext; |
4231 | |
4232 | QualType TOType; |
4233 | |
4234 | TypeOfType(QualType T, QualType can) |
4235 | : Type(TypeOf, can, T->isDependentType(), |
4236 | T->isInstantiationDependentType(), |
4237 | T->isVariablyModifiedType(), |
4238 | T->containsUnexpandedParameterPack()), |
4239 | TOType(T) { |
4240 | (0) . __assert_fail ("!isa(can) && \"Invalid canonical type\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 4240, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<TypedefType>(can) && "Invalid canonical type"); |
4241 | } |
4242 | |
4243 | public: |
4244 | QualType getUnderlyingType() const { return TOType; } |
4245 | |
4246 | |
4247 | QualType desugar() const { return getUnderlyingType(); } |
4248 | |
4249 | |
4250 | bool isSugared() const { return true; } |
4251 | |
4252 | static bool classof(const Type *T) { return T->getTypeClass() == TypeOf; } |
4253 | }; |
4254 | |
4255 | |
4256 | class DecltypeType : public Type { |
4257 | Expr *E; |
4258 | QualType UnderlyingType; |
4259 | |
4260 | protected: |
4261 | friend class ASTContext; |
4262 | |
4263 | DecltypeType(Expr *E, QualType underlyingType, QualType can = QualType()); |
4264 | |
4265 | public: |
4266 | Expr *getUnderlyingExpr() const { return E; } |
4267 | QualType getUnderlyingType() const { return UnderlyingType; } |
4268 | |
4269 | |
4270 | QualType desugar() const; |
4271 | |
4272 | |
4273 | bool isSugared() const; |
4274 | |
4275 | static bool classof(const Type *T) { return T->getTypeClass() == Decltype; } |
4276 | }; |
4277 | |
4278 | |
4279 | |
4280 | |
4281 | |
4282 | |
4283 | |
4284 | class DependentDecltypeType : public DecltypeType, public llvm::FoldingSetNode { |
4285 | const ASTContext &Context; |
4286 | |
4287 | public: |
4288 | DependentDecltypeType(const ASTContext &Context, Expr *E); |
4289 | |
4290 | void Profile(llvm::FoldingSetNodeID &ID) { |
4291 | Profile(ID, Context, getUnderlyingExpr()); |
4292 | } |
4293 | |
4294 | static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, |
4295 | Expr *E); |
4296 | }; |
4297 | |
4298 | |
4299 | class UnaryTransformType : public Type { |
4300 | public: |
4301 | enum UTTKind { |
4302 | EnumUnderlyingType |
4303 | }; |
4304 | |
4305 | private: |
4306 | |
4307 | QualType BaseType; |
4308 | |
4309 | |
4310 | QualType UnderlyingType; |
4311 | |
4312 | UTTKind UKind; |
4313 | |
4314 | protected: |
4315 | friend class ASTContext; |
4316 | |
4317 | UnaryTransformType(QualType BaseTy, QualType UnderlyingTy, UTTKind UKind, |
4318 | QualType CanonicalTy); |
4319 | |
4320 | public: |
4321 | bool isSugared() const { return !isDependentType(); } |
4322 | QualType desugar() const { return UnderlyingType; } |
4323 | |
4324 | QualType getUnderlyingType() const { return UnderlyingType; } |
4325 | QualType getBaseType() const { return BaseType; } |
4326 | |
4327 | UTTKind getUTTKind() const { return UKind; } |
4328 | |
4329 | static bool classof(const Type *T) { |
4330 | return T->getTypeClass() == UnaryTransform; |
4331 | } |
4332 | }; |
4333 | |
4334 | |
4335 | |
4336 | |
4337 | |
4338 | |
4339 | |
4340 | class DependentUnaryTransformType : public UnaryTransformType, |
4341 | public llvm::FoldingSetNode { |
4342 | public: |
4343 | DependentUnaryTransformType(const ASTContext &C, QualType BaseType, |
4344 | UTTKind UKind); |
4345 | |
4346 | void Profile(llvm::FoldingSetNodeID &ID) { |
4347 | Profile(ID, getBaseType(), getUTTKind()); |
4348 | } |
4349 | |
4350 | static void Profile(llvm::FoldingSetNodeID &ID, QualType BaseType, |
4351 | UTTKind UKind) { |
4352 | ID.AddPointer(BaseType.getAsOpaquePtr()); |
4353 | ID.AddInteger((unsigned)UKind); |
4354 | } |
4355 | }; |
4356 | |
4357 | class TagType : public Type { |
4358 | friend class ASTReader; |
4359 | |
4360 | |
4361 | |
4362 | TagDecl *decl; |
4363 | |
4364 | protected: |
4365 | TagType(TypeClass TC, const TagDecl *D, QualType can); |
4366 | |
4367 | public: |
4368 | TagDecl *getDecl() const; |
4369 | |
4370 | |
4371 | bool isBeingDefined() const; |
4372 | |
4373 | static bool classof(const Type *T) { |
4374 | return T->getTypeClass() >= TagFirst && T->getTypeClass() <= TagLast; |
4375 | } |
4376 | }; |
4377 | |
4378 | |
4379 | |
4380 | class RecordType : public TagType { |
4381 | protected: |
4382 | friend class ASTContext; |
4383 | |
4384 | explicit RecordType(const RecordDecl *D) |
4385 | : TagType(Record, reinterpret_cast<const TagDecl*>(D), QualType()) {} |
4386 | explicit RecordType(TypeClass TC, RecordDecl *D) |
4387 | : TagType(TC, reinterpret_cast<const TagDecl*>(D), QualType()) {} |
4388 | |
4389 | public: |
4390 | RecordDecl *getDecl() const { |
4391 | return reinterpret_cast<RecordDecl*>(TagType::getDecl()); |
4392 | } |
4393 | |
4394 | |
4395 | |
4396 | bool hasConstFields() const; |
4397 | |
4398 | bool isSugared() const { return false; } |
4399 | QualType desugar() const { return QualType(this, 0); } |
4400 | |
4401 | static bool classof(const Type *T) { return T->getTypeClass() == Record; } |
4402 | }; |
4403 | |
4404 | |
4405 | |
4406 | class EnumType : public TagType { |
4407 | friend class ASTContext; |
4408 | |
4409 | explicit EnumType(const EnumDecl *D) |
4410 | : TagType(Enum, reinterpret_cast<const TagDecl*>(D), QualType()) {} |
4411 | |
4412 | public: |
4413 | EnumDecl *getDecl() const { |
4414 | return reinterpret_cast<EnumDecl*>(TagType::getDecl()); |
4415 | } |
4416 | |
4417 | bool isSugared() const { return false; } |
4418 | QualType desugar() const { return QualType(this, 0); } |
4419 | |
4420 | static bool classof(const Type *T) { return T->getTypeClass() == Enum; } |
4421 | }; |
4422 | |
4423 | |
4424 | |
4425 | |
4426 | |
4427 | |
4428 | |
4429 | |
4430 | |
4431 | |
4432 | |
4433 | |
4434 | |
4435 | class AttributedType : public Type, public llvm::FoldingSetNode { |
4436 | public: |
4437 | using Kind = attr::Kind; |
4438 | |
4439 | private: |
4440 | friend class ASTContext; |
4441 | |
4442 | QualType ModifiedType; |
4443 | QualType EquivalentType; |
4444 | |
4445 | AttributedType(QualType canon, attr::Kind attrKind, QualType modified, |
4446 | QualType equivalent) |
4447 | : Type(Attributed, canon, equivalent->isDependentType(), |
4448 | equivalent->isInstantiationDependentType(), |
4449 | equivalent->isVariablyModifiedType(), |
4450 | equivalent->containsUnexpandedParameterPack()), |
4451 | ModifiedType(modified), EquivalentType(equivalent) { |
4452 | AttributedTypeBits.AttrKind = attrKind; |
4453 | } |
4454 | |
4455 | public: |
4456 | Kind getAttrKind() const { |
4457 | return static_cast<Kind>(AttributedTypeBits.AttrKind); |
4458 | } |
4459 | |
4460 | QualType getModifiedType() const { return ModifiedType; } |
4461 | QualType getEquivalentType() const { return EquivalentType; } |
4462 | |
4463 | bool isSugared() const { return true; } |
4464 | QualType desugar() const { return getEquivalentType(); } |
4465 | |
4466 | |
4467 | |
4468 | |
4469 | |
4470 | |
4471 | |
4472 | |
4473 | |
4474 | |
4475 | |
4476 | |
4477 | |
4478 | |
4479 | |
4480 | |
4481 | bool isQualifier() const; |
4482 | |
4483 | bool isMSTypeSpec() const; |
4484 | |
4485 | bool isCallingConv() const; |
4486 | |
4487 | llvm::Optional<NullabilityKind> getImmediateNullability() const; |
4488 | |
4489 | |
4490 | |
4491 | static Kind getNullabilityAttrKind(NullabilityKind kind) { |
4492 | switch (kind) { |
4493 | case NullabilityKind::NonNull: |
4494 | return attr::TypeNonNull; |
4495 | |
4496 | case NullabilityKind::Nullable: |
4497 | return attr::TypeNullable; |
4498 | |
4499 | case NullabilityKind::Unspecified: |
4500 | return attr::TypeNullUnspecified; |
4501 | } |
4502 | llvm_unreachable("Unknown nullability kind."); |
4503 | } |
4504 | |
4505 | |
4506 | |
4507 | |
4508 | |
4509 | |
4510 | |
4511 | |
4512 | |
4513 | |
4514 | static Optional<NullabilityKind> stripOuterNullability(QualType &T); |
4515 | |
4516 | void Profile(llvm::FoldingSetNodeID &ID) { |
4517 | Profile(ID, getAttrKind(), ModifiedType, EquivalentType); |
4518 | } |
4519 | |
4520 | static void Profile(llvm::FoldingSetNodeID &ID, Kind attrKind, |
4521 | QualType modified, QualType equivalent) { |
4522 | ID.AddInteger(attrKind); |
4523 | ID.AddPointer(modified.getAsOpaquePtr()); |
4524 | ID.AddPointer(equivalent.getAsOpaquePtr()); |
4525 | } |
4526 | |
4527 | static bool classof(const Type *T) { |
4528 | return T->getTypeClass() == Attributed; |
4529 | } |
4530 | }; |
4531 | |
4532 | class TemplateTypeParmType : public Type, public llvm::FoldingSetNode { |
4533 | friend class ASTContext; |
4534 | |
4535 | |
4536 | struct CanonicalTTPTInfo { |
4537 | unsigned Depth : 15; |
4538 | unsigned ParameterPack : 1; |
4539 | unsigned Index : 16; |
4540 | }; |
4541 | |
4542 | union { |
4543 | |
4544 | CanonicalTTPTInfo CanTTPTInfo; |
4545 | |
4546 | |
4547 | TemplateTypeParmDecl *TTPDecl; |
4548 | }; |
4549 | |
4550 | |
4551 | TemplateTypeParmType(TemplateTypeParmDecl *TTPDecl, QualType Canon) |
4552 | : Type(TemplateTypeParm, Canon, , |
4553 | , |
4554 | , |
4555 | Canon->containsUnexpandedParameterPack()), |
4556 | TTPDecl(TTPDecl) {} |
4557 | |
4558 | |
4559 | TemplateTypeParmType(unsigned D, unsigned I, bool PP) |
4560 | : Type(TemplateTypeParm, QualType(this, 0), |
4561 | , |
4562 | , |
4563 | , PP) { |
4564 | CanTTPTInfo.Depth = D; |
4565 | CanTTPTInfo.Index = I; |
4566 | CanTTPTInfo.ParameterPack = PP; |
4567 | } |
4568 | |
4569 | const CanonicalTTPTInfo& getCanTTPTInfo() const { |
4570 | QualType Can = getCanonicalTypeInternal(); |
4571 | return Can->castAs<TemplateTypeParmType>()->CanTTPTInfo; |
4572 | } |
4573 | |
4574 | public: |
4575 | unsigned getDepth() const { return getCanTTPTInfo().Depth; } |
4576 | unsigned getIndex() const { return getCanTTPTInfo().Index; } |
4577 | bool isParameterPack() const { return getCanTTPTInfo().ParameterPack; } |
4578 | |
4579 | TemplateTypeParmDecl *getDecl() const { |
4580 | return isCanonicalUnqualified() ? nullptr : TTPDecl; |
4581 | } |
4582 | |
4583 | IdentifierInfo *getIdentifier() const; |
4584 | |
4585 | bool isSugared() const { return false; } |
4586 | QualType desugar() const { return QualType(this, 0); } |
4587 | |
4588 | void Profile(llvm::FoldingSetNodeID &ID) { |
4589 | Profile(ID, getDepth(), getIndex(), isParameterPack(), getDecl()); |
4590 | } |
4591 | |
4592 | static void Profile(llvm::FoldingSetNodeID &ID, unsigned Depth, |
4593 | unsigned Index, bool ParameterPack, |
4594 | TemplateTypeParmDecl *TTPDecl) { |
4595 | ID.AddInteger(Depth); |
4596 | ID.AddInteger(Index); |
4597 | ID.AddBoolean(ParameterPack); |
4598 | ID.AddPointer(TTPDecl); |
4599 | } |
4600 | |
4601 | static bool classof(const Type *T) { |
4602 | return T->getTypeClass() == TemplateTypeParm; |
4603 | } |
4604 | }; |
4605 | |
4606 | |
4607 | |
4608 | |
4609 | |
4610 | |
4611 | |
4612 | |
4613 | class SubstTemplateTypeParmType : public Type, public llvm::FoldingSetNode { |
4614 | friend class ASTContext; |
4615 | |
4616 | |
4617 | const TemplateTypeParmType *Replaced; |
4618 | |
4619 | SubstTemplateTypeParmType(const TemplateTypeParmType *Param, QualType Canon) |
4620 | : Type(SubstTemplateTypeParm, Canon, Canon->isDependentType(), |
4621 | Canon->isInstantiationDependentType(), |
4622 | Canon->isVariablyModifiedType(), |
4623 | Canon->containsUnexpandedParameterPack()), |
4624 | Replaced(Param) {} |
4625 | |
4626 | public: |
4627 | |
4628 | const TemplateTypeParmType *getReplacedParameter() const { |
4629 | return Replaced; |
4630 | } |
4631 | |
4632 | |
4633 | |
4634 | QualType getReplacementType() const { |
4635 | return getCanonicalTypeInternal(); |
4636 | } |
4637 | |
4638 | bool isSugared() const { return true; } |
4639 | QualType desugar() const { return getReplacementType(); } |
4640 | |
4641 | void Profile(llvm::FoldingSetNodeID &ID) { |
4642 | Profile(ID, getReplacedParameter(), getReplacementType()); |
4643 | } |
4644 | |
4645 | static void Profile(llvm::FoldingSetNodeID &ID, |
4646 | const TemplateTypeParmType *Replaced, |
4647 | QualType Replacement) { |
4648 | ID.AddPointer(Replaced); |
4649 | ID.AddPointer(Replacement.getAsOpaquePtr()); |
4650 | } |
4651 | |
4652 | static bool classof(const Type *T) { |
4653 | return T->getTypeClass() == SubstTemplateTypeParm; |
4654 | } |
4655 | }; |
4656 | |
4657 | |
4658 | |
4659 | |
4660 | |
4661 | |
4662 | |
4663 | |
4664 | |
4665 | |
4666 | |
4667 | |
4668 | |
4669 | class SubstTemplateTypeParmPackType : public Type, public llvm::FoldingSetNode { |
4670 | friend class ASTContext; |
4671 | |
4672 | |
4673 | const TemplateTypeParmType *Replaced; |
4674 | |
4675 | |
4676 | |
4677 | const TemplateArgument *Arguments; |
4678 | |
4679 | SubstTemplateTypeParmPackType(const TemplateTypeParmType *Param, |
4680 | QualType Canon, |
4681 | const TemplateArgument &ArgPack); |
4682 | |
4683 | public: |
4684 | IdentifierInfo *getIdentifier() const { return Replaced->getIdentifier(); } |
4685 | |
4686 | |
4687 | const TemplateTypeParmType *getReplacedParameter() const { |
4688 | return Replaced; |
4689 | } |
4690 | |
4691 | unsigned getNumArgs() const { |
4692 | return SubstTemplateTypeParmPackTypeBits.NumArgs; |
4693 | } |
4694 | |
4695 | bool isSugared() const { return false; } |
4696 | QualType desugar() const { return QualType(this, 0); } |
4697 | |
4698 | TemplateArgument getArgumentPack() const; |
4699 | |
4700 | void Profile(llvm::FoldingSetNodeID &ID); |
4701 | static void Profile(llvm::FoldingSetNodeID &ID, |
4702 | const TemplateTypeParmType *Replaced, |
4703 | const TemplateArgument &ArgPack); |
4704 | |
4705 | static bool classof(const Type *T) { |
4706 | return T->getTypeClass() == SubstTemplateTypeParmPack; |
4707 | } |
4708 | }; |
4709 | |
4710 | |
4711 | |
4712 | |
4713 | |
4714 | |
4715 | |
4716 | |
4717 | |
4718 | |
4719 | class DeducedType : public Type { |
4720 | protected: |
4721 | DeducedType(TypeClass TC, QualType DeducedAsType, bool IsDependent, |
4722 | bool IsInstantiationDependent, bool ContainsParameterPack) |
4723 | : Type(TC, |
4724 | |
4725 | DeducedAsType.isNull() ? QualType(this, 0) |
4726 | : DeducedAsType.getCanonicalType(), |
4727 | IsDependent, IsInstantiationDependent, |
4728 | , ContainsParameterPack) { |
4729 | if (!DeducedAsType.isNull()) { |
4730 | if (DeducedAsType->isDependentType()) |
4731 | setDependent(); |
4732 | if (DeducedAsType->isInstantiationDependentType()) |
4733 | setInstantiationDependent(); |
4734 | if (DeducedAsType->containsUnexpandedParameterPack()) |
4735 | setContainsUnexpandedParameterPack(); |
4736 | } |
4737 | } |
4738 | |
4739 | public: |
4740 | bool isSugared() const { return !isCanonicalUnqualified(); } |
4741 | QualType desugar() const { return getCanonicalTypeInternal(); } |
4742 | |
4743 | |
4744 | |
4745 | QualType getDeducedType() const { |
4746 | return !isCanonicalUnqualified() ? getCanonicalTypeInternal() : QualType(); |
4747 | } |
4748 | bool isDeduced() const { |
4749 | return !isCanonicalUnqualified() || isDependentType(); |
4750 | } |
4751 | |
4752 | static bool classof(const Type *T) { |
4753 | return T->getTypeClass() == Auto || |
4754 | T->getTypeClass() == DeducedTemplateSpecialization; |
4755 | } |
4756 | }; |
4757 | |
4758 | |
4759 | class AutoType : public DeducedType, public llvm::FoldingSetNode { |
4760 | friend class ASTContext; |
4761 | |
4762 | AutoType(QualType DeducedAsType, AutoTypeKeyword Keyword, |
4763 | bool IsDeducedAsDependent) |
4764 | : DeducedType(Auto, DeducedAsType, IsDeducedAsDependent, |
4765 | IsDeducedAsDependent, ) { |
4766 | AutoTypeBits.Keyword = (unsigned)Keyword; |
4767 | } |
4768 | |
4769 | public: |
4770 | bool isDecltypeAuto() const { |
4771 | return getKeyword() == AutoTypeKeyword::DecltypeAuto; |
4772 | } |
4773 | |
4774 | AutoTypeKeyword getKeyword() const { |
4775 | return (AutoTypeKeyword)AutoTypeBits.Keyword; |
4776 | } |
4777 | |
4778 | void Profile(llvm::FoldingSetNodeID &ID) { |
4779 | Profile(ID, getDeducedType(), getKeyword(), isDependentType()); |
4780 | } |
4781 | |
4782 | static void Profile(llvm::FoldingSetNodeID &ID, QualType Deduced, |
4783 | AutoTypeKeyword Keyword, bool IsDependent) { |
4784 | ID.AddPointer(Deduced.getAsOpaquePtr()); |
4785 | ID.AddInteger((unsigned)Keyword); |
4786 | ID.AddBoolean(IsDependent); |
4787 | } |
4788 | |
4789 | static bool classof(const Type *T) { |
4790 | return T->getTypeClass() == Auto; |
4791 | } |
4792 | }; |
4793 | |
4794 | |
4795 | class DeducedTemplateSpecializationType : public DeducedType, |
4796 | public llvm::FoldingSetNode { |
4797 | friend class ASTContext; |
4798 | |
4799 | |
4800 | TemplateName Template; |
4801 | |
4802 | DeducedTemplateSpecializationType(TemplateName Template, |
4803 | QualType DeducedAsType, |
4804 | bool IsDeducedAsDependent) |
4805 | : DeducedType(DeducedTemplateSpecialization, DeducedAsType, |
4806 | IsDeducedAsDependent || Template.isDependent(), |
4807 | IsDeducedAsDependent || Template.isInstantiationDependent(), |
4808 | Template.containsUnexpandedParameterPack()), |
4809 | Template(Template) {} |
4810 | |
4811 | public: |
4812 | |
4813 | TemplateName getTemplateName() const { return Template;} |
4814 | |
4815 | void Profile(llvm::FoldingSetNodeID &ID) { |
4816 | Profile(ID, getTemplateName(), getDeducedType(), isDependentType()); |
4817 | } |
4818 | |
4819 | static void Profile(llvm::FoldingSetNodeID &ID, TemplateName Template, |
4820 | QualType Deduced, bool IsDependent) { |
4821 | Template.Profile(ID); |
4822 | ID.AddPointer(Deduced.getAsOpaquePtr()); |
4823 | ID.AddBoolean(IsDependent); |
4824 | } |
4825 | |
4826 | static bool classof(const Type *T) { |
4827 | return T->getTypeClass() == DeducedTemplateSpecialization; |
4828 | } |
4829 | }; |
4830 | |
4831 | |
4832 | |
4833 | |
4834 | |
4835 | |
4836 | |
4837 | |
4838 | |
4839 | |
4840 | |
4841 | |
4842 | |
4843 | |
4844 | |
4845 | |
4846 | |
4847 | |
4848 | |
4849 | |
4850 | |
4851 | class alignas(8) TemplateSpecializationType |
4852 | : public Type, |
4853 | public llvm::FoldingSetNode { |
4854 | friend class ASTContext; |
4855 | |
4856 | |
4857 | |
4858 | |
4859 | |
4860 | |
4861 | |
4862 | |
4863 | TemplateName Template; |
4864 | |
4865 | TemplateSpecializationType(TemplateName T, |
4866 | ArrayRef<TemplateArgument> Args, |
4867 | QualType Canon, |
4868 | QualType Aliased); |
4869 | |
4870 | public: |
4871 | |
4872 | static bool anyDependentTemplateArguments(ArrayRef<TemplateArgumentLoc> Args, |
4873 | bool &InstantiationDependent); |
4874 | |
4875 | static bool anyDependentTemplateArguments(const TemplateArgumentListInfo &, |
4876 | bool &InstantiationDependent); |
4877 | |
4878 | |
4879 | |
4880 | bool isCurrentInstantiation() const { |
4881 | return isa<InjectedClassNameType>(getCanonicalTypeInternal()); |
4882 | } |
4883 | |
4884 | |
4885 | |
4886 | |
4887 | |
4888 | |
4889 | |
4890 | |
4891 | |
4892 | |
4893 | |
4894 | |
4895 | |
4896 | |
4897 | |
4898 | |
4899 | bool isTypeAlias() const { return TemplateSpecializationTypeBits.TypeAlias; } |
4900 | |
4901 | |
4902 | |
4903 | QualType getAliasedType() const { |
4904 | (0) . __assert_fail ("isTypeAlias() && \"not a type alias template specialization\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 4904, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isTypeAlias() && "not a type alias template specialization"); |
4905 | return *reinterpret_cast<const QualType*>(end()); |
4906 | } |
4907 | |
4908 | using iterator = const TemplateArgument *; |
4909 | |
4910 | iterator begin() const { return getArgs(); } |
4911 | iterator end() const; |
4912 | |
4913 | |
4914 | TemplateName getTemplateName() const { return Template; } |
4915 | |
4916 | |
4917 | const TemplateArgument *getArgs() const { |
4918 | return reinterpret_cast<const TemplateArgument *>(this + 1); |
4919 | } |
4920 | |
4921 | |
4922 | unsigned getNumArgs() const { |
4923 | return TemplateSpecializationTypeBits.NumArgs; |
4924 | } |
4925 | |
4926 | |
4927 | |
4928 | const TemplateArgument &getArg(unsigned Idx) const; |
4929 | |
4930 | ArrayRef<TemplateArgument> template_arguments() const { |
4931 | return {getArgs(), getNumArgs()}; |
4932 | } |
4933 | |
4934 | bool isSugared() const { |
4935 | return !isDependentType() || isCurrentInstantiation() || isTypeAlias(); |
4936 | } |
4937 | |
4938 | QualType desugar() const { |
4939 | return isTypeAlias() ? getAliasedType() : getCanonicalTypeInternal(); |
4940 | } |
4941 | |
4942 | void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx) { |
4943 | Profile(ID, Template, template_arguments(), Ctx); |
4944 | if (isTypeAlias()) |
4945 | getAliasedType().Profile(ID); |
4946 | } |
4947 | |
4948 | static void Profile(llvm::FoldingSetNodeID &ID, TemplateName T, |
4949 | ArrayRef<TemplateArgument> Args, |
4950 | const ASTContext &Context); |
4951 | |
4952 | static bool classof(const Type *T) { |
4953 | return T->getTypeClass() == TemplateSpecialization; |
4954 | } |
4955 | }; |
4956 | |
4957 | |
4958 | |
4959 | void printTemplateArgumentList(raw_ostream &OS, |
4960 | ArrayRef<TemplateArgument> Args, |
4961 | const PrintingPolicy &Policy); |
4962 | |
4963 | void printTemplateArgumentList(raw_ostream &OS, |
4964 | ArrayRef<TemplateArgumentLoc> Args, |
4965 | const PrintingPolicy &Policy); |
4966 | |
4967 | void printTemplateArgumentList(raw_ostream &OS, |
4968 | const TemplateArgumentListInfo &Args, |
4969 | const PrintingPolicy &Policy); |
4970 | |
4971 | |
4972 | |
4973 | |
4974 | |
4975 | |
4976 | |
4977 | |
4978 | |
4979 | |
4980 | |
4981 | |
4982 | |
4983 | |
4984 | |
4985 | |
4986 | |
4987 | |
4988 | class InjectedClassNameType : public Type { |
4989 | friend class ASTContext; |
4990 | friend class ASTNodeImporter; |
4991 | friend class ASTReader; |
4992 | |
4993 | |
4994 | |
4995 | CXXRecordDecl *Decl; |
4996 | |
4997 | |
4998 | |
4999 | |
5000 | |
5001 | |
5002 | |
5003 | |
5004 | |
5005 | |
5006 | QualType InjectedType; |
5007 | |
5008 | InjectedClassNameType(CXXRecordDecl *D, QualType TST) |
5009 | : Type(InjectedClassName, QualType(), , |
5010 | , |
5011 | , |
5012 | ), |
5013 | Decl(D), InjectedType(TST) { |
5014 | (TST)", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 5014, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isa<TemplateSpecializationType>(TST)); |
5015 | assert(!TST.hasQualifiers()); |
5016 | isDependentType()", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 5016, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(TST->isDependentType()); |
5017 | } |
5018 | |
5019 | public: |
5020 | QualType getInjectedSpecializationType() const { return InjectedType; } |
5021 | |
5022 | const TemplateSpecializationType *getInjectedTST() const { |
5023 | return cast<TemplateSpecializationType>(InjectedType.getTypePtr()); |
5024 | } |
5025 | |
5026 | TemplateName getTemplateName() const { |
5027 | return getInjectedTST()->getTemplateName(); |
5028 | } |
5029 | |
5030 | CXXRecordDecl *getDecl() const; |
5031 | |
5032 | bool isSugared() const { return false; } |
5033 | QualType desugar() const { return QualType(this, 0); } |
5034 | |
5035 | static bool classof(const Type *T) { |
5036 | return T->getTypeClass() == InjectedClassName; |
5037 | } |
5038 | }; |
5039 | |
5040 | |
5041 | enum TagTypeKind { |
5042 | |
5043 | TTK_Struct, |
5044 | |
5045 | |
5046 | TTK_Interface, |
5047 | |
5048 | |
5049 | TTK_Union, |
5050 | |
5051 | |
5052 | TTK_Class, |
5053 | |
5054 | |
5055 | TTK_Enum |
5056 | }; |
5057 | |
5058 | |
5059 | |
5060 | enum ElaboratedTypeKeyword { |
5061 | |
5062 | ETK_Struct, |
5063 | |
5064 | |
5065 | ETK_Interface, |
5066 | |
5067 | |
5068 | ETK_Union, |
5069 | |
5070 | |
5071 | ETK_Class, |
5072 | |
5073 | |
5074 | ETK_Enum, |
5075 | |
5076 | |
5077 | |
5078 | ETK_Typename, |
5079 | |
5080 | |
5081 | ETK_None |
5082 | }; |
5083 | |
5084 | |
5085 | |
5086 | |
5087 | |
5088 | class TypeWithKeyword : public Type { |
5089 | protected: |
5090 | TypeWithKeyword(ElaboratedTypeKeyword Keyword, TypeClass tc, |
5091 | QualType Canonical, bool Dependent, |
5092 | bool InstantiationDependent, bool VariablyModified, |
5093 | bool ContainsUnexpandedParameterPack) |
5094 | : Type(tc, Canonical, Dependent, InstantiationDependent, VariablyModified, |
5095 | ContainsUnexpandedParameterPack) { |
5096 | TypeWithKeywordBits.Keyword = Keyword; |
5097 | } |
5098 | |
5099 | public: |
5100 | ElaboratedTypeKeyword getKeyword() const { |
5101 | return static_cast<ElaboratedTypeKeyword>(TypeWithKeywordBits.Keyword); |
5102 | } |
5103 | |
5104 | |
5105 | static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec); |
5106 | |
5107 | |
5108 | |
5109 | static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec); |
5110 | |
5111 | |
5112 | static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag); |
5113 | |
5114 | |
5115 | |
5116 | |
5117 | static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword); |
5118 | |
5119 | static bool KeywordIsTagTypeKind(ElaboratedTypeKeyword Keyword); |
5120 | |
5121 | static StringRef getKeywordName(ElaboratedTypeKeyword Keyword); |
5122 | |
5123 | static StringRef getTagTypeKindName(TagTypeKind Kind) { |
5124 | return getKeywordName(getKeywordForTagTypeKind(Kind)); |
5125 | } |
5126 | |
5127 | class CannotCastToThisType {}; |
5128 | static CannotCastToThisType classof(const Type *); |
5129 | }; |
5130 | |
5131 | |
5132 | |
5133 | |
5134 | |
5135 | |
5136 | |
5137 | |
5138 | |
5139 | class ElaboratedType final |
5140 | : public TypeWithKeyword, |
5141 | public llvm::FoldingSetNode, |
5142 | private llvm::TrailingObjects<ElaboratedType, TagDecl *> { |
5143 | friend class ASTContext; |
5144 | friend TrailingObjects; |
5145 | |
5146 | |
5147 | NestedNameSpecifier *NNS; |
5148 | |
5149 | |
5150 | QualType NamedType; |
5151 | |
5152 | |
5153 | |
5154 | |
5155 | |
5156 | ElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, |
5157 | QualType NamedType, QualType CanonType, TagDecl *OwnedTagDecl) |
5158 | : TypeWithKeyword(Keyword, Elaborated, CanonType, |
5159 | NamedType->isDependentType(), |
5160 | NamedType->isInstantiationDependentType(), |
5161 | NamedType->isVariablyModifiedType(), |
5162 | NamedType->containsUnexpandedParameterPack()), |
5163 | NNS(NNS), NamedType(NamedType) { |
5164 | ElaboratedTypeBits.HasOwnedTagDecl = false; |
5165 | if (OwnedTagDecl) { |
5166 | ElaboratedTypeBits.HasOwnedTagDecl = true; |
5167 | *getTrailingObjects<TagDecl *>() = OwnedTagDecl; |
5168 | } |
5169 | (0) . __assert_fail ("!(Keyword == ETK_None && NNS == nullptr) && \"ElaboratedType cannot have elaborated type keyword \" \"and name qualifier both null.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 5171, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!(Keyword == ETK_None && NNS == nullptr) && |
5170 | (0) . __assert_fail ("!(Keyword == ETK_None && NNS == nullptr) && \"ElaboratedType cannot have elaborated type keyword \" \"and name qualifier both null.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 5171, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "ElaboratedType cannot have elaborated type keyword " |
5171 | (0) . __assert_fail ("!(Keyword == ETK_None && NNS == nullptr) && \"ElaboratedType cannot have elaborated type keyword \" \"and name qualifier both null.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 5171, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "and name qualifier both null."); |
5172 | } |
5173 | |
5174 | public: |
5175 | |
5176 | NestedNameSpecifier *getQualifier() const { return NNS; } |
5177 | |
5178 | |
5179 | QualType getNamedType() const { return NamedType; } |
5180 | |
5181 | |
5182 | QualType desugar() const { return getNamedType(); } |
5183 | |
5184 | |
5185 | bool isSugared() const { return true; } |
5186 | |
5187 | |
5188 | |
5189 | TagDecl *getOwnedTagDecl() const { |
5190 | return ElaboratedTypeBits.HasOwnedTagDecl ? *getTrailingObjects<TagDecl *>() |
5191 | : nullptr; |
5192 | } |
5193 | |
5194 | void Profile(llvm::FoldingSetNodeID &ID) { |
5195 | Profile(ID, getKeyword(), NNS, NamedType, getOwnedTagDecl()); |
5196 | } |
5197 | |
5198 | static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword, |
5199 | NestedNameSpecifier *NNS, QualType NamedType, |
5200 | TagDecl *OwnedTagDecl) { |
5201 | ID.AddInteger(Keyword); |
5202 | ID.AddPointer(NNS); |
5203 | NamedType.Profile(ID); |
5204 | ID.AddPointer(OwnedTagDecl); |
5205 | } |
5206 | |
5207 | static bool classof(const Type *T) { return T->getTypeClass() == Elaborated; } |
5208 | }; |
5209 | |
5210 | |
5211 | |
5212 | |
5213 | |
5214 | |
5215 | |
5216 | |
5217 | |
5218 | |
5219 | |
5220 | |
5221 | |
5222 | class DependentNameType : public TypeWithKeyword, public llvm::FoldingSetNode { |
5223 | friend class ASTContext; |
5224 | |
5225 | |
5226 | NestedNameSpecifier *NNS; |
5227 | |
5228 | |
5229 | const IdentifierInfo *Name; |
5230 | |
5231 | DependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, |
5232 | const IdentifierInfo *Name, QualType CanonType) |
5233 | : TypeWithKeyword(Keyword, DependentName, CanonType, , |
5234 | , |
5235 | , |
5236 | NNS->containsUnexpandedParameterPack()), |
5237 | NNS(NNS), Name(Name) {} |
5238 | |
5239 | public: |
5240 | |
5241 | NestedNameSpecifier *getQualifier() const { return NNS; } |
5242 | |
5243 | |
5244 | |
5245 | |
5246 | |
5247 | |
5248 | const IdentifierInfo *getIdentifier() const { |
5249 | return Name; |
5250 | } |
5251 | |
5252 | bool isSugared() const { return false; } |
5253 | QualType desugar() const { return QualType(this, 0); } |
5254 | |
5255 | void Profile(llvm::FoldingSetNodeID &ID) { |
5256 | Profile(ID, getKeyword(), NNS, Name); |
5257 | } |
5258 | |
5259 | static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword, |
5260 | NestedNameSpecifier *NNS, const IdentifierInfo *Name) { |
5261 | ID.AddInteger(Keyword); |
5262 | ID.AddPointer(NNS); |
5263 | ID.AddPointer(Name); |
5264 | } |
5265 | |
5266 | static bool classof(const Type *T) { |
5267 | return T->getTypeClass() == DependentName; |
5268 | } |
5269 | }; |
5270 | |
5271 | |
5272 | |
5273 | |
5274 | class alignas(8) DependentTemplateSpecializationType |
5275 | : public TypeWithKeyword, |
5276 | public llvm::FoldingSetNode { |
5277 | friend class ASTContext; |
5278 | |
5279 | |
5280 | NestedNameSpecifier *NNS; |
5281 | |
5282 | |
5283 | const IdentifierInfo *Name; |
5284 | |
5285 | DependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, |
5286 | NestedNameSpecifier *NNS, |
5287 | const IdentifierInfo *Name, |
5288 | ArrayRef<TemplateArgument> Args, |
5289 | QualType Canon); |
5290 | |
5291 | const TemplateArgument *getArgBuffer() const { |
5292 | return reinterpret_cast<const TemplateArgument*>(this+1); |
5293 | } |
5294 | |
5295 | TemplateArgument *getArgBuffer() { |
5296 | return reinterpret_cast<TemplateArgument*>(this+1); |
5297 | } |
5298 | |
5299 | public: |
5300 | NestedNameSpecifier *getQualifier() const { return NNS; } |
5301 | const IdentifierInfo *getIdentifier() const { return Name; } |
5302 | |
5303 | |
5304 | const TemplateArgument *getArgs() const { |
5305 | return getArgBuffer(); |
5306 | } |
5307 | |
5308 | |
5309 | unsigned getNumArgs() const { |
5310 | return DependentTemplateSpecializationTypeBits.NumArgs; |
5311 | } |
5312 | |
5313 | const TemplateArgument &getArg(unsigned Idx) const; |
5314 | |
5315 | ArrayRef<TemplateArgument> template_arguments() const { |
5316 | return {getArgs(), getNumArgs()}; |
5317 | } |
5318 | |
5319 | using iterator = const TemplateArgument *; |
5320 | |
5321 | iterator begin() const { return getArgs(); } |
5322 | iterator end() const; |
5323 | |
5324 | bool isSugared() const { return false; } |
5325 | QualType desugar() const { return QualType(this, 0); } |
5326 | |
5327 | void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) { |
5328 | Profile(ID, Context, getKeyword(), NNS, Name, {getArgs(), getNumArgs()}); |
5329 | } |
5330 | |
5331 | static void Profile(llvm::FoldingSetNodeID &ID, |
5332 | const ASTContext &Context, |
5333 | ElaboratedTypeKeyword Keyword, |
5334 | NestedNameSpecifier *Qualifier, |
5335 | const IdentifierInfo *Name, |
5336 | ArrayRef<TemplateArgument> Args); |
5337 | |
5338 | static bool classof(const Type *T) { |
5339 | return T->getTypeClass() == DependentTemplateSpecialization; |
5340 | } |
5341 | }; |
5342 | |
5343 | |
5344 | |
5345 | |
5346 | |
5347 | |
5348 | |
5349 | |
5350 | |
5351 | |
5352 | |
5353 | |
5354 | |
5355 | |
5356 | |
5357 | |
5358 | |
5359 | |
5360 | |
5361 | |
5362 | |
5363 | |
5364 | |
5365 | class PackExpansionType : public Type, public llvm::FoldingSetNode { |
5366 | friend class ASTContext; |
5367 | |
5368 | |
5369 | QualType Pattern; |
5370 | |
5371 | PackExpansionType(QualType Pattern, QualType Canon, |
5372 | Optional<unsigned> NumExpansions) |
5373 | : Type(PackExpansion, Canon, ->isDependentType(), |
5374 | , |
5375 | ->isVariablyModifiedType(), |
5376 | ), |
5377 | Pattern(Pattern) { |
5378 | PackExpansionTypeBits.NumExpansions = |
5379 | NumExpansions ? *NumExpansions + 1 : 0; |
5380 | } |
5381 | |
5382 | public: |
5383 | |
5384 | |
5385 | |
5386 | QualType getPattern() const { return Pattern; } |
5387 | |
5388 | |
5389 | |
5390 | Optional<unsigned> getNumExpansions() const { |
5391 | if (PackExpansionTypeBits.NumExpansions) |
5392 | return PackExpansionTypeBits.NumExpansions - 1; |
5393 | return None; |
5394 | } |
5395 | |
5396 | bool isSugared() const { return !Pattern->isDependentType(); } |
5397 | QualType desugar() const { return isSugared() ? Pattern : QualType(this, 0); } |
5398 | |
5399 | void Profile(llvm::FoldingSetNodeID &ID) { |
5400 | Profile(ID, getPattern(), getNumExpansions()); |
5401 | } |
5402 | |
5403 | static void Profile(llvm::FoldingSetNodeID &ID, QualType Pattern, |
5404 | Optional<unsigned> NumExpansions) { |
5405 | ID.AddPointer(Pattern.getAsOpaquePtr()); |
5406 | ID.AddBoolean(NumExpansions.hasValue()); |
5407 | if (NumExpansions) |
5408 | ID.AddInteger(*NumExpansions); |
5409 | } |
5410 | |
5411 | static bool classof(const Type *T) { |
5412 | return T->getTypeClass() == PackExpansion; |
5413 | } |
5414 | }; |
5415 | |
5416 | |
5417 | |
5418 | template <class T> |
5419 | class ObjCProtocolQualifiers { |
5420 | protected: |
5421 | ObjCProtocolQualifiers() = default; |
5422 | |
5423 | ObjCProtocolDecl * const *getProtocolStorage() const { |
5424 | return const_cast<ObjCProtocolQualifiers*>(this)->getProtocolStorage(); |
5425 | } |
5426 | |
5427 | ObjCProtocolDecl **getProtocolStorage() { |
5428 | return static_cast<T*>(this)->getProtocolStorageImpl(); |
5429 | } |
5430 | |
5431 | void setNumProtocols(unsigned N) { |
5432 | static_cast<T*>(this)->setNumProtocolsImpl(N); |
5433 | } |
5434 | |
5435 | void initialize(ArrayRef<ObjCProtocolDecl *> protocols) { |
5436 | setNumProtocols(protocols.size()); |
5437 | (0) . __assert_fail ("getNumProtocols() == protocols.size() && \"bitfield overflow in protocol count\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 5438, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getNumProtocols() == protocols.size() && |
5438 | (0) . __assert_fail ("getNumProtocols() == protocols.size() && \"bitfield overflow in protocol count\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 5438, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "bitfield overflow in protocol count"); |
5439 | if (!protocols.empty()) |
5440 | memcpy(getProtocolStorage(), protocols.data(), |
5441 | protocols.size() * sizeof(ObjCProtocolDecl*)); |
5442 | } |
5443 | |
5444 | public: |
5445 | using qual_iterator = ObjCProtocolDecl * const *; |
5446 | using qual_range = llvm::iterator_range<qual_iterator>; |
5447 | |
5448 | qual_range quals() const { return qual_range(qual_begin(), qual_end()); } |
5449 | qual_iterator qual_begin() const { return getProtocolStorage(); } |
5450 | qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); } |
5451 | |
5452 | bool qual_empty() const { return getNumProtocols() == 0; } |
5453 | |
5454 | |
5455 | |
5456 | unsigned getNumProtocols() const { |
5457 | return static_cast<const T*>(this)->getNumProtocolsImpl(); |
5458 | } |
5459 | |
5460 | |
5461 | ObjCProtocolDecl *getProtocol(unsigned I) const { |
5462 | (0) . __assert_fail ("I < getNumProtocols() && \"Out-of-range protocol access\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 5462, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(I < getNumProtocols() && "Out-of-range protocol access"); |
5463 | return qual_begin()[I]; |
5464 | } |
5465 | |
5466 | |
5467 | ArrayRef<ObjCProtocolDecl *> getProtocols() const { |
5468 | return ArrayRef<ObjCProtocolDecl *>(qual_begin(), getNumProtocols()); |
5469 | } |
5470 | }; |
5471 | |
5472 | |
5473 | |
5474 | class ObjCTypeParamType : public Type, |
5475 | public ObjCProtocolQualifiers<ObjCTypeParamType>, |
5476 | public llvm::FoldingSetNode { |
5477 | friend class ASTContext; |
5478 | friend class ObjCProtocolQualifiers<ObjCTypeParamType>; |
5479 | |
5480 | |
5481 | unsigned NumProtocols : 6; |
5482 | |
5483 | ObjCTypeParamDecl *OTPDecl; |
5484 | |
5485 | |
5486 | |
5487 | |
5488 | ObjCProtocolDecl **getProtocolStorageImpl(); |
5489 | |
5490 | |
5491 | |
5492 | unsigned getNumProtocolsImpl() const { |
5493 | return NumProtocols; |
5494 | } |
5495 | |
5496 | void setNumProtocolsImpl(unsigned N) { |
5497 | NumProtocols = N; |
5498 | } |
5499 | |
5500 | ObjCTypeParamType(const ObjCTypeParamDecl *D, |
5501 | QualType can, |
5502 | ArrayRef<ObjCProtocolDecl *> protocols); |
5503 | |
5504 | public: |
5505 | bool isSugared() const { return true; } |
5506 | QualType desugar() const { return getCanonicalTypeInternal(); } |
5507 | |
5508 | static bool classof(const Type *T) { |
5509 | return T->getTypeClass() == ObjCTypeParam; |
5510 | } |
5511 | |
5512 | void Profile(llvm::FoldingSetNodeID &ID); |
5513 | static void Profile(llvm::FoldingSetNodeID &ID, |
5514 | const ObjCTypeParamDecl *OTPDecl, |
5515 | ArrayRef<ObjCProtocolDecl *> protocols); |
5516 | |
5517 | ObjCTypeParamDecl *getDecl() const { return OTPDecl; } |
5518 | }; |
5519 | |
5520 | |
5521 | |
5522 | |
5523 | |
5524 | |
5525 | |
5526 | |
5527 | |
5528 | |
5529 | |
5530 | |
5531 | |
5532 | |
5533 | |
5534 | |
5535 | |
5536 | |
5537 | |
5538 | |
5539 | |
5540 | |
5541 | |
5542 | |
5543 | |
5544 | |
5545 | |
5546 | |
5547 | |
5548 | class ObjCObjectType : public Type, |
5549 | public ObjCProtocolQualifiers<ObjCObjectType> { |
5550 | friend class ObjCProtocolQualifiers<ObjCObjectType>; |
5551 | |
5552 | |
5553 | |
5554 | |
5555 | |
5556 | |
5557 | |
5558 | |
5559 | |
5560 | |
5561 | |
5562 | |
5563 | |
5564 | |
5565 | QualType BaseType; |
5566 | |
5567 | |
5568 | mutable llvm::PointerIntPair<const ObjCObjectType *, 1, bool> |
5569 | CachedSuperClassType; |
5570 | |
5571 | QualType *getTypeArgStorage(); |
5572 | const QualType *getTypeArgStorage() const { |
5573 | return const_cast<ObjCObjectType *>(this)->getTypeArgStorage(); |
5574 | } |
5575 | |
5576 | ObjCProtocolDecl **getProtocolStorageImpl(); |
5577 | |
5578 | |
5579 | unsigned getNumProtocolsImpl() const { |
5580 | return ObjCObjectTypeBits.NumProtocols; |
5581 | } |
5582 | void setNumProtocolsImpl(unsigned N) { |
5583 | ObjCObjectTypeBits.NumProtocols = N; |
5584 | } |
5585 | |
5586 | protected: |
5587 | enum Nonce_ObjCInterface { Nonce_ObjCInterface }; |
5588 | |
5589 | ObjCObjectType(QualType Canonical, QualType Base, |
5590 | ArrayRef<QualType> typeArgs, |
5591 | ArrayRef<ObjCProtocolDecl *> protocols, |
5592 | bool isKindOf); |
5593 | |
5594 | ObjCObjectType(enum Nonce_ObjCInterface) |
5595 | : Type(ObjCInterface, QualType(), false, false, false, false), |
5596 | BaseType(QualType(this_(), 0)) { |
5597 | ObjCObjectTypeBits.NumProtocols = 0; |
5598 | ObjCObjectTypeBits.NumTypeArgs = 0; |
5599 | ObjCObjectTypeBits.IsKindOf = 0; |
5600 | } |
5601 | |
5602 | void computeSuperClassTypeSlow() const; |
5603 | |
5604 | public: |
5605 | |
5606 | |
5607 | |
5608 | |
5609 | |
5610 | |
5611 | QualType getBaseType() const { return BaseType; } |
5612 | |
5613 | bool isObjCId() const { |
5614 | return getBaseType()->isSpecificBuiltinType(BuiltinType::ObjCId); |
5615 | } |
5616 | |
5617 | bool isObjCClass() const { |
5618 | return getBaseType()->isSpecificBuiltinType(BuiltinType::ObjCClass); |
5619 | } |
5620 | |
5621 | bool isObjCUnqualifiedId() const { return qual_empty() && isObjCId(); } |
5622 | bool isObjCUnqualifiedClass() const { return qual_empty() && isObjCClass(); } |
5623 | bool isObjCUnqualifiedIdOrClass() const { |
5624 | if (!qual_empty()) return false; |
5625 | if (const BuiltinType *T = getBaseType()->getAs<BuiltinType>()) |
5626 | return T->getKind() == BuiltinType::ObjCId || |
5627 | T->getKind() == BuiltinType::ObjCClass; |
5628 | return false; |
5629 | } |
5630 | bool isObjCQualifiedId() const { return !qual_empty() && isObjCId(); } |
5631 | bool isObjCQualifiedClass() const { return !qual_empty() && isObjCClass(); } |
5632 | |
5633 | |
5634 | |
5635 | ObjCInterfaceDecl *getInterface() const; |
5636 | |
5637 | |
5638 | |
5639 | bool isSpecialized() const; |
5640 | |
5641 | |
5642 | bool isSpecializedAsWritten() const { |
5643 | return ObjCObjectTypeBits.NumTypeArgs > 0; |
5644 | } |
5645 | |
5646 | |
5647 | |
5648 | bool isUnspecialized() const { return !isSpecialized(); } |
5649 | |
5650 | |
5651 | |
5652 | bool isUnspecializedAsWritten() const { return !isSpecializedAsWritten(); } |
5653 | |
5654 | |
5655 | ArrayRef<QualType> getTypeArgs() const; |
5656 | |
5657 | |
5658 | |
5659 | ArrayRef<QualType> getTypeArgsAsWritten() const { |
5660 | return llvm::makeArrayRef(getTypeArgStorage(), |
5661 | ObjCObjectTypeBits.NumTypeArgs); |
5662 | } |
5663 | |
5664 | |
5665 | bool isKindOfTypeAsWritten() const { return ObjCObjectTypeBits.IsKindOf; } |
5666 | |
5667 | |
5668 | bool isKindOfType() const; |
5669 | |
5670 | |
5671 | |
5672 | |
5673 | |
5674 | |
5675 | |
5676 | QualType getSuperClassType() const { |
5677 | if (!CachedSuperClassType.getInt()) |
5678 | computeSuperClassTypeSlow(); |
5679 | |
5680 | (0) . __assert_fail ("CachedSuperClassType.getInt() && \"Superclass not set?\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 5680, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(CachedSuperClassType.getInt() && "Superclass not set?"); |
5681 | return QualType(CachedSuperClassType.getPointer(), 0); |
5682 | } |
5683 | |
5684 | |
5685 | |
5686 | QualType stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const; |
5687 | |
5688 | bool isSugared() const { return false; } |
5689 | QualType desugar() const { return QualType(this, 0); } |
5690 | |
5691 | static bool classof(const Type *T) { |
5692 | return T->getTypeClass() == ObjCObject || |
5693 | T->getTypeClass() == ObjCInterface; |
5694 | } |
5695 | }; |
5696 | |
5697 | |
5698 | |
5699 | |
5700 | |
5701 | class ObjCObjectTypeImpl : public ObjCObjectType, public llvm::FoldingSetNode { |
5702 | friend class ASTContext; |
5703 | |
5704 | |
5705 | |
5706 | |
5707 | ObjCObjectTypeImpl(QualType Canonical, QualType Base, |
5708 | ArrayRef<QualType> typeArgs, |
5709 | ArrayRef<ObjCProtocolDecl *> protocols, |
5710 | bool isKindOf) |
5711 | : ObjCObjectType(Canonical, Base, typeArgs, protocols, isKindOf) {} |
5712 | |
5713 | public: |
5714 | void Profile(llvm::FoldingSetNodeID &ID); |
5715 | static void Profile(llvm::FoldingSetNodeID &ID, |
5716 | QualType Base, |
5717 | ArrayRef<QualType> typeArgs, |
5718 | ArrayRef<ObjCProtocolDecl *> protocols, |
5719 | bool isKindOf); |
5720 | }; |
5721 | |
5722 | inline QualType *ObjCObjectType::getTypeArgStorage() { |
5723 | return reinterpret_cast<QualType *>(static_cast<ObjCObjectTypeImpl*>(this)+1); |
5724 | } |
5725 | |
5726 | inline ObjCProtocolDecl **ObjCObjectType::getProtocolStorageImpl() { |
5727 | return reinterpret_cast<ObjCProtocolDecl**>( |
5728 | getTypeArgStorage() + ObjCObjectTypeBits.NumTypeArgs); |
5729 | } |
5730 | |
5731 | inline ObjCProtocolDecl **ObjCTypeParamType::getProtocolStorageImpl() { |
5732 | return reinterpret_cast<ObjCProtocolDecl**>( |
5733 | static_cast<ObjCTypeParamType*>(this)+1); |
5734 | } |
5735 | |
5736 | |
5737 | |
5738 | |
5739 | |
5740 | |
5741 | |
5742 | |
5743 | |
5744 | |
5745 | |
5746 | |
5747 | |
5748 | class ObjCInterfaceType : public ObjCObjectType { |
5749 | friend class ASTContext; |
5750 | friend class ASTReader; |
5751 | friend class ObjCInterfaceDecl; |
5752 | |
5753 | mutable ObjCInterfaceDecl *Decl; |
5754 | |
5755 | ObjCInterfaceType(const ObjCInterfaceDecl *D) |
5756 | : ObjCObjectType(Nonce_ObjCInterface), |
5757 | Decl(const_cast<ObjCInterfaceDecl*>(D)) {} |
5758 | |
5759 | public: |
5760 | |
5761 | ObjCInterfaceDecl *getDecl() const { return Decl; } |
5762 | |
5763 | bool isSugared() const { return false; } |
5764 | QualType desugar() const { return QualType(this, 0); } |
5765 | |
5766 | static bool classof(const Type *T) { |
5767 | return T->getTypeClass() == ObjCInterface; |
5768 | } |
5769 | |
5770 | |
5771 | |
5772 | |
5773 | |
5774 | enum { |
5775 | qual_iterator, |
5776 | qual_begin, |
5777 | qual_end, |
5778 | getNumProtocols, |
5779 | getProtocol |
5780 | }; |
5781 | }; |
5782 | |
5783 | inline ObjCInterfaceDecl *ObjCObjectType::getInterface() const { |
5784 | QualType baseType = getBaseType(); |
5785 | while (const auto *ObjT = baseType->getAs<ObjCObjectType>()) { |
5786 | if (const auto *T = dyn_cast<ObjCInterfaceType>(ObjT)) |
5787 | return T->getDecl(); |
5788 | |
5789 | baseType = ObjT->getBaseType(); |
5790 | } |
5791 | |
5792 | return nullptr; |
5793 | } |
5794 | |
5795 | |
5796 | |
5797 | |
5798 | |
5799 | |
5800 | |
5801 | |
5802 | |
5803 | |
5804 | class ObjCObjectPointerType : public Type, public llvm::FoldingSetNode { |
5805 | friend class ASTContext; |
5806 | |
5807 | QualType PointeeType; |
5808 | |
5809 | ObjCObjectPointerType(QualType Canonical, QualType Pointee) |
5810 | : Type(ObjCObjectPointer, Canonical, |
5811 | Pointee->isDependentType(), |
5812 | Pointee->isInstantiationDependentType(), |
5813 | Pointee->isVariablyModifiedType(), |
5814 | Pointee->containsUnexpandedParameterPack()), |
5815 | PointeeType(Pointee) {} |
5816 | |
5817 | public: |
5818 | |
5819 | |
5820 | QualType getPointeeType() const { return PointeeType; } |
5821 | |
5822 | |
5823 | |
5824 | |
5825 | |
5826 | |
5827 | |
5828 | |
5829 | |
5830 | |
5831 | |
5832 | |
5833 | |
5834 | |
5835 | |
5836 | |
5837 | |
5838 | |
5839 | |
5840 | |
5841 | |
5842 | |
5843 | |
5844 | |
5845 | const ObjCObjectType *getObjectType() const { |
5846 | return PointeeType->castAs<ObjCObjectType>(); |
5847 | } |
5848 | |
5849 | |
5850 | |
5851 | |
5852 | |
5853 | |
5854 | const ObjCInterfaceType *getInterfaceType() const; |
5855 | |
5856 | |
5857 | |
5858 | |
5859 | |
5860 | ObjCInterfaceDecl *getInterfaceDecl() const { |
5861 | return getObjectType()->getInterface(); |
5862 | } |
5863 | |
5864 | |
5865 | |
5866 | bool isObjCIdType() const { |
5867 | return getObjectType()->isObjCUnqualifiedId(); |
5868 | } |
5869 | |
5870 | |
5871 | |
5872 | bool isObjCClassType() const { |
5873 | return getObjectType()->isObjCUnqualifiedClass(); |
5874 | } |
5875 | |
5876 | |
5877 | bool isObjCIdOrClassType() const { |
5878 | return getObjectType()->isObjCUnqualifiedIdOrClass(); |
5879 | } |
5880 | |
5881 | |
5882 | |
5883 | bool isObjCQualifiedIdType() const { |
5884 | return getObjectType()->isObjCQualifiedId(); |
5885 | } |
5886 | |
5887 | |
5888 | |
5889 | bool isObjCQualifiedClassType() const { |
5890 | return getObjectType()->isObjCQualifiedClass(); |
5891 | } |
5892 | |
5893 | |
5894 | bool isKindOfType() const { return getObjectType()->isKindOfType(); } |
5895 | |
5896 | |
5897 | bool isSpecialized() const { return getObjectType()->isSpecialized(); } |
5898 | |
5899 | |
5900 | bool isSpecializedAsWritten() const { |
5901 | return getObjectType()->isSpecializedAsWritten(); |
5902 | } |
5903 | |
5904 | |
5905 | bool isUnspecialized() const { return getObjectType()->isUnspecialized(); } |
5906 | |
5907 | |
5908 | |
5909 | bool isUnspecializedAsWritten() const { return !isSpecializedAsWritten(); } |
5910 | |
5911 | |
5912 | ArrayRef<QualType> getTypeArgs() const { |
5913 | return getObjectType()->getTypeArgs(); |
5914 | } |
5915 | |
5916 | |
5917 | ArrayRef<QualType> getTypeArgsAsWritten() const { |
5918 | return getObjectType()->getTypeArgsAsWritten(); |
5919 | } |
5920 | |
5921 | |
5922 | |
5923 | |
5924 | using qual_iterator = ObjCObjectType::qual_iterator; |
5925 | using qual_range = llvm::iterator_range<qual_iterator>; |
5926 | |
5927 | qual_range quals() const { return qual_range(qual_begin(), qual_end()); } |
5928 | |
5929 | qual_iterator qual_begin() const { |
5930 | return getObjectType()->qual_begin(); |
5931 | } |
5932 | |
5933 | qual_iterator qual_end() const { |
5934 | return getObjectType()->qual_end(); |
5935 | } |
5936 | |
5937 | bool qual_empty() const { return getObjectType()->qual_empty(); } |
5938 | |
5939 | |
5940 | unsigned getNumProtocols() const { |
5941 | return getObjectType()->getNumProtocols(); |
5942 | } |
5943 | |
5944 | |
5945 | ObjCProtocolDecl *getProtocol(unsigned I) const { |
5946 | return getObjectType()->getProtocol(I); |
5947 | } |
5948 | |
5949 | bool isSugared() const { return false; } |
5950 | QualType desugar() const { return QualType(this, 0); } |
5951 | |
5952 | |
5953 | |
5954 | |
5955 | |
5956 | |
5957 | |
5958 | QualType getSuperClassType() const; |
5959 | |
5960 | |
5961 | |
5962 | const ObjCObjectPointerType *stripObjCKindOfTypeAndQuals( |
5963 | const ASTContext &ctx) const; |
5964 | |
5965 | void Profile(llvm::FoldingSetNodeID &ID) { |
5966 | Profile(ID, getPointeeType()); |
5967 | } |
5968 | |
5969 | static void Profile(llvm::FoldingSetNodeID &ID, QualType T) { |
5970 | ID.AddPointer(T.getAsOpaquePtr()); |
5971 | } |
5972 | |
5973 | static bool classof(const Type *T) { |
5974 | return T->getTypeClass() == ObjCObjectPointer; |
5975 | } |
5976 | }; |
5977 | |
5978 | class AtomicType : public Type, public llvm::FoldingSetNode { |
5979 | friend class ASTContext; |
5980 | |
5981 | QualType ValueType; |
5982 | |
5983 | AtomicType(QualType ValTy, QualType Canonical) |
5984 | : Type(Atomic, Canonical, ValTy->isDependentType(), |
5985 | ValTy->isInstantiationDependentType(), |
5986 | ValTy->isVariablyModifiedType(), |
5987 | ValTy->containsUnexpandedParameterPack()), |
5988 | ValueType(ValTy) {} |
5989 | |
5990 | public: |
5991 | |
5992 | |
5993 | QualType getValueType() const { return ValueType; } |
5994 | |
5995 | bool isSugared() const { return false; } |
5996 | QualType desugar() const { return QualType(this, 0); } |
5997 | |
5998 | void Profile(llvm::FoldingSetNodeID &ID) { |
5999 | Profile(ID, getValueType()); |
6000 | } |
6001 | |
6002 | static void Profile(llvm::FoldingSetNodeID &ID, QualType T) { |
6003 | ID.AddPointer(T.getAsOpaquePtr()); |
6004 | } |
6005 | |
6006 | static bool classof(const Type *T) { |
6007 | return T->getTypeClass() == Atomic; |
6008 | } |
6009 | }; |
6010 | |
6011 | |
6012 | class PipeType : public Type, public llvm::FoldingSetNode { |
6013 | friend class ASTContext; |
6014 | |
6015 | QualType ElementType; |
6016 | bool isRead; |
6017 | |
6018 | PipeType(QualType elemType, QualType CanonicalPtr, bool isRead) |
6019 | : Type(Pipe, CanonicalPtr, elemType->isDependentType(), |
6020 | elemType->isInstantiationDependentType(), |
6021 | elemType->isVariablyModifiedType(), |
6022 | elemType->containsUnexpandedParameterPack()), |
6023 | ElementType(elemType), isRead(isRead) {} |
6024 | |
6025 | public: |
6026 | QualType getElementType() const { return ElementType; } |
6027 | |
6028 | bool isSugared() const { return false; } |
6029 | |
6030 | QualType desugar() const { return QualType(this, 0); } |
6031 | |
6032 | void Profile(llvm::FoldingSetNodeID &ID) { |
6033 | Profile(ID, getElementType(), isReadOnly()); |
6034 | } |
6035 | |
6036 | static void Profile(llvm::FoldingSetNodeID &ID, QualType T, bool isRead) { |
6037 | ID.AddPointer(T.getAsOpaquePtr()); |
6038 | ID.AddBoolean(isRead); |
6039 | } |
6040 | |
6041 | static bool classof(const Type *T) { |
6042 | return T->getTypeClass() == Pipe; |
6043 | } |
6044 | |
6045 | bool isReadOnly() const { return isRead; } |
6046 | }; |
6047 | |
6048 | |
6049 | class QualifierCollector : public Qualifiers { |
6050 | public: |
6051 | QualifierCollector(Qualifiers Qs = Qualifiers()) : Qualifiers(Qs) {} |
6052 | |
6053 | |
6054 | |
6055 | |
6056 | const Type *strip(QualType type) { |
6057 | addFastQualifiers(type.getLocalFastQualifiers()); |
6058 | if (!type.hasLocalNonFastQualifiers()) |
6059 | return type.getTypePtrUnsafe(); |
6060 | |
6061 | const ExtQuals *extQuals = type.getExtQualsUnsafe(); |
6062 | addConsistentQualifiers(extQuals->getQualifiers()); |
6063 | return extQuals->getBaseType(); |
6064 | } |
6065 | |
6066 | |
6067 | QualType apply(const ASTContext &Context, QualType QT) const; |
6068 | |
6069 | |
6070 | QualType apply(const ASTContext &Context, const Type* T) const; |
6071 | }; |
6072 | |
6073 | |
6074 | |
6075 | inline SplitQualType SplitQualType::getSingleStepDesugaredType() const { |
6076 | SplitQualType desugar = |
6077 | Ty->getLocallyUnqualifiedSingleStepDesugaredType().split(); |
6078 | desugar.Quals.addConsistentQualifiers(Quals); |
6079 | return desugar; |
6080 | } |
6081 | |
6082 | inline const Type *QualType::getTypePtr() const { |
6083 | return getCommonPtr()->BaseType; |
6084 | } |
6085 | |
6086 | inline const Type *QualType::getTypePtrOrNull() const { |
6087 | return (isNull() ? nullptr : getCommonPtr()->BaseType); |
6088 | } |
6089 | |
6090 | inline SplitQualType QualType::split() const { |
6091 | if (!hasLocalNonFastQualifiers()) |
6092 | return SplitQualType(getTypePtrUnsafe(), |
6093 | Qualifiers::fromFastMask(getLocalFastQualifiers())); |
6094 | |
6095 | const ExtQuals *eq = getExtQualsUnsafe(); |
6096 | Qualifiers qs = eq->getQualifiers(); |
6097 | qs.addFastQualifiers(getLocalFastQualifiers()); |
6098 | return SplitQualType(eq->getBaseType(), qs); |
6099 | } |
6100 | |
6101 | inline Qualifiers QualType::getLocalQualifiers() const { |
6102 | Qualifiers Quals; |
6103 | if (hasLocalNonFastQualifiers()) |
6104 | Quals = getExtQualsUnsafe()->getQualifiers(); |
6105 | Quals.addFastQualifiers(getLocalFastQualifiers()); |
6106 | return Quals; |
6107 | } |
6108 | |
6109 | inline Qualifiers QualType::getQualifiers() const { |
6110 | Qualifiers quals = getCommonPtr()->CanonicalType.getLocalQualifiers(); |
6111 | quals.addFastQualifiers(getLocalFastQualifiers()); |
6112 | return quals; |
6113 | } |
6114 | |
6115 | inline unsigned QualType::getCVRQualifiers() const { |
6116 | unsigned cvr = getCommonPtr()->CanonicalType.getLocalCVRQualifiers(); |
6117 | cvr |= getLocalCVRQualifiers(); |
6118 | return cvr; |
6119 | } |
6120 | |
6121 | inline QualType QualType::getCanonicalType() const { |
6122 | QualType canon = getCommonPtr()->CanonicalType; |
6123 | return canon.withFastQualifiers(getLocalFastQualifiers()); |
6124 | } |
6125 | |
6126 | inline bool QualType::isCanonical() const { |
6127 | return getTypePtr()->isCanonicalUnqualified(); |
6128 | } |
6129 | |
6130 | inline bool QualType::isCanonicalAsParam() const { |
6131 | if (!isCanonical()) return false; |
6132 | if (hasLocalQualifiers()) return false; |
6133 | |
6134 | const Type *T = getTypePtr(); |
6135 | if (T->isVariablyModifiedType() && T->hasSizedVLAType()) |
6136 | return false; |
6137 | |
6138 | return !isa<FunctionType>(T) && !isa<ArrayType>(T); |
6139 | } |
6140 | |
6141 | inline bool QualType::isConstQualified() const { |
6142 | return isLocalConstQualified() || |
6143 | getCommonPtr()->CanonicalType.isLocalConstQualified(); |
6144 | } |
6145 | |
6146 | inline bool QualType::isRestrictQualified() const { |
6147 | return isLocalRestrictQualified() || |
6148 | getCommonPtr()->CanonicalType.isLocalRestrictQualified(); |
6149 | } |
6150 | |
6151 | |
6152 | inline bool QualType::isVolatileQualified() const { |
6153 | return isLocalVolatileQualified() || |
6154 | getCommonPtr()->CanonicalType.isLocalVolatileQualified(); |
6155 | } |
6156 | |
6157 | inline bool QualType::hasQualifiers() const { |
6158 | return hasLocalQualifiers() || |
6159 | getCommonPtr()->CanonicalType.hasLocalQualifiers(); |
6160 | } |
6161 | |
6162 | inline QualType QualType::getUnqualifiedType() const { |
6163 | if (!getTypePtr()->getCanonicalTypeInternal().hasLocalQualifiers()) |
6164 | return QualType(getTypePtr(), 0); |
6165 | |
6166 | return QualType(getSplitUnqualifiedTypeImpl(*this).Ty, 0); |
6167 | } |
6168 | |
6169 | inline SplitQualType QualType::getSplitUnqualifiedType() const { |
6170 | if (!getTypePtr()->getCanonicalTypeInternal().hasLocalQualifiers()) |
6171 | return split(); |
6172 | |
6173 | return getSplitUnqualifiedTypeImpl(*this); |
6174 | } |
6175 | |
6176 | inline void QualType::removeLocalConst() { |
6177 | removeLocalFastQualifiers(Qualifiers::Const); |
6178 | } |
6179 | |
6180 | inline void QualType::removeLocalRestrict() { |
6181 | removeLocalFastQualifiers(Qualifiers::Restrict); |
6182 | } |
6183 | |
6184 | inline void QualType::removeLocalVolatile() { |
6185 | removeLocalFastQualifiers(Qualifiers::Volatile); |
6186 | } |
6187 | |
6188 | inline void QualType::removeLocalCVRQualifiers(unsigned Mask) { |
6189 | (0) . __assert_fail ("!(Mask & ~Qualifiers..CVRMask) && \"mask has non-CVR bits\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 6189, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!(Mask & ~Qualifiers::CVRMask) && "mask has non-CVR bits"); |
6190 | static_assert((int)Qualifiers::CVRMask == (int)Qualifiers::FastMask, |
6191 | "Fast bits differ from CVR bits!"); |
6192 | |
6193 | |
6194 | removeLocalFastQualifiers(Mask); |
6195 | } |
6196 | |
6197 | |
6198 | inline LangAS QualType::getAddressSpace() const { |
6199 | return getQualifiers().getAddressSpace(); |
6200 | } |
6201 | |
6202 | |
6203 | inline Qualifiers::GC QualType::getObjCGCAttr() const { |
6204 | return getQualifiers().getObjCGCAttr(); |
6205 | } |
6206 | |
6207 | inline FunctionType::ExtInfo getFunctionExtInfo(const Type &t) { |
6208 | if (const auto *PT = t.getAs<PointerType>()) { |
6209 | if (const auto *FT = PT->getPointeeType()->getAs<FunctionType>()) |
6210 | return FT->getExtInfo(); |
6211 | } else if (const auto *FT = t.getAs<FunctionType>()) |
6212 | return FT->getExtInfo(); |
6213 | |
6214 | return FunctionType::ExtInfo(); |
6215 | } |
6216 | |
6217 | inline FunctionType::ExtInfo getFunctionExtInfo(QualType t) { |
6218 | return getFunctionExtInfo(*t); |
6219 | } |
6220 | |
6221 | |
6222 | |
6223 | |
6224 | |
6225 | |
6226 | inline bool QualType::isMoreQualifiedThan(QualType other) const { |
6227 | Qualifiers MyQuals = getQualifiers(); |
6228 | Qualifiers OtherQuals = other.getQualifiers(); |
6229 | return (MyQuals != OtherQuals && MyQuals.compatiblyIncludes(OtherQuals)); |
6230 | } |
6231 | |
6232 | |
6233 | |
6234 | |
6235 | |
6236 | inline bool QualType::isAtLeastAsQualifiedAs(QualType other) const { |
6237 | Qualifiers OtherQuals = other.getQualifiers(); |
6238 | |
6239 | |
6240 | if (getUnqualifiedType()->isVoidType()) |
6241 | OtherQuals.removeUnaligned(); |
6242 | |
6243 | return getQualifiers().compatiblyIncludes(OtherQuals); |
6244 | } |
6245 | |
6246 | |
6247 | |
6248 | |
6249 | |
6250 | |
6251 | |
6252 | |
6253 | |
6254 | |
6255 | inline QualType QualType::getNonReferenceType() const { |
6256 | if (const auto *RefType = (*this)->getAs<ReferenceType>()) |
6257 | return RefType->getPointeeType(); |
6258 | else |
6259 | return *this; |
6260 | } |
6261 | |
6262 | inline bool QualType::isCForbiddenLValueType() const { |
6263 | return ((getTypePtr()->isVoidType() && !hasQualifiers()) || |
6264 | getTypePtr()->isFunctionType()); |
6265 | } |
6266 | |
6267 | |
6268 | |
6269 | |
6270 | inline bool Type::isFundamentalType() const { |
6271 | return isVoidType() || |
6272 | |
6273 | |
6274 | (isArithmeticType() && !isEnumeralType()); |
6275 | } |
6276 | |
6277 | |
6278 | |
6279 | |
6280 | inline bool Type::isCompoundType() const { |
6281 | |
6282 | |
6283 | |
6284 | return isArrayType() || |
6285 | |
6286 | isFunctionType() || |
6287 | |
6288 | isPointerType() || |
6289 | |
6290 | isReferenceType() || |
6291 | |
6292 | isRecordType() || |
6293 | |
6294 | |
6295 | isUnionType() || |
6296 | |
6297 | isEnumeralType() || |
6298 | |
6299 | isMemberPointerType(); |
6300 | } |
6301 | |
6302 | inline bool Type::isFunctionType() const { |
6303 | return isa<FunctionType>(CanonicalType); |
6304 | } |
6305 | |
6306 | inline bool Type::isPointerType() const { |
6307 | return isa<PointerType>(CanonicalType); |
6308 | } |
6309 | |
6310 | inline bool Type::isAnyPointerType() const { |
6311 | return isPointerType() || isObjCObjectPointerType(); |
6312 | } |
6313 | |
6314 | inline bool Type::isBlockPointerType() const { |
6315 | return isa<BlockPointerType>(CanonicalType); |
6316 | } |
6317 | |
6318 | inline bool Type::isReferenceType() const { |
6319 | return isa<ReferenceType>(CanonicalType); |
6320 | } |
6321 | |
6322 | inline bool Type::isLValueReferenceType() const { |
6323 | return isa<LValueReferenceType>(CanonicalType); |
6324 | } |
6325 | |
6326 | inline bool Type::isRValueReferenceType() const { |
6327 | return isa<RValueReferenceType>(CanonicalType); |
6328 | } |
6329 | |
6330 | inline bool Type::isFunctionPointerType() const { |
6331 | if (const auto *T = getAs<PointerType>()) |
6332 | return T->getPointeeType()->isFunctionType(); |
6333 | else |
6334 | return false; |
6335 | } |
6336 | |
6337 | inline bool Type::isMemberPointerType() const { |
6338 | return isa<MemberPointerType>(CanonicalType); |
6339 | } |
6340 | |
6341 | inline bool Type::isMemberFunctionPointerType() const { |
6342 | if (const auto *T = getAs<MemberPointerType>()) |
6343 | return T->isMemberFunctionPointer(); |
6344 | else |
6345 | return false; |
6346 | } |
6347 | |
6348 | inline bool Type::isMemberDataPointerType() const { |
6349 | if (const auto *T = getAs<MemberPointerType>()) |
6350 | return T->isMemberDataPointer(); |
6351 | else |
6352 | return false; |
6353 | } |
6354 | |
6355 | inline bool Type::isArrayType() const { |
6356 | return isa<ArrayType>(CanonicalType); |
6357 | } |
6358 | |
6359 | inline bool Type::isConstantArrayType() const { |
6360 | return isa<ConstantArrayType>(CanonicalType); |
6361 | } |
6362 | |
6363 | inline bool Type::isIncompleteArrayType() const { |
6364 | return isa<IncompleteArrayType>(CanonicalType); |
6365 | } |
6366 | |
6367 | inline bool Type::isVariableArrayType() const { |
6368 | return isa<VariableArrayType>(CanonicalType); |
6369 | } |
6370 | |
6371 | inline bool Type::isDependentSizedArrayType() const { |
6372 | return isa<DependentSizedArrayType>(CanonicalType); |
6373 | } |
6374 | |
6375 | inline bool Type::isBuiltinType() const { |
6376 | return isa<BuiltinType>(CanonicalType); |
6377 | } |
6378 | |
6379 | inline bool Type::isRecordType() const { |
6380 | return isa<RecordType>(CanonicalType); |
6381 | } |
6382 | |
6383 | inline bool Type::isEnumeralType() const { |
6384 | return isa<EnumType>(CanonicalType); |
6385 | } |
6386 | |
6387 | inline bool Type::isAnyComplexType() const { |
6388 | return isa<ComplexType>(CanonicalType); |
6389 | } |
6390 | |
6391 | inline bool Type::isVectorType() const { |
6392 | return isa<VectorType>(CanonicalType); |
6393 | } |
6394 | |
6395 | inline bool Type::isExtVectorType() const { |
6396 | return isa<ExtVectorType>(CanonicalType); |
6397 | } |
6398 | |
6399 | inline bool Type::isDependentAddressSpaceType() const { |
6400 | return isa<DependentAddressSpaceType>(CanonicalType); |
6401 | } |
6402 | |
6403 | inline bool Type::isObjCObjectPointerType() const { |
6404 | return isa<ObjCObjectPointerType>(CanonicalType); |
6405 | } |
6406 | |
6407 | inline bool Type::isObjCObjectType() const { |
6408 | return isa<ObjCObjectType>(CanonicalType); |
6409 | } |
6410 | |
6411 | inline bool Type::isObjCObjectOrInterfaceType() const { |
6412 | return isa<ObjCInterfaceType>(CanonicalType) || |
6413 | isa<ObjCObjectType>(CanonicalType); |
6414 | } |
6415 | |
6416 | inline bool Type::isAtomicType() const { |
6417 | return isa<AtomicType>(CanonicalType); |
6418 | } |
6419 | |
6420 | inline bool Type::isObjCQualifiedIdType() const { |
6421 | if (const auto *OPT = getAs<ObjCObjectPointerType>()) |
6422 | return OPT->isObjCQualifiedIdType(); |
6423 | return false; |
6424 | } |
6425 | |
6426 | inline bool Type::isObjCQualifiedClassType() const { |
6427 | if (const auto *OPT = getAs<ObjCObjectPointerType>()) |
6428 | return OPT->isObjCQualifiedClassType(); |
6429 | return false; |
6430 | } |
6431 | |
6432 | inline bool Type::isObjCIdType() const { |
6433 | if (const auto *OPT = getAs<ObjCObjectPointerType>()) |
6434 | return OPT->isObjCIdType(); |
6435 | return false; |
6436 | } |
6437 | |
6438 | inline bool Type::isObjCClassType() const { |
6439 | if (const auto *OPT = getAs<ObjCObjectPointerType>()) |
6440 | return OPT->isObjCClassType(); |
6441 | return false; |
6442 | } |
6443 | |
6444 | inline bool Type::isObjCSelType() const { |
6445 | if (const auto *OPT = getAs<PointerType>()) |
6446 | return OPT->getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCSel); |
6447 | return false; |
6448 | } |
6449 | |
6450 | inline bool Type::isObjCBuiltinType() const { |
6451 | return isObjCIdType() || isObjCClassType() || isObjCSelType(); |
6452 | } |
6453 | |
6454 | inline bool Type::isDecltypeType() const { |
6455 | return isa<DecltypeType>(this); |
6456 | } |
6457 | |
6458 | #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ |
6459 | inline bool Type::is##Id##Type() const { \ |
6460 | return isSpecificBuiltinType(BuiltinType::Id); \ |
6461 | } |
6462 | #include "clang/Basic/OpenCLImageTypes.def" |
6463 | |
6464 | inline bool Type::isSamplerT() const { |
6465 | return isSpecificBuiltinType(BuiltinType::OCLSampler); |
6466 | } |
6467 | |
6468 | inline bool Type::isEventT() const { |
6469 | return isSpecificBuiltinType(BuiltinType::OCLEvent); |
6470 | } |
6471 | |
6472 | inline bool Type::isClkEventT() const { |
6473 | return isSpecificBuiltinType(BuiltinType::OCLClkEvent); |
6474 | } |
6475 | |
6476 | inline bool Type::isQueueT() const { |
6477 | return isSpecificBuiltinType(BuiltinType::OCLQueue); |
6478 | } |
6479 | |
6480 | inline bool Type::isReserveIDT() const { |
6481 | return isSpecificBuiltinType(BuiltinType::OCLReserveID); |
6482 | } |
6483 | |
6484 | inline bool Type::isImageType() const { |
6485 | #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) is##Id##Type() || |
6486 | return |
6487 | #include "clang/Basic/OpenCLImageTypes.def" |
6488 | false; |
6489 | } |
6490 | |
6491 | inline bool Type::isPipeType() const { |
6492 | return isa<PipeType>(CanonicalType); |
6493 | } |
6494 | |
6495 | #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ |
6496 | inline bool Type::is##Id##Type() const { \ |
6497 | return isSpecificBuiltinType(BuiltinType::Id); \ |
6498 | } |
6499 | #include "clang/Basic/OpenCLExtensionTypes.def" |
6500 | |
6501 | inline bool Type::isOCLIntelSubgroupAVCType() const { |
6502 | #define INTEL_SUBGROUP_AVC_TYPE(ExtType, Id) \ |
6503 | isOCLIntelSubgroupAVC##Id##Type() || |
6504 | return |
6505 | #include "clang/Basic/OpenCLExtensionTypes.def" |
6506 | false; |
6507 | } |
6508 | |
6509 | inline bool Type::isOCLExtOpaqueType() const { |
6510 | #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) is##Id##Type() || |
6511 | return |
6512 | #include "clang/Basic/OpenCLExtensionTypes.def" |
6513 | false; |
6514 | } |
6515 | |
6516 | inline bool Type::isOpenCLSpecificType() const { |
6517 | return isSamplerT() || isEventT() || isImageType() || isClkEventT() || |
6518 | isQueueT() || isReserveIDT() || isPipeType() || isOCLExtOpaqueType(); |
6519 | } |
6520 | |
6521 | inline bool Type::isTemplateTypeParmType() const { |
6522 | return isa<TemplateTypeParmType>(CanonicalType); |
6523 | } |
6524 | |
6525 | inline bool Type::isSpecificBuiltinType(unsigned K) const { |
6526 | if (const BuiltinType *BT = getAs<BuiltinType>()) |
6527 | if (BT->getKind() == (BuiltinType::Kind) K) |
6528 | return true; |
6529 | return false; |
6530 | } |
6531 | |
6532 | inline bool Type::isPlaceholderType() const { |
6533 | if (const auto *BT = dyn_cast<BuiltinType>(this)) |
6534 | return BT->isPlaceholderType(); |
6535 | return false; |
6536 | } |
6537 | |
6538 | inline const BuiltinType *Type::getAsPlaceholderType() const { |
6539 | if (const auto *BT = dyn_cast<BuiltinType>(this)) |
6540 | if (BT->isPlaceholderType()) |
6541 | return BT; |
6542 | return nullptr; |
6543 | } |
6544 | |
6545 | inline bool Type::isSpecificPlaceholderType(unsigned K) const { |
6546 | assert(BuiltinType::isPlaceholderTypeKind((BuiltinType::Kind) K)); |
6547 | if (const auto *BT = dyn_cast<BuiltinType>(this)) |
6548 | return (BT->getKind() == (BuiltinType::Kind) K); |
6549 | return false; |
6550 | } |
6551 | |
6552 | inline bool Type::isNonOverloadPlaceholderType() const { |
6553 | if (const auto *BT = dyn_cast<BuiltinType>(this)) |
6554 | return BT->isNonOverloadPlaceholderType(); |
6555 | return false; |
6556 | } |
6557 | |
6558 | inline bool Type::isVoidType() const { |
6559 | if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) |
6560 | return BT->getKind() == BuiltinType::Void; |
6561 | return false; |
6562 | } |
6563 | |
6564 | inline bool Type::isHalfType() const { |
6565 | if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) |
6566 | return BT->getKind() == BuiltinType::Half; |
6567 | |
6568 | return false; |
6569 | } |
6570 | |
6571 | inline bool Type::isFloat16Type() const { |
6572 | if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) |
6573 | return BT->getKind() == BuiltinType::Float16; |
6574 | return false; |
6575 | } |
6576 | |
6577 | inline bool Type::isFloat128Type() const { |
6578 | if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) |
6579 | return BT->getKind() == BuiltinType::Float128; |
6580 | return false; |
6581 | } |
6582 | |
6583 | inline bool Type::isNullPtrType() const { |
6584 | if (const auto *BT = getAs<BuiltinType>()) |
6585 | return BT->getKind() == BuiltinType::NullPtr; |
6586 | return false; |
6587 | } |
6588 | |
6589 | bool IsEnumDeclComplete(EnumDecl *); |
6590 | bool IsEnumDeclScoped(EnumDecl *); |
6591 | |
6592 | inline bool Type::isIntegerType() const { |
6593 | if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) |
6594 | return BT->getKind() >= BuiltinType::Bool && |
6595 | BT->getKind() <= BuiltinType::Int128; |
6596 | if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) { |
6597 | |
6598 | |
6599 | return IsEnumDeclComplete(ET->getDecl()) && |
6600 | !IsEnumDeclScoped(ET->getDecl()); |
6601 | } |
6602 | return false; |
6603 | } |
6604 | |
6605 | inline bool Type::isFixedPointType() const { |
6606 | if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) { |
6607 | return BT->getKind() >= BuiltinType::ShortAccum && |
6608 | BT->getKind() <= BuiltinType::SatULongFract; |
6609 | } |
6610 | return false; |
6611 | } |
6612 | |
6613 | inline bool Type::isFixedPointOrIntegerType() const { |
6614 | return isFixedPointType() || isIntegerType(); |
6615 | } |
6616 | |
6617 | inline bool Type::isSaturatedFixedPointType() const { |
6618 | if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) { |
6619 | return BT->getKind() >= BuiltinType::SatShortAccum && |
6620 | BT->getKind() <= BuiltinType::SatULongFract; |
6621 | } |
6622 | return false; |
6623 | } |
6624 | |
6625 | inline bool Type::isUnsaturatedFixedPointType() const { |
6626 | return isFixedPointType() && !isSaturatedFixedPointType(); |
6627 | } |
6628 | |
6629 | inline bool Type::isSignedFixedPointType() const { |
6630 | if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) { |
6631 | return ((BT->getKind() >= BuiltinType::ShortAccum && |
6632 | BT->getKind() <= BuiltinType::LongAccum) || |
6633 | (BT->getKind() >= BuiltinType::ShortFract && |
6634 | BT->getKind() <= BuiltinType::LongFract) || |
6635 | (BT->getKind() >= BuiltinType::SatShortAccum && |
6636 | BT->getKind() <= BuiltinType::SatLongAccum) || |
6637 | (BT->getKind() >= BuiltinType::SatShortFract && |
6638 | BT->getKind() <= BuiltinType::SatLongFract)); |
6639 | } |
6640 | return false; |
6641 | } |
6642 | |
6643 | inline bool Type::isUnsignedFixedPointType() const { |
6644 | return isFixedPointType() && !isSignedFixedPointType(); |
6645 | } |
6646 | |
6647 | inline bool Type::isScalarType() const { |
6648 | if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) |
6649 | return BT->getKind() > BuiltinType::Void && |
6650 | BT->getKind() <= BuiltinType::NullPtr; |
6651 | if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) |
6652 | |
6653 | |
6654 | return IsEnumDeclComplete(ET->getDecl()); |
6655 | return isa<PointerType>(CanonicalType) || |
6656 | isa<BlockPointerType>(CanonicalType) || |
6657 | isa<MemberPointerType>(CanonicalType) || |
6658 | isa<ComplexType>(CanonicalType) || |
6659 | isa<ObjCObjectPointerType>(CanonicalType); |
6660 | } |
6661 | |
6662 | inline bool Type::isIntegralOrEnumerationType() const { |
6663 | if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) |
6664 | return BT->getKind() >= BuiltinType::Bool && |
6665 | BT->getKind() <= BuiltinType::Int128; |
6666 | |
6667 | |
6668 | |
6669 | if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) |
6670 | return IsEnumDeclComplete(ET->getDecl()); |
6671 | |
6672 | return false; |
6673 | } |
6674 | |
6675 | inline bool Type::isBooleanType() const { |
6676 | if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) |
6677 | return BT->getKind() == BuiltinType::Bool; |
6678 | return false; |
6679 | } |
6680 | |
6681 | inline bool Type::isUndeducedType() const { |
6682 | auto *DT = getContainedDeducedType(); |
6683 | return DT && !DT->isDeduced(); |
6684 | } |
6685 | |
6686 | |
6687 | |
6688 | inline bool Type::isOverloadableType() const { |
6689 | return isDependentType() || isRecordType() || isEnumeralType(); |
6690 | } |
6691 | |
6692 | |
6693 | inline bool Type::canDecayToPointerType() const { |
6694 | return isFunctionType() || isArrayType(); |
6695 | } |
6696 | |
6697 | inline bool Type::hasPointerRepresentation() const { |
6698 | return (isPointerType() || isReferenceType() || isBlockPointerType() || |
6699 | isObjCObjectPointerType() || isNullPtrType()); |
6700 | } |
6701 | |
6702 | inline bool Type::hasObjCPointerRepresentation() const { |
6703 | return isObjCObjectPointerType(); |
6704 | } |
6705 | |
6706 | inline const Type *Type::getBaseElementTypeUnsafe() const { |
6707 | const Type *type = this; |
6708 | while (const ArrayType *arrayType = type->getAsArrayTypeUnsafe()) |
6709 | type = arrayType->getElementType().getTypePtr(); |
6710 | return type; |
6711 | } |
6712 | |
6713 | inline const Type *Type::getPointeeOrArrayElementType() const { |
6714 | const Type *type = this; |
6715 | if (type->isAnyPointerType()) |
6716 | return type->getPointeeType().getTypePtr(); |
6717 | else if (type->isArrayType()) |
6718 | return type->getBaseElementTypeUnsafe(); |
6719 | return type; |
6720 | } |
6721 | |
6722 | |
6723 | |
6724 | inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, |
6725 | Qualifiers Q) { |
6726 | DB.AddTaggedVal(Q.getAsOpaqueValue(), |
6727 | DiagnosticsEngine::ArgumentKind::ak_qual); |
6728 | return DB; |
6729 | } |
6730 | |
6731 | |
6732 | |
6733 | inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, |
6734 | Qualifiers Q) { |
6735 | PD.AddTaggedVal(Q.getAsOpaqueValue(), |
6736 | DiagnosticsEngine::ArgumentKind::ak_qual); |
6737 | return PD; |
6738 | } |
6739 | |
6740 | |
6741 | |
6742 | inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, |
6743 | QualType T) { |
6744 | DB.AddTaggedVal(reinterpret_cast<intptr_t>(T.getAsOpaquePtr()), |
6745 | DiagnosticsEngine::ak_qualtype); |
6746 | return DB; |
6747 | } |
6748 | |
6749 | |
6750 | |
6751 | inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, |
6752 | QualType T) { |
6753 | PD.AddTaggedVal(reinterpret_cast<intptr_t>(T.getAsOpaquePtr()), |
6754 | DiagnosticsEngine::ak_qualtype); |
6755 | return PD; |
6756 | } |
6757 | |
6758 | |
6759 | |
6760 | template <typename T> |
6761 | using TypeIsArrayType = |
6762 | std::integral_constant<bool, std::is_same<T, ArrayType>::value || |
6763 | std::is_base_of<ArrayType, T>::value>; |
6764 | |
6765 | |
6766 | template <typename T> const T *Type::getAs() const { |
6767 | static_assert(!TypeIsArrayType<T>::value, |
6768 | "ArrayType cannot be used with getAs!"); |
6769 | |
6770 | |
6771 | if (const auto *Ty = dyn_cast<T>(this)) |
6772 | return Ty; |
6773 | |
6774 | |
6775 | if (!isa<T>(CanonicalType)) |
6776 | return nullptr; |
6777 | |
6778 | |
6779 | |
6780 | return cast<T>(getUnqualifiedDesugaredType()); |
6781 | } |
6782 | |
6783 | template <typename T> const T *Type::getAsAdjusted() const { |
6784 | static_assert(!TypeIsArrayType<T>::value, "ArrayType cannot be used with getAsAdjusted!"); |
6785 | |
6786 | |
6787 | if (const auto *Ty = dyn_cast<T>(this)) |
6788 | return Ty; |
6789 | |
6790 | |
6791 | if (!isa<T>(CanonicalType)) |
6792 | return nullptr; |
6793 | |
6794 | |
6795 | |
6796 | const Type *Ty = this; |
6797 | while (Ty) { |
6798 | if (const auto *A = dyn_cast<AttributedType>(Ty)) |
6799 | Ty = A->getModifiedType().getTypePtr(); |
6800 | else if (const auto *E = dyn_cast<ElaboratedType>(Ty)) |
6801 | Ty = E->desugar().getTypePtr(); |
6802 | else if (const auto *P = dyn_cast<ParenType>(Ty)) |
6803 | Ty = P->desugar().getTypePtr(); |
6804 | else if (const auto *A = dyn_cast<AdjustedType>(Ty)) |
6805 | Ty = A->desugar().getTypePtr(); |
6806 | else |
6807 | break; |
6808 | } |
6809 | |
6810 | |
6811 | |
6812 | return dyn_cast<T>(Ty); |
6813 | } |
6814 | |
6815 | inline const ArrayType *Type::getAsArrayTypeUnsafe() const { |
6816 | |
6817 | if (const auto *arr = dyn_cast<ArrayType>(this)) |
6818 | return arr; |
6819 | |
6820 | |
6821 | if (!isa<ArrayType>(CanonicalType)) |
6822 | return nullptr; |
6823 | |
6824 | |
6825 | |
6826 | return cast<ArrayType>(getUnqualifiedDesugaredType()); |
6827 | } |
6828 | |
6829 | template <typename T> const T *Type::castAs() const { |
6830 | static_assert(!TypeIsArrayType<T>::value, |
6831 | "ArrayType cannot be used with castAs!"); |
6832 | |
6833 | if (const auto *ty = dyn_cast<T>(this)) return ty; |
6834 | (CanonicalType)", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 6834, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isa<T>(CanonicalType)); |
6835 | return cast<T>(getUnqualifiedDesugaredType()); |
6836 | } |
6837 | |
6838 | inline const ArrayType *Type::castAsArrayTypeUnsafe() const { |
6839 | (CanonicalType)", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 6839, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isa<ArrayType>(CanonicalType)); |
6840 | if (const auto *arr = dyn_cast<ArrayType>(this)) return arr; |
6841 | return cast<ArrayType>(getUnqualifiedDesugaredType()); |
6842 | } |
6843 | |
6844 | DecayedType::DecayedType(QualType OriginalType, QualType DecayedPtr, |
6845 | QualType CanonicalPtr) |
6846 | : AdjustedType(Decayed, OriginalType, DecayedPtr, CanonicalPtr) { |
6847 | #ifndef NDEBUG |
6848 | QualType Adjusted = getAdjustedType(); |
6849 | (void)AttributedType::stripOuterNullability(Adjusted); |
6850 | (Adjusted)", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Type.h", 6850, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isa<PointerType>(Adjusted)); |
6851 | #endif |
6852 | } |
6853 | |
6854 | QualType DecayedType::getPointeeType() const { |
6855 | QualType Decayed = getDecayedType(); |
6856 | (void)AttributedType::stripOuterNullability(Decayed); |
6857 | return cast<PointerType>(Decayed)->getPointeeType(); |
6858 | } |
6859 | |
6860 | |
6861 | |
6862 | |
6863 | |
6864 | void FixedPointValueToString(SmallVectorImpl<char> &Str, llvm::APSInt Val, |
6865 | unsigned Scale); |
6866 | |
6867 | } |
6868 | |
6869 | #endif |
6870 | |