clang: include/clang/AST/TemplateName.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_CLANG_AST_TEMPLATENAME_H

14#define LLVM_CLANG_AST_TEMPLATENAME_H

15

21#include "llvm/ADT/FoldingSet.h"

22#include "llvm/ADT/PointerIntPair.h"

23#include "llvm/ADT/PointerUnion.h"

24#include "llvm/Support/PointerLikeTypeTraits.h"

25#include

26#include

27

29

48

49

50

52protected:

60

62 LLVM_PREFERRED_TYPE(Kind)

64

65

67

68

69

71 };

72

73 union {

76 };

77

83

84public:

90

96

102

108

114};

115

116

117

120

121 OverloadedTemplateStorage(unsigned size)

123

125 return reinterpret_cast<NamedDecl **>(this + 1);

126 }

127 NamedDecl * const *getStorage() const {

128 return reinterpret_cast<NamedDecl *const *>(this + 1);

129 }

130

131public:

132 unsigned size() const { return Bits.Data; }

133

135

138

142};

143

144

145

146

147

148

149

151 public llvm::FoldingSetNode {

153 llvm::PointerIntPair<Decl *, 1, bool> AssociatedDeclAndFinal;

154

155public:

157 Decl *AssociatedDecl, unsigned Index,

158 bool Final);

159

160

161

163

164

165

167

168

169 bool getFinal() const;

170

171

173

174

175

177

178 void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context);

179

180 static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,

182 unsigned Index, bool Final);

183};

184

186

187

190

191 operator bool() const { return Args.empty(); }

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

222class TemplateName {

223

224

225

226

227 using StorageType =

230

231 StorageType Storage;

232

233 explicit TemplateName(void *Ptr);

234

235public:

236

238

240

241

243

244

245

247

248

249

251

252

253

255

256

257

259

260

261

262

264

265

266

268

269

270

272 };

273

284

285

287

288

290

291

292

293

294

295

296

297

299

300

301

302

303 std::pair<TemplateName, DefaultArguments>

305

306

307

308

309

310

311

312

314

315

316

318

319

320

321

322

323

325

326

327

328

329

330

333

334

335

337

338

339

341

342

343

345

349

350

351

353

354

356

357 std::optional desugar(bool IgnoreDeduced) const;

358

360

361 TemplateNameDependence getDependence() const;

362

363

364 bool isDependent() const;

365

366

367

368 bool isInstantiationDependent() const;

369

370

371

372 bool containsUnexpandedParameterPack() const;

373

375

376

377

378

379

380

381

382

384 Qualified Qual = Qualified::AsWritten) const;

385

386

388

389

390

391 void dump() const;

392

393 void Profile(llvm::FoldingSetNodeID &ID) {

394 ID.AddPointer(Storage.getOpaqueValue());

395 }

396

397

399

400

402 return TemplateName(Ptr);

403 }

404

405

408};

409

410

411

412const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,

414

415

416

417class SubstTemplateTemplateParmStorage

420

422 Decl *AssociatedDecl;

423

424 SubstTemplateTemplateParmStorage(TemplateName Replacement,

425 Decl *AssociatedDecl, unsigned Index,

429 ((PackIndex.toInternalRepresentation()) << 1) | Final),

430 Replacement(Replacement), AssociatedDecl(AssociatedDecl) {

431 assert(AssociatedDecl != nullptr);

432 }

433

434public:

435

436

438

439

440

442

443

444

446

450

453

454 void Profile(llvm::FoldingSetNodeID &ID);

455

456 static void Profile(llvm::FoldingSetNodeID &ID, TemplateName Replacement,

457 Decl *AssociatedDecl, unsigned Index,

459};

460

462 public llvm::FoldingSetNode {

464

466

467 DeducedTemplateStorage(TemplateName Underlying,

469

470public:

472

478

479 void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const;

480

481 static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,

483};

484

491

492

493

494

495

496

497

498

499

500

501

502

503

504class QualifiedTemplateName : public llvm::FoldingSetNode {

506

507

508

509

510

511

512

513

514 llvm::PointerIntPair<NestedNameSpecifier, 1, bool> Qualifier;

515

516

517

518

519

520

522

525 : Qualifier(NNS, TemplateKeyword ? 1 : 0), UnderlyingTemplate(Template) {

528 }

529

530public:

531

533

534

535

537

538

540

541 void Profile(llvm::FoldingSetNodeID &ID) {

543 }

544

548 ID.AddBoolean(TemplateKeyword);

550 }

551};

552

557

558

561 return nullptr;

562 return reinterpret_cast<const IdentifierInfo *>(PtrOrOp);

563 }

564

565

571

572 void Profile(llvm::FoldingSetNodeID &ID) const;

573

575 return PtrOrOp == Other.PtrOrOp;

576 };

577

578private:

580};

581

582

583

584

585

586

587

588

589

591

592

593

594

595

596 llvm::PointerIntPair<NestedNameSpecifier, 1, bool> Qualifier;

597

598

600

601public:

604 bool HasTemplateKeyword);

605

606

608

610

611

613

614 TemplateNameDependence getDependence() const;

615

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

618 }

619

622 bool HasTemplateKeyword) {

624 ID.AddBoolean(HasTemplateKeyword);

625 Name.Profile(ID);

626 }

627

629};

630

631class DependentTemplateName : public DependentTemplateStorage,

632 public llvm::FoldingSetNode {

635 DependentTemplateName(const DependentTemplateStorage &S)

636 : DependentTemplateStorage(S) {}

637};

638

639}

640

641namespace llvm {

642

643

644template<>

657

658}

659

660#endif

static llvm::GlobalValue::DLLStorageClassTypes getStorage(CodeGenModule &CGM, StringRef Name)

static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)

static Decl::Kind getKind(const Decl *D)

static void print(llvm::raw_ostream &OS, const T &V, ASTContext &ASTCtx, QualType Ty)

Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.

Defines an enumeration for C++ overloaded operators.

Defines clang::UnsignedOrNone.

Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...

A structure for storing the information associated with a name that has been assumed to be a template...

Decl - This represents one declaration (or definition), e.g.

Definition TemplateName.h:462

TemplateName getUnderlying() const

Definition TemplateName.h:471

friend class ASTContext

Definition TemplateName.h:463

DefaultArguments getDefaultArguments() const

Definition TemplateName.h:473

Definition TemplateName.h:632

friend class ASTContext

Definition TemplateName.h:633

void Profile(llvm::FoldingSetNodeID &ID) const

Definition TemplateName.h:616

IdentifierOrOverloadedOperator getName() const

Definition TemplateName.h:609

NestedNameSpecifier getQualifier() const

Return the nested name specifier that qualifies this name.

Definition TemplateName.h:607

DependentTemplateStorage(NestedNameSpecifier Qualifier, IdentifierOrOverloadedOperator Name, bool HasTemplateKeyword)

static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier NNS, IdentifierOrOverloadedOperator Name, bool HasTemplateKeyword)

Definition TemplateName.h:620

bool hasTemplateKeyword() const

Was this template name was preceeded by the template keyword?

Definition TemplateName.h:612

One of these records is kept for each identifier that is lexed.

This represents a decl that may have a name.

Represents a C++ nested name specifier, such as "\::std::vector::".

void Profile(llvm::FoldingSetNodeID &ID) const

A structure for storing the information associated with an overloaded template name.

Definition TemplateName.h:118

iterator end() const

Definition TemplateName.h:137

unsigned size() const

Definition TemplateName.h:132

friend class ASTContext

Definition TemplateName.h:119

iterator begin() const

Definition TemplateName.h:136

llvm::ArrayRef< NamedDecl * > decls() const

Definition TemplateName.h:139

NamedDecl *const * iterator

Definition TemplateName.h:134

Represents a template name as written in source code.

Definition TemplateName.h:504

NestedNameSpecifier getQualifier() const

Return the nested name specifier that qualifies this name.

Definition TemplateName.h:532

friend class ASTContext

Definition TemplateName.h:505

static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier NNS, bool TemplateKeyword, TemplateName TN)

Definition TemplateName.h:545

void Profile(llvm::FoldingSetNodeID &ID)

Definition TemplateName.h:541

TemplateName getUnderlyingTemplate() const

Return the underlying template name.

Definition TemplateName.h:539

bool hasTemplateKeyword() const

Whether the template name was prefixed by the "template" keyword.

Definition TemplateName.h:536

A structure for storing an already-substituted template template parameter pack.

Definition TemplateName.h:151

Decl * getAssociatedDecl() const

A template-like entity which owns the whole pattern being substituted.

unsigned getIndex() const

Returns the index of the replaced parameter in the associated declaration.

Definition TemplateName.h:166

SubstTemplateTemplateParmPackStorage(ArrayRef< TemplateArgument > ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final)

A structure for storing the information associated with a substituted template template parameter.

Definition TemplateName.h:418

TemplateName getReplacement() const

Definition TemplateName.h:452

bool getFinal() const

Definition TemplateName.h:445

UnsignedOrNone getPackIndex() const

Definition TemplateName.h:447

friend class ASTContext

Definition TemplateName.h:419

unsigned getIndex() const

Returns the index of the replaced parameter in the associated declaration.

Definition TemplateName.h:441

Decl * getAssociatedDecl() const

A template-like entity which owns the whole pattern being substituted.

Definition TemplateName.h:437

Represents a template argument.

The base class of all kinds of template declarations (e.g., class, function, etc.).

Represents a C++ template name within the type system.

Definition TemplateName.h:222

TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const

Retrieve the underlying template declaration that this template name refers to, if known.

bool isNull() const

Determine whether this template name is NULL.

bool operator==(TemplateName Other) const

Structural equality.

Definition TemplateName.h:406

DependentTemplateName * getAsDependentTemplateName() const

Retrieve the underlying dependent template name structure, if any.

QualifiedTemplateName * getAsQualifiedTemplateName() const

Retrieve the underlying qualified template name structure, if any.

NestedNameSpecifier getQualifier() const

Definition TemplateName.h:346

OverloadedTemplateStorage * getAsOverloadedTemplate() const

Retrieve the underlying, overloaded function template declarations that this template name refers to,...

AssumedTemplateStorage * getAsAssumedTemplateName() const

Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...

std::pair< TemplateName, DefaultArguments > getTemplateDeclAndDefaultArgs() const

Retrieves the underlying template name that this template name refers to, along with the deduced defa...

Qualified

Definition TemplateName.h:374

@ None

Definition TemplateName.h:374

@ AsWritten

Definition TemplateName.h:374

static TemplateName getFromVoidPointer(void *Ptr)

Build a template name from a void pointer.

Definition TemplateName.h:401

bool operator!=(TemplateName Other) const

Definition TemplateName.h:407

void * getAsVoidPointer() const

Retrieve the template name as a void pointer.

Definition TemplateName.h:398

NameKind

Definition TemplateName.h:237

@ UsingTemplate

A template name that refers to a template declaration found through a specific using shadow declarati...

Definition TemplateName.h:267

@ OverloadedTemplate

A set of overloaded template declarations.

Definition TemplateName.h:242

@ Template

A single template declaration.

Definition TemplateName.h:239

@ DependentTemplate

A dependent template name that has not been resolved to a template (or set of templates).

Definition TemplateName.h:254

@ SubstTemplateTemplateParm

A template template parameter that has been substituted for some other template name.

Definition TemplateName.h:258

@ SubstTemplateTemplateParmPack

A template template parameter pack that has been substituted for a template template argument pack,...

Definition TemplateName.h:263

@ DeducedTemplate

A template name that refers to another TemplateName with deduced default arguments.

Definition TemplateName.h:271

@ QualifiedTemplate

A qualified template name, where the qualification is kept to describe the source code as written.

Definition TemplateName.h:250

@ AssumedTemplate

An unqualified-id that has been assumed to name a function template that will be found by ADL.

Definition TemplateName.h:246

SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const

Retrieve the substituted template template parameter pack, if known.

void Profile(llvm::FoldingSetNodeID &ID)

Definition TemplateName.h:393

TemplateName getUnderlying() const

Definition TemplateName.h:485

SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const

Retrieve the substituted template template parameter, if known.

std::tuple< NestedNameSpecifier, bool > getQualifierAndTemplateKeyword() const

void dump(raw_ostream &OS, const ASTContext &Context) const

Debugging aid that dumps the template name.

TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.

Implementation class used to describe either a set of overloaded template names or an already-substit...

Definition TemplateName.h:51

SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack()

Definition TemplateName.h:109

UncommonTemplateNameStorage(Kind Kind, unsigned Index, unsigned Data)

Definition TemplateName.h:78

Kind

Definition TemplateName.h:53

@ SubstTemplateTemplateParm

Definition TemplateName.h:57

@ Assumed

Definition TemplateName.h:55

@ SubstTemplateTemplateParmPack

Definition TemplateName.h:58

@ Deduced

Definition TemplateName.h:56

@ Overloaded

Definition TemplateName.h:54

SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm()

Definition TemplateName.h:103

AssumedTemplateStorage * getAsAssumedTemplateName()

Definition TemplateName.h:91

void * PointerAlignment

Definition TemplateName.h:75

DeducedTemplateStorage * getAsDeducedTemplateName()

Definition TemplateName.h:97

struct BitsTag Bits

Definition TemplateName.h:74

OverloadedTemplateStorage * getAsOverloadedStorage()

Definition TemplateName.h:85

Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...

The JSON file list parser is used to communicate input to InstallAPI.

OverloadedOperatorKind

Enumeration specifying the different kinds of C++ overloaded operators.

@ OO_None

Not an overloaded operator.

@ NUM_OVERLOADED_OPERATORS

@ TemplateName

The identifier is a template name. FIXME: Add an annotation for that.

@ Template

We are parsing a template declaration.

const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)

Insertion operator for diagnostics.

@ Other

Other implicit parameter.

__UINTPTR_TYPE__ uintptr_t

An unsigned integer type with the property that any valid pointer to void can be converted to this ty...

Definition TemplateName.h:185

unsigned StartPos

Definition TemplateName.h:188

ArrayRef< TemplateArgument > Args

Definition TemplateName.h:189

Definition TemplateName.h:553

IdentifierOrOverloadedOperator()=default

const IdentifierInfo * getIdentifier() const

Returns the identifier to which this template name refers.

Definition TemplateName.h:559

bool operator==(const IdentifierOrOverloadedOperator &Other) const

Definition TemplateName.h:574

OverloadedOperatorKind getOperator() const

Return the overloaded operator to which this template name refers.

Definition TemplateName.h:566

Describes how types, statements, expressions, and declarations should be printed.

Definition TemplateName.h:61

unsigned Index

Definition TemplateName.h:66

unsigned Kind

Definition TemplateName.h:63

unsigned Data

The pack index, or the number of stored templates or template arguments, depending on which subclass ...

Definition TemplateName.h:70

static constexpr UnsignedOrNone fromInternalRepresentation(unsigned Rep)

static void * getAsVoidPointer(clang::TemplateName TN)

Definition TemplateName.h:646

static constexpr int NumLowBitsAvailable

Definition TemplateName.h:655

static clang::TemplateName getFromVoidPointer(void *Ptr)

Definition TemplateName.h:650