Skip to content

Commit

Permalink
[clang] NFCI: Use FileEntryRef in `SourceManager::getMemoryBufferFo…
Browse files Browse the repository at this point in the history
…rFileOr{None,Fake}()`
  • Loading branch information
jansvoboda11 committed Sep 29, 2023
1 parent 9c1cdc2 commit 3661a48
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions clang/include/clang/Basic/SourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -942,12 +942,12 @@ class SourceManager : public RefCountedBase<SourceManager> {
///
/// Returns std::nullopt if the buffer is not valid.
std::optional<llvm::MemoryBufferRef>
getMemoryBufferForFileOrNone(const FileEntry *File);
getMemoryBufferForFileOrNone(FileEntryRef File);

/// Retrieve the memory buffer associated with the given file.
///
/// Returns a fake buffer if there isn't a real one.
llvm::MemoryBufferRef getMemoryBufferForFileOrFake(const FileEntry *File) {
llvm::MemoryBufferRef getMemoryBufferForFileOrFake(FileEntryRef File) {
if (auto B = getMemoryBufferForFileOrNone(File))
return *B;
return getFakeBufferForRecovery();
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Basic/SourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,8 @@ SourceManager::createExpansionLocImpl(const ExpansionInfo &Info,
}

std::optional<llvm::MemoryBufferRef>
SourceManager::getMemoryBufferForFileOrNone(const FileEntry *File) {
SrcMgr::ContentCache &IR = getOrCreateContentCache(File->getLastRef());
SourceManager::getMemoryBufferForFileOrNone(FileEntryRef File) {
SrcMgr::ContentCache &IR = getOrCreateContentCache(File);
return IR.getBufferOrNone(Diag, getFileManager(), SourceLocation());
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool isImportLine(llvm::StringRef Line) {
return Line.startswith("import");
}

llvm::StringRef getFileContents(const FileEntry *FE, const SourceManager &SM) {
llvm::StringRef getFileContents(FileEntryRef FE, const SourceManager &SM) {
return const_cast<SourceManager &>(SM)
.getMemoryBufferForFileOrNone(FE)
.value_or(llvm::MemoryBufferRef())
Expand Down

0 comments on commit 3661a48

Please sign in to comment.