Skip to content

Commit 416f101

Browse files
[clang] Use std::optional::value_or (NFC) (#109894)
1 parent 4bd3a62 commit 416f101

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

clang/include/clang/AST/PropertiesBase.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class EnumPropertyType<string typeName = ""> : PropertyType<typeName> {}
3939
/// Supports optional values by using the null representation.
4040
class RefPropertyType<string className> : PropertyType<className # "*"> {
4141
let PackOptional =
42-
"value ? *value : nullptr";
42+
"value.value_or(nullptr)";
4343
let UnpackOptional =
4444
"value ? std::optional<" # CXXName # ">(value) : std::nullopt";
4545
}

clang/include/clang/Basic/FileManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class FileManager : public RefCountedBase<FileManager> {
293293
bool RequiresNullTerminator = true,
294294
std::optional<int64_t> MaybeLimit = std::nullopt) const {
295295
return getBufferForFileImpl(Filename,
296-
/*FileSize=*/(MaybeLimit ? *MaybeLimit : -1),
296+
/*FileSize=*/MaybeLimit.value_or(-1),
297297
isVolatile, RequiresNullTerminator);
298298
}
299299

clang/lib/APINotes/APINotesYAMLCompiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,8 @@ class YAMLConverter {
757757
OutInfo.addTypeInfo(idx++, N);
758758
audited = Nullability.size() > 0 || ReturnNullability;
759759
if (audited)
760-
OutInfo.addTypeInfo(0, ReturnNullability ? *ReturnNullability
761-
: NullabilityKind::NonNull);
760+
OutInfo.addTypeInfo(0,
761+
ReturnNullability.value_or(NullabilityKind::NonNull));
762762
if (!audited)
763763
return;
764764
OutInfo.NullabilityAudited = audited;

0 commit comments

Comments
 (0)