[clang-tools-extra] b57533d - [clang-tools-extra] llvm::Optional::value => operator*/operator->
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 17 12:03:06 PST 2022
Author: Fangrui Song
Date: 2022-12-17T20:03:01Z
New Revision: b57533d1d5a2fa6b9402aa6255cb67b2dd7529a4
URL: https://github.com/llvm/llvm-project/commit/b57533d1d5a2fa6b9402aa6255cb67b2dd7529a4
DIFF: https://github.com/llvm/llvm-project/commit/b57533d1d5a2fa6b9402aa6255cb67b2dd7529a4.diff
LOG: [clang-tools-extra] llvm::Optional::value => operator*/operator->
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.
Added:
Modified:
clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp
clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
index ea3d64ef700e8..17537f1d1f867 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -818,7 +818,7 @@ void NotNullTerminatedResultCheck::check(
}
if (AreSafeFunctionsWanted)
- UseSafeFunctions = AreSafeFunctionsWanted.value();
+ UseSafeFunctions = *AreSafeFunctionsWanted;
}
StringRef Name = FunctionExpr->getDirectCallee()->getName();
diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp
index 6e566fbf91b1e..b9c76076f4907 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -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
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp
index b2b6c44744765..9c8803bbfb1ce 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -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
diff --git a/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp b/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp
index c28e89cffac37..dfe04c175b791 100644
--- a/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp
@@ -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(),
diff --git a/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp b/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp
index c27a1f0b132ed..717d2bed15fd1 100644
--- a/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp
@@ -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(
More information about the cfe-commits
mailing list