clang: include/clang/Basic/SourceManager.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34#ifndef LLVM_CLANG_BASIC_SOURCEMANAGER_H

35#define LLVM_CLANG_BASIC_SOURCEMANAGER_H

36

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

42#include "llvm/ADT/BitVector.h"

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

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

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

46#include "llvm/ADT/PagedVector.h"

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

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

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

50#include "llvm/Support/Allocator.h"

51#include "llvm/Support/Compiler.h"

52#include "llvm/Support/MemoryBuffer.h"

53#include

54#include

55#include

56#include

57#include

58#include

59#include

60#include

61

63

64class ASTReader;

65class ASTWriter;

66class FileManager;

67class LineTableInfo;

68class SourceManager;

69

70

71

72namespace SrcMgr {

73

74

75

76

77

78

79

80

88

89

92}

93

94

97}

98

99

100

102public:

103 explicit operator bool() const { return Storage; }

105 assert(Storage);

106 return Storage[0];

107 }

109 assert(Storage);

111 }

113 const unsigned *end() const { return getLines().end(); }

115

117 llvm::BumpPtrAllocator &Alloc);

118

121 llvm::BumpPtrAllocator &Alloc);

122

123private:

124

125 unsigned *Storage = nullptr;

126};

127

128

129

130

132

133

134 mutable std::unique_ptrllvm::MemoryBuffer Buffer;

135

136public:

137

138

139

140

141

142

143

144

145

147

148

149

150

151

153

154

155

156

158

159

160

161

162

164

165

166

167

168

169

170 LLVM_PREFERRED_TYPE(bool)

172

173

174

175 LLVM_PREFERRED_TYPE(bool)

177

178

179

180

181 LLVM_PREFERRED_TYPE(bool)

183

184 LLVM_PREFERRED_TYPE(bool)

186

191

193

197

198

199

200

206

208 "Passed ContentCache object cannot own a buffer.");

209 }

210

212

213

214

215

216

217

218

219

220 std::optionalllvm::MemoryBufferRef

223

224

225

226

227

228

229

230 unsigned getSize() const;

231

232

233

234

235

237

238

239

241

242

244 if (Buffer)

245 return Buffer->getMemBufferRef();

246 return std::nullopt;

247 }

248

249

250

252 if (Buffer)

253 return Buffer->getBuffer();

254 return std::nullopt;

255 }

256

257

258 void setBuffer(std::unique_ptrllvm::MemoryBuffer B) {

260 Buffer = std::move(B);

261 }

262

263

264

265

267 assert(!Buffer && "Expected to be called right after construction");

268 if (B)

269 setBuffer(llvm::MemoryBuffer::getMemBuffer(*B));

270 }

271

272

273

274 static const char *getInvalidBOM(StringRef BufStr);

275};

276

277

278

279static_assert(alignof(ContentCache) >= 8,

280 "ContentCache must be 8-byte aligned.");

281

282

283

284

285

286

287

288

289

290

291

292

293

294

299

300

301

302

304

305

306

307

308

309 unsigned NumCreatedFIDs : 31;

310

311

312 LLVM_PREFERRED_TYPE(bool)

313 unsigned HasLineDirectives : 1;

314

315

316 llvm::PointerIntPair<const ContentCache *, 3, CharacteristicKind>

317 ContentAndKind;

318

319public:

320

324 X.IncludeLoc = IL;

325 X.NumCreatedFIDs = 0;

326 X.HasLineDirectives = false;

327 X.ContentAndKind.setPointer(&Con);

328 X.ContentAndKind.setInt(FileCharacter);

330 return X;

331 }

332

334 return IncludeLoc;

335 }

336

338 return *ContentAndKind.getPointer();

339 }

340

341

343 return ContentAndKind.getInt();

344 }

345

346

348

349

350

352

353

354

356};

357

358

359

360

362

363

364

366

367

368

369

370

371

372

374

375

376 bool ExpansionIsTokenRange;

377

378public:

381 }

382

384 return ExpansionLocStart;

385 }

386

389 : ExpansionLocEnd;

390 }

391

393

398 }

399

401

403 }

404

407 }

408

412 }

413

414

415

416

417

418

419

422 bool ExpansionIsTokenRange = true) {

424 X.SpellingLoc = SpellingLoc;

425 X.ExpansionLocStart = Start;

426 X.ExpansionLocEnd = End;

427 X.ExpansionIsTokenRange = ExpansionIsTokenRange;

428 return X;

429 }

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

452

453

454

456 }

457

458

459

460

461

462

466 return create(SpellingLoc, Start, End, false);

467 }

468};

469

470

471

472

473

474static_assert(sizeof(FileInfo) <= sizeof(ExpansionInfo),

475 "FileInfo must be no larger than ExpansionInfo.");

476

477

478

479

480

484 LLVM_PREFERRED_TYPE(bool)

486 union {

489 };

490

491public:

493

495

498

501 }

502

504 assert(isFile() && "Not a file SLocEntry!");

506 }

507

509 assert(isExpansion() && "Not a macro expansion SLocEntry!");

511 }

512

513

515 assert(!(Offset & (1ULL << OffsetBits)) && "Offset is too large");

517 E.Offset = Offset;

518 return E;

519 }

520

522 assert(!(Offset & (1ULL << OffsetBits)) && "Offset is too large");

524 E.Offset = Offset;

525 E.IsExpansion = false;

526 E.File = FI;

527 return E;

528 }

529

532 assert(!(Offset & (1ULL << OffsetBits)) && "Offset is too large");

534 E.Offset = Offset;

535 E.IsExpansion = true;

537 return E;

538 }

539};

540

541}

542

543

545public:

547

548

549

550

551

552

554

555

556

557

558

560

561

562

563

565};

566

567

568

569

570

572

573

574

575 FileID LQueryFID, RQueryFID;

576

577

578

579

580 bool LChildBeforeRChild;

581

582

583

585

586

587

588

589

590

591 unsigned LCommonOffset, RCommonOffset;

592

593public:

596 assert(L != R);

597 }

598

599

600

601

602

604 return CommonFID.isValid();

605 }

606

607

608

610

611

612 if (LQueryFID != CommonFID) LOffset = LCommonOffset;

613 if (RQueryFID != CommonFID) ROffset = RCommonOffset;

614

615

616

617

618

619

620 if (LOffset == ROffset)

621 return LChildBeforeRChild;

622

623 return LOffset < ROffset;

624 }

625

626

627

629 assert(LHS != RHS);

630 if (LQueryFID != LHS || RQueryFID != RHS) {

631 LQueryFID = LHS;

632 RQueryFID = RHS;

633 CommonFID = FileID();

634 }

635 }

636

638 unsigned rCommonOffset, bool LParentBeforeRParent) {

639 CommonFID = commonFID;

640 LCommonOffset = lCommonOffset;

641 RCommonOffset = rCommonOffset;

642 LChildBeforeRChild = LParentBeforeRParent;

643 }

644};

645

646

647

648

650

651

652

653

654

655

656

657

658

659

660

661

662

664

666

668

669 mutable llvm::BumpPtrAllocator ContentCacheAlloc;

670

671

672

673

674

675

676

677 llvm::DenseMap<FileEntryRef, SrcMgr::ContentCache*> FileInfos;

678

679

680

681 bool OverridenFilesKeepOriginalName = true;

682

683

684

685 bool UserFilesAreVolatile;

686

687

688

689

690 bool FilesAreTransient = false;

691

692 struct OverriddenFilesInfoTy {

693

694

695 llvm::DenseMap<const FileEntry *, FileEntryRef> OverriddenFiles;

696

697

698 llvm::DenseSet<const FileEntry *> OverriddenFilesWithBuffer;

699 };

700

701

702

703 std::unique_ptr OverriddenFilesInfo;

704

705 OverriddenFilesInfoTy &getOverriddenFilesInfo() {

706 if (!OverriddenFilesInfo)

707 OverriddenFilesInfo.reset(new OverriddenFilesInfoTy);

708 return *OverriddenFilesInfo;

709 }

710

711

712

713

714

715 std::vectorSrcMgr::ContentCache\* MemBufferInfos;

716

717

718

719

720

722

723

724

725

726

727 llvm::PagedVector<SrcMgr::SLocEntry, 32> LoadedSLocEntryTable;

728

729

730

731

733

734

735

736

738

739

740

741

742

744

745

746

749

750

751

752

753

754 llvm::BitVector SLocEntryLoaded;

755

756

757

758

759

760 llvm::BitVector SLocEntryOffsetLoaded;

761

762

764

765

766

767

768

769 mutable FileID LastFileIDLookup;

770

771

772

773

774 std::unique_ptr LineTable;

775

776

777

778 mutable FileID LastLineNoFileIDQuery;

780 mutable unsigned LastLineNoFilePos;

781 mutable unsigned LastLineNoResult;

782

783

785

786

787 FileID PreambleFileID;

788

789

790 mutable unsigned NumLinearScans = 0;

791 mutable unsigned NumBinaryProbes = 0;

792

793

794

795

796

797

798 mutable llvm::DenseMap<FileID, std::pair<FileID, unsigned>> IncludedLocMap;

799

800

801 using IsBeforeInTUCacheKey = std::pair<FileID, FileID>;

802

803

804

805 using InBeforeInTUCache =

806 llvm::DenseMap<IsBeforeInTUCacheKey, InBeforeInTUCacheEntry>;

807

808

809 mutable InBeforeInTUCache IBTUCache;

811

812

813

815

816

817 mutable std::unique_ptrllvm::MemoryBuffer FakeBufferForRecovery;

818

819 mutable std::unique_ptrSrcMgr::ContentCache FakeContentCacheForRecovery;

820

821 mutable std::unique_ptrSrcMgr::SLocEntry FakeSLocEntryForRecovery;

822

823

824

825 using MacroArgsMap = std::map<unsigned, SourceLocation>;

826

827 mutable llvm::DenseMap<FileID, std::unique_ptr>

828 MacroArgsCacheMap;

829

830

831

832

833

834

835

836

838

839public:

841 bool UserFilesAreVolatile = false);

845

847

848

849

851

853

855

856

857

858

860 OverridenFilesKeepOriginalName = value;

861 }

862

863

864

866

867

869 return StoredModuleBuildStack;

870 }

871

872

874 StoredModuleBuildStack.clear();

875 StoredModuleBuildStack.append(stack.begin(), stack.end());

876 }

877

878

880 StoredModuleBuildStack.push_back(std::make_pair(moduleName.str(),importLoc));

881 }

882

883

884

885

886

887

889

890

892 MainFileID = FID;

893 }

894

895

896

897

899

900

902 assert(PreambleFileID.isInvalid() && "PreambleFileID already set!");

904 }

905

906

908

909

910

911

912

913

914

917 int LoadedID = 0,

919

920

921

922

923

928

929

930

931

932

937

938

939

942

943

944

945

946

947

950 unsigned Length);

951

952

953

954

955

959 unsigned Length,

960 bool ExpansionIsTokenRange = true,

961 int LoadedID = 0,

963

964

965

969

970

971

972

973 std::optionalllvm::MemoryBufferRef

975

976

977

978

981 return *B;

982 return getFakeBufferForRecovery();

983 }

984

985

986

987

988

989

990

991

993 const llvm::MemoryBufferRef &Buffer) {

995 }

996

997

998

999

1000

1001

1002

1003

1005 std::unique_ptrllvm::MemoryBuffer Buffer);

1006

1007

1008

1009

1010

1011

1012

1014

1015

1017 if (OverriddenFilesInfo) {

1018 if (OverriddenFilesInfo->OverriddenFilesWithBuffer.count(File))

1019 return true;

1020 if (OverriddenFilesInfo->OverriddenFiles.contains(File))

1021 return true;

1022 }

1023 return false;

1024 }

1025

1026

1027

1028

1029

1030

1032

1033

1035

1036

1037

1039 FilesAreTransient = Transient;

1040 }

1041

1042

1043

1044

1045

1046

1047

1048

1049

1050 std::optionalllvm::MemoryBufferRef

1052 if (auto *Entry = getSLocEntryForFile(FID))

1053 return Entry->getFile().getContentCache().getBufferOrNone(

1055 return std::nullopt;

1056 }

1057

1058

1059

1060

1061

1062 llvm::MemoryBufferRef

1065 return *B;

1066 return getFakeBufferForRecovery();

1067 }

1068

1069

1072 return *FE;

1073 return nullptr;

1074 }

1075

1076

1078 if (auto *Entry = getSLocEntryForFile(FID))

1079 return Entry->getFile().getContentCache().OrigEntry;

1080 return std::nullopt;

1081 }

1082

1083

1084

1085

1086

1088

1089

1093 return *FE;

1094 return nullptr;

1095 }

1096

1097

1098

1099

1100

1101

1103

1104

1105

1106

1107

1109

1110

1111

1112

1113

1115

1116

1117

1119 if (auto *Entry = getSLocEntryForFile(FID))

1120 return Entry->getFile().NumCreatedFIDs;

1121 return 0;

1122 }

1123

1124

1125

1127 bool Force = false) {

1128 auto *Entry = getSLocEntryForFile(FID);

1129 if (!Entry)

1130 return;

1131 assert((Force || Entry->getFile().NumCreatedFIDs == 0) && "Already set!");

1132 Entry->getFile().NumCreatedFIDs = NumFIDs;

1133 }

1134

1135

1136

1137

1138

1139

1140

1141

1142

1143

1144

1146 return getFileID(SpellingLoc.getOffset());

1147 }

1148

1149

1151

1152

1153

1155 if (auto *Entry = getSLocEntryForFile(FID))

1156 return SourceLocation::getFileLoc(Entry->getOffset());

1158 }

1159

1160

1161

1163 if (auto *Entry = getSLocEntryForFile(FID))

1164 return SourceLocation::getFileLoc(Entry->getOffset() +

1167 }

1168

1169

1170

1172 if (auto *Entry = getSLocEntryForFile(FID))

1173 return Entry->getFile().getIncludeLoc();

1175 }

1176

1177

1178

1179

1180 std::pair<SourceLocation, StringRef>

1183

1184

1185

1186 if (FID.ID >= -1)

1188

1190 }

1191

1192

1193

1195

1196

1197 if (Loc.isFileID()) return Loc;

1198 return getExpansionLocSlowCase(Loc);

1199 }

1200

1201

1202

1203

1205 if (Loc.isFileID()) return Loc;

1206 return getFileLocSlowCase(Loc);

1207 }

1208

1209

1210

1211

1212

1214

1215

1216

1218

1219

1220

1225 End.isTokenRange());

1226 }

1227

1228

1229

1232 if (Expansion.getEnd() == Range.getEnd())

1234 return Expansion;

1235 }

1236

1237

1238

1239

1240

1241

1243

1244

1245 if (Loc.isFileID()) return Loc;

1246 return getSpellingLocSlowCase(Loc);

1247 }

1248

1249

1250

1251

1252

1253

1254

1256

1257

1259 auto *Entry = getSLocEntryOrNull(FID);

1260 if (!Entry)

1262

1264 return Entry->isFile() ? SourceLocation::getFileLoc(GlobalOffset)

1265 : SourceLocation::getMacroLoc(GlobalOffset);

1266 }

1267

1268

1269

1270

1271

1274 auto *Entry = getSLocEntryOrNull(FID);

1275 if (!Entry)

1276 return std::make_pair(FileID(), 0);

1277 return std::make_pair(FID, Loc.getOffset() - Entry->getOffset());

1278 }

1279

1280

1281

1282

1283

1284 std::pair<FileID, unsigned>

1287 auto *E = getSLocEntryOrNull(FID);

1288 if (E)

1289 return std::make_pair(FileID(), 0);

1290

1291 unsigned Offset = Loc.getOffset()-E->getOffset();

1292 if (Loc.isFileID())

1293 return std::make_pair(FID, Offset);

1294

1295 return getDecomposedExpansionLocSlowCase(E);

1296 }

1297

1298

1299

1300

1301

1302 std::pair<FileID, unsigned>

1305 auto *E = getSLocEntryOrNull(FID);

1306 if (E)

1307 return std::make_pair(FileID(), 0);

1308

1309 unsigned Offset = Loc.getOffset()-E->getOffset();

1310 if (Loc.isFileID())

1311 return std::make_pair(FID, Offset);

1312 return getDecomposedSpellingLocSlowCase(E, Offset);

1313 }

1314

1315

1316

1318

1319

1320

1321

1322

1325 }

1326

1327

1328

1329

1330

1331

1332

1333

1334

1335

1338

1339

1340

1341

1342

1343

1345

1346

1347

1348

1349

1350

1353

1354

1355

1356

1357

1358

1359 bool

1362

1363

1364

1365

1366

1367

1368 bool

1371 assert(((Start.getOffset() < NextLocalOffset &&

1372 Start.getOffset()+Length <= NextLocalOffset) ||

1373 (Start.getOffset() >= CurrentLoadedOffset &&

1374 Start.getOffset()+Length < MaxLoadedOffset)) &&

1375 "Chunk is not valid SLoc address space");

1379 if (LocOffs >= BeginOffs && LocOffs < EndOffs) {

1380 if (RelativeOffset)

1381 *RelativeOffset = LocOffs - BeginOffs;

1382 return true;

1383 }

1384

1385 return false;

1386 }

1387

1388

1389

1390

1391

1392

1396 bool LHSLoaded = LHSOffs >= CurrentLoadedOffset;

1397 bool RHSLoaded = RHSOffs >= CurrentLoadedOffset;

1398

1399 if (LHSLoaded == RHSLoaded) {

1400 if (RelativeOffset)

1401 *RelativeOffset = RHSOffs - LHSOffs;

1402 return true;

1403 }

1404

1405 return false;

1406 }

1407

1408

1409

1410

1411

1412

1413

1414

1415

1417 bool *Invalid = nullptr) const;

1418

1419

1420

1421

1422

1423

1424

1426 bool *Invalid = nullptr) const;

1428 bool *Invalid = nullptr) const;

1430 bool *Invalid = nullptr) const;

1432 bool *Invalid = nullptr) const;

1433

1434

1435

1436

1437

1438

1439

1444

1445

1446

1447

1448

1449

1451

1452

1453

1454

1455

1456

1457

1458

1459

1460

1461

1463

1464

1465

1466

1467

1468

1469

1470

1471

1472

1473

1474

1475

1476

1478 bool UseLineDirectives = true) const;

1479

1480

1481

1482

1483

1484

1485

1486

1488

1489

1490

1491

1492

1495 }

1496

1497

1498

1499

1500

1503 }

1504

1505

1509 return false;

1511 return Filename == "";

1512 }

1513

1514

1518 return false;

1520 return Filename == "";

1521 }

1522

1523

1527 return false;

1529 return Filename == "";

1530 }

1531

1532

1534 if (Loc.isInvalid())

1535 return false;

1537 }

1538

1539

1542 }

1543

1544

1547 return false;

1548

1549

1550

1551

1553 do {

1557 }

1558

1560 }

1561

1562

1564

1565

1566

1567

1569 unsigned *RelativeOffset = nullptr) const {

1571 if (isOffsetInFileID(FID, Offs)) {

1572 if (RelativeOffset)

1574 return true;

1575 }

1576

1577 return false;

1578 }

1579

1580

1581

1582

1583

1584

1586

1587

1588

1589

1590

1592 bool IsFileEntry, bool IsFileExit,

1594

1595

1597

1598

1600

1601

1602

1603

1604

1605

1606

1608 return ContentCacheAlloc.getTotalMemory();

1609 }

1610

1614

1617 };

1618

1619

1620

1622

1623

1624

1626

1627

1628

1629

1630

1631

1632

1633

1634

1636 unsigned Line, unsigned Col) const;

1637

1638

1639

1640

1641

1645 }

1646

1647

1648

1650 unsigned Line, unsigned Col) const;

1651

1652

1653

1654

1655

1656

1657

1658

1659

1660

1662

1663

1664

1665

1667

1668

1669

1670

1671

1672

1673

1674

1675 std::pair<bool, bool>

1677 std::pair<FileID, unsigned> &ROffs) const;

1678

1679

1680

1681

1683

1684

1686 const std::pair<FileID, unsigned> &LOffs,

1687 const std::pair<FileID, unsigned> &ROffs) const;

1688

1689

1690

1693 }

1694

1695

1696

1697

1698

1702 bool LHSLoaded = LHSOffset >= CurrentLoadedOffset;

1703 bool RHSLoaded = RHS >= CurrentLoadedOffset;

1704 if (LHSLoaded == RHSLoaded)

1705 return LHSOffset < RHS;

1706

1707 return LHSLoaded;

1708 }

1709

1710

1713 return Location == Start || Location == End ||

1716 }

1717

1718

1720 llvm::DenseMap<FileEntryRef, SrcMgr::ContentCache *>::const_iterator;

1721

1725 return FileInfos.find_as(File) != FileInfos.end();

1726 }

1727

1728

1730

1731 void dump() const;

1732

1733

1735 std::optional MaxNotes = 32) const;

1736

1737

1739

1740

1743 }

1744

1745

1747 assert(Index < LocalSLocEntryTable.size() && "Invalid index");

1748 return LocalSLocEntryTable[Index];

1749 }

1750

1751

1753

1754

1756 bool *Invalid = nullptr) const {

1759 }

1760

1761

1763 bool *Invalid = nullptr) {

1764 assert(Index < LoadedSLocEntryTable.size() && "Invalid index");

1765 if (SLocEntryLoaded[Index])

1766 return LoadedSLocEntryTable[Index];

1767 return loadSLocEntry(Index, Invalid);

1768 }

1769

1771 bool *Invalid = nullptr) const {

1773 }

1774

1776 if (FID.ID == 0 || FID.ID == -1) {

1778 return LocalSLocEntryTable[0];

1779 }

1780 return getSLocEntryByID(FID.ID, Invalid);

1781 }

1782

1784

1786 assert(LoadedSLocEntryTable.empty() &&

1787 "Invalidating existing loaded entries");

1788 ExternalSLocEntries = Source;

1789 }

1790

1791

1792

1793

1794

1795

1796

1797 std::pair<int, SourceLocation::UIntTy>

1800

1801

1803 return isLoadedOffset(Loc.getOffset());

1804 }

1805

1806

1808 return isLocalOffset(Loc.getOffset());

1809 }

1810

1811

1813 assert(FID.ID != -1 && "Using FileID sentinel value");

1814 return FID.ID < 0;

1815 }

1816

1817

1820 }

1821

1822

1823

1825 if (Loc.isMacroID()) return Loc;

1826

1827

1828

1829

1832

1833

1834

1836 }

1837

1838

1840

1841private:

1844

1845 llvm::MemoryBufferRef getFakeBufferForRecovery() const;

1847

1850

1852 return const_cast<SourceManager *>(this)->getSLocEntryOrNull(FID);

1853 }

1854

1858 return Invalid ? nullptr : &Entry;

1859 }

1860

1861 const SrcMgr::SLocEntry *getSLocEntryForFile(FileID FID) const {

1862 return const_cast<SourceManager *>(this)->getSLocEntryForFile(FID);

1863 }

1864

1865 SrcMgr::SLocEntry *getSLocEntryForFile(FileID FID) {

1866 if (auto *Entry = getSLocEntryOrNull(FID))

1867 if (Entry->isFile())

1868 return Entry;

1869 return nullptr;

1870 }

1871

1872

1873

1874 const SrcMgr::SLocEntry &getSLocEntryByID(int ID,

1875 bool *Invalid = nullptr) const {

1877 }

1878

1879 SrcMgr::SLocEntry &getSLocEntryByID(int ID, bool *Invalid = nullptr) {

1880 assert(ID != -1 && "Using FileID sentinel value");

1881 if (ID < 0)

1882 return getLoadedSLocEntryByID(ID, Invalid);

1884 }

1885

1886 const SrcMgr::SLocEntry &

1887 getLoadedSLocEntryByID(int ID, bool *Invalid = nullptr) const {

1888 return const_cast<SourceManager *>(this)->getLoadedSLocEntryByID(ID,

1890 }

1891

1892 SrcMgr::SLocEntry &getLoadedSLocEntryByID(int ID, bool *Invalid = nullptr) {

1894 }

1895

1897

1898 if (isOffsetInFileID(LastFileIDLookup, SLocOffset))

1899 return LastFileIDLookup;

1900

1901 return getFileIDSlow(SLocOffset);

1902 }

1903

1905 return SLocOffset < CurrentLoadedOffset;

1906 }

1907

1909 return SLocOffset >= CurrentLoadedOffset;

1910 }

1911

1912

1913

1914 SourceLocation

1915 createExpansionLocImpl(const SrcMgr::ExpansionInfo &Expansion,

1916 unsigned Length, int LoadedID = 0,

1918

1919

1920

1921 inline bool isOffsetInFileID(FileID FID,

1923 const SrcMgr::SLocEntry &Entry = getSLocEntry(FID);

1924

1925 if (SLocOffset < Entry.getOffset()) return false;

1926

1927

1928 if (FID.ID == -2)

1929 return true;

1930

1931

1932 if (FID.ID+1 == static_cast<int>(LocalSLocEntryTable.size()))

1933 return SLocOffset < NextLocalOffset;

1934

1935

1936

1937 return SLocOffset < getSLocEntryByID(FID.ID+1).getOffset();

1938 }

1939

1940

1941

1942 FileID getPreviousFileID(FileID FID) const;

1943

1944

1945

1946 FileID getNextFileID(FileID FID) const;

1947

1948

1949

1950

1951

1952

1953 FileID createFileIDImpl(SrcMgr::ContentCache &File, StringRef Filename,

1954 SourceLocation IncludePos,

1957

1958 SrcMgr::ContentCache &getOrCreateContentCache(FileEntryRef SourceFile,

1959 bool isSystemFile = false);

1960

1961

1962 SrcMgr::ContentCache &

1963 createMemBufferContentCache(std::unique_ptrllvm::MemoryBuffer Buf);

1964

1968

1969 SourceLocation getExpansionLocSlowCase(SourceLocation Loc) const;

1970 SourceLocation getSpellingLocSlowCase(SourceLocation Loc) const;

1971 SourceLocation getFileLocSlowCase(SourceLocation Loc) const;

1972

1973 std::pair<FileID, unsigned>

1974 getDecomposedExpansionLocSlowCase(const SrcMgr::SLocEntry *E) const;

1975 std::pair<FileID, unsigned>

1976 getDecomposedSpellingLocSlowCase(const SrcMgr::SLocEntry *E,

1977 unsigned Offset) const;

1978 void computeMacroArgsCache(MacroArgsMap &MacroArgsCache, FileID FID) const;

1979 void associateFileChunkWithMacroArgExp(MacroArgsMap &MacroArgsCache,

1980 FileID FID,

1981 SourceLocation SpellLoc,

1982 SourceLocation ExpansionLoc,

1983 unsigned ExpansionLength) const;

1984 void updateSlocUsageStats() const;

1985};

1986

1987

1988template

1990

1991

1992template<>

1995

1996public:

1998

2000 return SM.isBeforeInTranslationUnit(LHS, RHS);

2001 }

2002};

2003

2004

2005template<>

2008

2009public:

2011

2013 return SM.isBeforeInTranslationUnit(LHS.getBegin(), RHS.getBegin());

2014 }

2015};

2016

2017

2018

2020public:

2021

2022

2024

2026 assert(SourceMgr);

2027 return *SourceMgr;

2028 }

2029

2030private:

2031

2032

2033

2034 std::unique_ptr FileMgr;

2035 std::unique_ptr Diagnostics;

2036 std::unique_ptr SourceMgr;

2037};

2038

2039}

2040

2041#endif

Defines the Diagnostic-related interfaces.

Defines interfaces for clang::FileEntry and clang::FileEntryRef.

Defines the clang::FileManager interface and associated types.

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.

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

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

bool operator()(SourceLocation LHS, SourceLocation RHS) const

BeforeThanCompare(SourceManager &SM)

BeforeThanCompare(SourceManager &SM)

bool operator()(SourceRange LHS, SourceRange RHS) const

Comparison function object.

Represents a character-granular source range.

SourceLocation getEnd() const

SourceLocation getBegin() const

void setTokenRange(bool TR)

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

External source of source location entries.

virtual int getSLocEntryID(SourceLocation::UIntTy SLocOffset)=0

Get the index ID for the loaded SourceLocation offset.

virtual std::pair< SourceLocation, StringRef > getModuleImportLoc(int ID)=0

Retrieve the module import location and name for the given ID, if in fact it was loaded from a module...

virtual ~ExternalSLocEntrySource()

virtual bool ReadSLocEntry(int ID)=0

Read the source location entry with index ID, which will always be less than -1.

A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...

const FileEntry & getFileEntry() const

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.

A SourceLocation and its associated SourceManager.

Holds the cache used by isBeforeInTranslationUnit.

void setCommonLoc(FileID commonFID, unsigned lCommonOffset, unsigned rCommonOffset, bool LParentBeforeRParent)

bool getCachedResult(unsigned LOffset, unsigned ROffset) const

If the cache is valid, compute the result given the specified offsets in the LHS/RHS FileID's.

void setQueryFIDs(FileID LHS, FileID RHS)

Set up a new query.

InBeforeInTUCacheEntry(FileID L, FileID R)

InBeforeInTUCacheEntry()=default

bool isCacheValid() const

Return true if the currently cached values match up with the specified LHS/RHS query.

Used to hold and unique data used to represent #line information.

Represents an unpacked "presumed" location which can be presented to the user.

const char * getFilename() const

Return the presumed filename of this location.

bool isInvalid() const

Return true if this object is invalid or uninitialized.

Encodes a location in the source.

bool isValid() const

Return true if this is a valid SourceLocation object.

SourceManager and necessary dependencies (e.g.

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

std::optional< StringRef > getNonBuiltinFilenameForID(FileID FID) const

Returns the filename for the provided FileID, unless it's a built-in buffer that's not represented by...

bool isMacroBodyExpansion(SourceLocation Loc) const

Tests whether the given source location represents the expansion of a macro body.

unsigned getPresumedLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const

bool isBeforeInSLocAddrSpace(SourceLocation LHS, SourceLocation RHS) const

Determines the order of 2 source locations in the "source location address space".

FileID getFileID(SourceLocation SpellingLoc) const

Return the FileID for a SourceLocation.

bool isAtEndOfImmediateMacroExpansion(SourceLocation Loc, SourceLocation *MacroEnd=nullptr) const

Returns true if the given MacroID location points at the character end of the immediate macro expansi...

DiagnosticsEngine & getDiagnostics() const

SourceLocation::UIntTy getNextLocalOffset() const

bool isWrittenInBuiltinFile(SourceLocation Loc) const

Returns whether Loc is located in a file.

unsigned getColumnNumber(FileID FID, unsigned FilePos, bool *Invalid=nullptr) const

Return the column # for the specified file position.

void noteSLocAddressSpaceUsage(DiagnosticsEngine &Diag, std::optional< unsigned > MaxNotes=32) const

void setAllFilesAreTransient(bool Transient)

Specify that all files that are read during this compilation are transient.

unsigned getFileOffset(SourceLocation SpellingLoc) const

Returns the offset from the start of the file that the specified SourceLocation represents.

bool isLocalSourceLocation(SourceLocation Loc) const

Returns true if Loc did not come from a PCH/Module.

bool isInMainFile(SourceLocation Loc) const

Returns whether the PresumedLoc for a given SourceLocation is in the main file.

void AddLineNote(SourceLocation Loc, unsigned LineNo, int FilenameID, bool IsFileEntry, bool IsFileExit, SrcMgr::CharacteristicKind FileKind)

Add a line note to the line table for the FileID and offset specified by Loc.

SourceManager(DiagnosticsEngine &Diag, FileManager &FileMgr, bool UserFilesAreVolatile=false)

SourceLocation createTokenSplitLoc(SourceLocation SpellingLoc, SourceLocation TokenStart, SourceLocation TokenEnd)

Return a new SourceLocation that encodes that the token starting at TokenStart ends prematurely at To...

PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const

Returns the "presumed" location of a SourceLocation specifies.

const FileEntry * getFileEntryForSLocEntry(const SrcMgr::SLocEntry &SLocEntry) const

Returns the FileEntry record for the provided SLocEntry.

bool isWrittenInCommandLineFile(SourceLocation Loc) const

Returns whether Loc is located in a file.

MemoryBufferSizes getMemoryBufferSizes() const

Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...

void setFileIsTransient(FileEntryRef SourceFile)

Specify that a file is transient.

bool isFileOverridden(const FileEntry *File) const

Returns true if the file contents have been overridden.

OptionalFileEntryRef getFileEntryRefForID(FileID FID) const

Returns the FileEntryRef for the provided FileID.

CharSourceRange getExpansionRange(SourceRange Range) const

Given a SourceRange object, return the range of tokens or characters covered by the expansion in the ...

SourceLocation getFileLoc(SourceLocation Loc) const

Given Loc, if it is a macro location return the expansion location or the spelling location,...

bool isInSLocAddrSpace(SourceLocation Loc, SourceLocation Start, unsigned Length, SourceLocation::UIntTy *RelativeOffset=nullptr) const

Returns true if Loc is inside the [Start, +Length) chunk of the source location address space.

SourceLocation translateLineCol(FileID FID, unsigned Line, unsigned Col) const

Get the source location in FID for the given line:col.

size_t getContentCacheSize() const

Return the total amount of physical memory allocated by the ContentCache allocator.

StringRef getBufferName(SourceLocation Loc, bool *Invalid=nullptr) const

Return the filename or buffer identifier of the buffer the location is in.

SourceLocation getTopMacroCallerLoc(SourceLocation Loc) const

std::optional< StringRef > getBufferDataOrNone(FileID FID) const

Return a StringRef to the source buffer data for the specified FileID, returning std::nullopt if inva...

unsigned getExpansionColumnNumber(SourceLocation Loc, bool *Invalid=nullptr) const

FileID translateFile(const FileEntry *SourceFile) const

Get the FileID for the given file.

CharSourceRange getExpansionRange(CharSourceRange Range) const

Given a CharSourceRange object, return the range of tokens or characters covered by the expansion in ...

void setModuleBuildStack(ModuleBuildStack stack)

Set the module build stack.

StringRef getBufferData(FileID FID, bool *Invalid=nullptr) const

Return a StringRef to the source buffer data for the specified FileID.

FileID createFileID(FileEntryRef SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0)

Create a new FileID that represents the specified file being #included from the specified IncludePosi...

void PrintStats() const

Print statistics to stderr.

FileID getUniqueLoadedASTFileID(SourceLocation Loc) const

SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr)

bool isMainFile(const FileEntry &SourceFile)

Returns true when the given FileEntry corresponds to the main file.

size_t getDataStructureSizes() const

Return the amount of memory used for various side tables and data structures in the SourceManager.

bool isMacroArgExpansion(SourceLocation Loc, SourceLocation *StartLoc=nullptr) const

Tests whether the given source location represents a macro argument's expansion into the function-lik...

bool isInTheSameTranslationUnitImpl(const std::pair< FileID, unsigned > &LOffs, const std::pair< FileID, unsigned > &ROffs) const

Determines whether the two decomposed source location is in the same TU.

const SrcMgr::SLocEntry & getLocalSLocEntry(unsigned Index) const

Get a local SLocEntry. This is exposed for indexing.

SourceLocation getComposedLoc(FileID FID, unsigned Offset) const

Form a SourceLocation from a FileID and Offset pair.

void setPreambleFileID(FileID Preamble)

Set the file ID for the precompiled preamble.

OptionalFileEntryRef bypassFileContentsOverride(FileEntryRef File)

Bypass the overridden contents of a file.

bool userFilesAreVolatile() const

True if non-system source files should be treated as volatile (likely to change while trying to use t...

const SrcMgr::SLocEntry & getLoadedSLocEntry(unsigned Index, bool *Invalid=nullptr) const

Get a loaded SLocEntry. This is exposed for indexing.

SourceLocation getSpellingLoc(SourceLocation Loc) const

Given a SourceLocation object, return the spelling location referenced by the ID.

FileManager & getFileManager() const

void setOverridenFilesKeepOriginalName(bool value)

Set true if the SourceManager should report the original file name for contents of files that were ov...

fileinfo_iterator fileinfo_end() const

FileID translateFile(FileEntryRef SourceFile) const

ModuleBuildStack getModuleBuildStack() const

Retrieve the module build stack.

unsigned local_sloc_entry_size() const

Get the number of local SLocEntries we have.

std::optional< StringRef > getBufferDataIfLoaded(FileID FID) const

Return a StringRef to the source buffer data for the specified FileID, returning std::nullopt if it's...

SourceLocation getLocForEndOfFile(FileID FID) const

Return the source location corresponding to the last byte of the specified file.

FileID getMainFileID() const

Returns the FileID of the main source file.

SourceLocation getImmediateMacroCallerLoc(SourceLocation Loc) const

Gets the location of the immediate macro caller, one level up the stack toward the initial macro type...

const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const

Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer.

std::pair< int, SourceLocation::UIntTy > AllocateLoadedSLocEntries(unsigned NumSLocEntries, SourceLocation::UIntTy TotalSize)

Allocate a number of loaded SLocEntries, which will be actually loaded on demand from the external so...

void pushModuleBuildStack(StringRef moduleName, FullSourceLoc importLoc)

Push an entry to the module build stack.

void overrideFileContents(FileEntryRef SourceFile, const llvm::MemoryBufferRef &Buffer)

Override the contents of the given source file by providing an already-allocated buffer.

SourceLocation getIncludeLoc(FileID FID) const

Returns the include location if FID is a #include'd file otherwise it returns an invalid location.

llvm::MemoryBufferRef getBufferOrFake(FileID FID, SourceLocation Loc=SourceLocation()) const

Return the buffer for the specified FileID.

unsigned getSpellingLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const

unsigned getFileIDSize(FileID FID) const

The size of the SLocEntry that FID represents.

bool isInSystemMacro(SourceLocation loc) const

Returns whether Loc is expanded from a macro in a system header.

void setMainFileID(FileID FID)

Set the file ID for the main source file.

unsigned getLineNumber(FileID FID, unsigned FilePos, bool *Invalid=nullptr) const

Given a SourceLocation, return the spelling line number for the position indicated.

std::pair< bool, bool > isInTheSameTranslationUnit(std::pair< FileID, unsigned > &LOffs, std::pair< FileID, unsigned > &ROffs) const

Determines whether the two decomposed source location is in the same translation unit.

llvm::DenseMap< FileEntryRef, SrcMgr::ContentCache * >::const_iterator fileinfo_iterator

CharSourceRange getImmediateExpansionRange(SourceLocation Loc) const

Return the start/end of the expansion information for an expansion location.

unsigned getSpellingColumnNumber(SourceLocation Loc, bool *Invalid=nullptr) const

bool hasLineTable() const

Determine if the source manager has a line table.

CharSourceRange getExpansionRange(SourceLocation Loc) const

Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate fi...

bool isWrittenInScratchSpace(SourceLocation Loc) const

Returns whether Loc is located in a file.

bool isInFileID(SourceLocation Loc, FileID FID, unsigned *RelativeOffset=nullptr) const

Given a specific FileID, returns true if Loc is inside that FileID chunk and sets relative offset (of...

void setExternalSLocEntrySource(ExternalSLocEntrySource *Source)

unsigned getLineTableFilenameID(StringRef Str)

Return the uniqued ID for the specified filename.

void setNumCreatedFIDsForFileID(FileID FID, unsigned NumFIDs, bool Force=false)

Set the number of FileIDs (files and macros) that were created during preprocessing of FID,...

bool isLocalFileID(FileID FID) const

Returns true if FID did not come from a PCH/Module.

bool isInSystemHeader(SourceLocation Loc) const

Returns if a SourceLocation is in a system header.

FileID getPreambleFileID() const

Get the file ID for the precompiled preamble if there is one.

std::pair< FileID, unsigned > getDecomposedExpansionLoc(SourceLocation Loc) const

Decompose the specified location into a raw FileID + Offset pair.

SrcMgr::SLocEntry & getLocalSLocEntry(unsigned Index)

Get a local SLocEntry. This is exposed for indexing.

unsigned getExpansionLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const

void initializeForReplay(const SourceManager &Old)

Initialize this source manager suitably to replay the compilation described by Old.

bool isLoadedSourceLocation(SourceLocation Loc) const

Returns true if Loc came from a PCH/Module.

unsigned loaded_sloc_entry_size() const

Get the number of loaded SLocEntries we have.

SourceManager & operator=(const SourceManager &)=delete

FileID getOrCreateFileID(FileEntryRef SourceFile, SrcMgr::CharacteristicKind FileCharacter)

Get the FileID for SourceFile if it exists.

bool hasFileInfo(const FileEntry *File) const

SourceLocation translateFileLineCol(const FileEntry *SourceFile, unsigned Line, unsigned Col) const

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

std::pair< SourceLocation, StringRef > getModuleImportLoc(SourceLocation Loc) const

std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const

Decompose the specified location into a raw FileID + Offset pair.

bool isLoadedFileID(FileID FID) const

Returns true if FID came from a PCH/Module.

const FileEntry * getFileEntryForID(FileID FID) const

Returns the FileEntry record for the provided FileID.

std::pair< FileID, unsigned > getDecomposedSpellingLoc(SourceLocation Loc) const

Decompose the specified location into a raw FileID + Offset pair.

bool isInSameSLocAddrSpace(SourceLocation LHS, SourceLocation RHS, SourceLocation::IntTy *RelativeOffset) const

Return true if both LHS and RHS are in the local source location address space or the loaded one.

llvm::MemoryBufferRef getMemoryBufferForFileOrFake(FileEntryRef File)

Retrieve the memory buffer associated with the given file.

SrcMgr::SLocEntry & getLoadedSLocEntry(unsigned Index, bool *Invalid=nullptr)

Get a loaded SLocEntry. This is exposed for indexing.

SourceLocation getLocForStartOfFile(FileID FID) const

Return the source location corresponding to the first byte of the specified file.

bool isAtStartOfImmediateMacroExpansion(SourceLocation Loc, SourceLocation *MacroBegin=nullptr) const

Returns true if the given MacroID location points at the beginning of the immediate macro expansion.

SrcMgr::CharacteristicKind getFileCharacteristic(SourceLocation Loc) const

Return the file characteristic of the specified source location, indicating whether this is a normal ...

SourceLocation createExpansionLoc(SourceLocation SpellingLoc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned Length, bool ExpansionIsTokenRange=true, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0)

Creates an expansion SLocEntry for a macro use.

bool isWrittenInSameFile(SourceLocation Loc1, SourceLocation Loc2) const

Returns true if the spelling locations for both SourceLocations are part of the same file buffer.

bool isInExternCSystemHeader(SourceLocation Loc) const

Returns if a SourceLocation is in an "extern C" system header.

unsigned getPresumedColumnNumber(SourceLocation Loc, bool *Invalid=nullptr) const

bool isWrittenInMainFile(SourceLocation Loc) const

Returns true if the spelling location for the given location is in the main file buffer.

bool isPointWithin(SourceLocation Location, SourceLocation Start, SourceLocation End) const

Return true if the Point is within Start and End.

SourceManager(const SourceManager &)=delete

std::pair< FileID, unsigned > getDecomposedIncludedLoc(FileID FID) const

Returns the "included/expanded in" decomposed location of the given FileID.

StringRef getFilename(SourceLocation SpellingLoc) const

Return the filename of the file containing a SourceLocation.

SourceLocation getExpansionLoc(SourceLocation Loc) const

Given a SourceLocation object Loc, return the expansion location referenced by the ID.

SourceLocation getMacroArgExpandedLocation(SourceLocation Loc) const

If Loc points inside a function macro argument, the returned location will be the macro location in w...

bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const

Determines the order of 2 source locations in the translation unit.

unsigned getNumCreatedFIDsForFileID(FileID FID) const

Get the number of FileIDs (files and macros) that were created during preprocessing of FID,...

std::optional< llvm::MemoryBufferRef > getBufferOrNone(FileID FID, SourceLocation Loc=SourceLocation()) const

Return the buffer for the specified FileID.

fileinfo_iterator fileinfo_begin() const

bool isBeforeInSLocAddrSpace(SourceLocation LHS, SourceLocation::UIntTy RHS) const

Determines the order of a source location and a source location offset in the "source location addres...

LineTableInfo & getLineTable()

Retrieve the stored line table.

SourceLocation getImmediateSpellingLoc(SourceLocation Loc) const

Given a SourceLocation object, return the spelling location referenced by the ID.

std::optional< llvm::MemoryBufferRef > getMemoryBufferForFileOrNone(FileEntryRef File)

Retrieve the memory buffer associated with the given file.

const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const

SourceLocation createMacroArgExpansionLoc(SourceLocation SpellingLoc, SourceLocation ExpansionLoc, unsigned Length)

Creates an expansion SLocEntry for the substitution of an argument into a function-like macro's body.

A trivial tuple used to represent a source range.

SourceLocation getBegin() const

One instance of this struct is kept for every file loaded or used.

void setBuffer(std::unique_ptr< llvm::MemoryBuffer > B)

Set the buffer.

std::optional< StringRef > getBufferDataIfLoaded() const

Return a StringRef to the source buffer data, only if it has already been loaded.

void setUnownedBuffer(std::optional< llvm::MemoryBufferRef > B)

Set the buffer to one that's not owned (or to nullptr).

OptionalFileEntryRef ContentsEntry

References the file which the contents were actually loaded from.

unsigned getSizeBytesMapped() const

Returns the number of bytes actually mapped for this ContentCache.

unsigned IsTransient

True if this file may be transient, that is, if it might not exist at some later point in time when t...

StringRef Filename

The filename that is used to access OrigEntry.

ContentCache(FileEntryRef Ent)

ContentCache(FileEntryRef Ent, FileEntryRef contentEnt)

unsigned getSize() const

Returns the size of the content encapsulated by this ContentCache.

llvm::MemoryBuffer::BufferKind getMemoryBufferKind() const

Returns the kind of memory used to back the memory buffer for this content cache.

unsigned IsFileVolatile

True if this content cache was initially created for a source file considered to be volatile (likely ...

LineOffsetMapping SourceLineCache

A bump pointer allocated array of offsets for each source line.

std::optional< llvm::MemoryBufferRef > getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM, SourceLocation Loc=SourceLocation()) const

Returns the memory buffer for the associated content.

static const char * getInvalidBOM(StringRef BufStr)

std::optional< llvm::MemoryBufferRef > getBufferIfLoaded() const

Return the buffer, only if it has been loaded.

unsigned BufferOverridden

Indicates whether the buffer itself was provided to override the actual file contents.

ContentCache(const ContentCache &RHS)

The copy ctor does not allow copies where source object has either a non-NULL Buffer or SourceLineCac...

ContentCache & operator=(const ContentCache &RHS)=delete

OptionalFileEntryRef OrigEntry

Reference to the file entry representing this ContentCache.

Each ExpansionInfo encodes the expansion location - where the token was ultimately expanded,...

SourceLocation getExpansionLocStart() const

static ExpansionInfo create(SourceLocation SpellingLoc, SourceLocation Start, SourceLocation End, bool ExpansionIsTokenRange=true)

Return a ExpansionInfo for an expansion.

bool isMacroBodyExpansion() const

bool isExpansionTokenRange() const

bool isFunctionMacroExpansion() const

SourceLocation getSpellingLoc() const

CharSourceRange getExpansionLocRange() const

bool isMacroArgExpansion() const

static ExpansionInfo createForMacroArg(SourceLocation SpellingLoc, SourceLocation ExpansionLoc)

Return a special ExpansionInfo for the expansion of a macro argument into a function-like macro's bod...

static ExpansionInfo createForTokenSplit(SourceLocation SpellingLoc, SourceLocation Start, SourceLocation End)

Return a special ExpansionInfo representing a token that ends prematurely.

SourceLocation getExpansionLocEnd() const

Information about a FileID, basically just the logical file that it represents and include stack info...

const ContentCache & getContentCache() const

CharacteristicKind getFileCharacteristic() const

Return whether this is a system header or not.

static FileInfo get(SourceLocation IL, ContentCache &Con, CharacteristicKind FileCharacter, StringRef Filename)

Return a FileInfo object.

bool hasLineDirectives() const

Return true if this FileID has #line directives in it.

void setHasLineDirectives()

Set the flag that indicates that this FileID has line table entries associated with it.

SourceLocation getIncludeLoc() const

StringRef getName() const

Returns the name of the file that was used when the file was loaded from the underlying file system.

Mapping of line offsets into a source file.

const unsigned * begin() const

LineOffsetMapping()=default

const unsigned * end() const

const unsigned & operator[](int I) const

static LineOffsetMapping get(llvm::MemoryBufferRef Buffer, llvm::BumpPtrAllocator &Alloc)

ArrayRef< unsigned > getLines() const

This is a discriminated union of FileInfo and ExpansionInfo.

SourceLocation::UIntTy getOffset() const

static SLocEntry getOffsetOnly(SourceLocation::UIntTy Offset)

Creates an incomplete SLocEntry that is only able to report its offset.

static SLocEntry get(SourceLocation::UIntTy Offset, const FileInfo &FI)

const FileInfo & getFile() const

static SLocEntry get(SourceLocation::UIntTy Offset, const ExpansionInfo &Expansion)

const ExpansionInfo & getExpansion() const

CharacteristicKind

Indicates whether a file or directory holds normal user code, system code, or system code which is im...

bool isSystem(CharacteristicKind CK)

Determine whether a file / directory characteristic is for system code.

bool isModuleMap(CharacteristicKind CK)

Determine whether a file characteristic is for a module map.

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

const size_t malloc_bytes

MemoryBufferSizes(size_t malloc_bytes, size_t mmap_bytes)