clang: include/clang/AST/CanonicalType.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_CLANG_AST_CANONICALTYPE_H
15#define LLVM_CLANG_AST_CANONICALTYPE_H
16
20#include "llvm/ADT/ArrayRef.h"
21#include "llvm/ADT/FoldingSet.h"
22#include "llvm/ADT/iterator.h"
23#include "llvm/Support/Casting.h"
24#include "llvm/Support/PointerLikeTypeTraits.h"
25#include
26#include
27#include <type_traits>
28
30
31template class CanProxy;
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65template
67
69
70public:
71
73
74
75
76 template
78 std::enable_if_t<std::is_base_of<T, U>::value, int> = 0);
79
80
81
82
83
85
86
87
89 return cast_or_null(Stored.getTypePtrOrNull());
90 }
91
92
93 operator QualType() const { return Stored; }
94
95
96 explicit operator bool() const { return (); }
97
99 return Stored.isNull();
100 }
101
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
122
124
125
126
128
129
131
132
133 unsigned getCVRQualifiers() const { return Stored.getLocalCVRQualifiers(); }
134
135
136 bool hasQualifiers() const { return Stored.hasLocalQualifiers(); }
137
139 return Stored.isLocalConstQualified();
140 }
141
143 return Stored.isLocalVolatileQualified();
144 }
145
147 return Stored.isLocalRestrictQualified();
148 }
149
150
151
152
154 return Stored.isCanonicalAsParam();
155 }
156
157
159
160
161
165
166
167
169 return Stored.isMoreQualifiedThan(Other.Stored, Ctx);
170 }
171
172
173
175 return Stored.isAtLeastAsQualifiedAs(Other.Stored, Ctx);
176 }
177
178
179
181
182
184
185
187
188
189
190
191
192
194
195 void dump() const { Stored.dump(); }
196
197 void Profile(llvm::FoldingSetNodeID &ID) const {
199 }
200};
201
202template<typename T, typename U>
206
207template<typename T, typename U>
211
212
214
219
222 DB << static_cast(T);
223 return DB;
224}
225
226
227
228
229
230#define LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(Accessor) \
231CanQualType Accessor() const { \
232return CanQualType::CreateUnsafe(this->getTypePtr()->Accessor()); \
233}
234
235#define LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Type, Accessor) \
236Type Accessor() const { return this->getTypePtr()->Accessor(); }
237
238
239
240template
242protected:
244
245public:
246
248
249
250
251
252
253
254
255
257
258
259
261 return this->Stored.template getAs();
262 }
263
265
266
318
319
320
321
322
323
324
328};
329
330
331
332
333
334
335
336
337
338
339
340template
342
343
344
345
346
347
348
349
350template
352public:
353
355
356
358
359
361};
362
363}
364
365namespace llvm {
366
367
368
369
370template
378
379
380template
393
394}
395
397
398
399
400
401
402
403
404template
406 : llvm::iterator_adaptor_base<
407 CanTypeIterator, InputIterator,
408 typename std::iterator_traits::iterator_category,
409 CanQualType,
410 typename std::iterator_traits::difference_type,
411 CanProxy, CanQualType> {
415
418};
419
420template<>
424
425template<>
429
430template<>
435
436template<>
440
441template<>
446
447template<>
452
453template<>
459 getMostRecentCXXRecordDecl)
460};
461
462
463
469
470template<>
472 : public CanProxyBase {
476};
477
478template<>
483
484template<>
489
490template<>
495
496template<>
502
503template<>
516
519
522
526
530
531
532};
533
534template<>
538
539template<>
544
545template <>
552
553template<>
557
558template<>
563
564template<>
568
569template<>
578
579template<>
584 getInterface)
589
591
596};
597
598template<>
603 getInterfaceType)
608
610
615};
616
617
618
619
620template<typename T>
624
625template
628 return RefType->getPointeeType();
629 else
630 return *this;
631}
632
633template
637 assert(( || Result.Stored.getAsOpaquePtr() == (void*)-1 ||
638 Result.Stored.isCanonical()) && "Type is not canonical!");
640}
641
642template
644 assert((Other.isNull() || Other.isCanonical()) && "Type is not canonical!");
646 "Dynamic type does not meet the static type's requires");
650}
651
652template
653template
656 "ArrayType cannot be used with getAs!");
657
658 if (Stored.isNull())
660
661 if (isa(Stored.getTypePtr()))
663
665}
666
667template
668template
671 "ArrayType cannot be used with castAs!");
672
673 assert(!Stored.isNull() && isa(Stored.getTypePtr()));
675}
676
677template
681
682template
686
687}
688
689#endif
Defines the Diagnostic-related interfaces.
static bool isBooleanType(QualType Ty)
static std::optional< NonLoc > getIndex(ProgramStateRef State, const ElementRegion *ER, CharKind CK)
#define LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(Accessor)
Definition CanonicalType.h:230
#define LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Type, Accessor)
Definition CanonicalType.h:235
static StringRef getIdentifier(const Token &Tok)
static QualType getUnderlyingType(const SubRegion *R)
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
static bool isParameterPack(Expr *PackExpression)
Defines the clang::SourceLocation class and associated facilities.
static QualType getPointeeType(const MemRegion *R)
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Represents a C++ struct/union/class.
Base class of all canonical proxy types, which is responsible for storing the underlying canonical ty...
Definition CanonicalType.h:241
CanProxy< U > getAs() const
Try to convert the given canonical type to a specific structural type.
Definition CanonicalType.h:260
const T * getTypePtr() const
Retrieve the pointer to the underlying Type.
Definition CanonicalType.h:247
CanQual< T > Stored
Definition CanonicalType.h:243
Canonical proxy type returned when retrieving the members of a canonical type or as the result of the...
Definition CanonicalType.h:351
CanProxy(CanQual< T > Stored)
Build a proxy to the given canonical type.
Definition CanonicalType.h:357
CanProxy()=default
Build a NULL proxy.
Represents a canonical, potentially-qualified type.
Definition CanonicalType.h:66
void * getAsOpaquePtr() const
Retrieve the internal representation of this canonical type.
Definition CanonicalType.h:183
CanQual< Type > getNonReferenceType() const
If the canonical type is a reference type, returns the type that it refers to; otherwise,...
Definition CanonicalType.h:626
CanQual()=default
Constructs a NULL canonical type.
const T * getTypePtrOrNull() const
Retrieve the underlying type pointer, which refers to a canonical type, or nullptr.
Definition CanonicalType.h:88
bool isMoreQualifiedThan(CanQual< T > Other, const ASTContext &Ctx) const
Determines whether this canonical type is more qualified than the Other canonical type.
Definition CanonicalType.h:168
bool isRestrictQualified() const
Definition CanonicalType.h:146
unsigned getCVRQualifiers() const
Retrieve the const/volatile/restrict qualifiers.
Definition CanonicalType.h:133
CanProxy< T > operator->() const
Overloaded arrow operator that produces a canonical type proxy.
Definition CanonicalType.h:678
SplitQualType split() const
Definition CanonicalType.h:102
bool hasQualifiers() const
Determines whether this type has any qualifiers.
Definition CanonicalType.h:136
bool isAtLeastAsQualifiedAs(CanQual< T > Other, const ASTContext &Ctx) const
Determines whether this canonical type is at least as qualified as the Other canonical type.
Definition CanonicalType.h:174
static CanQual< T > CreateUnsafe(QualType Other)
Builds a canonical type from a QualType.
Definition CanonicalType.h:643
QualType withConst() const
Retrieves a version of this type with const applied.
Definition CanonicalType.h:162
CanQual(const CanQual< U > &Other, std::enable_if_t< std::is_base_of< T, U >::value, int >=0)
Converting constructor that permits implicit upcasting of canonical type pointers.
CanProxy< U > castAs() const
Definition CanonicalType.h:669
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Definition CanonicalType.h:621
void dump() const
Definition CanonicalType.h:195
bool isConstQualified() const
Definition CanonicalType.h:138
bool isNull() const
Definition CanonicalType.h:98
bool isCanonicalAsParam() const
Determines if this canonical type is furthermore canonical as a parameter.
Definition CanonicalType.h:153
Qualifiers getQualifiers() const
Retrieve all qualifiers.
Definition CanonicalType.h:130
void Profile(llvm::FoldingSetNodeID &ID) const
Definition CanonicalType.h:197
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
Definition CanonicalType.h:654
static CanQual< T > getFromOpaquePtr(void *Ptr)
Construct a canonical type from its internal representation.
Definition CanonicalType.h:634
bool isVolatileQualified() const
Definition CanonicalType.h:142
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
Definition CanonicalType.h:84
Complex values, per C99 6.2.5p11.
Represents the canonical version of C arrays with a specified constant size.
Represents an array type in C++ whose size is a value-dependent expression.
Represents an extended vector type where either the type or size is dependent.
This represents one expression.
ExtVectorType - Extended vector type.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
A class which abstracts out some details necessary for making a call.
FunctionType - C99 6.7.5.3 - Function Declarators.
One of these records is kept for each identifier that is lexed.
Represents a C array with an unspecified size.
An lvalue reference type, per C++11 [dcl.ref].
A pointer to member type per C++ 8.3.3 - Pointers to members.
Represents a C++ nested name specifier, such as "\::std::vector::".
Represents an ObjC class declaration.
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
Represents a pointer to an Objective C object.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
QualType withConst() const
static QualType getFromOpaquePtr(const void *Ptr)
The collection of all-type qualifiers we support.
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
Base for LValueReferenceType and RValueReferenceType.
Encodes a location in the source.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
Represents the declaration of a struct/union/class/enum.
Declaration of a template type parameter.
CanQualType getCanonicalTypeUnqualified() const
Definition CanonicalType.h:215
QualType getCanonicalTypeInternal() const
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
Definition CanonicalType.h:213
bool isa(CodeGen::Address addr)
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
@ Result
The result type of a method or function.
const FunctionProtoType * T
std::is_base_of< ArrayType, T > TypeIsArrayType
bool operator!=(CanQual< T > x, CanQual< U > y)
Definition CanonicalType.h:208
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
U cast(CodeGen::Address addr)
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
CanTypeIterator< FunctionProtoType::param_type_iterator > param_type_iterator
Definition CanonicalType.h:520
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayRef< FunctionProtoType::ExtParameterInfo >, getExtParameterInfos) CanQualType getParamType(unsigned i) const
Definition CanonicalType.h:510
param_type_iterator param_type_end() const
Definition CanonicalType.h:527
param_type_iterator param_type_begin() const
Definition CanonicalType.h:523
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const ObjCInterfaceType *, getInterfaceType) using qual_iterator
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const ObjCInterfaceDecl *, getInterface) using qual_iterator
Replaceable canonical proxy adaptor class that provides the link between a canonical type and the acc...
Definition CanonicalType.h:341
Iterator adaptor that turns an iterator over canonical QualTypes into an iterator over CanQualTypes.
Definition CanonicalType.h:411
CanQualType operator*() const
Definition CanonicalType.h:416
CanProxy< Type > operator->() const
Definition CanonicalType.h:683
CanTypeIterator()=default
CanTypeIterator(InputIterator Iter)
Definition CanonicalType.h:413
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
static clang::CanQual< T > getFromVoidPointer(void *P)
Definition CanonicalType.h:386
static constexpr int NumLowBitsAvailable
Definition CanonicalType.h:391
static void * getAsVoidPointer(clang::CanQual< T > P)
Definition CanonicalType.h:382
const T * SimpleType
Definition CanonicalType.h:372
static SimpleType getSimplifiedValue(::clang::CanQual< T > Val)
Definition CanonicalType.h:374