diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-10-14 18:06:29 -0400 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-10-20 17:01:23 -0400 |
commit | 2dc7e0c6a586135fe236cd7ebf065617a7638bdb (patch) | |
tree | 9d75fd6071d23062e6bfdb9a605d4106308f087d /clang/lib/Basic/SourceManager.cpp | |
parent | e557b6a66d5476dd5b9905934099f5f7357310b8 (diff) | |
download | llvm-2dc7e0c6a586135fe236cd7ebf065617a7638bdb.zip llvm-2dc7e0c6a586135fe236cd7ebf065617a7638bdb.tar.gz llvm-2dc7e0c6a586135fe236cd7ebf065617a7638bdb.tar.bz2 |
clang/Basic: Replace SourceManager::getMemoryBufferForFile, NFC
Replace `SourceManager::getMemoryBufferForFile`, which returned a
dereferenceable `MemoryBuffer*` and had a `bool*Invalid` out parameter,
with `getMemoryBufferForFileOrNone` (returning
`Optional<MemoryBufferRef>`) and `getMemoryBufferForFileOrFake`
(returning `MemoryBufferRef`).
Differential Revision: https://reviews.llvm.org/D89429
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 9902709..51772d5 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -701,14 +701,11 @@ SourceManager::createExpansionLocImpl(const ExpansionInfo &Info, return SourceLocation::getMacroLoc(NextLocalOffset - (TokLength + 1)); } -const llvm::MemoryBuffer * -SourceManager::getMemoryBufferForFile(const FileEntry *File, bool *Invalid) { +llvm::Optional<llvm::MemoryBufferRef> +SourceManager::getMemoryBufferForFileOrNone(const FileEntry *File) { const SrcMgr::ContentCache *IR = getOrCreateContentCache(File); assert(IR && "getOrCreateContentCache() cannot return NULL"); - auto *B = IR->getBufferPointer(Diag, getFileManager(), SourceLocation()); - if (Invalid) - *Invalid = !B; - return B ? B : getFakeBufferForRecovery(); + return IR->getBufferOrNone(Diag, getFileManager(), SourceLocation()); } void SourceManager::overrideFileContents(const FileEntry *SourceFile, |