14#ifndef LLVM_CLANG_AST_CANONICALTYPE_H
15#define LLVM_CLANG_AST_CANONICALTYPE_H
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"
65template<
typename T = Type>
78 std::enable_if_t<std::is_base_of<T, U>::value,
int> = 0);
89 return cast_or_null<T>(Stored.getTypePtrOrNull());
99 return Stored.isNull();
139 return Stored.isLocalConstQualified();
143 return Stored.isLocalVolatileQualified();
147 return Stored.isLocalRestrictQualified();
154 return Stored.isCanonicalAsParam();
169 return Stored.isMoreQualifiedThan(
Other.Stored, Ctx);
175 return Stored.isAtLeastAsQualifiedAs(
Other.Stored, Ctx);
195 void dump()
const { Stored.dump(); }
197 void Profile(llvm::FoldingSetNodeID &ID)
const {
202template<
typename T,
typename U>
207template<
typename T,
typename U>
221 DB << static_cast<QualType>(
T);
229#define LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(Accessor) \
230CanQualType Accessor() const { \
231return CanQualType::CreateUnsafe(this->getTypePtr()->Accessor()); \
234#define LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Type, Accessor) \
235Type Accessor() const { return this->getTypePtr()->Accessor(); }
260 return this->Stored.template
getAs<U>();
403template <
typename InputIterator>
405 : llvm::iterator_adaptor_base<
406 CanTypeIterator<InputIterator>, InputIterator,
407 typename std::iterator_traits<InputIterator>::iterator_category,
409 typename std::iterator_traits<InputIterator>::difference_type,
410 CanProxy<Type>, CanQualType> {
458 getMostRecentCXXRecordDecl)
627 return RefType->getPointeeType();
636 assert((!
Result ||
Result.Stored.getAsOpaquePtr() == (
void*)-1 ||
637 Result.Stored.isCanonical()) &&
"Type is not canonical!");
643 assert((
Other.isNull() ||
Other.isCanonical()) &&
"Type is not canonical!");
645 "Dynamic type does not meet the static type's requires");
655 "ArrayType cannot be used with getAs!");
660 if (
isa<U>(Stored.getTypePtr()))
670 "ArrayType cannot be used with castAs!");
672 assert(!Stored.isNull() &&
isa<U>(Stored.getTypePtr()));
681template <
typename InputIterator>
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)
#define LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Type, Accessor)
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...
CanProxy< U > getAs() const
Try to convert the given canonical type to a specific structural type.
const T * getTypePtr() const
Retrieve the pointer to the underlying Type.
Canonical proxy type returned when retrieving the members of a canonical type or as the result of the...
CanProxy(CanQual< T > Stored)
Build a proxy to the given canonical type.
CanProxy()=default
Build a NULL proxy.
Represents a canonical, potentially-qualified type.
void * getAsOpaquePtr() const
Retrieve the internal representation of this canonical type.
CanQual< Type > getNonReferenceType() const
If the canonical type is a reference type, returns the type that it refers to; otherwise,...
CanQual()=default
Constructs a NULL canonical type.
const T * getTypePtrOrNull() const
Retrieve the underlying type pointer, which refers to a canonical type, or nullptr.
bool isMoreQualifiedThan(CanQual< T > Other, const ASTContext &Ctx) const
Determines whether this canonical type is more qualified than the Other canonical type.
bool isRestrictQualified() const
unsigned getCVRQualifiers() const
Retrieve the const/volatile/restrict qualifiers.
CanProxy< T > operator->() const
Overloaded arrow operator that produces a canonical type proxy.
SplitQualType split() const
bool hasQualifiers() const
Determines whether this type has any qualifiers.
bool isAtLeastAsQualifiedAs(CanQual< T > Other, const ASTContext &Ctx) const
Determines whether this canonical type is at least as qualified as the Other canonical type.
static CanQual< T > CreateUnsafe(QualType Other)
Builds a canonical type from a QualType.
QualType withConst() const
Retrieves a version of this type with const applied.
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
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
bool isConstQualified() const
bool isCanonicalAsParam() const
Determines if this canonical type is furthermore canonical as a parameter.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
void Profile(llvm::FoldingSetNodeID &ID) const
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
static CanQual< T > getFromOpaquePtr(void *Ptr)
Construct a canonical type from its internal representation.
bool isVolatileQualified() const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
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<int>::".
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
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.
bool isa(CodeGen::Address addr)
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
@ 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)
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
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayRef< FunctionProtoType::ExtParameterInfo >, getExtParameterInfos) CanQualType getParamType(unsigned i) const
param_type_iterator param_type_end() const
param_type_iterator param_type_begin() const
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...
Iterator adaptor that turns an iterator over canonical QualTypes into an iterator over CanQualTypes.
CanQualType operator*() const
CanProxy< Type > operator->() const
CanTypeIterator()=default
CanTypeIterator(InputIterator Iter)
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)
static constexpr int NumLowBitsAvailable
static void * getAsVoidPointer(clang::CanQual< T > P)
static SimpleType getSimplifiedValue(::clang::CanQual< T > Val)