-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[clang] NFCI: Use FileEntryRef
for FileID
creation
#67838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Were there no callers that could pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not that I could find. |
||
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); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,7 +228,7 @@ int main(int argc, const char **argv) { | |
|
||
Tool.applyAllReplacements(Rewrite); | ||
for (const auto &File : Files) { | ||
auto Entry = FileMgr.getFile(File); | ||
auto Entry = FileMgr.getOptionalFileRef(File); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another place we could use |
||
if (!Entry) { | ||
errs() << "clang-rename: " << File << " does not exist.\n"; | ||
return 1; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend
getFileRef
and then print the error message as well if it fails.