aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp4
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp4
-rw-r--r--clang/lib/Frontend/HeaderIncludeGen.cpp2
-rw-r--r--clang/lib/Frontend/LogDiagnosticPrinter.cpp4
-rw-r--r--clang/lib/Frontend/PrecompiledPreamble.cpp16
-rw-r--r--clang/lib/Frontend/Rewrite/FixItRewriter.cpp3
-rw-r--r--clang/lib/Frontend/Rewrite/HTMLPrint.cpp2
-rw-r--r--clang/lib/Frontend/SARIFDiagnostic.cpp2
-rw-r--r--clang/lib/Frontend/TextDiagnostic.cpp2
-rw-r--r--clang/lib/Frontend/VerifyDiagnosticConsumer.cpp4
10 files changed, 22 insertions, 21 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index a4753f52..4e42028 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1493,8 +1493,8 @@ StringRef ASTUnit::getMainFileName() const {
}
if (SourceMgr) {
- if (const FileEntry *
- FE = SourceMgr->getFileEntryForID(SourceMgr->getMainFileID()))
+ if (OptionalFileEntryRef FE =
+ SourceMgr->getFileEntryRefForID(SourceMgr->getMainFileID()))
return FE->getName();
}
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index 2da25be..248558e 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -666,7 +666,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
} else {
auto &OldSM = AST->getSourceManager();
FileID ID = OldSM.getMainFileID();
- if (auto *File = OldSM.getFileEntryForID(ID))
+ if (auto File = OldSM.getFileEntryRefForID(ID))
Input = FrontendInputFile(File->getName(), Kind);
else
Input = FrontendInputFile(OldSM.getBufferOrFake(ID), Kind);
@@ -844,7 +844,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
return false;
}
// We now have the filename...
- FileName = FE->getFileEntry().getName();
+ FileName = FE->getName();
// ... still a header unit, but now use the path as written.
Kind = Input.getKind().withHeaderUnit(InputKind::HeaderUnit_Abs);
Input = FrontendInputFile(FileName, Kind, Input.isSystem());
diff --git a/clang/lib/Frontend/HeaderIncludeGen.cpp b/clang/lib/Frontend/HeaderIncludeGen.cpp
index 9c1bf49..992c267 100644
--- a/clang/lib/Frontend/HeaderIncludeGen.cpp
+++ b/clang/lib/Frontend/HeaderIncludeGen.cpp
@@ -259,7 +259,7 @@ void HeaderIncludesCallback::FileSkipped(const FileEntryRef &SkippedFile, const
}
void HeaderIncludesJSONCallback::EndOfMainFile() {
- const FileEntry *FE = SM.getFileEntryForID(SM.getMainFileID());
+ OptionalFileEntryRef FE = SM.getFileEntryRefForID(SM.getMainFileID());
SmallString<256> MainFile(FE->getName());
SM.getFileManager().makeAbsolutePath(MainFile);
diff --git a/clang/lib/Frontend/LogDiagnosticPrinter.cpp b/clang/lib/Frontend/LogDiagnosticPrinter.cpp
index d810b37..32fc6cb 100644
--- a/clang/lib/Frontend/LogDiagnosticPrinter.cpp
+++ b/clang/lib/Frontend/LogDiagnosticPrinter.cpp
@@ -118,7 +118,7 @@ void LogDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,
const SourceManager &SM = Info.getSourceManager();
FileID FID = SM.getMainFileID();
if (FID.isValid()) {
- if (const FileEntry *FE = SM.getFileEntryForID(FID))
+ if (OptionalFileEntryRef FE = SM.getFileEntryRefForID(FID))
MainFilename = std::string(FE->getName());
}
}
@@ -147,7 +147,7 @@ void LogDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,
// At least print the file name if available:
FileID FID = SM.getFileID(Info.getLocation());
if (FID.isValid()) {
- if (const FileEntry *FE = SM.getFileEntryForID(FID))
+ if (OptionalFileEntryRef FE = SM.getFileEntryRefForID(FID))
DE.Filename = std::string(FE->getName());
}
} else {
diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp b/clang/lib/Frontend/PrecompiledPreamble.cpp
index b768c53..62373b2 100644
--- a/clang/lib/Frontend/PrecompiledPreamble.cpp
+++ b/clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -550,19 +550,19 @@ llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build(
SourceManager &SourceMgr = Clang->getSourceManager();
for (auto &Filename : PreambleDepCollector->getDependencies()) {
- auto FileOrErr = Clang->getFileManager().getFile(Filename);
- if (!FileOrErr ||
- *FileOrErr == SourceMgr.getFileEntryForID(SourceMgr.getMainFileID()))
+ auto MaybeFile = Clang->getFileManager().getOptionalFileRef(Filename);
+ if (!MaybeFile ||
+ MaybeFile == SourceMgr.getFileEntryRefForID(SourceMgr.getMainFileID()))
continue;
- auto File = *FileOrErr;
- if (time_t ModTime = File->getModificationTime()) {
- FilesInPreamble[File->getName()] =
- PrecompiledPreamble::PreambleFileHash::createForFile(File->getSize(),
+ auto File = *MaybeFile;
+ if (time_t ModTime = File.getModificationTime()) {
+ FilesInPreamble[File.getName()] =
+ PrecompiledPreamble::PreambleFileHash::createForFile(File.getSize(),
ModTime);
} else {
llvm::MemoryBufferRef Buffer =
SourceMgr.getMemoryBufferForFileOrFake(File);
- FilesInPreamble[File->getName()] =
+ FilesInPreamble[File.getName()] =
PrecompiledPreamble::PreambleFileHash::createForMemoryBuffer(Buffer);
}
}
diff --git a/clang/lib/Frontend/Rewrite/FixItRewriter.cpp b/clang/lib/Frontend/Rewrite/FixItRewriter.cpp
index 4fe64b9..567bac5 100644
--- a/clang/lib/Frontend/Rewrite/FixItRewriter.cpp
+++ b/clang/lib/Frontend/Rewrite/FixItRewriter.cpp
@@ -93,7 +93,8 @@ bool FixItRewriter::WriteFixedFiles(
}
for (iterator I = buffer_begin(), E = buffer_end(); I != E; ++I) {
- const FileEntry *Entry = Rewrite.getSourceMgr().getFileEntryForID(I->first);
+ OptionalFileEntryRef Entry =
+ Rewrite.getSourceMgr().getFileEntryRefForID(I->first);
int fd;
std::string Filename =
FixItOpts->RewriteFilename(std::string(Entry->getName()), fd);
diff --git a/clang/lib/Frontend/Rewrite/HTMLPrint.cpp b/clang/lib/Frontend/Rewrite/HTMLPrint.cpp
index 1388c2e..69baa8f 100644
--- a/clang/lib/Frontend/Rewrite/HTMLPrint.cpp
+++ b/clang/lib/Frontend/Rewrite/HTMLPrint.cpp
@@ -62,7 +62,7 @@ void HTMLPrinter::HandleTranslationUnit(ASTContext &Ctx) {
// Format the file.
FileID FID = R.getSourceMgr().getMainFileID();
- const FileEntry* Entry = R.getSourceMgr().getFileEntryForID(FID);
+ OptionalFileEntryRef Entry = R.getSourceMgr().getFileEntryRefForID(FID);
StringRef Name;
// In some cases, in particular the case where the input is from stdin,
// there is no entry. Fall back to the memory buffer for a name in those
diff --git a/clang/lib/Frontend/SARIFDiagnostic.cpp b/clang/lib/Frontend/SARIFDiagnostic.cpp
index 416e913..ee8e8b54 100644
--- a/clang/lib/Frontend/SARIFDiagnostic.cpp
+++ b/clang/lib/Frontend/SARIFDiagnostic.cpp
@@ -70,7 +70,7 @@ SarifResult SARIFDiagnostic::addLocationToResult(
// At least add the file name if available:
FileID FID = Loc.getFileID();
if (FID.isValid()) {
- if (const FileEntry *FE = Loc.getFileEntry()) {
+ if (OptionalFileEntryRef FE = Loc.getFileEntryRef()) {
emitFilename(FE->getName(), Loc.getManager());
// FIXME(llvm-project/issues/57366): File-only locations
}
diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp
index 1b58261..7f55854 100644
--- a/clang/lib/Frontend/TextDiagnostic.cpp
+++ b/clang/lib/Frontend/TextDiagnostic.cpp
@@ -779,7 +779,7 @@ void TextDiagnostic::emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc,
if (PLoc.isInvalid()) {
// At least print the file name if available:
if (FileID FID = Loc.getFileID(); FID.isValid()) {
- if (const FileEntry *FE = Loc.getFileEntry()) {
+ if (OptionalFileEntryRef FE = Loc.getFileEntryRef()) {
emitFilename(FE->getName(), Loc.getManager());
OS << ": ";
}
diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index c811db8..d70f2a9 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -868,8 +868,8 @@ static unsigned PrintUnexpected(DiagnosticsEngine &Diags, SourceManager *SourceM
OS << "\n (frontend)";
else {
OS << "\n ";
- if (const FileEntry *File = SourceMgr->getFileEntryForID(
- SourceMgr->getFileID(I->first)))
+ if (OptionalFileEntryRef File =
+ SourceMgr->getFileEntryRefForID(SourceMgr->getFileID(I->first)))
OS << " File " << File->getName();
OS << " Line " << SourceMgr->getPresumedLineNumber(I->first);
}