[clang] 416f101 - [clang] Use std::optional::value_or (NFC) (#109894)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 24 23:01:48 PDT 2024
Author: Kazu Hirata
Date: 2024-09-24T23:01:45-07:00
New Revision: 416f101111e06339387ac456c288cb5e60f41bc1
URL: https://github.com/llvm/llvm-project/commit/416f101111e06339387ac456c288cb5e60f41bc1
DIFF: https://github.com/llvm/llvm-project/commit/416f101111e06339387ac456c288cb5e60f41bc1.diff
LOG: [clang] Use std::optional::value_or (NFC) (#109894)
Added:
Modified:
clang/include/clang/AST/PropertiesBase.td
clang/include/clang/Basic/FileManager.h
clang/lib/APINotes/APINotesYAMLCompiler.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/PropertiesBase.td b/clang/include/clang/AST/PropertiesBase.td
index 9b934b20cf2559..3057669e3758b5 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -39,7 +39,7 @@ class EnumPropertyType<string typeName = ""> : PropertyType<typeName> {}
/// Supports optional values by using the null representation.
class RefPropertyType<string className> : PropertyType<className # "*"> {
let PackOptional =
- "value ? *value : nullptr";
+ "value.value_or(nullptr)";
let UnpackOptional =
"value ? std::optional<" # CXXName # ">(value) : std::nullopt";
}
diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h
index 527bbef24793ee..74029a91d1a6d0 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -293,7 +293,7 @@ class FileManager : public RefCountedBase<FileManager> {
bool RequiresNullTerminator = true,
std::optional<int64_t> MaybeLimit = std::nullopt) const {
return getBufferForFileImpl(Filename,
- /*FileSize=*/(MaybeLimit ? *MaybeLimit : -1),
+ /*FileSize=*/MaybeLimit.value_or(-1),
isVolatile, RequiresNullTerminator);
}
diff --git a/clang/lib/APINotes/APINotesYAMLCompiler.cpp b/clang/lib/APINotes/APINotesYAMLCompiler.cpp
index 16fd59244086fd..f72a1d65b5456f 100644
--- a/clang/lib/APINotes/APINotesYAMLCompiler.cpp
+++ b/clang/lib/APINotes/APINotesYAMLCompiler.cpp
@@ -757,8 +757,8 @@ class YAMLConverter {
OutInfo.addTypeInfo(idx++, N);
audited = Nullability.size() > 0 || ReturnNullability;
if (audited)
- OutInfo.addTypeInfo(0, ReturnNullability ? *ReturnNullability
- : NullabilityKind::NonNull);
+ OutInfo.addTypeInfo(0,
+ ReturnNullability.value_or(NullabilityKind::NonNull));
if (!audited)
return;
OutInfo.NullabilityAudited = audited;
More information about the cfe-commits
mailing list