diff options
author | Kazu Hirata <kazu@google.com> | 2022-12-03 11:34:27 -0800 |
---|---|---|
committer | Kazu Hirata <kazu@google.com> | 2022-12-03 11:34:27 -0800 |
commit | eeee3fee37a65d68ebbfcb6e78b6b2e018180b0c (patch) | |
tree | c56d82b81c020e541040542c478b1f4da3a4ac46 /clang/lib/Basic/SourceManager.cpp | |
parent | 34e0d0579a3a6617b9b3212f2bc63d959c8f56c6 (diff) | |
download | llvm-eeee3fee37a65d68ebbfcb6e78b6b2e018180b0c.zip llvm-eeee3fee37a65d68ebbfcb6e78b6b2e018180b0c.tar.gz llvm-eeee3fee37a65d68ebbfcb6e78b6b2e018180b0c.tar.bz2 |
[Basic] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated. The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index a5f673f..44ced42 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -105,11 +105,11 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM, // Lazily create the Buffer for ContentCaches that wrap files. If we already // computed it, just return what we have. if (IsBufferInvalid) - return None; + return std::nullopt; if (Buffer) return Buffer->getMemBufferRef(); if (!ContentsEntry) - return None; + return std::nullopt; // Start with the assumption that the buffer is invalid to simplify early // return paths. @@ -131,7 +131,7 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM, Diag.Report(Loc, diag::err_cannot_open_file) << ContentsEntry->getName() << BufferOrError.getError().message(); - return None; + return std::nullopt; } Buffer = std::move(*BufferOrError); @@ -153,7 +153,7 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM, Diag.Report(Loc, diag::err_file_too_large) << ContentsEntry->getName(); - return None; + return std::nullopt; } // Unless this is a named pipe (in which case we can handle a mismatch), @@ -168,7 +168,7 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM, Diag.Report(Loc, diag::err_file_modified) << ContentsEntry->getName(); - return None; + return std::nullopt; } // If the buffer is valid, check to see if it has a UTF Byte Order Mark @@ -180,7 +180,7 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM, if (InvalidBOM) { Diag.Report(Loc, diag::err_unsupported_bom) << InvalidBOM << ContentsEntry->getName(); - return None; + return std::nullopt; } // Buffer has been validated. @@ -720,7 +720,7 @@ SourceManager::bypassFileContentsOverride(FileEntryRef File) { // If the file can't be found in the FS, give up. if (!BypassFile) - return None; + return std::nullopt; (void)getOrCreateContentCache(*BypassFile); return BypassFile; @@ -735,7 +735,7 @@ SourceManager::getNonBuiltinFilenameForID(FileID FID) const { if (const SrcMgr::SLocEntry *Entry = getSLocEntryForFile(FID)) if (Entry->getFile().getContentCache().OrigEntry) return Entry->getFile().getName(); - return None; + return std::nullopt; } StringRef SourceManager::getBufferData(FileID FID, bool *Invalid) const { @@ -749,7 +749,7 @@ llvm::Optional<StringRef> SourceManager::getBufferDataIfLoaded(FileID FID) const { if (const SrcMgr::SLocEntry *Entry = getSLocEntryForFile(FID)) return Entry->getFile().getContentCache().getBufferDataIfLoaded(); - return None; + return std::nullopt; } llvm::Optional<StringRef> SourceManager::getBufferDataOrNone(FileID FID) const { @@ -757,7 +757,7 @@ llvm::Optional<StringRef> SourceManager::getBufferDataOrNone(FileID FID) const { if (auto B = Entry->getFile().getContentCache().getBufferOrNone( Diag, getFileManager(), SourceLocation())) return B->getBuffer(); - return None; + return std::nullopt; } //===----------------------------------------------------------------------===// @@ -2230,7 +2230,7 @@ LLVM_DUMP_METHOD void SourceManager::dump() const { DumpSLocEntry(ID, LoadedSLocEntryTable[Index], NextStart); NextStart = LoadedSLocEntryTable[Index].getOffset(); } else { - NextStart = None; + NextStart = std::nullopt; } } } |