clang: include/clang/Serialization/ASTWriter.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CLANG_SERIALIZATION_ASTWRITER_H

15#define LLVM_CLANG_SERIALIZATION_ASTWRITER_H

16

28#include "llvm/ADT/ArrayRef.h"

29#include "llvm/ADT/DenseMap.h"

30#include "llvm/ADT/DenseSet.h"

31#include "llvm/ADT/MapVector.h"

32#include "llvm/ADT/STLExtras.h"

33#include "llvm/ADT/SetVector.h"

34#include "llvm/ADT/SmallVector.h"

35#include "llvm/ADT/StringRef.h"

36#include "llvm/Bitstream/BitstreamWriter.h"

37#include

38#include

39#include

40#include

41#include

42#include

43#include

44#include

45#include

46

48

49class ASTContext;

50class ASTReader;

51class Attr;

52class CXXRecordDecl;

53class FileEntry;

54class FPOptionsOverride;

55class FunctionDecl;

57class HeaderSearchOptions;

58class IdentifierResolver;

59class LangOptions;

60class MacroDefinitionRecord;

61class MacroInfo;

63class InMemoryModuleCache;

64class ModuleFileExtension;

65class ModuleFileExtensionWriter;

66class NamedDecl;

67class ObjCInterfaceDecl;

68class PreprocessingRecord;

69class Preprocessor;

70class RecordDecl;

71class Sema;

72class SourceManager;

73class Stmt;

74class StoredDeclsList;

75class SwitchCase;

76class Token;

77

78namespace SrcMgr {

79class FileInfo;

80}

81

82

83

84

85

86

87

90public:

93

97

98private:

99

100

101

102

103

104

105

106

107

110

112

113

114 llvm::BitstreamWriter &Stream;

115

116

118

119

121

122

124

125

127

128

129 Module *WritingModule = nullptr;

130

131

132 std::pair<uint64_t, uint64_t> UnhashedControlBlockRange;

133

134 uint64_t ASTBlockHashOffset = 0;

135

136 uint64_t SignatureOffset = 0;

137

138

139 uint64_t ASTBlockStartOffset = 0;

140

141

142 std::pair<uint64_t, uint64_t> ASTBlockRange;

143

144

145 std::string BaseDirectory;

146

147

148

149

150

151 bool IncludeTimestamps;

152

153

154

155

156 bool BuildingImplicitModule = false;

157

158

159

160 bool WritingAST = false;

161

162

163

164 bool DoneWritingDeclsAndTypes = false;

165

166

167 bool ASTHasCompilerErrors = false;

168

169

170

171 bool GeneratingReducedBMI = false;

172

173

174

175 llvm::DenseMap<const FileEntry *, uint32_t> InputFileIDs;

176

177

178 class DeclOrType {

179 public:

180 DeclOrType(Decl *D) : Stored(D), IsType(false) {}

181 DeclOrType(QualType T) : Stored(T.getAsOpaquePtr()), IsType(true) {}

182

183 bool isType() const { return IsType; }

184 bool isDecl() const { return !IsType; }

185

187 assert(isType() && "Not a type!");

189 }

190

191 Decl *getDecl() const {

192 assert(isDecl() && "Not a decl!");

193 return static_cast<Decl *>(Stored);

194 }

195

196 private:

197 void *Stored;

198 bool IsType;

199 };

200

201

202 std::queue DeclTypesToEmit;

203

204

205

206

207

208

209

210

211

213

214

216

217

219

220

221

222

223

224

225

226 llvm::DenseMap<const Decl *, LocalDeclID> DeclIDs;

227

228

229

230

232

233

234

235

236

237

238 llvm::DenseMap<LocalDeclID, SmallVector<LocalDeclID, 4>> RelatedDeclsMap;

239

240

241

242 std::vectorserialization::DeclOffset DeclOffsets;

243

244

245

246 uint64_t DeclTypesBlockStartOffset = 0;

247

248

250 struct DeclIDInFileInfo {

251 LocDeclIDsTy DeclIDs;

252

253

254

255 unsigned FirstDeclIndex;

256 };

257 using FileDeclIDsTy =

258 llvm::DenseMap<FileID, std::unique_ptr>;

259

260

261

262 FileDeclIDsTy FileDeclIDs;

263

264 void associateDeclWithFile(const Decl *D, LocalDeclID);

265

266

268

269

271

272

273

274

275

276

277

278

279

280

281 TypeIdxMap TypeIdxs;

282

283

284

285 std::vectorserialization::UnalignedUInt64 TypeOffsets;

286

287

289

290

292

293

294

295

296

297

298

299 llvm::MapVector<const IdentifierInfo *, serialization::IdentifierID> IdentifierIDs;

300

301

303

304

306

307

308 llvm::DenseMap<MacroInfo *, serialization::MacroID> MacroIDs;

309

310 struct MacroInfoToEmitData {

311 const IdentifierInfo *Name;

312 MacroInfo *MI;

314 };

315

316

317 std::vector MacroInfosToEmit;

318

319 llvm::DenseMap<const IdentifierInfo *, uint32_t>

320 IdentMacroDirectivesOffsetMap;

321

322

323

324

325

326 llvm::DenseSet<Stmt *> ParentStmts;

327

328

329

330 llvm::DenseMap<Stmt *, uint64_t> SubStmtEntries;

331

332

333

334

335

336 std::vector<uint32_t> IdentifierOffsets;

337

338

341

342

344

345

348

349

351

352

353 llvm::MapVector<Selector, serialization::SelectorID> SelectorIDs;

354

355

356

357 std::vector<uint32_t> SelectorOffsets;

358

359

360

361 llvm::DenseMap<const MacroDefinitionRecord *,

363

364

365

366 llvm::DenseMap<const Decl *, unsigned> AnonymousDeclarationNumbers;

367

368

369

370

371

372

373 llvm::DenseSet<Module *> TouchedTopLevelModules;

374

375

376 class DeclUpdate {

377

378 unsigned Kind;

379 union {

380 const Decl *Dcl;

383 unsigned Val;

385 const Attr *Attribute;

386 };

387

388 public:

389 DeclUpdate(unsigned Kind) : Kind(Kind), Dcl(nullptr) {}

390 DeclUpdate(unsigned Kind, const Decl *Dcl) : Kind(Kind), Dcl(Dcl) {}

391 DeclUpdate(unsigned Kind, QualType Type)

393 DeclUpdate(unsigned Kind, SourceLocation Loc)

395 DeclUpdate(unsigned Kind, unsigned Val) : Kind(Kind), Val(Val) {}

396 DeclUpdate(unsigned Kind, Module *M) : Kind(Kind), Mod(M) {}

397 DeclUpdate(unsigned Kind, const Attr *Attribute)

398 : Kind(Kind), Attribute(Attribute) {}

399

400 unsigned getKind() const { return Kind; }

401 const Decl *getDecl() const { return Dcl; }

403

404 SourceLocation getLoc() const {

406 }

407

408 unsigned getNumber() const { return Val; }

409 Module *getModule() const { return Mod; }

410 const Attr *getAttr() const { return Attribute; }

411 };

412

413 using UpdateRecord = SmallVector<DeclUpdate, 1>;

414 using DeclUpdateMap = llvm::MapVector<const Decl *, UpdateRecord>;

415

416

417

418 DeclUpdateMap DeclUpdates;

419

420

421

422

423 DeclUpdateMap DeclUpdatesFromGMF;

424

425

426

427 using SpecializationUpdateMap =

428 llvm::MapVector<const NamedDecl *, SmallVector<const Decl *>>;

429 SpecializationUpdateMap SpecializationsUpdates;

430 SpecializationUpdateMap PartialSpecializationsUpdates;

431

432 using FirstLatestDeclMap = llvm::DenseMap<Decl *, Decl *>;

433

434

435

436 FirstLatestDeclMap FirstLatestDecls;

437

438

439

440

441

442

443

444

445

446

447

448

451

452

453

454

455

456

457

458

460

461

462

463

464 SmallVector<const Decl *, 16> DeclsToEmitEvenIfUnreferenced;

465

466

467

468 llvm::SetVector<ObjCInterfaceDecl *> ObjCClassesWithCategories;

469

470

471

473

474

475

476 llvm::DenseMap<const Decl *, const Decl *> FirstLocalDeclCache;

477

478

479 llvm::DenseMap<SwitchCase *, unsigned> SwitchCaseIDs;

480

481

482 unsigned NumStatements = 0;

483

484

485 unsigned NumMacros = 0;

486

487

488

489 unsigned NumLexicalDeclContexts = 0;

490

491

492

493 unsigned NumVisibleDeclContexts = 0;

494

495

496

497 unsigned NumModuleLocalDeclContexts = 0;

498

499

500 unsigned NumTULocalDeclContexts = 0;

501

502

503

504 llvm::DenseMap<const Module *, unsigned> SubmoduleIDs;

505

506

507 std::vector<std::unique_ptr>

508 ModuleFileExtensionWriters;

509

510

511 llvm::BitVector IsSLocAffecting;

512

513

514 llvm::BitVector IsSLocFileEntryAffecting;

515

516

517 std::vector NonAffectingFileIDs;

518 std::vector NonAffectingFileIDAdjustments;

519

520

521 std::vector NonAffectingRanges;

522 std::vectorSourceLocation::UIntTy NonAffectingOffsetAdjustments;

523

524

525

527

528

529

530

531 void computeNonAffectingInputFiles();

532

533

534

535 SourceLocation getAffectingIncludeLoc(const SourceManager &SourceMgr,

536 const SrcMgr::FileInfo &File);

537

538

539

540 FileID getAdjustedFileID(FileID FID) const;

541

542

543 unsigned getAdjustedNumCreatedFIDs(FileID FID) const;

544

545

546 SourceLocation getAdjustedLocation(SourceLocation Loc) const;

547

548

549 SourceRange getAdjustedRange(SourceRange Range) const;

550

551

553

554

556

557

558 unsigned getSubmoduleID(Module *Mod);

559

560

561 void WriteSubStmt(ASTContext &Context, Stmt *S);

562

563 void WriteBlockInfoBlock();

564 void WriteControlBlock(Preprocessor &PP, StringRef isysroot);

565

566

567 void writeUnhashedControlBlock(Preprocessor &PP);

568 ASTFileSignature backpatchSignature();

569

570

571 std::pair<ASTFileSignature, ASTFileSignature> createSignature() const;

572 ASTFileSignature createSignatureForNamedModule() const;

573

574 void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts);

575 void WriteSourceManagerBlock(SourceManager &SourceMgr);

576 void WritePreprocessor(const Preprocessor &PP, bool IsModule);

577 void WriteHeaderSearch(const HeaderSearch &HS);

578 void WritePreprocessorDetail(PreprocessingRecord &PPRec,

579 uint64_t MacroOffsetsBase);

580 void WriteSubmodules(Module *WritingModule, ASTContext *Context);

581

582 void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,

583 bool isModule);

584

585 unsigned TypeExtQualAbbrev = 0;

586 void WriteTypeAbbrevs();

587 void WriteType(ASTContext &Context, QualType T);

588

589 bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);

590

591 void GenerateSpecializationInfoLookupTable(

594 uint64_t WriteSpecializationInfoLookupTable(

596 bool IsPartial);

597 void

598 GenerateNameLookupTable(ASTContext &Context, const DeclContext *DC,

602 uint64_t WriteDeclContextLexicalBlock(ASTContext &Context,

603 const DeclContext *DC);

604 void WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC,

605 uint64_t &VisibleBlockOffset,

606 uint64_t &ModuleLocalBlockOffset,

607 uint64_t &TULocalBlockOffset);

608 void WriteTypeDeclOffsets();

609 void WriteFileDeclIDsMap();

610 void WriteComments(ASTContext &Context);

611 void WriteSelectors(Sema &SemaRef);

612 void WriteReferencedSelectorsPool(Sema &SemaRef);

613 void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver *IdResolver,

614 bool IsModule);

615 void WriteDeclAndTypes(ASTContext &Context);

616 void PrepareWritingSpecialDecls(Sema &SemaRef);

617 void WriteSpecialDeclRecords(Sema &SemaRef);

618 void WriteSpecializationsUpdates(bool IsPartial);

619 void WriteDeclUpdatesBlocks(ASTContext &Context,

621 void WriteDeclContextVisibleUpdate(ASTContext &Context,

622 const DeclContext *DC);

623 void WriteFPPragmaOptions(const FPOptionsOverride &Opts);

624 void WriteOpenCLExtensions(Sema &SemaRef);

625 void WriteCUDAPragmas(Sema &SemaRef);

626 void WriteObjCCategories();

627 void WriteLateParsedTemplates(Sema &SemaRef);

628 void WriteOptimizePragmaOptions(Sema &SemaRef);

629 void WriteMSStructPragmaOptions(Sema &SemaRef);

630 void WriteMSPointersToMembersPragmaOptions(Sema &SemaRef);

631 void WritePackPragmaOptions(Sema &SemaRef);

632 void WriteFloatControlPragmaOptions(Sema &SemaRef);

633 void WriteDeclsWithEffectsToVerify(Sema &SemaRef);

634 void WriteModuleFileExtension(Sema &SemaRef,

635 ModuleFileExtensionWriter &Writer);

636

637 unsigned DeclParmVarAbbrev = 0;

638 unsigned DeclContextLexicalAbbrev = 0;

639 unsigned DeclContextVisibleLookupAbbrev = 0;

640 unsigned DeclModuleLocalVisibleLookupAbbrev = 0;

641 unsigned DeclTULocalLookupAbbrev = 0;

642 unsigned UpdateVisibleAbbrev = 0;

643 unsigned ModuleLocalUpdateVisibleAbbrev = 0;

644 unsigned TULocalUpdateVisibleAbbrev = 0;

645 unsigned DeclRecordAbbrev = 0;

646 unsigned DeclTypedefAbbrev = 0;

647 unsigned DeclVarAbbrev = 0;

648 unsigned DeclFieldAbbrev = 0;

649 unsigned DeclEnumAbbrev = 0;

650 unsigned DeclObjCIvarAbbrev = 0;

651 unsigned DeclCXXMethodAbbrev = 0;

652 unsigned DeclSpecializationsAbbrev = 0;

653 unsigned DeclPartialSpecializationsAbbrev = 0;

654

655 unsigned DeclDependentNonTemplateCXXMethodAbbrev = 0;

656 unsigned DeclTemplateCXXMethodAbbrev = 0;

657 unsigned DeclMemberSpecializedCXXMethodAbbrev = 0;

658 unsigned DeclTemplateSpecializedCXXMethodAbbrev = 0;

659 unsigned DeclDependentSpecializationCXXMethodAbbrev = 0;

660 unsigned DeclTemplateTypeParmAbbrev = 0;

661 unsigned DeclUsingShadowAbbrev = 0;

662

663 unsigned DeclRefExprAbbrev = 0;

664 unsigned CharacterLiteralAbbrev = 0;

665 unsigned IntegerLiteralAbbrev = 0;

666 unsigned ExprImplicitCastAbbrev = 0;

667 unsigned BinaryOperatorAbbrev = 0;

668 unsigned CompoundAssignOperatorAbbrev = 0;

669 unsigned CallExprAbbrev = 0;

670 unsigned CXXOperatorCallExprAbbrev = 0;

671 unsigned CXXMemberCallExprAbbrev = 0;

672

673 unsigned CompoundStmtAbbrev = 0;

674

675 void WriteDeclAbbrevs();

676 void WriteDecl(ASTContext &Context, Decl *D);

677

678 ASTFileSignature WriteASTCore(Sema *SemaPtr, StringRef isysroot,

679 Module *WritingModule);

680

681public:

682

683

684 ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl &Buffer,

685 InMemoryModuleCache &ModuleCache,

686 ArrayRef<std::shared_ptr> Extensions,

687 bool IncludeTimestamps = true, bool BuildingImplicitModule = false,

688 bool GeneratingReducedBMI = false);

690

692

693

694

695

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

716 StringRef OutputFile, Module *WritingModule,

717 StringRef isysroot,

718 bool ShouldCacheASTInMemory = false);

719

720

722

723

726

727

729

730

733

734

737

738

741

742

744

745

747

748

750

751

753

754

756

758

759

761

762

764

765

766

768

769

770

771

773 if (D->isFromASTFile())

774 return false;

775 auto I = DeclIDs.find(D);

777 };

778

779

781

783

784

785

787

788

789

791

792

793

794

795

796

797

798

800

802

803

807

808

809

811

812

816

817

819 StringRef Path);

820

821

823

824

825

826

828

829

830

832

833

834

836

837

839

840

842

844

846 return TypeExtQualAbbrev;

847 }

848

857 switch (Kind) {

859 return DeclCXXMethodAbbrev;

861 return DeclTemplateCXXMethodAbbrev;

863 return DeclMemberSpecializedCXXMethodAbbrev;

865 return DeclTemplateSpecializedCXXMethodAbbrev;

867 return DeclDependentNonTemplateCXXMethodAbbrev;

869 return DeclDependentSpecializationCXXMethodAbbrev;

870 }

871 llvm_unreachable("Unknwon Template Kind!");

872 }

874 return DeclTemplateTypeParmAbbrev;

875 }

877

884 return CompoundAssignOperatorAbbrev;

885 }

889

891

894

896

898 return WritingModule && WritingModule->isNamedModule();

899 }

900

902

904

906 return PredefinedDecls.count(D);

907 }

908

910

911private:

912

913 void ReaderInitialized(ASTReader *Reader) override;

922

923

924 void CompletedTagDefinition(const TagDecl *D) override;

925 void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override;

926 void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) override;

927 void AddedCXXTemplateSpecialization(

930 void AddedCXXTemplateSpecialization(

935 void ResolvedExceptionSpec(const FunctionDecl *FD) override;

936 void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) override;

939 Expr *ThisArg) override;

940 void CompletedImplicitDefinition(const FunctionDecl *D) override;

941 void InstantiationRequested(const ValueDecl *D) override;

942 void VariableDefinitionInstantiated(const VarDecl *D) override;

943 void FunctionDefinitionInstantiated(const FunctionDecl *D) override;

944 void DefaultArgumentInstantiated(const ParmVarDecl *D) override;

945 void DefaultMemberInitializerInstantiated(const FieldDecl *D) override;

946 void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,

948 void DeclarationMarkedUsed(const Decl *D) override;

949 void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) override;

950 void DeclarationMarkedOpenMPDeclareTarget(const Decl *D,

952 void DeclarationMarkedOpenMPAllocate(const Decl *D, const Attr *A) override;

953 void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) override;

954 void AddedAttributeToRecord(const Attr *Attr,

956 void EnteringModulePurview() override;

957 void AddedManglingNumber(const Decl *D, unsigned) override;

958 void AddedStaticLocalNumbers(const Decl *D, unsigned) override;

961};

962

963

964

966 void anchor() override;

967

969 llvm::PointerUnion<Sema *, Preprocessor *> Subject;

970 std::string OutputFile;

971 std::string isysroot;

972 std::shared_ptr Buffer;

973 llvm::BitstreamWriter Stream;

975 bool AllowASTWithErrors;

976 bool ShouldCacheASTInMemory;

977

978protected:

982

983 bool isComplete() const { return Buffer->IsComplete; }

988

990

991public:

993 StringRef OutputFile, StringRef isysroot,

994 std::shared_ptr Buffer,

995 ArrayRef<std::shared_ptr> Extensions,

996 bool AllowASTWithErrors = false, bool IncludeTimestamps = true,

997 bool BuildingImplicitModule = false,

998 bool ShouldCacheASTInMemory = false,

999 bool GeneratingReducedBMI = false);

1001

1008};

1009

1011 void anchor() override;

1012

1013protected:

1015

1017 StringRef OutputFile, bool GeneratingReducedBMI,

1018 bool AllowASTWithErrors);

1019

1020public:

1022 StringRef OutputFile, bool AllowASTWithErrors = false)

1024 false,

1025 AllowASTWithErrors) {}

1026

1028};

1029

1031 void anchor() override;

1032

1033public:

1035 StringRef OutputFile, bool AllowASTWithErrors = false)

1037 true,

1038 AllowASTWithErrors) {}

1039};

1040

1041

1042

1043

1044

1046

1047

1048

1050 constexpr static uint32_t BitIndexUpbound = 32u;

1051

1052public:

1059

1061 return CurrentBitIndex + BitsWidth < BitIndexUpbound;

1062 }

1063

1065 UnderlyingValue = Value;

1066 CurrentBitIndex = 0;

1067 }

1068

1071 assert(BitsWidth < BitIndexUpbound);

1072 assert((Value < (1u << BitsWidth)) && "Passing narrower bit width!");

1074 "Inserting too much bits into a value!");

1075

1076 UnderlyingValue |= Value << CurrentBitIndex;

1077 CurrentBitIndex += BitsWidth;

1078 }

1079

1080 operator uint32_t() { return UnderlyingValue; }

1081

1082private:

1083 uint32_t UnderlyingValue = 0;

1084 uint32_t CurrentBitIndex = 0;

1085};

1086

1087}

1088

1089#endif

enum clang::sema::@1727::IndirectLocalPathEntry::EntryKind Kind

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

static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)

Produce a diagnostic highlighting some portion of a literal.

llvm::MachO::Record Record

Defines the clang::SourceLocation class and associated facilities.

C Language Family Type Representation.

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

An abstract interface that should be implemented by listeners that want to be notified when an AST en...

Reads an AST files chain containing the contents of a translation unit.

An object for streaming information to a record.

Writes an AST file containing the contents of a translation unit.

serialization::MacroID getMacroID(MacroInfo *MI)

Determine the ID of an already-emitted macro.

unsigned getDeclParmVarAbbrev() const

void AddEmittedDeclRef(const Decl *D, RecordDataImpl &Record)

void AddSourceRange(SourceRange Range, RecordDataImpl &Record, LocSeq *Seq=nullptr)

Emit a source range.

unsigned getBinaryOperatorAbbrev() const

unsigned getDeclTemplateTypeParmAbbrev() const

bool isWritingStdCXXNamedModules() const

ArrayRef< uint64_t > RecordDataRef

void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record, StringRef Path)

Emit the current record with the given path as a blob.

void AddFileID(FileID FID, RecordDataImpl &Record)

Emit a FileID.

unsigned getDeclObjCIvarAbbrev() const

unsigned getExprImplicitCastAbbrev() const

bool isDeclPredefined(const Decl *D) const

unsigned getDeclTypedefAbbrev() const

unsigned getSwitchCaseID(SwitchCase *S)

Retrieve the ID for the given switch-case statement.

void AddPath(StringRef Path, RecordDataImpl &Record)

Add a path to the given record.

SmallVectorImpl< uint64_t > RecordDataImpl

unsigned getDeclUsingShadowAbbrev() const

unsigned getTypeExtQualAbbrev() const

void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record)

Add a version tuple to the given record.

bool isGeneratingReducedBMI() const

uint32_t getMacroDirectivesOffset(const IdentifierInfo *Name)

unsigned getDeclVarAbbrev() const

unsigned getDeclEnumAbbrev() const

void AddAlignPackInfo(const Sema::AlignPackInfo &Info, RecordDataImpl &Record)

Emit a AlignPackInfo.

void AddPathBlob(StringRef Str, RecordDataImpl &Record, SmallVectorImpl< char > &Blob)

bool IsLocalDecl(const Decl *D)

Is this a local declaration (that is, one that will be written to our AST file)? This is the case for...

unsigned getDeclRefExprAbbrev() const

void AddTypeRef(ASTContext &Context, QualType T, RecordDataImpl &Record)

Emit a reference to a type.

unsigned getCXXOperatorCallExprAbbrev()

bool wasDeclEmitted(const Decl *D) const

Whether or not the declaration got emitted.

void AddString(StringRef Str, RecordDataImpl &Record)

Add a string to the given record.

time_t getTimestampForOutput(const FileEntry *E) const

Get a timestamp for output into the AST file.

void ClearSwitchCaseIDs()

bool isWritingModule() const

LocalDeclID GetDeclRef(const Decl *D)

Force a declaration to be emitted and get its local ID to the module file been writing.

LocalDeclID getDeclID(const Decl *D)

Determine the local declaration ID of an already-emitted declaration.

void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record)

Emit a reference to an identifier.

serialization::MacroID getMacroRef(MacroInfo *MI, const IdentifierInfo *Name)

Get the unique number used to refer to the given macro.

void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record, LocSeq *Seq=nullptr)

Emit a source location.

unsigned getCXXMemberCallExprAbbrev()

ASTFileSignature WriteAST(llvm::PointerUnion< Sema *, Preprocessor * > Subject, StringRef OutputFile, Module *WritingModule, StringRef isysroot, bool ShouldCacheASTInMemory=false)

Write a precompiled header or a module with the AST produced by the Sema object, or a dependency scan...

ASTReader * getChain() const

unsigned getCompoundAssignOperatorAbbrev() const

bool getDoneWritingDeclsAndTypes() const

serialization::IdentifierID getIdentifierRef(const IdentifierInfo *II)

Get the unique number used to refer to the given identifier.

unsigned RecordSwitchCaseID(SwitchCase *S)

Record an ID for the given switch-case statement.

unsigned getCharacterLiteralAbbrev() const

unsigned getDeclCXXMethodAbbrev(FunctionDecl::TemplatedKind Kind) const

void handleVTable(CXXRecordDecl *RD)

unsigned getCompoundStmtAbbrev() const

unsigned getLocalOrImportedSubmoduleID(const Module *Mod)

Retrieve or create a submodule ID for this module, or return 0 if the submodule is neither local (a s...

const Decl * getFirstLocalDecl(const Decl *D)

Find the first local declaration of a given local redeclarable decl.

void AddToken(const Token &Tok, RecordDataImpl &Record)

Emit a token.

serialization::SelectorID getSelectorRef(Selector Sel)

Get the unique number used to refer to the given selector.

SourceLocationEncoding::RawLocEncoding getRawSourceLocationEncoding(SourceLocation Loc, LocSeq *Seq=nullptr)

Return the raw encodings for source locations.

ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl< char > &Buffer, InMemoryModuleCache &ModuleCache, ArrayRef< std::shared_ptr< ModuleFileExtension > > Extensions, bool IncludeTimestamps=true, bool BuildingImplicitModule=false, bool GeneratingReducedBMI=false)

Create a new precompiled header writer that outputs to the given bitstream.

SmallVector< uint64_t, 64 > RecordData

serialization::TypeID GetOrCreateTypeID(ASTContext &Context, QualType T)

Force a type to be emitted and get its ID.

unsigned getAnonymousDeclarationNumber(const NamedDecl *D)

unsigned getDeclFieldAbbrev() const

const LangOptions & getLangOpts() const

void SetSelectorOffset(Selector Sel, uint32_t Offset)

Note that the selector Sel occurs at the given offset within the method pool/selector table.

bool PreparePathForOutput(SmallVectorImpl< char > &Path)

Convert a path from this build process into one that is appropriate for emission in the module file.

unsigned getCallExprAbbrev() const

void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset)

Note that the identifier II occurs at the given offset within the identifier table.

unsigned getDeclRecordAbbrev() const

void AddDeclRef(const Decl *D, RecordDataImpl &Record)

Emit a reference to a declaration.

void AddStringBlob(StringRef Str, RecordDataImpl &Record, SmallVectorImpl< char > &Blob)

unsigned getIntegerLiteralAbbrev() const

Attr - This represents one attribute.

A simple helper class to pack several bits in order into (a) 32 bit integer(s).

bool canWriteNextNBits(uint32_t BitsWidth) const

BitsPacker operator=(BitsPacker &&)=delete

BitsPacker(BitsPacker &&)=delete

void addBits(uint32_t Value, uint32_t BitsWidth)

void reset(uint32_t Value)

BitsPacker(const BitsPacker &)=delete

BitsPacker operator=(const BitsPacker &)=delete

CXX20ModulesGenerator(Preprocessor &PP, InMemoryModuleCache &ModuleCache, StringRef OutputFile, bool AllowASTWithErrors=false)

void HandleTranslationUnit(ASTContext &Ctx) override

HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...

virtual Module * getEmittingModule(ASTContext &Ctx) override

Represents a C++ destructor within a class.

Represents a C++ struct/union/class.

Declaration of a class template.

Represents a class template specialization, which refers to a class template with a given set of temp...

DeclContext - This is used only as base class of specific decl types that can act as declaration cont...

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

Concrete class used by the front-end to report problems and issues.

This represents one expression.

Represents a member of a struct/union/class.

Cached information about one file (either on disk or in the virtual file system).

An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...

Represents a function declaration or definition.

TemplatedKind

The kind of templated function a FunctionDecl can be.

@ TK_MemberSpecialization

@ TK_DependentNonTemplate

@ TK_FunctionTemplateSpecialization

@ TK_DependentFunctionTemplateSpecialization

Declaration of a template function.

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

In-memory cache for modules.

Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...

Record the location of a macro definition.

Encapsulates the data about a macro definition (e.g.

Describes a module or submodule.

bool isNamedModule() const

Does this Module is a named module of a standard named module?

This represents a decl that may have a name.

Represent a C++ namespace.

ObjCCategoryDecl - Represents a category declaration.

Represents an ObjC class declaration.

AST and semantic-analysis consumer that generates a precompiled header from the parsed source code.

ASTMutationListener * GetASTMutationListener() override

If the consumer is interested in entities getting modified after their initial creation,...

void InitializeSema(Sema &S) override

Initialize the semantic consumer with the Sema instance being used to perform semantic analysis on th...

PCHBuffer * getBufferPtr()

Preprocessor & getPreprocessor()

virtual Module * getEmittingModule(ASTContext &Ctx)

SmallVectorImpl< char > & getPCH() const

StringRef getOutputFile() const

void HandleVTable(CXXRecordDecl *RD) override

Callback involved at the end of a translation unit to notify the consumer that a vtable for the given...

ASTDeserializationListener * GetASTDeserializationListener() override

If the consumer is interested in entities being deserialized from AST files, it should return a point...

const ASTWriter & getWriter() const

void HandleTranslationUnit(ASTContext &Ctx) override

HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...

bool hasEmittedPCH() const

DiagnosticsEngine & getDiagnostics() const

Represents a parameter to a function.

Engages in a tight little dance with the lexer to efficiently preprocess tokens.

A (possibly-)qualified type.

static QualType getFromOpaquePtr(const void *Ptr)

Represents a struct/union/class.

ReducedBMIGenerator(Preprocessor &PP, InMemoryModuleCache &ModuleCache, StringRef OutputFile, bool AllowASTWithErrors=false)

Smart pointer class that efficiently represents Objective-C method names.

An abstract interface that should be implemented by clients that read ASTs and then require further s...

Sema - This implements semantic analysis and AST building for C.

Serialized encoding of a sequence of SourceLocations.

Encodes a location in the source.

static SourceLocation getFromRawEncoding(UIntTy Encoding)

Turn a raw encoding of a SourceLocation object into a real SourceLocation.

A trivial tuple used to represent a source range.

Represents the declaration of a struct/union/class/enum.

Token - This structure provides full information about a lexed token.

The top declaration context.

Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...

Represents a variable declaration or definition.

Declaration of a variable template.

Represents a variable template specialization, which refers to a variable template with a given set o...

A type index; the type ID with the qualifier bits removed.

const unsigned NUM_PREDEF_TYPE_IDS

The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.

@ Decl

The l-value was an access to a declared entity or something equivalently strong, like the address of ...

uint64_t TypeID

An ID number that refers to a type in an AST file.

const unsigned int NUM_PREDEF_IDENT_IDS

The number of predefined identifier IDs.

uint32_t SubmoduleID

An ID number that refers to a submodule in a module file.

uint32_t SelectorID

An ID number that refers to an ObjC selector in an AST file.

uint32_t PreprocessedEntityID

An ID number that refers to an entity in the detailed preprocessing record.

const unsigned int NUM_PREDEF_SUBMODULE_IDS

The number of predefined submodule IDs.

const unsigned int NUM_PREDEF_SELECTOR_IDS

The number of predefined selector IDs.

uint64_t IdentifierID

An ID number that refers to an identifier in an AST file.

const unsigned int NUM_PREDEF_MACRO_IDS

The number of predefined macro IDs.

uint32_t MacroID

An ID number that refers to a macro in an AST file.

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

@ Seq

'seq' clause, allowed on 'loop' and 'routine' directives.

@ Delete

'delete' clause, allowed on the 'exit data' construct.

@ Module

Module linkage, which indicates that the entity can be referred to from other translation units withi...

PredefinedDeclIDs

Predefined declaration IDs.

@ NUM_PREDEF_DECL_IDS

The number of declaration IDs that are predefined.

@ Result

The result type of a method or function.

bool CanElideDeclDef(const Decl *D)

If we can elide the definition of.

const FunctionProtoType * T

The signature of a module, which is a hash of the AST content.

A structure for putting "fast"-unqualified QualTypes into a DenseMap.