diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2023-10-03 22:07:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-03 13:07:46 -0700 |
commit | 27254ae51192d83fd45777cc33b004d06c2ceb50 (patch) | |
tree | 2a6f9e94613ecc6c3a80404ab99000577745761d /clang/lib/Basic/SourceManager.cpp | |
parent | c6fed74f6f2e0c208ea0324fa1668b2cba5277a9 (diff) | |
download | llvm-27254ae51192d83fd45777cc33b004d06c2ceb50.zip llvm-27254ae51192d83fd45777cc33b004d06c2ceb50.tar.gz llvm-27254ae51192d83fd45777cc33b004d06c2ceb50.tar.bz2 |
[clang] NFCI: Use `FileEntryRef` for `FileID` creation (#67838)
This patch removes the `SourceManager` APIs that create `FileID` from a
`const FileEntry *` in favor of APIs that take `FileEntryRef`. This also
removes a misleading documentation that claims `nullptr` file entry
represents stdin. I don't think that's right, since we just try to
dereference that pointer anyways.
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 3066cc5..7312f05 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -527,17 +527,6 @@ FileID SourceManager::getNextFileID(FileID FID) const { /// Create a new FileID that represents the specified file /// being \#included from the specified IncludePosition. -/// -/// This translates NULL into standard input. -FileID SourceManager::createFileID(const FileEntry *SourceFile, - SourceLocation IncludePos, - SrcMgr::CharacteristicKind FileCharacter, - int LoadedID, - SourceLocation::UIntTy LoadedOffset) { - return createFileID(SourceFile->getLastRef(), IncludePos, FileCharacter, - LoadedID, LoadedOffset); -} - FileID SourceManager::createFileID(FileEntryRef SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, @@ -585,7 +574,7 @@ FileID SourceManager::createFileID(const llvm::MemoryBufferRef &Buffer, /// Get the FileID for \p SourceFile if it exists. Otherwise, create a /// new FileID for the \p SourceFile. FileID -SourceManager::getOrCreateFileID(const FileEntry *SourceFile, +SourceManager::getOrCreateFileID(FileEntryRef SourceFile, SrcMgr::CharacteristicKind FileCharacter) { FileID ID = translateFile(SourceFile); return ID.isValid() ? ID : createFileID(SourceFile, SourceLocation(), @@ -2375,8 +2364,9 @@ SourceManagerForFile::SourceManagerForFile(StringRef FileName, IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), new DiagnosticOptions); SourceMgr = std::make_unique<SourceManager>(*Diagnostics, *FileMgr); - FileID ID = SourceMgr->createFileID(*FileMgr->getFile(FileName), - SourceLocation(), clang::SrcMgr::C_User); + FileEntryRef FE = llvm::cantFail(FileMgr->getFileRef(FileName)); + FileID ID = + SourceMgr->createFileID(FE, SourceLocation(), clang::SrcMgr::C_User); assert(ID.isValid()); SourceMgr->setMainFileID(ID); } |