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;

32template struct CanProxyAdaptor;

33class ASTContext;

34class CXXRecordDecl;

35class EnumDecl;

36class Expr;

37class IdentifierInfo;

38class ObjCInterfaceDecl;

39class RecordDecl;

40class TagDecl;

41class TemplateTypeParmDecl;

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

90 }

91

92

93 operator QualType() const { return Stored; }

94

95

96 explicit operator bool() const { return isNull(); }

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

134

135

137

140 }

141

144 }

145

148 }

149

150

151

152

155 }

156

157

159

160

161

164 }

165

166

167

170 }

171

172

173

176 }

177

178

179

181

182

184

185

187

188

189

190

191

192

194

196

197 void Profile(llvm::FoldingSetNodeID &ID) const {

199 }

200};

201

202template<typename T, typename U>

205}

206

207template<typename T, typename U>

210}

211

212

214

217}

218

221 DB << static_cast(T);

222 return DB;

223}

224

225

226

227

228

229#define LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(Accessor) \

230CanQualType Accessor() const { \

231return CanQualType::CreateUnsafe(this->getTypePtr()->Accessor()); \

232}

233

234#define LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Type, Accessor) \

235Type Accessor() const { return this->getTypePtr()->Accessor(); }

236

237

238

239template

241protected:

243

244public:

245

247

248

249

250

251

252

253

254

256

257

258

260 return this->Stored.template getAs();

261 }

262

264

265

317

318

319

320

321

322

323

326 }

327};

328

329

330

331

332

333

334

335

336

337

338

339template

341

342

343

344

345

346

347

348

349template

351public:

352

354

355

357

358

360};

361

362}

363

364namespace llvm {

365

366

367

368

369template

372

375 }

376};

377

378

379template

382 return P.getAsOpaquePtr();

383 }

384

387 }

388

389

390 static constexpr int NumLowBitsAvailable = 0;

391};

392

393}

394

396

397

398

399

400

401

402

403template

405 : llvm::iterator_adaptor_base<

406 CanTypeIterator, InputIterator,

407 typename std::iterator_traits::iterator_category,

408 CanQualType,

409 typename std::iterator_traits::difference_type,

410 CanProxy, CanQualType> {

414

417};

418

419template<>

422};

423

424template<>

427};

428

429template<>

433};

434

435template<>

438};

439

440template<>

444};

445

446template<>

450};

451

452template<>

457};

458

459

460

466

467template<>

469 : public CanProxyBase {

473};

474

475template<>

479};

480

481template<>

485};

486

487template<>

491};

492

493template<>

498};

499

500template<>

509

512 }

513

516

519

522 }

523

526 }

527

528

529};

530

531template<>

534};

535

536template<>

540};

541

542template <>

548};

549

550template<>

554};

555

556template<>

561};

562

563template<>

567};

568

569template<>

571 : public CanProxyBase {

577};

578

579template<>

584 getInterface)

589

591

596};

597

598template<>

603 getInterfaceType)

608

610

615};

616

617

618

619

620template<typename T>

623}

624

625template

628 return RefType->getPointeeType();

629 else

630 return *this;

631}

632

633template

637 assert((Result || 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!");

645 assert((Other.isNull() || isa(Other.getTypePtr())) &&

646 "Dynamic type does not meet the static type's requires");

650}

651

652template

653template

656 "ArrayType cannot be used with getAs!");

657

660

663

665}

666

667template

668template

671 "ArrayType cannot be used with castAs!");

672

675}

676

677template

680}

681

682template

685}

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)

#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 the type decltype(expr) (C++11).

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.

A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.

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 an ObjC class declaration.

Interfaces are the core concept in Objective-C for object oriented design.

Represents a pointer to an Objective C object.

Represents a class type in Objective C.

PointerType - C99 6.7.5.1 - Pointer Declarators.

A (possibly-)qualified type.

bool isLocalConstQualified() const

Determine whether this particular QualType instance has the "const" qualifier set,...

bool isLocalRestrictQualified() const

Determine whether this particular QualType instance has the "restrict" qualifier set,...

QualType withConst() const

bool hasLocalQualifiers() const

Determine whether this particular QualType instance has any qualifiers, without looking through any t...

bool isNull() const

Return true if this QualType doesn't point to a type yet.

const Type * getTypePtr() const

Retrieves a pointer to the underlying (unqualified) type.

static QualType getFromOpaquePtr(const void *Ptr)

void dump(const char *s) const

unsigned getLocalCVRQualifiers() const

Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...

SplitQualType split() const

Divides a QualType into its unqualified type and a set of local qualifiers.

void * getAsOpaquePtr() const

bool isMoreQualifiedThan(QualType Other, const ASTContext &Ctx) const

Determine whether this type is more qualified than the other given type, requiring exact equality for...

bool isCanonicalAsParam() const

bool isLocalVolatileQualified() const

Determine whether this particular QualType instance has the "volatile" qualifier set,...

const Type * getTypePtrOrNull() const

bool isAtLeastAsQualifiedAs(QualType Other, const ASTContext &Ctx) const

Determine whether this type is at least as qualified as the other given type, requiring exact equalit...

Qualifiers getLocalQualifiers() const

Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...

The collection of all-type qualifiers we support.

An rvalue reference type, per C++11 [dcl.ref].

Represents a struct/union/class.

A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...

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.

Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...

The base class of the type hierarchy.

CanQualType getCanonicalTypeUnqualified() const

QualType getCanonicalTypeInternal() const

A unary type transform, which is a type constructed from another.

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.

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.

bool operator!=(CanQual< T > x, CanQual< U > y)

std::integral_constant< bool, std::is_same< T, ArrayType >::value||std::is_base_of< ArrayType, T >::value > TypeIsArrayType

const FunctionProtoType * T

@ Other

Other implicit parameter.

Diagnostic wrappers for TextAPI types for error reporting.

param_type_iterator param_type_end() const

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 void * getAsVoidPointer(clang::CanQual< T > P)

static SimpleType getSimplifiedValue(::clang::CanQual< T > Val)