Author: Fangrui Song Date: 2022-12-17T03:12:04Z New Revision: 53243f2a296178b899dcc569475bdcc7e5f30d3b
URL: https://github.com/llvm/llvm-project/commit/53243f2a296178b899dcc569475bdcc7e5f30d3b DIFF: https://github.com/llvm/llvm-project/commit/53243f2a296178b899dcc569475bdcc7e5f30d3b.diff LOG: std::optional::value => operator*/operator-> value() has undesired exception checking semantics and calls __throw_bad_optional_access in libc++. Moreover, the API is unavailable without _LIBCPP_NO_EXCEPTIONS on older Mach-O platforms (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). This fixes check-clang-tools. Added: Modified: clang-tools-extra/clang-doc/HTMLGenerator.cpp clang-tools-extra/clangd/ClangdLSPServer.cpp clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp llvm/lib/Transforms/IPO/AttributorAttributes.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp b/clang-tools-extra/clang-doc/HTMLGenerator.cpp index 03c698cde0459..37598c43e9572 100644 --- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp +++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp @@ -655,10 +655,10 @@ genHTML(const EnumInfo &I, const ClangDocContext &CDCtx) { if (I.DefLoc) { if (!CDCtx.RepositoryUrl) - Out.emplace_back(writeFileDefinition(I.DefLoc.value())); + Out.emplace_back(writeFileDefinition(*I.DefLoc)); else Out.emplace_back(writeFileDefinition( - I.DefLoc.value(), StringRef{CDCtx.RepositoryUrl.value()})); + *I.DefLoc, StringRef{*CDCtx.RepositoryUrl})); } std::string Description; @@ -704,10 +704,10 @@ genHTML(const FunctionInfo &I, const ClangDocContext &CDCtx, if (I.DefLoc) { if (!CDCtx.RepositoryUrl) - Out.emplace_back(writeFileDefinition(I.DefLoc.value())); + Out.emplace_back(writeFileDefinition(*I.DefLoc)); else Out.emplace_back(writeFileDefinition( - I.DefLoc.value(), StringRef{CDCtx.RepositoryUrl.value()})); + *I.DefLoc, StringRef{*CDCtx.RepositoryUrl})); } std::string Description; @@ -771,10 +771,10 @@ genHTML(const RecordInfo &I, Index &InfoIndex, const ClangDocContext &CDCtx, if (I.DefLoc) { if (!CDCtx.RepositoryUrl) - Out.emplace_back(writeFileDefinition(I.DefLoc.value())); + Out.emplace_back(writeFileDefinition(*I.DefLoc)); else Out.emplace_back(writeFileDefinition( - I.DefLoc.value(), StringRef{CDCtx.RepositoryUrl.value()})); + *I.DefLoc, StringRef{*CDCtx.RepositoryUrl})); } std::string Description; diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp index 306ff3bcec925..6259057e9cf47 100644 --- a/clang-tools-extra/clangd/ClangdLSPServer.cpp +++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -670,8 +670,8 @@ void ClangdLSPServer::onDocumentDidChange( const DidChangeTextDocumentParams &Params) { auto WantDiags = WantDiagnostics::Auto; if (Params.wantDiagnostics) - WantDiags = Params.wantDiagnostics.value() ? WantDiagnostics::Yes - : WantDiagnostics::No; + WantDiags = + *Params.wantDiagnostics ? WantDiagnostics::Yes : WantDiagnostics::No; PathRef File = Params.textDocument.uri.file(); auto Code = Server->getDraft(File); diff --git a/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp b/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp index 72bec106c12e0..37d71dd4c5c57 100644 --- a/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp @@ -103,7 +103,7 @@ TEST_F(WalkUsedTest, Basic) { auto PrivateFile = Header(AST.fileManager().getFile("private.h").get()); auto PublicFile = Header("\"path/public.h\""); auto MainFile = Header(SM.getFileEntryForID(SM.getMainFileID())); - auto VectorSTL = Header(tooling::stdlib::Header::named("<vector>").value()); + auto VectorSTL = Header(*tooling::stdlib::Header::named("<vector>")); EXPECT_THAT( offsetToProviders(AST, SM), UnorderedElementsAre( diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index e8c1b4a5ea4a5..f5c462eaba91b 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -9940,7 +9940,7 @@ struct AAFunctionReachabilityFunction : public AAFunctionReachability { const Function &Fn) { std::optional<bool> Cached = isCachedReachable(Fn); if (Cached) - return Cached.value(); + return *Cached; // The query was not cached, thus it is new. We need to request an update // explicitly to make sure this the information is properly run to a _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits