clang: include/clang/Frontend/ASTUnit.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_CLANG_FRONTEND_ASTUNIT_H

14#define LLVM_CLANG_FRONTEND_ASTUNIT_H

15

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

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

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

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

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

38#include "llvm/ADT/StringMap.h"

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

40#include "llvm/ADT/iterator_range.h"

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

42#include

43#include

44#include

45#include

46#include

47#include

48#include

49#include

50

51namespace llvm {

52

53class MemoryBuffer;

54

55namespace vfs {

56

57class FileSystem;

58

59}

60}

61

63

85

86

88

89

91

92

93class ASTUnit {

94 std::unique_ptr LangOpts;

95 std::unique_ptr CodeGenOpts;

96

97

98

99

100 std::shared_ptr DiagOpts;

105 std::unique_ptr HeaderInfo;

107 std::shared_ptr PP;

109 std::shared_ptr TargetOpts;

110 std::unique_ptr HSOpts;

111 std::shared_ptr PPOpts;

113 bool HadModuleLoaderFatalFailure = false;

114 bool StorePreamblesInMemory = false;

115

116

117 struct ASTWriterData {

119 llvm::BitstreamWriter Stream;

121

123 : Stream(Buffer), Writer(Stream, Buffer, ModCache, CGOpts, {}) {}

124 };

125 std::unique_ptr WriterData;

126

128 std::string PreambleStoragePath;

129

130

131

132 std::unique_ptr Consumer;

133

134

135

136 std::unique_ptr TheSema;

137

138

139

140 std::shared_ptr Invocation;

141

142

143 std::shared_ptr CCInvocation;

144

145

146

147 std::shared_ptr ModifiedInvocation;

148

149

151

152

153

154

155 bool OnlyLocalDecls = false;

156

157

159

160

161 bool MainFileIsAST;

162

163

165

166

167 bool WantTiming;

168

169

170 bool OwnsRemappedFileBuffers = true;

171

172

173

174

175

176

177

178

179 std::vector<Decl*> TopLevelDecls;

180

181

183 using FileDeclsTy = llvm::DenseMap<FileID, std::unique_ptr>;

184

185

186

187 FileDeclsTy FileDecls;

188

189

190 std::string OriginalSourceFile;

191

192

194

195

196

198

199

200

202

203

204

205

206

207

208 unsigned NumStoredDiagnosticsFromDriver = 0;

209

210

211

212

213

214

215

216

217

218

219 unsigned PreambleRebuildCountdown = 0;

220

221

222 unsigned PreambleCounter = 0;

223

224

225

226

227

228

229

230 llvm::StringMap PreambleSrcLocCache;

231

232

233 std::optional Preamble;

234

235

236

237

238 std::unique_ptrllvm::MemoryBuffer SavedMainFileBuffer;

239

240

241

242

243

244

245

246 unsigned NumWarningsInPreamble = 0;

247

248

249

250 std::vector TopLevelDeclsInPreamble;

251

252

253 bool ShouldCacheCodeCompletionResults : 1;

254

255

256

257 bool IncludeBriefCommentsInCodeCompletion : 1;

258

259

260

261 bool UserFilesAreVolatile : 1;

262

265

266 void clearFileLevelDecls();

267

268public:

269

270

272

273

275

276

277

278

279

280

281

282

284

285

287

288

289

291

292

294

295

297

298

299

300

301

302

303

305 };

306

307

308

310 return CachedCompletionTypes;

311 }

312

313

314 std::shared_ptr

316 return CachedCompletionAllocator;

317 }

318

320 if (!CCTUInfo)

321 CCTUInfo = std::make_unique(

322 std::make_shared());

323 return *CCTUInfo;

324 }

325

326private:

327

328 std::shared_ptr CachedCompletionAllocator;

329

330 std::unique_ptr CCTUInfo;

331

332

333 std::vector CachedCompletionResults;

334

335

336

337 llvm::StringMap CachedCompletionTypes;

338

339

340

341

342

343

344 unsigned CompletionCacheTopLevelHashValue = 0;

345

346

347

348

349

350

351 unsigned PreambleTopLevelHashValue = 0;

352

353

354

355 unsigned CurrentTopLevelHashValue = 0;

356

357

358

359 LLVM_PREFERRED_TYPE(bool)

360 unsigned UnsafeToFree : 1;

361

362

364

365

366

367 void CacheCodeCompletionResults();

368

369

370 void ClearCachedCompletionResults();

371

372 explicit ASTUnit(bool MainFileIsAST);

373

374 bool Parse(std::shared_ptr PCHContainerOps,

375 std::unique_ptrllvm::MemoryBuffer OverrideMainBuffer,

377

378 std::unique_ptrllvm::MemoryBuffer getMainBufferWithPrecompiledPreamble(

379 std::shared_ptr PCHContainerOps,

382 unsigned MaxLines = 0);

383 void RealizeTopLevelDeclsFromPreamble();

384

385

386

387 void transferASTDataFromCompilerInstance(CompilerInstance &CI);

388

389

390

391

392

393

394

395

396 class ConcurrencyState {

397 void *Mutex;

398

399 public:

400 ConcurrencyState();

401 ~ConcurrencyState();

402

403 void start();

404 void finish();

405 };

406 ConcurrencyState ConcurrencyCheckValue;

407

408public:

410

412 ASTUnit &Self;

413

414 public:

416 Self.ConcurrencyCheckValue.start();

417 }

418

420 Self.ConcurrencyCheckValue.finish();

421 }

422 };

423

425 ASTUnit &operator=(const ASTUnit &) = delete;

427

429

432

436 return Diagnostics;

437 }

438

442 return SourceMgr;

443 }

444

448

452

454 Ctx = std::move(ctx);

455 }

457

458

459

460

461

462

463

464

466

467 bool hasSema() const { return (bool)TheSema; }

468

470 assert(TheSema && "ASTUnit does not have a Sema object!");

471 return *TheSema;

472 }

473

475 assert(LangOpts && "ASTUnit does not have language options");

476 return *LangOpts;

477 }

478

480 assert(HSOpts && "ASTUnit does not have header search options");

481 return *HSOpts;

482 }

483

485 assert(PPOpts && "ASTUnit does not have preprocessor options");

486 return *PPOpts;

487 }

488

490

491 return FileMgr->getVirtualFileSystemPtr();

492 }

493

497

499

501

503 return OriginalSourceFile;

504 }

505

508

510

513

515

516

518

520

522 assert(isMainFileAST() && "Invalid call for AST based ASTUnit!");

523 if (!TopLevelDeclsInPreamble.empty())

524 RealizeTopLevelDeclsFromPreamble();

525 return TopLevelDecls.begin();

526 }

527

529 assert(isMainFileAST() && "Invalid call for AST based ASTUnit!");

530 if (!TopLevelDeclsInPreamble.empty())

531 RealizeTopLevelDeclsFromPreamble();

532 return TopLevelDecls.end();

533 }

534

536 assert(isMainFileAST() && "Invalid call for AST based ASTUnit!");

537 return TopLevelDeclsInPreamble.size() + TopLevelDecls.size();

538 }

539

541 assert(isMainFileAST() && "Invalid call for AST based ASTUnit!");

542 return TopLevelDeclsInPreamble.empty() && TopLevelDecls.empty();

543 }

544

545

547 TopLevelDecls.push_back(D);

548 }

549

550

552

553

554

555

558

559

560

561

563

564

565

566

567

568

570 unsigned Line, unsigned Col) const;

571

572

574

575

576

577

579

580

581

582

584

589

590

595

596

601

603

604

607

609 return StoredDiagnostics.begin();

610 }

611

613 return StoredDiagnostics.begin();

614 }

615

617 return StoredDiagnostics.end();

618 }

619

621 return StoredDiagnostics.end();

622 }

623

624 using diags_range = llvm::iterator_range<stored_diag_iterator>;

626

630

634

636

638 if (NumStoredDiagnosticsFromDriver > StoredDiagnostics.size())

639 NumStoredDiagnosticsFromDriver = 0;

640 return StoredDiagnostics.begin() + NumStoredDiagnosticsFromDriver;

641 }

642

644 std::vector::iterator;

645

647 return CachedCompletionResults.begin();

648 }

649

651 return CachedCompletionResults.end();

652 }

653

655 return CachedCompletionResults.size();

656 }

657

658

659

660

661 llvm::iterator_rangePreprocessingRecord::iterator

663

664

665

667

668

669

670

671

673

674

676

677

678

680

681 std::unique_ptrllvm::MemoryBuffer

682 getBufferForFile(StringRef Filename, std::string *ErrorStr = nullptr);

683

684

686

687

689

690

691

692 using RemappedFile = std::pair<std::string, llvm::MemoryBuffer *>;

693

694

695 static std::unique_ptr

696 create(std::shared_ptr CI,

697 std::shared_ptr DiagOpts,

699 CaptureDiagsKind CaptureDiagnostics, bool UserFilesAreVolatile);

700

702

704

705

707

708

710 };

711

712

713

714

715

716

717

718

719

720

721

725 std::shared_ptr DiagOpts,

729 bool OnlyLocalDecls = false,

731 bool AllowASTWithCompilerErrors = false,

732 bool UserFilesAreVolatile = false);

733

734private:

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749 bool LoadFromCompilerInvocation(

750 std::shared_ptr PCHContainerOps,

751 unsigned PrecompilePreambleAfterNParses,

753

754public:

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

784 std::shared_ptr CI,

785 std::shared_ptr PCHContainerOps,

786 std::shared_ptr DiagOpts,

789 bool Persistent = true, StringRef ResourceFilesPath = StringRef(),

790 bool OnlyLocalDecls = false,

792 unsigned PrecompilePreambleAfterNParses = 0,

793 bool CacheCodeCompletionResults = false,

794 bool UserFilesAreVolatile = false,

795 std::unique_ptr *ErrAST = nullptr);

796

797

798

799

800

801

802

803

804

805

806

807

808

809

810

811 static std::unique_ptr LoadFromCompilerInvocation(

812 std::shared_ptr CI,

813 std::shared_ptr PCHContainerOps,

814 std::shared_ptr DiagOpts,

818 unsigned PrecompilePreambleAfterNParses = 0,

820 bool CacheCodeCompletionResults = false,

821 bool IncludeBriefCommentsInCodeCompletion = false,

822 bool UserFilesAreVolatile = false);

823

825 const char **ArgBegin, const char **ArgEnd,

826 std::shared_ptr PCHContainerOps,

827 std::shared_ptr DiagOpts,

829 bool StorePreamblesInMemory, StringRef PreambleStoragePath,

832 bool RemappedFilesKeepOriginalName,

834 bool CacheCodeCompletionResults,

835 bool IncludeBriefCommentsInCodeCompletion,

836 bool AllowPCHWithCompilerErrors,

838 bool UserFilesAreVolatile, bool ForSerialization,

839 bool RetainExcludedConditionalBlocks,

840 std::optional ModuleFormat, std::unique_ptr *ErrAST,

842

843

844

845

846

847

848

849

850

851

852

853

854 bool Reparse(std::shared_ptr PCHContainerOps,

857

858

859

860

862

863

864

865

866

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

889 bool IncludeCodePatterns, bool IncludeBriefComments,

891 std::shared_ptr PCHContainerOps,

898 std::unique_ptr Act);

899

900

901

902

903

905

906

907

908

910};

911

912

916 bool CaptureNonErrorsFromIncludes = true;

919

920public:

924 bool CaptureNonErrorsFromIncludes);

925

928

931};

932

933

934

939 std::unique_ptr OwningPreviousClient;

940

941public:

946

948};

949

950}

951

952#endif

Defines the clang::ASTContext interface.

Defines the Diagnostic-related interfaces.

Defines the clang::FileSystemOptions interface.

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

Defines the clang::LangOptions interface.

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.

Defines the clang::SourceLocation class and associated facilities.

Defines the SourceManager interface.

Defines the clang::TargetOptions class.

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.

ConcurrencyCheck(ASTUnit &Self)

Definition ASTUnit.h:415

~ConcurrencyCheck()

Definition ASTUnit.h:419

Utility class for loading a ASTContext from an AST file.

Definition ASTUnit.h:93

const PreprocessorOptions & getPreprocessorOpts() const

Definition ASTUnit.h:484

unsigned & getCurrentTopLevelHashValue()

Retrieve a reference to the current top-level name hash value.

Definition ASTUnit.h:562

ASTContext & getASTContext()

Definition ASTUnit.h:450

CodeCompletionTUInfo & getCodeCompletionTUInfo()

Definition ASTUnit.h:319

void enableSourceFileDiagnostics()

Enable source-range based diagnostic messages.

stored_diag_iterator stored_diag_end()

Definition ASTUnit.h:620

void addFileLevelDecl(Decl *D)

Add a new local file-level declaration.

const FileManager & getFileManager() const

Definition ASTUnit.h:494

void setOwnsRemappedFileBuffers(bool val)

Definition ASTUnit.h:512

bool isUnsafeToFree() const

Definition ASTUnit.h:430

void CodeComplete(StringRef File, unsigned Line, unsigned Column, ArrayRef< RemappedFile > RemappedFiles, bool IncludeMacros, bool IncludeCodePatterns, bool IncludeBriefComments, CodeCompleteConsumer &Consumer, std::shared_ptr< PCHContainerOperations > PCHContainerOps, llvm::IntrusiveRefCntPtr< DiagnosticsEngine > Diag, LangOptions &LangOpts, llvm::IntrusiveRefCntPtr< SourceManager > SourceMgr, llvm::IntrusiveRefCntPtr< FileManager > FileMgr, SmallVectorImpl< StoredDiagnostic > &StoredDiagnostics, SmallVectorImpl< const llvm::MemoryBuffer * > &OwnedBuffers, std::unique_ptr< SyntaxOnlyAction > Act)

Perform code completion at the given file, line, and column within this translation unit.

cached_completion_iterator cached_completion_end()

Definition ASTUnit.h:650

SourceRange mapRangeFromPreamble(SourceRange R) const

Definition ASTUnit.h:591

bool hasSema() const

Definition ASTUnit.h:467

static std::unique_ptr< ASTUnit > LoadFromASTFile(StringRef Filename, const PCHContainerReader &PCHContainerRdr, WhatToLoad ToLoad, IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS, std::shared_ptr< DiagnosticOptions > DiagOpts, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, const FileSystemOptions &FileSystemOpts, const HeaderSearchOptions &HSOpts, const LangOptions *LangOpts=nullptr, bool OnlyLocalDecls=false, CaptureDiagsKind CaptureDiagnostics=CaptureDiagsKind::None, bool AllowASTWithCompilerErrors=false, bool UserFilesAreVolatile=false)

Create a ASTUnit from an AST file.

bool top_level_empty() const

Definition ASTUnit.h:540

llvm::IntrusiveRefCntPtr< ASTContext > getASTContextPtr()

Definition ASTUnit.h:451

bool serialize(raw_ostream &OS)

Serialize this translation unit with the given output stream.

llvm::iterator_range< stored_diag_iterator > diags_range

Definition ASTUnit.h:624

bool getOwnsRemappedFileBuffers() const

Definition ASTUnit.h:511

const FileSystemOptions & getFileSystemOpts() const

Definition ASTUnit.h:498

ASTDeserializationListener * getDeserializationListener()

stored_diag_const_iterator stored_diag_end() const

Definition ASTUnit.h:616

bool Reparse(std::shared_ptr< PCHContainerOperations > PCHContainerOps, ArrayRef< RemappedFile > RemappedFiles={}, IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS=nullptr)

Reparse the source files using the same command-line options that were originally used to produce thi...

void setUnsafeToFree(bool Value)

Definition ASTUnit.h:431

std::unique_ptr< llvm::MemoryBuffer > getBufferForFile(StringRef Filename, std::string *ErrorStr=nullptr)

llvm::StringMap< unsigned > & getCachedCompletionTypes()

Retrieve the mapping from formatted type names to unique type identifiers.

Definition ASTUnit.h:309

const DiagnosticsEngine & getDiagnostics() const

Definition ASTUnit.h:433

SourceLocation getLocation(const FileEntry *File, unsigned Line, unsigned Col) const

Get the source location for the given file:line:col triplet.

void ResetForParse()

Free data that will be re-generated on the next parse.

llvm::IntrusiveRefCntPtr< SourceManager > getSourceManagerPtr()

Definition ASTUnit.h:441

bool getOnlyLocalDecls() const

Definition ASTUnit.h:509

InputKind getInputKind() const

Determine the input kind this AST unit represents.

OptionalFileEntryRef getPCHFile()

Get the PCH file if one was included.

StringRef getMainFileName() const

Sema & getSema() const

Definition ASTUnit.h:469

ASTUnit(const ASTUnit &)=delete

stored_diag_const_iterator stored_diag_begin() const

Definition ASTUnit.h:608

SourceLocation mapLocationToPreamble(SourceLocation Loc) const

If Loc is a local location of the main file but inside the preamble chunk, returns the corresponding ...

cached_completion_iterator cached_completion_begin()

Definition ASTUnit.h:646

const LangOptions & getLangOpts() const

Definition ASTUnit.h:474

bool isMainFileAST() const

Definition ASTUnit.h:428

std::vector< Decl * >::iterator top_level_iterator

Definition ASTUnit.h:519

const SourceManager & getSourceManager() const

Definition ASTUnit.h:439

ASTUnit & operator=(const ASTUnit &)=delete

unsigned stored_diag_size() const

Definition ASTUnit.h:635

const_diags_range storedDiagnostics() const

Definition ASTUnit.h:631

Preprocessor & getPreprocessor()

Definition ASTUnit.h:446

DiagnosticsEngine & getDiagnostics()

Definition ASTUnit.h:434

const StoredDiagnostic * stored_diag_const_iterator

Definition ASTUnit.h:606

SourceLocation getEndOfPreambleFileID() const

std::vector< CachedCodeCompletionResult >::iterator cached_completion_iterator

Definition ASTUnit.h:643

stored_diag_iterator stored_diag_afterDriver_begin()

Definition ASTUnit.h:637

llvm::IntrusiveRefCntPtr< DiagnosticsEngine > getDiagnosticsPtr()

Definition ASTUnit.h:435

static ASTUnit * LoadFromCompilerInvocationAction(std::shared_ptr< CompilerInvocation > CI, std::shared_ptr< PCHContainerOperations > PCHContainerOps, std::shared_ptr< DiagnosticOptions > DiagOpts, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, FrontendAction *Action=nullptr, ASTUnit *Unit=nullptr, bool Persistent=true, StringRef ResourceFilesPath=StringRef(), bool OnlyLocalDecls=false, CaptureDiagsKind CaptureDiagnostics=CaptureDiagsKind::None, unsigned PrecompilePreambleAfterNParses=0, bool CacheCodeCompletionResults=false, bool UserFilesAreVolatile=false, std::unique_ptr< ASTUnit > *ErrAST=nullptr)

Create an ASTUnit from a source file, via a CompilerInvocation object, by invoking the optionally pro...

WhatToLoad

Definition ASTUnit.h:701

@ LoadPreprocessorOnly

Load options and the preprocessor state.

Definition ASTUnit.h:703

@ LoadASTOnly

Load the AST, but do not restore Sema state.

Definition ASTUnit.h:706

@ LoadEverything

Load everything, including Sema.

Definition ASTUnit.h:709

top_level_iterator top_level_end()

Definition ASTUnit.h:528

SourceLocation getStartOfMainFileID() const

SourceRange mapRangeToPreamble(SourceRange R) const

Definition ASTUnit.h:597

diags_range storedDiagnostics()

Definition ASTUnit.h:627

FileManager & getFileManager()

Definition ASTUnit.h:495

IntrusiveRefCntPtr< ASTReader > getASTReader() const

IntrusiveRefCntPtr< FileManager > getFileManagerPtr()

Definition ASTUnit.h:496

bool(*)(void *context, const Decl *D) DeclVisitorFn

Type for a function iterating over a number of declarations.

Definition ASTUnit.h:666

StoredDiagnostic * stored_diag_iterator

Definition ASTUnit.h:605

bool visitLocalTopLevelDecls(void *context, DeclVisitorFn Fn)

Iterate over local declarations (locally parsed if this is a parsed source file or the loaded declara...

IntrusiveRefCntPtr< llvm::vfs::FileSystem > getVirtualFileSystemPtr()

Definition ASTUnit.h:489

llvm::iterator_range< PreprocessingRecord::iterator > getLocalPreprocessingEntities() const

Returns an iterator range for the local preprocessing entities of the local Preprocessor,...

StringRef getOriginalSourceFileName() const

Definition ASTUnit.h:502

top_level_iterator top_level_begin()

Definition ASTUnit.h:521

ASTMutationListener * getASTMutationListener()

stored_diag_iterator stored_diag_begin()

Definition ASTUnit.h:612

TranslationUnitKind getTranslationUnitKind() const

Determine what kind of translation unit this AST represents.

Definition ASTUnit.h:685

std::shared_ptr< Preprocessor > getPreprocessorPtr() const

Definition ASTUnit.h:447

void setPreprocessor(std::shared_ptr< Preprocessor > pp)

StringRef getASTFileName() const

If this ASTUnit came from an AST file, returns the filename for it.

bool Save(StringRef File)

Save this translation unit to a file with the given name.

SourceManager & getSourceManager()

Definition ASTUnit.h:440

const HeaderSearchOptions & getHeaderSearchOpts() const

Definition ASTUnit.h:479

friend std::unique_ptr< ASTUnit > CreateASTUnitFromCommandLine(const char **ArgBegin, const char **ArgEnd, std::shared_ptr< PCHContainerOperations > PCHContainerOps, std::shared_ptr< DiagnosticOptions > DiagOpts, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, StringRef ResourceFilesPath, bool StorePreamblesInMemory, StringRef PreambleStoragePath, bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics, ArrayRef< ASTUnit::RemappedFile > RemappedFiles, bool RemappedFilesKeepOriginalName, unsigned PrecompilePreambleAfterNParses, TranslationUnitKind TUKind, bool CacheCodeCompletionResults, bool IncludeBriefCommentsInCodeCompletion, bool AllowPCHWithCompilerErrors, SkipFunctionBodiesScope SkipFunctionBodies, bool SingleFileParse, bool UserFilesAreVolatile, bool ForSerialization, bool RetainExcludedConditionalBlocks, std::optional< StringRef > ModuleFormat, std::unique_ptr< ASTUnit > *ErrAST, IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS)

Create an ASTUnit from a vector of command line arguments, which must specify exactly one source file...

void setASTContext(llvm::IntrusiveRefCntPtr< ASTContext > ctx)

Definition ASTUnit.h:453

unsigned getPreambleCounterForTests() const

Definition ASTUnit.h:602

unsigned cached_completion_size() const

Definition ASTUnit.h:654

static std::unique_ptr< ASTUnit > create(std::shared_ptr< CompilerInvocation > CI, std::shared_ptr< DiagnosticOptions > DiagOpts, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, CaptureDiagsKind CaptureDiagnostics, bool UserFilesAreVolatile)

Create a ASTUnit. Gets ownership of the passed CompilerInvocation.

void addTopLevelDecl(Decl *D)

Add a new top-level declaration.

Definition ASTUnit.h:546

const Preprocessor & getPreprocessor() const

Definition ASTUnit.h:445

std::shared_ptr< GlobalCodeCompletionAllocator > getCachedCompletionAllocator()

Retrieve the allocator used to cache global code completions.

Definition ASTUnit.h:315

llvm::iterator_range< stored_diag_const_iterator > const_diags_range

Definition ASTUnit.h:625

bool isInMainFileID(SourceLocation Loc) const

bool isModuleFile() const

Returns true if the ASTUnit was constructed from a serialized module file.

void findFileRegionDecls(FileID File, unsigned Offset, unsigned Length, SmallVectorImpl< Decl * > &Decls)

Get the decls that are contained in a file in the Offset/Length range.

const ASTContext & getASTContext() const

Definition ASTUnit.h:449

bool isInPreambleFileID(SourceLocation Loc) const

SourceLocation mapLocationFromPreamble(SourceLocation Loc) const

If Loc is a loaded location from the preamble, returns the corresponding local location of the main f...

std::pair< std::string, llvm::MemoryBuffer * > RemappedFile

A mapping from a file name to the memory buffer that stores the remapped contents of that file.

Definition ASTUnit.h:692

std::size_t top_level_size() const

Definition ASTUnit.h:535

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

~CaptureDroppedDiagnostics()

CaptureDroppedDiagnostics(CaptureDiagsKind CaptureDiagnostics, DiagnosticsEngine &Diags, SmallVectorImpl< StoredDiagnostic > *StoredDiags, SmallVectorImpl< StandaloneDiagnostic > *StandaloneDiags)

Abstract interface for a consumer of code-completion information.

A "string" used to describe how code completion can be performed for an entity.

CodeGenOptions - Track various options which control how the code is optimized and passed to the back...

CompilerInstance - Helper class for managing a single instance of the Clang compiler.

Helper class for holding the data necessary to invoke the compiler.

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

Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...

DiagnosticConsumer()=default

A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine a...

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

Level

The level of the diagnostic, after it has been through mapping.

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...

Implements support for file system lookup, file system caching, and directory search management.

Keeps track of options that affect how file operations are performed.

Diagnostic consumer that saves each diagnostic it is given.

Definition ASTUnit.h:913

void BeginSourceFile(const LangOptions &LangOpts, const Preprocessor *PP=nullptr) override

Callback to inform the diagnostic client that processing of a source file is beginning.

FilterAndStoreDiagnosticConsumer(SmallVectorImpl< StoredDiagnostic > *StoredDiags, SmallVectorImpl< StandaloneDiagnostic > *StandaloneDiags, bool CaptureNonErrorsFromIncludes)

void HandleDiagnostic(DiagnosticsEngine::Level Level, const Diagnostic &Info) override

Handle this diagnostic, reporting it to the user or capturing it to a log as needed.

Abstract base class for actions which can be performed by the frontend.

The kind of a file that we've been handed as an input.

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

The module cache used for compiling modules implicitly.

A registry of PCHContainerWriter and -Reader objects for different formats.

This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...

PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...

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

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

Encodes a location in the source.

This class handles loading and caching of source files into memory.

A trivial tuple used to represent a source range.

SourceLocation getEnd() const

SourceLocation getBegin() const

Represents a diagnostic in a form that can be retained until its corresponding source manager is dest...

Exposes information about the current target.

A module loader that doesn't know how to create or load modules.

CXCursorKind

Describes the kind of entity that a cursor refers to.

CXAvailabilityKind

Describes the availability of a particular entity, which indicates whether the use of this entity wil...

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

CustomizableOptional< FileEntryRef > OptionalFileEntryRef

SkipFunctionBodiesScope

Enumerates the available scopes for skipping function bodies.

Definition ASTUnit.h:87

@ Preamble

Definition ASTUnit.h:87

@ None

Definition ASTUnit.h:87

@ PreambleAndMainFile

Definition ASTUnit.h:87

@ Parse

Parse the block; this code is always used.

SimplifiedTypeClass

A simplified classification of types used when determining "similar" types for code completion.

CaptureDiagsKind

Enumerates the available kinds for capturing diagnostics.

Definition ASTUnit.h:90

@ AllWithoutNonErrorsFromIncludes

Definition ASTUnit.h:90

@ None

Definition ASTUnit.h:90

TranslationUnitKind

Describes the kind of translation unit being processed.

@ TU_Complete

The translation unit is a complete translation unit.

@ None

The alignment was not explicit in code.

Diagnostic wrappers for TextAPI types for error reporting.

A cached code-completion result, which may be introduced in one of many different contexts.

Definition ASTUnit.h:271

unsigned Type

The type of a non-macro completion result, stored as a unique integer used by the string map of cache...

Definition ASTUnit.h:304

CXCursorKind Kind

The libclang cursor kind corresponding to this code-completion result.

Definition ASTUnit.h:290

CXAvailabilityKind Availability

The availability of this code-completion result.

Definition ASTUnit.h:293

unsigned Priority

The priority given to this code-completion result.

Definition ASTUnit.h:286

SimplifiedTypeClass TypeClass

The simplified type class for a non-macro completion result.

Definition ASTUnit.h:296

uint64_t ShowInContexts

A bitmask that indicates which code-completion contexts should contain this completion result.

Definition ASTUnit.h:283

CodeCompletionString * Completion

The code-completion string corresponding to this completion result.

Definition ASTUnit.h:274