aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/HeaderMap.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2023-01-14 12:31:01 -0800
committerKazu Hirata <kazu@google.com>2023-01-14 12:31:01 -0800
commit6ad0788c332bb2043142954d300c49ac3e537f34 (patch)
treea67542ce4ca8dbcc65ef3cd01e76ff9cb861208b /clang/lib/Lex/HeaderMap.cpp
parentff39b7ea89476c78177aff5cb0ddb441e74c8838 (diff)
downloadllvm-6ad0788c332bb2043142954d300c49ac3e537f34.zip
llvm-6ad0788c332bb2043142954d300c49ac3e537f34.tar.gz
llvm-6ad0788c332bb2043142954d300c49ac3e537f34.tar.bz2
[clang] Use std::optional instead of llvm::Optional (NFC)
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h". 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/Lex/HeaderMap.cpp')
-rw-r--r--clang/lib/Lex/HeaderMap.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/clang/lib/Lex/HeaderMap.cpp b/clang/lib/Lex/HeaderMap.cpp
index 2a444b5..bb50a4e 100644
--- a/clang/lib/Lex/HeaderMap.cpp
+++ b/clang/lib/Lex/HeaderMap.cpp
@@ -146,7 +146,7 @@ HMapBucket HeaderMapImpl::getBucket(unsigned BucketNo) const {
return Result;
}
-Optional<StringRef> HeaderMapImpl::getString(unsigned StrTabIdx) const {
+std::optional<StringRef> HeaderMapImpl::getString(unsigned StrTabIdx) const {
// Add the start of the string table to the idx.
StrTabIdx += getEndianAdjustedWord(getHeader().StringsOffset);
@@ -178,7 +178,7 @@ LLVM_DUMP_METHOD void HeaderMapImpl::dump() const {
<< ", " << getEndianAdjustedWord(Hdr.NumEntries) << "\n";
auto getStringOrInvalid = [this](unsigned Id) -> StringRef {
- if (Optional<StringRef> S = getString(Id))
+ if (std::optional<StringRef> S = getString(Id))
return *S;
return "<invalid>";
};
@@ -209,7 +209,7 @@ StringRef HeaderMapImpl::lookupFilename(StringRef Filename,
if (B.Key == HMAP_EmptyBucketKey) return StringRef(); // Hash miss.
// See if the key matches. If not, probe on.
- Optional<StringRef> Key = getString(B.Key);
+ std::optional<StringRef> Key = getString(B.Key);
if (LLVM_UNLIKELY(!Key))
continue;
if (!Filename.equals_insensitive(*Key))
@@ -217,8 +217,8 @@ StringRef HeaderMapImpl::lookupFilename(StringRef Filename,
// If so, we have a match in the hash table. Construct the destination
// path.
- Optional<StringRef> Prefix = getString(B.Prefix);
- Optional<StringRef> Suffix = getString(B.Suffix);
+ std::optional<StringRef> Prefix = getString(B.Prefix);
+ std::optional<StringRef> Suffix = getString(B.Suffix);
DestPath.clear();
if (LLVM_LIKELY(Prefix && Suffix)) {
@@ -241,9 +241,9 @@ StringRef HeaderMapImpl::reverseLookupFilename(StringRef DestPath) const {
if (B.Key == HMAP_EmptyBucketKey)
continue;
- Optional<StringRef> Key = getString(B.Key);
- Optional<StringRef> Prefix = getString(B.Prefix);
- Optional<StringRef> Suffix = getString(B.Suffix);
+ std::optional<StringRef> Key = getString(B.Key);
+ std::optional<StringRef> Prefix = getString(B.Prefix);
+ std::optional<StringRef> Suffix = getString(B.Suffix);
if (LLVM_LIKELY(Key && Prefix && Suffix)) {
SmallVector<char, 1024> Buf;
Buf.append(Prefix->begin(), Prefix->end());