Skip to content

Commit

Permalink
[clang-tools-extra] llvm::Optional::value => operator*/operator->
Browse files Browse the repository at this point in the history
std::optional::value() has undesired exception checking semantics and is
unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The
call sites block std::optional migration.
  • Loading branch information
MaskRay committed Dec 17, 2022
1 parent d1f4753 commit b57533d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
Expand Up @@ -818,7 +818,7 @@ void NotNullTerminatedResultCheck::check(
}

if (AreSafeFunctionsWanted)
UseSafeFunctions = AreSafeFunctionsWanted.value();
UseSafeFunctions = *AreSafeFunctionsWanted;
}

StringRef Name = FunctionExpr->getDirectCallee()->getName();
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/AST.cpp
Expand Up @@ -955,7 +955,7 @@ resolveForwardingParameters(const FunctionDecl *D, unsigned MaxDepth) {
break;
}
// If we found something: Fill in non-pack parameters
auto Info = V.Info.value();
auto Info = *V.Info;
HeadIt = std::copy(Info.Head.begin(), Info.Head.end(), HeadIt);
TailIt = std::copy(Info.Tail.rbegin(), Info.Tail.rend(), TailIt);
// Prepare next recursion level
Expand Down
3 changes: 1 addition & 2 deletions clang-tools-extra/clangd/ClangdServer.cpp
Expand Up @@ -415,8 +415,7 @@ void ClangdServer::codeComplete(PathRef File, Position Pos,
}
if (SpecFuzzyFind && SpecFuzzyFind->NewReq) {
std::lock_guard<std::mutex> Lock(CachedCompletionFuzzyFindRequestMutex);
CachedCompletionFuzzyFindRequestByFile[File] =
SpecFuzzyFind->NewReq.value();
CachedCompletionFuzzyFindRequestByFile[File] = *SpecFuzzyFind->NewReq;
}
// SpecFuzzyFind is only destroyed after speculative fuzzy find finishes.
// We don't want `codeComplete` to wait for the async call if it doesn't use
Expand Down
Expand Up @@ -35,7 +35,7 @@ class InsertAliasCheck : public ClangTidyCheck {
auto Hint = Aliaser->createAlias(*Result.Context, *Call, "::foo::bar",
{"b", "some_alias"});
if (Hint)
diag(Call->getBeginLoc(), "Fix for testing") << Hint.value();
diag(Call->getBeginLoc(), "Fix for testing") << *Hint;

diag(Call->getBeginLoc(), "insert call") << FixItHint::CreateInsertion(
Call->getBeginLoc(),
Expand Down
Expand Up @@ -38,7 +38,7 @@ class InsertUsingCheck : public clang::tidy::ClangTidyCheck {
Inserter->createUsingDeclaration(*Result.Context, *Call, "::foo::func");

if (Hint)
diag(Call->getBeginLoc(), "Fix for testing") << Hint.value();
diag(Call->getBeginLoc(), "Fix for testing") << *Hint;

diag(Call->getBeginLoc(), "insert call")
<< clang::FixItHint::CreateReplacement(
Expand Down

0 comments on commit b57533d

Please sign in to comment.