Skip to content

Commit 79e3e42

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:bbe40b9e0a24605e0526475e643312839772294f into amd-gfx:c169650cd441
Local branch amd-gfx c169650 Merged main:b27eb0ae8280675fc8fb249d39f1ccafa3ee2187 into amd-gfx:ea66a9b7b6c7 Remote branch main bbe40b9 [MCAsmStreamer] Do not crash on switching to sections of unknown types (llvm#92380)
2 parents c169650 + bbe40b9 commit 79e3e42

File tree

47 files changed

+2720
-2071
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2720
-2071
lines changed

clang/include/clang/Basic/SourceManager.h

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,10 @@ class SLocEntry {
497497
bool isFile() const { return !isExpansion(); }
498498

499499
const FileInfo &getFile() const {
500+
return const_cast<SLocEntry *>(this)->getFile();
501+
}
502+
503+
FileInfo &getFile() {
500504
assert(isFile() && "Not a file SLocEntry!");
501505
return File;
502506
}
@@ -1120,12 +1124,12 @@ class SourceManager : public RefCountedBase<SourceManager> {
11201124
/// Set the number of FileIDs (files and macros) that were created
11211125
/// during preprocessing of \p FID, including it.
11221126
void setNumCreatedFIDsForFileID(FileID FID, unsigned NumFIDs,
1123-
bool Force = false) const {
1127+
bool Force = false) {
11241128
auto *Entry = getSLocEntryForFile(FID);
11251129
if (!Entry)
11261130
return;
11271131
assert((Force || Entry->getFile().NumCreatedFIDs == 0) && "Already set!");
1128-
const_cast<SrcMgr::FileInfo &>(Entry->getFile()).NumCreatedFIDs = NumFIDs;
1132+
Entry->getFile().NumCreatedFIDs = NumFIDs;
11291133
}
11301134

11311135
//===--------------------------------------------------------------------===//
@@ -1730,6 +1734,11 @@ class SourceManager : public RefCountedBase<SourceManager> {
17301734

17311735
/// Get a local SLocEntry. This is exposed for indexing.
17321736
const SrcMgr::SLocEntry &getLocalSLocEntry(unsigned Index) const {
1737+
return const_cast<SourceManager *>(this)->getLocalSLocEntry(Index);
1738+
}
1739+
1740+
/// Get a local SLocEntry. This is exposed for indexing.
1741+
SrcMgr::SLocEntry &getLocalSLocEntry(unsigned Index) {
17331742
assert(Index < LocalSLocEntryTable.size() && "Invalid index");
17341743
return LocalSLocEntryTable[Index];
17351744
}
@@ -1740,6 +1749,13 @@ class SourceManager : public RefCountedBase<SourceManager> {
17401749
/// Get a loaded SLocEntry. This is exposed for indexing.
17411750
const SrcMgr::SLocEntry &getLoadedSLocEntry(unsigned Index,
17421751
bool *Invalid = nullptr) const {
1752+
return const_cast<SourceManager *>(this)->getLoadedSLocEntry(Index,
1753+
Invalid);
1754+
}
1755+
1756+
/// Get a loaded SLocEntry. This is exposed for indexing.
1757+
SrcMgr::SLocEntry &getLoadedSLocEntry(unsigned Index,
1758+
bool *Invalid = nullptr) {
17431759
assert(Index < LoadedSLocEntryTable.size() && "Invalid index");
17441760
if (SLocEntryLoaded[Index])
17451761
return LoadedSLocEntryTable[Index];
@@ -1748,6 +1764,10 @@ class SourceManager : public RefCountedBase<SourceManager> {
17481764

17491765
const SrcMgr::SLocEntry &getSLocEntry(FileID FID,
17501766
bool *Invalid = nullptr) const {
1767+
return const_cast<SourceManager *>(this)->getSLocEntry(FID, Invalid);
1768+
}
1769+
1770+
SrcMgr::SLocEntry &getSLocEntry(FileID FID, bool *Invalid = nullptr) {
17511771
if (FID.ID == 0 || FID.ID == -1) {
17521772
if (Invalid) *Invalid = true;
17531773
return LocalSLocEntryTable[0];
@@ -1821,14 +1841,23 @@ class SourceManager : public RefCountedBase<SourceManager> {
18211841
SrcMgr::ContentCache &getFakeContentCacheForRecovery() const;
18221842

18231843
const SrcMgr::SLocEntry &loadSLocEntry(unsigned Index, bool *Invalid) const;
1844+
SrcMgr::SLocEntry &loadSLocEntry(unsigned Index, bool *Invalid);
18241845

18251846
const SrcMgr::SLocEntry *getSLocEntryOrNull(FileID FID) const {
1847+
return const_cast<SourceManager *>(this)->getSLocEntryOrNull(FID);
1848+
}
1849+
1850+
SrcMgr::SLocEntry *getSLocEntryOrNull(FileID FID) {
18261851
bool Invalid = false;
1827-
const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, &Invalid);
1852+
SrcMgr::SLocEntry &Entry = getSLocEntry(FID, &Invalid);
18281853
return Invalid ? nullptr : &Entry;
18291854
}
18301855

18311856
const SrcMgr::SLocEntry *getSLocEntryForFile(FileID FID) const {
1857+
return const_cast<SourceManager *>(this)->getSLocEntryForFile(FID);
1858+
}
1859+
1860+
SrcMgr::SLocEntry *getSLocEntryForFile(FileID FID) {
18321861
if (auto *Entry = getSLocEntryOrNull(FID))
18331862
if (Entry->isFile())
18341863
return Entry;
@@ -1839,6 +1868,10 @@ class SourceManager : public RefCountedBase<SourceManager> {
18391868
/// Invalid will not be modified for Local IDs.
18401869
const SrcMgr::SLocEntry &getSLocEntryByID(int ID,
18411870
bool *Invalid = nullptr) const {
1871+
return const_cast<SourceManager *>(this)->getSLocEntryByID(ID, Invalid);
1872+
}
1873+
1874+
SrcMgr::SLocEntry &getSLocEntryByID(int ID, bool *Invalid = nullptr) {
18421875
assert(ID != -1 && "Using FileID sentinel value");
18431876
if (ID < 0)
18441877
return getLoadedSLocEntryByID(ID, Invalid);
@@ -1847,6 +1880,11 @@ class SourceManager : public RefCountedBase<SourceManager> {
18471880

18481881
const SrcMgr::SLocEntry &
18491882
getLoadedSLocEntryByID(int ID, bool *Invalid = nullptr) const {
1883+
return const_cast<SourceManager *>(this)->getLoadedSLocEntryByID(ID,
1884+
Invalid);
1885+
}
1886+
1887+
SrcMgr::SLocEntry &getLoadedSLocEntryByID(int ID, bool *Invalid = nullptr) {
18501888
return getLoadedSLocEntry(static_cast<unsigned>(-ID - 2), Invalid);
18511889
}
18521890

clang/lib/Basic/SourceManager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,10 @@ ContentCache &SourceManager::createMemBufferContentCache(
431431

432432
const SrcMgr::SLocEntry &SourceManager::loadSLocEntry(unsigned Index,
433433
bool *Invalid) const {
434+
return const_cast<SourceManager *>(this)->loadSLocEntry(Index, Invalid);
435+
}
436+
437+
SrcMgr::SLocEntry &SourceManager::loadSLocEntry(unsigned Index, bool *Invalid) {
434438
assert(!SLocEntryLoaded[Index]);
435439
if (ExternalSLocEntries->ReadSLocEntry(-(static_cast<int>(Index) + 2))) {
436440
if (Invalid)

0 commit comments

Comments
 (0)