Skip to content

Commit

Permalink
[clang] Use std::optional::value_or (NFC) (#109894)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata authored Sep 25, 2024
1 parent 4bd3a62 commit 416f101
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/AST/PropertiesBase.td
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/FileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/APINotes/APINotesYAMLCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 416f101

Please sign in to comment.