use new llvm::Optional API

`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
This commit is contained in:
Erik Eckstein
2022-11-15 15:08:30 +01:00
parent 567b68aa6f
commit ab1b343dad
328 changed files with 1537 additions and 1536 deletions

View File

@@ -84,8 +84,8 @@ static bool isTargetTooNew(const llvm::Triple &moduleTarget,
moduleTarget.getMacOSXVersion(osVersion);
// TODO: Add isMacOSXVersionLT(Triple) API (or taking a VersionTuple)
return ctxTarget.isMacOSXVersionLT(osVersion.getMajor(),
osVersion.getMinor().getValueOr(0),
osVersion.getSubminor().getValueOr(0));
osVersion.getMinor().value_or(0),
osVersion.getSubminor().value_or(0));
}
return ctxTarget.isOSVersionLT(moduleTarget);
}
@@ -508,7 +508,7 @@ void ModuleFile::getImportDecls(SmallVectorImpl<Decl *> &Results) {
TopLevelModule, DeclNameRef(ScopeID),
NL_QualifiedDefault, Decls);
Optional<ImportKind> FoundKind = ImportDecl::findBestImportKind(Decls);
assert(FoundKind.hasValue() &&
assert(FoundKind.has_value() &&
"deserialized imports should not be ambiguous");
Kind = *FoundKind;
}
@@ -1067,8 +1067,8 @@ void ModuleFile::collectBasicSourceFileInfo(
abort();
}
callback(BasicSourceFileInfo(filePath,
fingerprintIncludingTypeMembers.getValue(),
fingerprintExcludingTypeMembers.getValue(),
fingerprintIncludingTypeMembers.value(),
fingerprintExcludingTypeMembers.value(),
llvm::sys::TimePoint<>(std::chrono::nanoseconds(timestamp)),
fileSize));
}
@@ -1193,29 +1193,29 @@ Optional<StringRef> ModuleFile::getSourceFileNameById(unsigned Id) const {
Optional<StringRef> ModuleFile::getGroupNameForDecl(const Decl *D) const {
auto Triple = getCommentForDecl(D);
if (!Triple.hasValue()) {
if (!Triple.has_value()) {
return None;
}
return getGroupNameById(Triple.getValue().Group);
return getGroupNameById(Triple.value().Group);
}
Optional<StringRef>
ModuleFile::getSourceFileNameForDecl(const Decl *D) const {
auto Triple = getCommentForDecl(D);
if (!Triple.hasValue()) {
if (!Triple.has_value()) {
return None;
}
return getSourceFileNameById(Triple.getValue().Group);
return getSourceFileNameById(Triple.value().Group);
}
Optional<unsigned>
ModuleFile::getSourceOrderForDecl(const Decl *D) const {
auto Triple = getCommentForDecl(D);
if (!Triple.hasValue()) {
if (!Triple.has_value()) {
return None;
}
return Triple.getValue().SourceOrder;
return Triple.value().SourceOrder;
}
void ModuleFile::collectAllGroups(SmallVectorImpl<StringRef> &Names) const {
@@ -1264,7 +1264,7 @@ ModuleFile::getCommentForDeclByUSR(StringRef USR) const {
Optional<StringRef>
ModuleFile::getGroupNameByUSR(StringRef USR) const {
if (auto Comment = getCommentForDeclByUSR(USR)) {
return getGroupNameById(Comment.getValue().Group);
return getGroupNameById(Comment.value().Group);
}
return None;
}