1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
|
//===--- Type.h - C Language Family Type Representation ---------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the Type interface and subclasses.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_AST_TYPE_H
#define LLVM_CLANG_AST_TYPE_H
#include "llvm/Support/Casting.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/Bitcode/SerializationFwd.h"
using llvm::isa;
using llvm::cast;
using llvm::cast_or_null;
using llvm::dyn_cast;
using llvm::dyn_cast_or_null;
namespace clang {
class ASTContext;
class Type;
class TypedefDecl;
class TagDecl;
class RecordDecl;
class EnumDecl;
class FieldDecl;
class ObjCInterfaceDecl;
class ObjCProtocolDecl;
class ObjCMethodDecl;
class Expr;
class SourceLocation;
class PointerLikeType;
class PointerType;
class ReferenceType;
class VectorType;
class ArrayType;
class ConstantArrayType;
class VariableArrayType;
class IncompleteArrayType;
class RecordType;
class ComplexType;
class TagType;
class TypedefType;
class FunctionType;
class ExtVectorType;
class BuiltinType;
class ObjCInterfaceType;
class ObjCQualifiedIdType;
class ObjCQualifiedInterfaceType;
class StmtIteratorBase;
/// QualType - For efficiency, we don't store CVR-qualified types as nodes on
/// their own: instead each reference to a type stores the qualifiers. This
/// greatly reduces the number of nodes we need to allocate for types (for
/// example we only need one for 'int', 'const int', 'volatile int',
/// 'const volatile int', etc).
///
/// As an added efficiency bonus, instead of making this a pair, we just store
/// the three bits we care about in the low bits of the pointer. To handle the
/// packing/unpacking, we make QualType be a simple wrapper class that acts like
/// a smart pointer.
class QualType {
uintptr_t ThePtr;
public:
enum TQ { // NOTE: These flags must be kept in sync with DeclSpec::TQ.
Const = 0x1,
Restrict = 0x2,
Volatile = 0x4,
CVRFlags = Const|Restrict|Volatile
};
QualType() : ThePtr(0) {}
QualType(Type *Ptr, unsigned Quals) {
assert((Quals & ~CVRFlags) == 0 && "Invalid type qualifiers!");
ThePtr = reinterpret_cast<uintptr_t>(Ptr);
assert((ThePtr & CVRFlags) == 0 && "Type pointer not 8-byte aligned?");
ThePtr |= Quals;
}
static QualType getFromOpaquePtr(void *Ptr) {
QualType T;
T.ThePtr = reinterpret_cast<uintptr_t>(Ptr);
return T;
}
unsigned getCVRQualifiers() const {
return ThePtr & CVRFlags;
}
Type *getTypePtr() const {
return reinterpret_cast<Type*>(ThePtr & ~CVRFlags);
}
void *getAsOpaquePtr() const {
return reinterpret_cast<void*>(ThePtr);
}
Type &operator*() const {
return *getTypePtr();
}
Type *operator->() const {
return getTypePtr();
}
/// isNull - Return true if this QualType doesn't point to a type yet.
bool isNull() const {
return ThePtr == 0;
}
bool isConstQualified() const {
return (ThePtr & Const) ? true : false;
}
bool isVolatileQualified() const {
return (ThePtr & Volatile) ? true : false;
}
bool isRestrictQualified() const {
return (ThePtr & Restrict) ? true : false;
}
/// addConst/addVolatile/addRestrict - add the specified type qual to this
/// QualType.
void addConst() { ThePtr |= Const; }
void addVolatile() { ThePtr |= Volatile; }
void addRestrict() { ThePtr |= Restrict; }
QualType getQualifiedType(unsigned TQs) const {
return QualType(getTypePtr(), TQs);
}
inline QualType getUnqualifiedType() const;
/// operator==/!= - Indicate whether the specified types and qualifiers are
/// identical.
bool operator==(const QualType &RHS) const {
return ThePtr == RHS.ThePtr;
}
bool operator!=(const QualType &RHS) const {
return ThePtr != RHS.ThePtr;
}
std::string getAsString() const {
std::string S;
getAsStringInternal(S);
return S;
}
void getAsStringInternal(std::string &Str) const;
void dump(const char *s = 0) const;
//private:
/// getCanonicalType - Return the canonical version of this type, with the
/// appropriate type qualifiers on it.
inline QualType getCanonicalType() const;
public:
/// getAddressSpace - Return the address space of this type.
inline unsigned getAddressSpace() const;
/// Emit - Serialize a QualType to Bitcode.
void Emit(llvm::Serializer& S) const;
/// Read - Deserialize a QualType from Bitcode.
static QualType ReadVal(llvm::Deserializer& D);
private:
void ReadBackpatch(llvm::Deserializer& D);
friend class FieldDecl;
};
} // end clang.
namespace llvm {
/// Implement simplify_type for QualType, so that we can dyn_cast from QualType
/// to a specific Type class.
template<> struct simplify_type<const ::clang::QualType> {
typedef ::clang::Type* SimpleType;
static SimpleType getSimplifiedValue(const ::clang::QualType &Val) {
return Val.getTypePtr();
}
};
template<> struct simplify_type< ::clang::QualType>
: public simplify_type<const ::clang::QualType> {};
} // end namespace llvm
namespace clang {
/// Type - This is the base class of the type hierarchy. A central concept
/// with types is that each type always has a canonical type. A canonical type
/// is the type with any typedef names stripped out of it or the types it
/// references. For example, consider:
///
/// typedef int foo;
/// typedef foo* bar;
/// 'int *' 'foo *' 'bar'
///
/// There will be a Type object created for 'int'. Since int is canonical, its
/// canonicaltype pointer points to itself. There is also a Type for 'foo' (a
/// TypeNameType). Its CanonicalType pointer points to the 'int' Type. Next
/// there is a PointerType that represents 'int*', which, like 'int', is
/// canonical. Finally, there is a PointerType type for 'foo*' whose canonical
/// type is 'int*', and there is a TypeNameType for 'bar', whose canonical type
/// is also 'int*'.
///
/// Non-canonical types are useful for emitting diagnostics, without losing
/// information about typedefs being used. Canonical types are useful for type
/// comparisons (they allow by-pointer equality tests) and useful for reasoning
/// about whether something has a particular form (e.g. is a function type),
/// because they implicitly, recursively, strip all typedefs out of a type.
///
/// Types, once created, are immutable.
///
class Type {
public:
enum TypeClass {
Builtin, Complex, Pointer, Reference,
ConstantArray, VariableArray, IncompleteArray,
Vector, ExtVector,
FunctionNoProto, FunctionProto,
TypeName, Tagged, ASQual,
ObjCInterface, ObjCQualifiedInterface,
ObjCQualifiedId,
TypeOfExp, TypeOfTyp // GNU typeof extension.
};
private:
QualType CanonicalType;
/// TypeClass bitfield - Enum that specifies what subclass this belongs to.
/// Note that this should stay at the end of the ivars for Type so that
/// subclasses can pack their bitfields into the same word.
unsigned TC : 5;
protected:
// silence VC++ warning C4355: 'this' : used in base member initializer list
Type *this_() { return this; }
Type(TypeClass tc, QualType Canonical)
: CanonicalType(Canonical.isNull() ? QualType(this_(), 0) : Canonical),
TC(tc) {}
virtual ~Type();
friend class ASTContext;
void EmitTypeInternal(llvm::Serializer& S) const;
void ReadTypeInternal(llvm::Deserializer& D);
public:
TypeClass getTypeClass() const { return static_cast<TypeClass>(TC); }
bool isCanonical() const { return CanonicalType.getTypePtr() == this; }
/// Types are partitioned into 3 broad categories (C99 6.2.5p1):
/// object types, function types, and incomplete types.
/// isObjectType - types that fully describe objects. An object is a region
/// of memory that can be examined and stored into (H&S).
bool isObjectType() const;
/// isIncompleteType - Return true if this is an incomplete type.
/// A type that can describe objects, but which lacks information needed to
/// determine its size (e.g. void, or a fwd declared struct). Clients of this
/// routine will need to determine if the size is actually required.
bool isIncompleteType() const;
/// isIncompleteOrObjectType - Return true if this is an incomplete or object
/// type, in other words, not a function type.
bool isIncompleteOrObjectType() const {
return !isFunctionType();
}
/// isVariablyModifiedType (C99 6.7.5.2p2) - Return true for variable array
/// types that have a non-constant expression. This does not include "[]".
bool isVariablyModifiedType() const;
/// isIncompleteArrayType (C99 6.2.5p22) - Return true for variable array
/// types that don't have any expression ("[]").
bool isIncompleteArrayType() const;
/// Helper methods to distinguish type categories. All type predicates
/// operate on the canonical type, ignoring typedefs and qualifiers.
/// isIntegerType() does *not* include complex integers (a GCC extension).
/// isComplexIntegerType() can be used to test for complex integers.
bool isIntegerType() const; // C99 6.2.5p17 (int, char, bool, enum)
bool isEnumeralType() const;
bool isBooleanType() const;
bool isCharType() const;
bool isIntegralType() const;
/// Floating point categories.
bool isRealFloatingType() const; // C99 6.2.5p10 (float, double, long double)
/// isComplexType() does *not* include complex integers (a GCC extension).
/// isComplexIntegerType() can be used to test for complex integers.
bool isComplexType() const; // C99 6.2.5p11 (complex)
bool isAnyComplexType() const; // C99 6.2.5p11 (complex) + Complex Int.
bool isFloatingType() const; // C99 6.2.5p11 (real floating + complex)
bool isRealType() const; // C99 6.2.5p17 (real floating + integer)
bool isArithmeticType() const; // C99 6.2.5p18 (integer + floating)
bool isVoidType() const; // C99 6.2.5p19
bool isDerivedType() const; // C99 6.2.5p20
bool isScalarType() const; // C99 6.2.5p21 (arithmetic + pointers)
bool isAggregateType() const; // C99 6.2.5p21 (arrays, structures)
// Type Predicates: Check to see if this type is structurally the specified
// type, ignoring typedefs and qualifiers.
bool isFunctionType() const;
bool isPointerLikeType() const; // Pointer or Reference.
bool isPointerType() const;
bool isReferenceType() const;
bool isFunctionPointerType() const;
bool isArrayType() const;
bool isRecordType() const;
bool isClassType() const;
bool isStructureType() const;
bool isUnionType() const;
bool isComplexIntegerType() const; // GCC _Complex integer type.
bool isVectorType() const; // GCC vector type.
bool isExtVectorType() const; // Extended vector type.
bool isObjCInterfaceType() const; // NSString or NSString<foo>
bool isObjCQualifiedInterfaceType() const; // NSString<foo>
bool isObjCQualifiedIdType() const; // id<foo>
// Type Checking Functions: Check to see if this type is structurally the
// specified type, ignoring typedefs and qualifiers, and return a pointer to
// the best type we can.
const BuiltinType *getAsBuiltinType() const;
const FunctionType *getAsFunctionType() const;
const PointerLikeType *getAsPointerLikeType() const; // Pointer or Reference.
const PointerType *getAsPointerType() const;
const ReferenceType *getAsReferenceType() const;
const ArrayType *getAsArrayType() const;
const ConstantArrayType *getAsConstantArrayType() const;
const VariableArrayType *getAsVariableArrayType() const;
const IncompleteArrayType *getAsIncompleteArrayType() const;
const RecordType *getAsRecordType() const;
const RecordType *getAsStructureType() const;
const TypedefType *getAsTypedefType() const;
const RecordType *getAsUnionType() const;
const VectorType *getAsVectorType() const; // GCC vector type.
const ComplexType *getAsComplexType() const;
const ComplexType *getAsComplexIntegerType() const; // GCC complex int type.
const ExtVectorType *getAsExtVectorType() const; // Extended vector type.
const ObjCInterfaceType *getAsObjCInterfaceType() const;
const ObjCQualifiedInterfaceType *getAsObjCQualifiedInterfaceType() const;
const ObjCQualifiedIdType *getAsObjCQualifiedIdType() const;
/// getDesugaredType - Return the specified type with any "sugar" removed from
/// the type. This takes off typedefs, typeof's etc. If the outer level of
/// the type is already concrete, it returns it unmodified. This is similar
/// to getting the canonical type, but it doesn't remove *all* typedefs. For
/// example, it returns "T*" as "T*", (not as "int*"), because the pointer is
/// concrete.
const Type *getDesugaredType() const;
/// More type predicates useful for type checking/promotion
bool isPromotableIntegerType() const; // C99 6.3.1.1p2
/// isSignedIntegerType - Return true if this is an integer type that is
/// signed, according to C99 6.2.5p4 [char, signed char, short, int, long..],
/// an enum decl which has a signed representation, or a vector of signed
/// integer element type.
bool isSignedIntegerType() const;
/// isUnsignedIntegerType - Return true if this is an integer type that is
/// unsigned, according to C99 6.2.5p6 [which returns true for _Bool], an enum
/// decl which has an unsigned representation, or a vector of unsigned integer
/// element type.
bool isUnsignedIntegerType() const;
/// isConstantSizeType - Return true if this is not a variable sized type,
/// according to the rules of C99 6.7.5p3. It is not legal to call this on
/// incomplete types.
bool isConstantSizeType() const;
private:
QualType getCanonicalTypeInternal() const { return CanonicalType; }
friend class QualType;
public:
virtual void getAsStringInternal(std::string &InnerString) const = 0;
static bool classof(const Type *) { return true; }
protected:
/// Emit - Emit a Type to bitcode. Used by ASTContext.
void Emit(llvm::Serializer& S) const;
/// Create - Construct a Type from bitcode. Used by ASTContext.
static void Create(ASTContext& Context, unsigned i, llvm::Deserializer& S);
/// EmitImpl - Subclasses must implement this method in order to
/// be serialized.
virtual void EmitImpl(llvm::Serializer& S) const;
};
/// ASQualType - TR18037 (C embedded extensions) 6.2.5p26
/// This supports address space qualified types.
///
class ASQualType : public Type, public llvm::FoldingSetNode {
/// BaseType - This is the underlying type that this qualifies. All CVR
/// qualifiers are stored on the QualType that references this type, so we
/// can't have any here.
Type *BaseType;
/// Address Space ID - The address space ID this type is qualified with.
unsigned AddressSpace;
ASQualType(Type *Base, QualType CanonicalPtr, unsigned AddrSpace) :
Type(ASQual, CanonicalPtr), BaseType(Base), AddressSpace(AddrSpace) {
}
friend class ASTContext; // ASTContext creates these.
public:
Type *getBaseType() const { return BaseType; }
unsigned getAddressSpace() const { return AddressSpace; }
virtual void getAsStringInternal(std::string &InnerString) const;
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getBaseType(), AddressSpace);
}
static void Profile(llvm::FoldingSetNodeID &ID, Type *Base,
unsigned AddrSpace) {
ID.AddPointer(Base);
ID.AddInteger(AddrSpace);
}
static bool classof(const Type *T) { return T->getTypeClass() == ASQual; }
static bool classof(const ASQualType *) { return true; }
protected:
virtual void EmitImpl(llvm::Serializer& S) const;
static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
friend class Type;
};
/// BuiltinType - This class is used for builtin types like 'int'. Builtin
/// types are always canonical and have a literal name field.
class BuiltinType : public Type {
public:
enum Kind {
Void,
Bool, // This is bool and/or _Bool.
Char_U, // This is 'char' for targets where char is unsigned.
UChar, // This is explicitly qualified unsigned char.
UShort,
UInt,
ULong,
ULongLong,
Char_S, // This is 'char' for targets where char is signed.
SChar, // This is explicitly qualified signed char.
Short,
Int,
Long,
LongLong,
Float, Double, LongDouble
};
private:
Kind TypeKind;
public:
BuiltinType(Kind K) : Type(Builtin, QualType()), TypeKind(K) {}
Kind getKind() const { return TypeKind; }
const char *getName() const;
virtual void getAsStringInternal(std::string &InnerString) const;
static bool classof(const Type *T) { return T->getTypeClass() == Builtin; }
static bool classof(const BuiltinType *) { return true; }
};
/// ComplexType - C99 6.2.5p11 - Complex values. This supports the C99 complex
/// types (_Complex float etc) as well as the GCC integer complex extensions.
///
class ComplexType : public Type, public llvm::FoldingSetNode {
QualType ElementType;
ComplexType(QualType Element, QualType CanonicalPtr) :
Type(Complex, CanonicalPtr), ElementType(Element) {
}
friend class ASTContext; // ASTContext creates these.
public:
QualType getElementType() const { return ElementType; }
virtual void getAsStringInternal(std::string &InnerString) const;
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getElementType());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType Element) {
ID.AddPointer(Element.getAsOpaquePtr());
}
static bool classof(const Type *T) { return T->getTypeClass() == Complex; }
static bool classof(const ComplexType *) { return true; }
protected:
virtual void EmitImpl(llvm::Serializer& S) const;
static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
friend class Type;
};
/// PointerLikeType - Common base class for pointers and references.
///
class PointerLikeType : public Type {
QualType PointeeType;
protected:
PointerLikeType(TypeClass K, QualType Pointee, QualType CanonicalPtr) :
Type(K, CanonicalPtr), PointeeType(Pointee) {
}
public:
QualType getPointeeType() const { return PointeeType; }
static bool classof(const Type *T) {
return T->getTypeClass() == Pointer || T->getTypeClass() == Reference;
}
static bool classof(const PointerLikeType *) { return true; }
};
/// PointerType - C99 6.7.5.1 - Pointer Declarators.
///
class PointerType : public PointerLikeType, public llvm::FoldingSetNode {
PointerType(QualType Pointee, QualType CanonicalPtr) :
PointerLikeType(Pointer, Pointee, CanonicalPtr) {
}
friend class ASTContext; // ASTContext creates these.
public:
virtual void getAsStringInternal(std::string &InnerString) const;
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getPointeeType());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee) {
ID.AddPointer(Pointee.getAsOpaquePtr());
}
static bool classof(const Type *T) { return T->getTypeClass() == Pointer; }
static bool classof(const PointerType *) { return true; }
protected:
virtual void EmitImpl(llvm::Serializer& S) const;
static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
friend class Type;
};
/// ReferenceType - C++ 8.3.2 - Reference Declarators.
///
class ReferenceType : public PointerLikeType, public llvm::FoldingSetNode {
ReferenceType(QualType Referencee, QualType CanonicalRef) :
PointerLikeType(Reference, Referencee, CanonicalRef) {
}
friend class ASTContext; // ASTContext creates these.
public:
virtual void getAsStringInternal(std::string &InnerString) const;
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getPointeeType());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType Referencee) {
ID.AddPointer(Referencee.getAsOpaquePtr());
}
static bool classof(const Type *T) { return T->getTypeClass() == Reference; }
static bool classof(const ReferenceType *) { return true; }
};
/// ArrayType - C99 6.7.5.2 - Array Declarators.
///
class ArrayType : public Type, public llvm::FoldingSetNode {
public:
/// ArraySizeModifier - Capture whether this is a normal array (e.g. int X[4])
/// an array with a static size (e.g. int X[static 4]), or with a star size
/// (e.g. int X[*]). 'static' is only allowed on function parameters.
enum ArraySizeModifier {
Normal, Static, Star
};
private:
/// ElementType - The element type of the array.
QualType ElementType;
// NOTE: VC++ treats enums as signed, avoid using the ArraySizeModifier enum
/// NOTE: These fields are packed into the bitfields space in the Type class.
unsigned SizeModifier : 2;
/// IndexTypeQuals - Capture qualifiers in declarations like:
/// 'int X[static restrict 4]'. For function parameters only.
unsigned IndexTypeQuals : 3;
protected:
ArrayType(TypeClass tc, QualType et, QualType can,
ArraySizeModifier sm, unsigned tq)
: Type(tc, can), ElementType(et), SizeModifier(sm), IndexTypeQuals(tq) {}
friend class ASTContext; // ASTContext creates these.
public:
QualType getElementType() const { return ElementType; }
ArraySizeModifier getSizeModifier() const {
return ArraySizeModifier(SizeModifier);
}
unsigned getIndexTypeQualifier() const { return IndexTypeQuals; }
QualType getBaseType() const {
const ArrayType *AT;
QualType ElmtType = getElementType();
// If we have a multi-dimensional array, navigate to the base type.
while ((AT = ElmtType->getAsArrayType()))
ElmtType = AT->getElementType();
return ElmtType;
}
static bool classof(const Type *T) {
return T->getTypeClass() == ConstantArray ||
T->getTypeClass() == VariableArray ||
T->getTypeClass() == IncompleteArray;
}
static bool classof(const ArrayType *) { return true; }
};
/// ConstantArrayType - This class represents C arrays with a specified constant
/// size. For example 'int A[100]' has ConstantArrayType where the element type
/// is 'int' and the size is 100.
class ConstantArrayType : public ArrayType {
llvm::APInt Size; // Allows us to unique the type.
ConstantArrayType(QualType et, QualType can, llvm::APInt sz,
ArraySizeModifier sm, unsigned tq)
: ArrayType(ConstantArray, et, can, sm, tq), Size(sz) {}
friend class ASTContext; // ASTContext creates these.
public:
llvm::APInt getSize() const { return Size; }
int getMaximumElements() const {
QualType ElmtType = getElementType();
int maxElements = static_cast<int>(getSize().getZExtValue());
const ConstantArrayType *CAT;
// If we have a multi-dimensional array, include it's elements.
while ((CAT = ElmtType->getAsConstantArrayType())) {
ElmtType = CAT->getElementType();
maxElements *= static_cast<int>(CAT->getSize().getZExtValue());
}
return maxElements;
}
virtual void getAsStringInternal(std::string &InnerString) const;
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getElementType(), getSize());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType ET,
llvm::APInt ArraySize) {
ID.AddPointer(ET.getAsOpaquePtr());
ID.AddInteger(ArraySize.getZExtValue());
}
static bool classof(const Type *T) {
return T->getTypeClass() == ConstantArray;
}
static bool classof(const ConstantArrayType *) { return true; }
protected:
virtual void EmitImpl(llvm::Serializer& S) const;
static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D);
friend class Type;
};
/// IncompleteArrayType - This class represents C arrays with an unspecified
/// size. For example 'int A[]' has an IncompleteArrayType where the element
/// type is 'int' and the size is unspecified.
class IncompleteArrayType : public ArrayType {
IncompleteArrayType(QualType et, QualType can,
ArraySizeModifier sm, unsigned tq)
: ArrayType(IncompleteArray, et, can, sm, tq) {}
friend class ASTContext; // ASTContext creates these.
public:
virtual void getAsStringInternal(std::string &InnerString) const;
static bool classof(const Type *T) {
return T->getTypeClass() == IncompleteArray;
}
static bool classof(const IncompleteArrayType *) { return true; }
friend class StmtIteratorBase;
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getElementType());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType ET) {
ID.AddPointer(ET.getAsOpaquePtr());
}
protected:
virtual void EmitImpl(llvm::Serializer& S) const;
static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
friend class Type;
};
/// VariableArrayType - This class represents C arrays with a specified size
/// which is not an integer-constant-expression. For example, 'int s[x+foo()]'.
/// Since the size expression is an arbitrary expression, we store it as such.
///
/// Note: VariableArrayType's aren't uniqued (since the expressions aren't) and
/// should not be: two lexically equivalent variable array types could mean
/// different things, for example, these variables do not have the same type
/// dynamically:
///
/// void foo(int x) {
/// int Y[x];
/// ++x;
/// int Z[x];
/// }
///
class VariableArrayType : public ArrayType {
/// SizeExpr - An assignment expression. VLA's are only permitted within
/// a function block.
Expr *SizeExpr;
VariableArrayType(QualType et, QualType can, Expr *e,
ArraySizeModifier sm, unsigned tq)
: ArrayType(VariableArray, et, can, sm, tq), SizeExpr(e) {}
friend class ASTContext; // ASTContext creates these.
public:
const Expr *getSizeExpr() const { return SizeExpr; }
Expr *getSizeExpr() { return SizeExpr; }
virtual void getAsStringInternal(std::string &InnerString) const;
static bool classof(const Type *T) {
return T->getTypeClass() == VariableArray;
}
static bool classof(const VariableArrayType *) { return true; }
friend class StmtIteratorBase;
void Profile(llvm::FoldingSetNodeID &ID) {
assert (0 && "Cannnot unique VariableArrayTypes.");
}
protected:
virtual void EmitImpl(llvm::Serializer& S) const;
static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
friend class Type;
};
/// VectorType - GCC generic vector type. This type is created using
/// __attribute__((vector_size(n)), where "n" specifies the vector size in
/// bytes. Since the constructor takes the number of vector elements, the
/// client is responsible for converting the size into the number of elements.
class VectorType : public Type, public llvm::FoldingSetNode {
protected:
/// ElementType - The element type of the vector.
QualType ElementType;
/// NumElements - The number of elements in the vector.
unsigned NumElements;
VectorType(QualType vecType, unsigned nElements, QualType canonType) :
Type(Vector, canonType), ElementType(vecType), NumElements(nElements) {}
VectorType(TypeClass tc, QualType vecType, unsigned nElements,
QualType canonType) : Type(tc, canonType), ElementType(vecType),
NumElements(nElements) {}
friend class ASTContext; // ASTContext creates these.
public:
QualType getElementType() const { return ElementType; }
unsigned getNumElements() const { return NumElements; }
virtual void getAsStringInternal(std::string &InnerString) const;
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getElementType(), getNumElements(), getTypeClass());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType ElementType,
unsigned NumElements, TypeClass TypeClass) {
ID.AddPointer(ElementType.getAsOpaquePtr());
ID.AddInteger(NumElements);
ID.AddInteger(TypeClass);
}
static bool classof(const Type *T) {
return T->getTypeClass() == Vector || T->getTypeClass() == ExtVector;
}
static bool classof(const VectorType *) { return true; }
};
/// ExtVectorType - Extended vector type. This type is created using
/// __attribute__((ext_vector_type(n)), where "n" is the number of elements.
/// Unlike vector_size, ext_vector_type is only allowed on typedef's. This
/// class enables syntactic extensions, like Vector Components for accessing
/// points, colors, and textures (modeled after OpenGL Shading Language).
class ExtVectorType : public VectorType {
ExtVectorType(QualType vecType, unsigned nElements, QualType canonType) :
VectorType(ExtVector, vecType, nElements, canonType) {}
friend class ASTContext; // ASTContext creates these.
public:
static int getPointAccessorIdx(char c) {
switch (c) {
default: return -1;
case 'x': return 0;
case 'y': return 1;
case 'z': return 2;
case 'w': return 3;
}
}
static int getColorAccessorIdx(char c) {
switch (c) {
default: return -1;
case 'r': return 0;
case 'g': return 1;
case 'b': return 2;
case 'a': return 3;
}
}
static int getTextureAccessorIdx(char c) {
switch (c) {
default: return -1;
case 's': return 0;
case 't': return 1;
case 'p': return 2;
case 'q': return 3;
}
};
static int getAccessorIdx(char c) {
if (int idx = getPointAccessorIdx(c)+1) return idx-1;
if (int idx = getColorAccessorIdx(c)+1) return idx-1;
return getTextureAccessorIdx(c);
}
bool isAccessorWithinNumElements(char c) const {
if (int idx = getAccessorIdx(c)+1)
return unsigned(idx-1) < NumElements;
return false;
}
virtual void getAsStringInternal(std::string &InnerString) const;
static bool classof(const Type *T) {
return T->getTypeClass() == ExtVector;
}
static bool classof(const ExtVectorType *) { return true; }
};
/// FunctionType - C99 6.7.5.3 - Function Declarators. This is the common base
/// class of FunctionTypeNoProto and FunctionTypeProto.
///
class FunctionType : public Type {
/// SubClassData - This field is owned by the subclass, put here to pack
/// tightly with the ivars in Type.
bool SubClassData : 1;
// The type returned by the function.
QualType ResultType;
protected:
FunctionType(TypeClass tc, QualType res, bool SubclassInfo,QualType Canonical)
: Type(tc, Canonical), SubClassData(SubclassInfo), ResultType(res) {}
bool getSubClassData() const { return SubClassData; }
public:
QualType getResultType() const { return ResultType; }
static bool classof(const Type *T) {
return T->getTypeClass() == FunctionNoProto ||
T->getTypeClass() == FunctionProto;
}
static bool classof(const FunctionType *) { return true; }
};
/// FunctionTypeNoProto - Represents a K&R-style 'int foo()' function, which has
/// no information available about its arguments.
class FunctionTypeNoProto : public FunctionType, public llvm::FoldingSetNode {
FunctionTypeNoProto(QualType Result, QualType Canonical)
: FunctionType(FunctionNoProto, Result, false, Canonical) {}
friend class ASTContext; // ASTContext creates these.
public:
// No additional state past what FunctionType provides.
virtual void getAsStringInternal(std::string &InnerString) const;
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getResultType());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType ResultType) {
ID.AddPointer(ResultType.getAsOpaquePtr());
}
static bool classof(const Type *T) {
return T->getTypeClass() == FunctionNoProto;
}
static bool classof(const FunctionTypeNoProto *) { return true; }
protected:
virtual void EmitImpl(llvm::Serializer& S) const;
static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
friend class Type;
};
/// FunctionTypeProto - Represents a prototype with argument type info, e.g.
/// 'int foo(int)' or 'int foo(void)'. 'void' is represented as having no
/// arguments, not as having a single void argument.
class FunctionTypeProto : public FunctionType, public llvm::FoldingSetNode {
FunctionTypeProto(QualType Result, QualType *ArgArray, unsigned numArgs,
bool isVariadic, QualType Canonical)
: FunctionType(FunctionProto, Result, isVariadic, Canonical),
NumArgs(numArgs) {
// Fill in the trailing argument array.
QualType *ArgInfo = reinterpret_cast<QualType *>(this+1);;
for (unsigned i = 0; i != numArgs; ++i)
ArgInfo[i] = ArgArray[i];
}
/// NumArgs - The number of arguments this function has, not counting '...'.
unsigned NumArgs;
/// ArgInfo - There is an variable size array after the class in memory that
/// holds the argument types.
friend class ASTContext; // ASTContext creates these.
public:
unsigned getNumArgs() const { return NumArgs; }
QualType getArgType(unsigned i) const {
assert(i < NumArgs && "Invalid argument number!");
return arg_type_begin()[i];
}
bool isVariadic() const { return getSubClassData(); }
typedef const QualType *arg_type_iterator;
arg_type_iterator arg_type_begin() const {
return reinterpret_cast<const QualType *>(this+1);
}
arg_type_iterator arg_type_end() const { return arg_type_begin()+NumArgs; }
virtual void getAsStringInternal(std::string &InnerString) const;
static bool classof(const Type *T) {
return T->getTypeClass() == FunctionProto;
}
static bool classof(const FunctionTypeProto *) { return true; }
void Profile(llvm::FoldingSetNodeID &ID);
static void Profile(llvm::FoldingSetNodeID &ID, QualType Result,
arg_type_iterator ArgTys, unsigned NumArgs,
bool isVariadic);
protected:
virtual void EmitImpl(llvm::Serializer& S) const;
static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
friend class Type;
};
class TypedefType : public Type {
TypedefDecl *Decl;
protected:
TypedefType(TypeClass tc, TypedefDecl *D, QualType can)
: Type(tc, can), Decl(D) {
assert(!isa<TypedefType>(can) && "Invalid canonical type");
}
friend class ASTContext; // ASTContext creates these.
public:
TypedefDecl *getDecl() const { return Decl; }
/// LookThroughTypedefs - Return the ultimate type this typedef corresponds to
/// potentially looking through *all* consequtive typedefs. This returns the
/// sum of the type qualifiers, so if you have:
/// typedef const int A;
/// typedef volatile A B;
/// looking through the typedefs for B will give you "const volatile A".
QualType LookThroughTypedefs() const;
virtual void getAsStringInternal(std::string &InnerString) const;
static bool classof(const Type *T) { return T->getTypeClass() == TypeName; }
static bool classof(const TypedefType *) { return true; }
protected:
virtual void EmitImpl(llvm::Serializer& S) const;
static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
friend class Type;
};
/// TypeOfExpr (GCC extension).
class TypeOfExpr : public Type {
Expr *TOExpr;
TypeOfExpr(Expr *E, QualType can) : Type(TypeOfExp, can), TOExpr(E) {
assert(!isa<TypedefType>(can) && "Invalid canonical type");
}
friend class ASTContext; // ASTContext creates these.
public:
Expr *getUnderlyingExpr() const { return TOExpr; }
virtual void getAsStringInternal(std::string &InnerString) const;
static bool classof(const Type *T) { return T->getTypeClass() == TypeOfExp; }
static bool classof(const TypeOfExpr *) { return true; }
};
/// TypeOfType (GCC extension).
class TypeOfType : public Type {
QualType TOType;
TypeOfType(QualType T, QualType can) : Type(TypeOfTyp, can), TOType(T) {
assert(!isa<TypedefType>(can) && "Invalid canonical type");
}
friend class ASTContext; // ASTContext creates these.
public:
QualType getUnderlyingType() const { return TOType; }
virtual void getAsStringInternal(std::string &InnerString) const;
static bool classof(const Type *T) { return T->getTypeClass() == TypeOfTyp; }
static bool classof(const TypeOfType *) { return true; }
};
class TagType : public Type {
TagDecl *decl;
protected:
TagType(TagDecl *D, QualType can) : Type(Tagged, can), decl(D) {}
public:
TagDecl *getDecl() const { return decl; }
virtual void getAsStringInternal(std::string &InnerString) const;
static bool classof(const Type *T) { return T->getTypeClass() == Tagged; }
static bool classof(const TagType *) { return true; }
protected:
virtual void EmitImpl(llvm::Serializer& S) const;
static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D);
friend class Type;
};
/// RecordType - This is a helper class that allows the use of isa/cast/dyncast
/// to detect TagType objects of structs/unions/classes.
class RecordType : public TagType {
explicit RecordType(RecordDecl *D) : TagType(cast<TagDecl>(D), QualType()) { }
friend class ASTContext; // ASTContext creates these.
public:
RecordDecl *getDecl() const {
return reinterpret_cast<RecordDecl*>(TagType::getDecl());
}
// FIXME: This predicate is a helper to QualType/Type. It needs to
// recursively check all fields for const-ness. If any field is declared
// const, it needs to return false.
bool hasConstFields() const { return false; }
// FIXME: RecordType needs to check when it is created that all fields are in
// the same address space, and return that.
unsigned getAddressSpace() const { return 0; }
static bool classof(const TagType *T);
static bool classof(const Type *T) {
return isa<TagType>(T) && classof(cast<TagType>(T));
}
static bool classof(const RecordType *) { return true; }
};
/// EnumType - This is a helper class that allows the use of isa/cast/dyncast
/// to detect TagType objects of enums.
class EnumType : public TagType {
explicit EnumType(EnumDecl *D) : TagType(cast<TagDecl>(D), QualType()) { }
friend class ASTContext; // ASTContext creates these.
public:
EnumDecl *getDecl() const {
return reinterpret_cast<EnumDecl*>(TagType::getDecl());
}
static bool classof(const TagType *T);
static bool classof(const Type *T) {
return isa<TagType>(T) && classof(cast<TagType>(T));
}
static bool classof(const EnumType *) { return true; }
};
class ObjCInterfaceType : public Type {
ObjCInterfaceDecl *Decl;
protected:
ObjCInterfaceType(TypeClass tc, ObjCInterfaceDecl *D) :
Type(tc, QualType()), Decl(D) { }
friend class ASTContext; // ASTContext creates these.
public:
ObjCInterfaceDecl *getDecl() const { return Decl; }
virtual void getAsStringInternal(std::string &InnerString) const;
static bool classof(const Type *T) {
return T->getTypeClass() == ObjCInterface ||
T->getTypeClass() == ObjCQualifiedInterface;
}
static bool classof(const ObjCInterfaceType *) { return true; }
};
/// ObjCQualifiedInterfaceType - This class represents interface types
/// conforming to a list of protocols, such as INTF<Proto1, Proto2, Proto1>.
///
/// Duplicate protocols are removed and protocol list is canonicalized to be in
/// alphabetical order.
class ObjCQualifiedInterfaceType : public ObjCInterfaceType,
public llvm::FoldingSetNode {
// List of protocols for this protocol conforming object type
// List is sorted on protocol name. No protocol is enterred more than once.
llvm::SmallVector<ObjCProtocolDecl*, 8> Protocols;
ObjCQualifiedInterfaceType(ObjCInterfaceDecl *D,
ObjCProtocolDecl **Protos, unsigned NumP) :
ObjCInterfaceType(ObjCQualifiedInterface, D),
Protocols(Protos, Protos+NumP) { }
friend class ASTContext; // ASTContext creates these.
public:
ObjCProtocolDecl *getProtocols(unsigned i) const {
return Protocols[i];
}
unsigned getNumProtocols() const {
return Protocols.size();
}
typedef llvm::SmallVector<ObjCProtocolDecl*, 8>::const_iterator qual_iterator;
qual_iterator qual_begin() const { return Protocols.begin(); }
qual_iterator qual_end() const { return Protocols.end(); }
virtual void getAsStringInternal(std::string &InnerString) const;
void Profile(llvm::FoldingSetNodeID &ID);
static void Profile(llvm::FoldingSetNodeID &ID,
const ObjCInterfaceDecl *Decl,
ObjCProtocolDecl **protocols, unsigned NumProtocols);
static bool classof(const Type *T) {
return T->getTypeClass() == ObjCQualifiedInterface;
}
static bool classof(const ObjCQualifiedInterfaceType *) { return true; }
};
/// ObjCQualifiedIdType - to represent id<protocol-list>.
///
/// Duplicate protocols are removed and protocol list is canonicalized to be in
/// alphabetical order.
class ObjCQualifiedIdType : public Type,
public llvm::FoldingSetNode {
// List of protocols for this protocol conforming 'id' type
// List is sorted on protocol name. No protocol is enterred more than once.
llvm::SmallVector<ObjCProtocolDecl*, 8> Protocols;
ObjCQualifiedIdType(QualType can, ObjCProtocolDecl **Protos, unsigned NumP)
: Type(ObjCQualifiedId, can),
Protocols(Protos, Protos+NumP) { }
friend class ASTContext; // ASTContext creates these.
public:
ObjCProtocolDecl *getProtocols(unsigned i) const {
return Protocols[i];
}
unsigned getNumProtocols() const {
return Protocols.size();
}
ObjCProtocolDecl **getReferencedProtocols() {
return &Protocols[0];
}
typedef llvm::SmallVector<ObjCProtocolDecl*, 8>::const_iterator qual_iterator;
qual_iterator qual_begin() const { return Protocols.begin(); }
qual_iterator qual_end() const { return Protocols.end(); }
virtual void getAsStringInternal(std::string &InnerString) const;
void Profile(llvm::FoldingSetNodeID &ID);
static void Profile(llvm::FoldingSetNodeID &ID,
ObjCProtocolDecl **protocols, unsigned NumProtocols);
static bool classof(const Type *T) {
return T->getTypeClass() == ObjCQualifiedId;
}
static bool classof(const ObjCQualifiedIdType *) { return true; }
};
// Inline function definitions.
/// getCanonicalType - Return the canonical version of this type, with the
/// appropriate type qualifiers on it.
inline QualType QualType::getCanonicalType() const {
QualType CanType = getTypePtr()->getCanonicalTypeInternal();
return QualType(CanType.getTypePtr(),
getCVRQualifiers() | CanType.getCVRQualifiers());
}
/// getUnqualifiedType - Return the type without any qualifiers.
inline QualType QualType::getUnqualifiedType() const {
Type *TP = getTypePtr();
if (const ASQualType *ASQT = dyn_cast<ASQualType>(TP))
TP = ASQT->getBaseType();
return QualType(TP, 0);
}
/// getAddressSpace - Return the address space of this type.
inline unsigned QualType::getAddressSpace() const {
if (const ArrayType *AT = dyn_cast<ArrayType>(getCanonicalType()))
return AT->getBaseType().getAddressSpace();
if (const RecordType *RT = dyn_cast<RecordType>(getCanonicalType()))
return RT->getAddressSpace();
if (const ASQualType *ASQT = dyn_cast<ASQualType>(getCanonicalType()))
return ASQT->getAddressSpace();
return 0;
}
inline const TypedefType* Type::getAsTypedefType() const {
return dyn_cast<TypedefType>(this);
}
inline bool Type::isFunctionType() const {
return isa<FunctionType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isPointerType() const {
return isa<PointerType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isReferenceType() const {
return isa<ReferenceType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isPointerLikeType() const {
return isa<PointerLikeType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isFunctionPointerType() const {
if (const PointerType* T = getAsPointerType())
return T->getPointeeType()->isFunctionType();
else
return false;
}
inline bool Type::isArrayType() const {
return isa<ArrayType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isRecordType() const {
return isa<RecordType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isAnyComplexType() const {
return isa<ComplexType>(CanonicalType);
}
inline bool Type::isVectorType() const {
return isa<VectorType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isExtVectorType() const {
return isa<ExtVectorType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isObjCInterfaceType() const {
return isa<ObjCInterfaceType>(CanonicalType);
}
inline bool Type::isObjCQualifiedInterfaceType() const {
return isa<ObjCQualifiedInterfaceType>(CanonicalType);
}
inline bool Type::isObjCQualifiedIdType() const {
return isa<ObjCQualifiedIdType>(CanonicalType);
}
} // end namespace clang
#endif
|