[clang] Use std::optional::value_or (NFC) (#109894)

This commit is contained in:
Kazu Hirata
2024-09-24 23:01:45 -07:00
committed by GitHub
parent 4bd3a62cd6
commit 416f101111
3 changed files with 4 additions and 4 deletions

View File

@@ -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";
}

View File

@@ -293,7 +293,7 @@ public:
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);
}

View File

@@ -757,8 +757,8 @@ public:
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;