Author: Kazu Hirata Date: 2022-12-05T21:49:31-08:00 New Revision: 649ef3386b90363af3c807ebe82d0facc75fa381
URL: https://github.com/llvm/llvm-project/commit/649ef3386b90363af3c807ebe82d0facc75fa381 DIFF: https://github.com/llvm/llvm-project/commit/649ef3386b90363af3c807ebe82d0facc75fa381.diff LOG: [clang-tools-extra] Use std::nullopt instead of llvm::None (NFC) This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 Added: Modified: clang-tools-extra/clangd/unittests/ClangdTests.cpp clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp clang-tools-extra/clangd/unittests/FuzzyMatchTests.cpp clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp clang-tools-extra/clangd/unittests/HeadersTests.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp clang-tools-extra/clangd/unittests/IndexTests.cpp clang-tools-extra/clangd/unittests/InlayHintTests.cpp clang-tools-extra/clangd/unittests/PreambleTests.cpp clang-tools-extra/clangd/unittests/RenameTests.cpp clang-tools-extra/clangd/unittests/SourceCodeTests.cpp clang-tools-extra/clangd/unittests/StdLibTests.cpp clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp clang-tools-extra/clangd/unittests/TestFS.cpp clang-tools-extra/clangd/unittests/TestWorkspace.cpp clang-tools-extra/clangd/unittests/XRefsTests.cpp clang-tools-extra/pseudo/unittests/LRTableTest.cpp clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/unittests/ClangdTests.cpp b/clang-tools-extra/clangd/unittests/ClangdTests.cpp index d3399f4d98e0b..4ca9e104e56d4 100644 --- a/clang-tools-extra/clangd/unittests/ClangdTests.cpp +++ b/clang-tools-extra/clangd/unittests/ClangdTests.cpp @@ -943,7 +943,7 @@ void f() {} FS.Files[Path] = Code; runAddDocument(Server, Path, Code); - auto Replaces = runFormatFile(Server, Path, /*Rng=*/llvm::None); + auto Replaces = runFormatFile(Server, Path, /*Rng=*/std::nullopt); EXPECT_TRUE(static_cast<bool>(Replaces)); auto Changed = tooling::applyAllReplacements(Code, *Replaces); EXPECT_TRUE(static_cast<bool>(Changed)); diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp index 42d2521491689..a7ae1112c533f 100644 --- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -3555,7 +3555,7 @@ TEST(CompletionTest, CompletionRange) { // heuristics as normal and reports a range. It'd be nice to be consistent. const char *NoCompletion = "/* foo [[]]^ */"; Completions = completions(NoCompletion); - EXPECT_EQ(Completions.CompletionRange, llvm::None); + EXPECT_EQ(Completions.CompletionRange, std::nullopt); Completions = completionsNoCompile(NoCompletion); EXPECT_EQ(Completions.CompletionRange, Annotations(NoCompletion).range()); } diff --git a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp index b3286e58efef1..e19777663f69e 100644 --- a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp +++ b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp @@ -471,7 +471,7 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) { EXPECT_THAT(Conf.Index.External.MountPoint, FooPath); // None defaults to ".". - Frag = GetFrag(FooPath, llvm::None); + Frag = GetFrag(FooPath, std::nullopt); compileAndApply(); ASSERT_THAT(Diags.Diagnostics, IsEmpty()); ASSERT_EQ(Conf.Index.External.Kind, Config::ExternalIndexSpec::File); diff --git a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp index 6af1e3bb74111..50b56fa9f15a9 100644 --- a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp +++ b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp @@ -129,7 +129,7 @@ CompileFlags: {$unexpected^ "Entry, or Flow Mapping End."), diagKind(llvm::SourceMgr::DK_Error), diagPos(YAML.point("unexpected")), - diagRange(llvm::None)))); + diagRange(std::nullopt)))); ASSERT_EQ(Results.size(), 1u); // invalid fragment discarded. EXPECT_THAT(Results.front().CompileFlags.Add, ElementsAre(val("first"))); @@ -215,7 +215,7 @@ TEST(ParseYAML, AllScopesWarn) { diagPos(YAML.range("diagrange").start), diagRange(YAML.range("diagrange"))))); ASSERT_EQ(Results.size(), 1u); - EXPECT_THAT(Results[0].Completion.AllScopes, testing::Eq(llvm::None)); + EXPECT_THAT(Results[0].Completion.AllScopes, testing::Eq(std::nullopt)); } TEST(ParseYAML, ShowAKA) { @@ -244,7 +244,7 @@ TEST(ParseYAML, InlayHints) { ASSERT_EQ(Results.size(), 1u); EXPECT_THAT(Results[0].InlayHints.Enabled, llvm::ValueIs(val(false))); EXPECT_THAT(Results[0].InlayHints.ParameterNames, llvm::ValueIs(val(true))); - EXPECT_EQ(Results[0].InlayHints.DeducedTypes, llvm::None); + EXPECT_EQ(Results[0].InlayHints.DeducedTypes, std::nullopt); } TEST(ParseYAML, IncludesIgnoreHeader) { diff --git a/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp b/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp index 88c37005eaec7..7581808518002 100644 --- a/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp +++ b/clang-tools-extra/clangd/unittests/ExpectedTypeTest.cpp @@ -164,10 +164,10 @@ int* int_ptr_; auto IntPtrTy = *OpaqueType::fromType(astCtx(), typeOf("int_ptr_")); EXPECT_EQ(fromCompletionResult(decl("returns_not_dependent")), IntPtrTy); - EXPECT_EQ(fromCompletionResult(decl("returns_dependent")), llvm::None); + EXPECT_EQ(fromCompletionResult(decl("returns_dependent")), std::nullopt); EXPECT_EQ(fromCompletionResult(decl("var_not_dependent")), IntPtrTy); - EXPECT_EQ(fromCompletionResult(decl("var_dependent")), llvm::None); + EXPECT_EQ(fromCompletionResult(decl("var_dependent")), std::nullopt); } } // namespace diff --git a/clang-tools-extra/clangd/unittests/FuzzyMatchTests.cpp b/clang-tools-extra/clangd/unittests/FuzzyMatchTests.cpp index b8b3484fdd4a3..683b9a30e9f9e 100644 --- a/clang-tools-extra/clangd/unittests/FuzzyMatchTests.cpp +++ b/clang-tools-extra/clangd/unittests/FuzzyMatchTests.cpp @@ -22,7 +22,7 @@ struct ExpectedMatch { for (char C : "[]") Word.erase(std::remove(Word.begin(), Word.end(), C), Word.end()); if (Word.size() == Annotated->size()) - Annotated = llvm::None; + Annotated = std::nullopt; } bool accepts(llvm::StringRef ActualAnnotated) const { return !Annotated || ActualAnnotated == *Annotated; diff --git a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp index 22ee0921b6552..7aed47e94b593 100644 --- a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp +++ b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp @@ -67,7 +67,7 @@ class OverlayCDBTest : public ::testing::Test { getCompileCommand(llvm::StringRef File) const override { if (File == testPath("foo.cc")) return cmd(File, "-DA=1"); - return None; + return std::nullopt; } tooling::CompileCommand @@ -89,13 +89,13 @@ TEST_F(OverlayCDBTest, GetCompileCommand) { OverlayCDB CDB(Base.get()); EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine, AllOf(Contains(testPath("foo.cc")), Contains("-DA=1"))); - EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None); + EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), std::nullopt); auto Override = cmd(testPath("foo.cc"), "-DA=3"); CDB.setCompileCommand(testPath("foo.cc"), Override); EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine, Contains("-DA=3")); - EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None); + EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), std::nullopt); CDB.setCompileCommand(testPath("missing.cc"), Override); EXPECT_THAT(CDB.getCompileCommand(testPath("missing.cc"))->CommandLine, Contains("-DA=3")); @@ -109,7 +109,7 @@ TEST_F(OverlayCDBTest, GetFallbackCommand) { TEST_F(OverlayCDBTest, NoBase) { OverlayCDB CDB(nullptr, {"-DA=6"}); - EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None); + EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), std::nullopt); auto Override = cmd(testPath("bar.cc"), "-DA=5"); CDB.setCompileCommand(testPath("bar.cc"), Override); EXPECT_THAT(CDB.getCompileCommand(testPath("bar.cc"))->CommandLine, @@ -130,8 +130,8 @@ TEST_F(OverlayCDBTest, Watch) { Inner.setCompileCommand("A.cpp", tooling::CompileCommand()); Outer.setCompileCommand("B.cpp", tooling::CompileCommand()); - Inner.setCompileCommand("A.cpp", llvm::None); - Outer.setCompileCommand("C.cpp", llvm::None); + Inner.setCompileCommand("A.cpp", std::nullopt); + Outer.setCompileCommand("C.cpp", std::nullopt); EXPECT_THAT(Changes, ElementsAre(ElementsAre("A.cpp"), ElementsAre("B.cpp"), ElementsAre("A.cpp"), ElementsAre("C.cpp"))); } diff --git a/clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp b/clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp index a467da419972a..748fea058f2e1 100644 --- a/clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp +++ b/clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp @@ -32,11 +32,11 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) { FS.Files[FooH]; FS.Files[Invalid]; Optional<Path> PathResult = - getCorrespondingHeaderOrSource(FooCpp, FS.view(llvm::None)); + getCorrespondingHeaderOrSource(FooCpp, FS.view(std::nullopt)); EXPECT_TRUE(PathResult.has_value()); ASSERT_EQ(PathResult.value(), FooH); - PathResult = getCorrespondingHeaderOrSource(FooH, FS.view(llvm::None)); + PathResult = getCorrespondingHeaderOrSource(FooH, FS.view(std::nullopt)); EXPECT_TRUE(PathResult.has_value()); ASSERT_EQ(PathResult.value(), FooCpp); @@ -47,7 +47,7 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) { FS.Files[FooC]; FS.Files[FooHH]; - PathResult = getCorrespondingHeaderOrSource(FooC, FS.view(llvm::None)); + PathResult = getCorrespondingHeaderOrSource(FooC, FS.view(std::nullopt)); EXPECT_TRUE(PathResult.has_value()); ASSERT_EQ(PathResult.value(), FooHH); @@ -56,7 +56,7 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) { auto Foo2HH = testPath("foo2.HH"); FS.Files[Foo2C]; FS.Files[Foo2HH]; - PathResult = getCorrespondingHeaderOrSource(Foo2C, FS.view(llvm::None)); + PathResult = getCorrespondingHeaderOrSource(Foo2C, FS.view(std::nullopt)); EXPECT_TRUE(PathResult.has_value()); ASSERT_EQ(PathResult.value(), Foo2HH); @@ -66,13 +66,13 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) { FS.Files[Foo3C]; FS.Files[Foo3HXX]; - PathResult = getCorrespondingHeaderOrSource(Foo3C, FS.view(llvm::None)); + PathResult = getCorrespondingHeaderOrSource(Foo3C, FS.view(std::nullopt)); EXPECT_TRUE(PathResult.has_value()); ASSERT_EQ(PathResult.value(), Foo3HXX); // Test if asking for a corresponding file that doesn't exist returns an empty // string. - PathResult = getCorrespondingHeaderOrSource(Invalid, FS.view(llvm::None)); + PathResult = getCorrespondingHeaderOrSource(Invalid, FS.view(std::nullopt)); EXPECT_FALSE(PathResult.has_value()); } @@ -144,12 +144,12 @@ TEST(HeaderSourceSwitchTest, FromHeaderToSource) { llvm::StringRef HeaderCode; llvm::Optional<std::string> ExpectedSource; } TestCases[] = { - {"// empty, no header found", llvm::None}, + {"// empty, no header found", std::nullopt}, {R"cpp( // no definition found in the index. void NonDefinition(); )cpp", - llvm::None}, + std::nullopt}, {R"cpp( void A_Sym1(); )cpp", @@ -168,11 +168,11 @@ TEST(HeaderSourceSwitchTest, FromHeaderToSource) { )cpp", testPath("a.cpp")}, - {R"cpp( + {R"cpp( // We don't have definition in the index, so stay in the header. void B_Sym3_NoDef(); )cpp", - None}, + std::nullopt}, }; for (const auto &Case : TestCases) { TestTU TU = TestTU::withCode(Case.HeaderCode); @@ -213,12 +213,12 @@ TEST(HeaderSourceSwitchTest, FromSourceToHeader) { llvm::StringRef SourceCode; llvm::Optional<std::string> ExpectedResult; } TestCases[] = { - {"// empty, no header found", llvm::None}, + {"// empty, no header found", std::nullopt}, {R"cpp( // symbol not in index, no header found void Local() {} )cpp", - llvm::None}, + std::nullopt}, {R"cpp( // a.h wins. diff --git a/clang-tools-extra/clangd/unittests/HeadersTests.cpp b/clang-tools-extra/clangd/unittests/HeadersTests.cpp index cad81d40ffc81..4546b27dab08e 100644 --- a/clang-tools-extra/clangd/unittests/HeadersTests.cpp +++ b/clang-tools-extra/clangd/unittests/HeadersTests.cpp @@ -353,7 +353,7 @@ TEST(Headers, NoHeaderSearchInfo) { EXPECT_EQ(Inserter.shouldInsertInclude(HeaderPath, Verbatim), true); EXPECT_EQ(Inserter.calculateIncludePath(Inserting, "sub2/main2.cpp"), - llvm::None); + std::nullopt); } TEST_F(HeadersTest, PresumedLocations) { diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp index 4b1dbdfa31f5a..2dc5ae21539d5 100644 --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -240,11 +240,11 @@ class Foo final {})cpp"; HI.TemplateParameters = { {{"template <typename, bool...> class"}, std::string("C"), - llvm::None}, - {{"typename"}, llvm::None, std::string("char")}, - {{"int"}, llvm::None, std::string("0")}, + std::nullopt}, + {{"typename"}, std::nullopt, std::string("char")}, + {{"int"}, std::nullopt, std::string("0")}, {{"bool"}, std::string("Q"), std::string("false")}, - {{"class..."}, std::string("Ts"), llvm::None}, + {{"class..."}, std::string("Ts"), std::nullopt}, }; }}, // Function template @@ -286,7 +286,7 @@ class Foo final {})cpp"; HI.ReturnType = "Foo<bool, true, false>"; HI.Type = "Foo<bool, true, false> (int, bool)"; HI.Parameters = { - {{"int"}, llvm::None, llvm::None}, + {{"int"}, std::nullopt, std::nullopt}, {{"bool"}, std::string("T"), std::string("false")}, }; }}, @@ -307,8 +307,8 @@ class Foo final {})cpp"; HI.Type = "(lambda) **"; HI.ReturnType = "bool"; HI.Parameters = { - {{"int"}, std::string("T"), llvm::None}, - {{"bool"}, std::string("B"), llvm::None}, + {{"int"}, std::string("T"), std::nullopt}, + {{"bool"}, std::string("B"), std::nullopt}, }; return HI; }}, @@ -328,8 +328,8 @@ class Foo final {})cpp"; HI.Type = {"decltype(lamb) &", "(lambda) &"}; HI.ReturnType = "bool"; HI.Parameters = { - {{"int"}, std::string("T"), llvm::None}, - {{"bool"}, std::string("B"), llvm::None}, + {{"int"}, std::string("T"), std::nullopt}, + {{"bool"}, std::string("B"), std::nullopt}, }; return HI; }}, @@ -349,8 +349,8 @@ class Foo final {})cpp"; HI.Type = "class (lambda)"; HI.ReturnType = "bool"; HI.Parameters = { - {{"int"}, std::string("T"), llvm::None}, - {{"bool"}, std::string("B"), llvm::None}, + {{"int"}, std::string("T"), std::nullopt}, + {{"bool"}, std::string("B"), std::nullopt}, }; HI.Value = "false"; return HI; @@ -372,8 +372,8 @@ class Foo final {})cpp"; HI.Type = "class (lambda)"; HI.ReturnType = "bool"; HI.Parameters = { - {{"int"}, std::string("T"), llvm::None}, - {{"bool"}, std::string("B"), llvm::None}, + {{"int"}, std::string("T"), std::nullopt}, + {{"bool"}, std::string("B"), std::nullopt}, }; return HI; }}, @@ -988,7 +988,7 @@ class Foo final {})cpp"; HI.Type = {"m_int[Size]", "int[Size]"}; HI.NamespaceScope = ""; HI.Definition = "template <int Size> m_int arr[Size]"; - HI.TemplateParameters = {{{"int"}, {"Size"}, llvm::None}}; + HI.TemplateParameters = {{{"int"}, {"Size"}, std::nullopt}}; }}, {// Var template decl specialization R"cpp( @@ -1036,8 +1036,9 @@ class Foo final {})cpp"; HI.Definition = "template <typename T> void foo(T arg)"; HI.Type = "void (T)"; HI.ReturnType = "void"; - HI.Parameters = {{{"T"}, std::string("arg"), llvm::None}}; - HI.TemplateParameters = {{{"typename"}, std::string("T"), llvm::None}}; + HI.Parameters = {{{"T"}, std::string("arg"), std::nullopt}}; + HI.TemplateParameters = { + {{"typename"}, std::string("T"), std::nullopt}}; }}, {// TypeAlias Template R"cpp( @@ -1051,7 +1052,8 @@ class Foo final {})cpp"; HI.Kind = index::SymbolKind::TypeAlias; HI.Definition = "template <typename T> using alias = T"; HI.Type = "T"; - HI.TemplateParameters = {{{"typename"}, std::string("T"), llvm::None}}; + HI.TemplateParameters = { + {{"typename"}, std::string("T"), std::nullopt}}; }}, {// TypeAlias Template R"cpp( @@ -1068,7 +1070,8 @@ class Foo final {})cpp"; HI.Kind = index::SymbolKind::TypeAlias; HI.Definition = "template <typename T> using AA = A<T>"; HI.Type = {"A<T>", "type-parameter-0-0"}; // FIXME: should be 'T' - HI.TemplateParameters = {{{"typename"}, std::string("T"), llvm::None}}; + HI.TemplateParameters = { + {{"typename"}, std::string("T"), std::nullopt}}; }}, {// Constant array R"cpp( @@ -1425,7 +1428,7 @@ TEST(Hover, All) { HI.Documentation = "Function definition via pointer"; HI.ReturnType = "void"; HI.Parameters = { - {{"int"}, llvm::None, llvm::None}, + {{"int"}, std::nullopt, std::nullopt}, }; }}, { @@ -1444,7 +1447,7 @@ TEST(Hover, All) { HI.Documentation = "Function declaration via call"; HI.ReturnType = "int"; HI.Parameters = { - {{"int"}, llvm::None, llvm::None}, + {{"int"}, std::nullopt, std::nullopt}, }; }}, { @@ -2475,7 +2478,7 @@ TEST(Hover, All) { HI.Type = {"auto (decltype(a)) -> decltype(a)", "auto (int) -> int"}; HI.ReturnType = "int"; - HI.Parameters = {{{"int"}, std::string("x"), llvm::None}}; + HI.Parameters = {{{"int"}, std::string("x"), std::nullopt}}; }}, { R"cpp(// sizeof expr @@ -2508,7 +2511,8 @@ TEST(Hover, All) { HI.Kind = index::SymbolKind::Function; HI.Type = "void (const int &)"; HI.ReturnType = "void"; - HI.Parameters = {{{"const int &"}, llvm::None, std::string("T()")}}; + HI.Parameters = { + {{"const int &"}, std::nullopt, std::string("T()")}}; HI.Definition = "template <> void foo<int>(const int &)"; HI.NamespaceScope = ""; }}, @@ -2883,7 +2887,7 @@ TEST(Hover, Present) { HI.Kind = index::SymbolKind::Class; HI.Size = 10; HI.TemplateParameters = { - {{"typename"}, std::string("T"), llvm::None}, + {{"typename"}, std::string("T"), std::nullopt}, {{"typename"}, std::string("C"), std::string("bool")}, }; HI.Documentation = "documentation"; diff --git a/clang-tools-extra/clangd/unittests/IndexTests.cpp b/clang-tools-extra/clangd/unittests/IndexTests.cpp index 1fff454211155..5b9b3606779a2 100644 --- a/clang-tools-extra/clangd/unittests/IndexTests.cpp +++ b/clang-tools-extra/clangd/unittests/IndexTests.cpp @@ -504,7 +504,7 @@ TEST(MergeIndexTest, Refs) { AST = Test.build(); Dyn.updateMain(testPath(Test.Filename), AST); - Request.Limit = llvm::None; + Request.Limit = std::nullopt; RefSlab::Builder Results3; EXPECT_FALSE( Merge.refs(Request, [&](const Ref &O) { Results3.insert(Foo.ID, O); })); diff --git a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp index 7127f6cc54c53..26e3936595db1 100644 --- a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp +++ b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp @@ -33,7 +33,7 @@ using ::testing::IsEmpty; std::vector<InlayHint> hintsOfKind(ParsedAST &AST, InlayHintKind Kind) { std::vector<InlayHint> Result; - for (auto &Hint : inlayHints(AST, /*RestrictRange=*/llvm::None)) { + for (auto &Hint : inlayHints(AST, /*RestrictRange=*/std::nullopt)) { if (Hint.kind == Kind) Result.push_back(Hint); } @@ -93,7 +93,7 @@ void assertHints(InlayHintKind Kind, llvm::StringRef AnnotatedSource, // Sneak in a cross-cutting check that hints are disabled by config. // We'll hit an assertion failure if addInlayHint still gets called. WithContextValue WithCfg(Config::Key, noHintsConfig()); - EXPECT_THAT(inlayHints(AST, llvm::None), IsEmpty()); + EXPECT_THAT(inlayHints(AST, std::nullopt), IsEmpty()); } // Hack to allow expression-statements operating on parameter packs in C++14. diff --git a/clang-tools-extra/clangd/unittests/PreambleTests.cpp b/clang-tools-extra/clangd/unittests/PreambleTests.cpp index 49d39000d6b7e..f38e297049a32 100644 --- a/clang-tools-extra/clangd/unittests/PreambleTests.cpp +++ b/clang-tools-extra/clangd/unittests/PreambleTests.cpp @@ -194,7 +194,7 @@ llvm::Optional<ParsedAST> createPatchedAST(llvm::StringRef Baseline, auto BaselinePreamble = TestTU::withCode(Baseline).preamble(); if (!BaselinePreamble) { ADD_FAILURE() << "Failed to build baseline preamble"; - return llvm::None; + return std::nullopt; } IgnoreDiagnostics Diags; @@ -203,7 +203,7 @@ llvm::Optional<ParsedAST> createPatchedAST(llvm::StringRef Baseline, auto CI = buildCompilerInvocation(TU.inputs(FS), Diags); if (!CI) { ADD_FAILURE() << "Failed to build compiler invocation"; - return llvm::None; + return std::nullopt; } return ParsedAST::build(testPath(TU.Filename), TU.inputs(FS), std::move(CI), {}, BaselinePreamble); diff --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp b/clang-tools-extra/clangd/unittests/RenameTests.cpp index 39232a56f0b4a..5b99f8c4fc44c 100644 --- a/clang-tools-extra/clangd/unittests/RenameTests.cpp +++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp @@ -1279,7 +1279,7 @@ TEST(RenameTest, PrepareRename) { runAddDocument(Server, FooCCPath, FooCC.code()); auto Results = runPrepareRename(Server, FooCCPath, FooCC.point(), - /*NewName=*/llvm::None, {}); + /*NewName=*/std::nullopt, {}); // Verify that for multi-file rename, we only return main-file occurrences. ASSERT_TRUE(bool(Results)) << Results.takeError(); // We don't know the result is complete in prepareRename (passing a nullptr diff --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp index ce22062ab4d5e..459b4dbb93611 100644 --- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp +++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp @@ -633,7 +633,7 @@ TEST(SourceCodeTests, HalfOpenFileRange) { const NamedDecl &Decl = findUnqualifiedDecl(AST, Name); auto FileRange = toHalfOpenFileRange(SM, LangOpts, Decl.getSourceRange()); SCOPED_TRACE("Checking range: " + Name); - ASSERT_NE(FileRange, llvm::None); + ASSERT_NE(FileRange, std::nullopt); Range HalfOpenRange = SourceRangeToRange(*FileRange); EXPECT_EQ(HalfOpenRange, Test.ranges(Name)[0]); }; diff --git a/clang-tools-extra/clangd/unittests/StdLibTests.cpp b/clang-tools-extra/clangd/unittests/StdLibTests.cpp index 0fadc872305c0..f70de71edfc3d 100644 --- a/clang-tools-extra/clangd/unittests/StdLibTests.cpp +++ b/clang-tools-extra/clangd/unittests/StdLibTests.cpp @@ -88,7 +88,7 @@ TEST(StdLibTests, StdLibSet) { auto Add = [&](const LangOptions &LO, std::vector<llvm::StringRef> SearchPath) { SourceManagerForFile SM("scratch", ""); - SM.get().getFileManager().setVirtualFileSystem(FS.view(llvm::None)); + SM.get().getFileManager().setVirtualFileSystem(FS.view(std::nullopt)); HeaderSearch HS(/*HSOpts=*/nullptr, SM.get(), SM.get().getDiagnostics(), LO, /*Target=*/nullptr); for (auto P : SearchPath) diff --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp index 62564b989a186..a7869f0a2fdb2 100644 --- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -877,7 +877,7 @@ TEST_F(SymbolCollectorTest, RefContainers) { return Ref; } } - return llvm::None; + return std::nullopt; }; auto Container = [&](llvm::StringRef RangeName) { auto Ref = FindRefWithRange(Code.range(RangeName)); diff --git a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp index ef8ef31731600..67d6fd2cbe560 100644 --- a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp +++ b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp @@ -1206,7 +1206,7 @@ TEST_F(TUSchedulerTests, IncluderCache) { llvm::Optional<tooling::CompileCommand> getCompileCommand(PathRef File) const override { if (File == NoCmd || File == NotIncluded || FailAll) - return llvm::None; + return std::nullopt; auto Basic = getFallbackCommand(File); Basic.Heuristic.clear(); if (File == Unreliable) { diff --git a/clang-tools-extra/clangd/unittests/TestFS.cpp b/clang-tools-extra/clangd/unittests/TestFS.cpp index 80745e488bfa0..c544c926a0b2f 100644 --- a/clang-tools-extra/clangd/unittests/TestFS.cpp +++ b/clang-tools-extra/clangd/unittests/TestFS.cpp @@ -60,7 +60,7 @@ MockCompilationDatabase::getProjectInfo(PathRef File) const { llvm::Optional<tooling::CompileCommand> MockCompilationDatabase::getCompileCommand(PathRef File) const { if (ExtraClangFlags.empty()) - return None; + return std::nullopt; auto FileName = llvm::sys::path::filename(File); diff --git a/clang-tools-extra/clangd/unittests/TestWorkspace.cpp b/clang-tools-extra/clangd/unittests/TestWorkspace.cpp index 3b1f242f380fa..bca24fca3a04c 100644 --- a/clang-tools-extra/clangd/unittests/TestWorkspace.cpp +++ b/clang-tools-extra/clangd/unittests/TestWorkspace.cpp @@ -35,7 +35,7 @@ Optional<ParsedAST> TestWorkspace::openFile(llvm::StringRef Filename) { auto It = Inputs.find(Filename); if (It == Inputs.end()) { ADD_FAILURE() << "Accessing non-existing file: " << Filename; - return llvm::None; + return std::nullopt; } TU.Code = It->second.Code; TU.Filename = It->first().str(); diff --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp b/clang-tools-extra/clangd/unittests/XRefsTests.cpp index dba7f4f85b404..fe351aeae85f0 100644 --- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp +++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp @@ -395,8 +395,8 @@ TEST(LocateSymbol, FindOverrides) { TestTU TU = TestTU::withCode(Code.code()); auto AST = TU.build(); EXPECT_THAT(locateSymbolAt(AST, Code.point(), TU.index().get()), - UnorderedElementsAre(sym("foo", Code.range("1"), llvm::None), - sym("foo", Code.range("2"), llvm::None))); + UnorderedElementsAre(sym("foo", Code.range("1"), std::nullopt), + sym("foo", Code.range("2"), std::nullopt))); } TEST(LocateSymbol, WithIndexPreferredLocation) { @@ -1317,20 +1317,20 @@ TEST(LocateSymbol, Ambiguous) { // FIXME: Target the constructor as well. EXPECT_THAT(locateSymbolAt(AST, T.point("9")), ElementsAre(sym("Foo"))); EXPECT_THAT(locateSymbolAt(AST, T.point("10")), - ElementsAre(sym("Foo", T.range("ConstructorLoc"), llvm::None))); + ElementsAre(sym("Foo", T.range("ConstructorLoc"), std::nullopt))); EXPECT_THAT(locateSymbolAt(AST, T.point("11")), - ElementsAre(sym("Foo", T.range("ConstructorLoc"), llvm::None))); + ElementsAre(sym("Foo", T.range("ConstructorLoc"), std::nullopt))); // These assertions are unordered because the order comes from // CXXRecordDecl::lookupDependentName() which doesn't appear to provide // an order guarantee. EXPECT_THAT(locateSymbolAt(AST, T.point("12")), UnorderedElementsAre( - sym("bar", T.range("NonstaticOverload1"), llvm::None), - sym("bar", T.range("NonstaticOverload2"), llvm::None))); - EXPECT_THAT( - locateSymbolAt(AST, T.point("13")), - UnorderedElementsAre(sym("baz", T.range("StaticOverload1"), llvm::None), - sym("baz", T.range("StaticOverload2"), llvm::None))); + sym("bar", T.range("NonstaticOverload1"), std::nullopt), + sym("bar", T.range("NonstaticOverload2"), std::nullopt))); + EXPECT_THAT(locateSymbolAt(AST, T.point("13")), + UnorderedElementsAre( + sym("baz", T.range("StaticOverload1"), std::nullopt), + sym("baz", T.range("StaticOverload2"), std::nullopt))); } TEST(LocateSymbol, TextualDependent) { @@ -1360,10 +1360,11 @@ TEST(LocateSymbol, TextualDependent) { // interaction between locateASTReferent() and // locateSymbolNamedTextuallyAt(). auto Results = locateSymbolAt(AST, Source.point(), Index.get()); - EXPECT_THAT(Results, - UnorderedElementsAre( - sym("uniqueMethodName", Header.range("FooLoc"), llvm::None), - sym("uniqueMethodName", Header.range("BarLoc"), llvm::None))); + EXPECT_THAT( + Results, + UnorderedElementsAre( + sym("uniqueMethodName", Header.range("FooLoc"), std::nullopt), + sym("uniqueMethodName", Header.range("BarLoc"), std::nullopt))); } TEST(LocateSymbol, Alias) { @@ -1625,7 +1626,7 @@ TEST(LocateSymbol, WithPreamble) { // stale one. EXPECT_THAT( cantFail(runLocateSymbolAt(Server, FooCpp, FooWithoutHeader.point())), - ElementsAre(sym("foo", FooWithoutHeader.range(), llvm::None))); + ElementsAre(sym("foo", FooWithoutHeader.range(), std::nullopt))); // Reset test environment. runAddDocument(Server, FooCpp, FooWithHeader.code()); @@ -1635,7 +1636,7 @@ TEST(LocateSymbol, WithPreamble) { // Use the AST being built in above request. EXPECT_THAT( cantFail(runLocateSymbolAt(Server, FooCpp, FooWithoutHeader.point())), - ElementsAre(sym("foo", FooWithoutHeader.range(), llvm::None))); + ElementsAre(sym("foo", FooWithoutHeader.range(), std::nullopt))); } TEST(LocateSymbol, NearbyTokenSmoke) { @@ -1739,7 +1740,7 @@ TEST(LocateSymbol, NearbyIdentifier) { Nearby = halfOpenToRange(SM, CharSourceRange::getCharRange( Tok->location(), Tok->endLocation())); if (T.ranges().empty()) - EXPECT_THAT(Nearby, Eq(llvm::None)) << Test; + EXPECT_THAT(Nearby, Eq(std::nullopt)) << Test; else EXPECT_EQ(Nearby, T.range()) << Test; } @@ -1820,7 +1821,7 @@ TEST(FindImplementations, CaptureDefinition) { EXPECT_THAT( findImplementations(AST, Code.point(), TU.index().get()), UnorderedElementsAre(sym("Foo", Code.range("Decl"), Code.range("Def")), - sym("Foo", Code.range("Child2"), llvm::None))) + sym("Foo", Code.range("Child2"), std::nullopt))) << Test; } @@ -2390,9 +2391,9 @@ TEST(FindReferences, NoQueryForLocalSymbols) { auto AST = TestTU::withCode(File.code()).build(); findReferences(AST, File.point(), 0, &Rec); if (T.WantQuery) - EXPECT_NE(Rec.RefIDs, None) << T.AnnotatedCode; + EXPECT_NE(Rec.RefIDs, std::nullopt) << T.AnnotatedCode; else - EXPECT_EQ(Rec.RefIDs, None) << T.AnnotatedCode; + EXPECT_EQ(Rec.RefIDs, std::nullopt) << T.AnnotatedCode; } } diff --git a/clang-tools-extra/pseudo/unittests/LRTableTest.cpp b/clang-tools-extra/pseudo/unittests/LRTableTest.cpp index f56178a8582bf..9c9f18e03a3d4 100644 --- a/clang-tools-extra/pseudo/unittests/LRTableTest.cpp +++ b/clang-tools-extra/pseudo/unittests/LRTableTest.cpp @@ -52,18 +52,18 @@ TEST(LRTable, Builder) { B.Reduce[StateID{2}].insert(RuleID{1}); LRTable T = std::move(B).build(); - EXPECT_EQ(T.getShiftState(0, Eof), llvm::None); + EXPECT_EQ(T.getShiftState(0, Eof), std::nullopt); EXPECT_THAT(T.getShiftState(0, Identifier), ValueIs(0)); EXPECT_THAT(T.getReduceRules(0), ElementsAre(0)); - EXPECT_EQ(T.getShiftState(1, Eof), llvm::None); - EXPECT_EQ(T.getShiftState(1, Identifier), llvm::None); + EXPECT_EQ(T.getShiftState(1, Eof), std::nullopt); + EXPECT_EQ(T.getShiftState(1, Identifier), std::nullopt); EXPECT_THAT(T.getGoToState(1, Term), ValueIs(3)); EXPECT_THAT(T.getReduceRules(1), ElementsAre(2)); // Verify the behaivor for other non-available-actions terminals. SymbolID Int = tokenSymbol(tok::kw_int); - EXPECT_EQ(T.getShiftState(2, Int), llvm::None); + EXPECT_EQ(T.getShiftState(2, Int), std::nullopt); // Check follow sets. EXPECT_TRUE(T.canFollow(Term, Plus)); diff --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h index c0459cc80ca4c..f10b91be2ed2c 100644 --- a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h +++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h @@ -86,7 +86,7 @@ template <typename... CheckTypes> std::string runCheckOnCode(StringRef Code, std::vector<ClangTidyError> *Errors = nullptr, const Twine &Filename = "input.cc", - ArrayRef<std::string> ExtraArgs = None, + ArrayRef<std::string> ExtraArgs = std::nullopt, const ClangTidyOptions &ExtraOptions = ClangTidyOptions(), std::map<StringRef, StringRef> PathsToContent = std::map<StringRef, StringRef>()) { diff --git a/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp b/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp index a736c557a0a09..71496dd03f9bd 100644 --- a/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp @@ -167,7 +167,7 @@ class ObjCGeneratedHeaderInserterCheck : public IncludeInserterCheckBase { template <typename Check> std::string runCheckOnCode(StringRef Code, StringRef Filename) { std::vector<ClangTidyError> Errors; - return test::runCheckOnCode<Check>(Code, &Errors, Filename, None, + return test::runCheckOnCode<Check>(Code, &Errors, Filename, std::nullopt, ClangTidyOptions(), {// Main file include {"clang_tidy/tests/" diff --git a/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp b/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp index 93cffadb8279e..5394e75268099 100644 --- a/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp @@ -78,7 +78,7 @@ TEST(LLVMHeaderGuardCheckTest, FixHeaderGuards) { runHeaderGuardCheck("#ifndef LLVM_ADT_FOO_H_\n" "#define LLVM_ADT_FOO_H_\n" "#endif\n", - "include/llvm/ADT/foo.h", None)); + "include/llvm/ADT/foo.h", std::nullopt)); EXPECT_EQ("#ifndef LLVM_CLANG_C_BAR_H\n" "#define LLVM_CLANG_C_BAR_H\n" @@ -184,7 +184,8 @@ TEST(LLVMHeaderGuardCheckTest, FixHeaderGuards) { runHeaderGuardCheckWithEndif("#ifndef LLVM_ADT_FOO_H\n" "#define LLVM_ADT_FOO_H\n" "#endif /* LLVM_ADT_FOO_H */\n", - "include/llvm/ADT/foo.h", None)); + "include/llvm/ADT/foo.h", + std::nullopt)); EXPECT_EQ("#ifndef LLVM_ADT_FOO_H_\n" "#define LLVM_ADT_FOO_H_\n" @@ -192,7 +193,8 @@ TEST(LLVMHeaderGuardCheckTest, FixHeaderGuards) { runHeaderGuardCheckWithEndif("#ifndef LLVM_ADT_FOO_H_\n" "#define LLVM_ADT_FOO_H_\n" "#endif // LLVM_ADT_FOO_H_\n", - "include/llvm/ADT/foo.h", None)); + "include/llvm/ADT/foo.h", + std::nullopt)); EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n" "#define LLVM_ADT_FOO_H\n" @@ -209,8 +211,8 @@ TEST(LLVMHeaderGuardCheckTest, FixHeaderGuards) { "#define LLVM_ADT_FOO_H\n" "#endif // LLVM_ADT_FOO_H\n"; EXPECT_EQ(WithExtraSpace, - runHeaderGuardCheckWithEndif(WithExtraSpace, - "include/llvm/ADT/foo.h", None)); + runHeaderGuardCheckWithEndif( + WithExtraSpace, "include/llvm/ADT/foo.h", std::nullopt)); EXPECT_EQ("#ifndef LLVM_ADT_FOO_H\n" "#define LLVM_ADT_FOO_H\n" @@ -232,7 +234,8 @@ TEST(LLVMHeaderGuardCheckTest, FixHeaderGuards) { "#define LLVM_ADT_FOO_H\n" "#endif /* LLVM_ADT_FOO_H\\ \n" " FOO */", - "include/llvm/ADT/foo.h", None)); + "include/llvm/ADT/foo.h", + std::nullopt)); EXPECT_EQ("#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n" "#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n" diff --git a/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp b/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp index 86a9a0fa2ac17..c28e89cffac37 100644 --- a/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp @@ -57,7 +57,7 @@ std::string runChecker(StringRef Code, unsigned ExpectedWarningCount) { std::vector<ClangTidyError> errors; std::string result = - test::runCheckOnCode<Check>(Code, &errors, "foo.cc", None, + test::runCheckOnCode<Check>(Code, &errors, "foo.cc", std::nullopt, ClangTidyOptions(), AdditionalFileContents); EXPECT_EQ(ExpectedWarningCount, errors.size()); diff --git a/clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp b/clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp index 376feb819c71e..f8e4268b0d977 100644 --- a/clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp @@ -256,7 +256,7 @@ TEST(BracesAroundStatementsCheckTest, IfElseWithShortStatements) { " else if (1 == 2) return -2;\n" " else return -3;\n" "}", - nullptr, "input.cc", None, Options)); + nullptr, "input.cc", std::nullopt, Options)); // If the last else is an else-if, we also force it. EXPECT_EQ("int main() {\n" @@ -269,7 +269,7 @@ TEST(BracesAroundStatementsCheckTest, IfElseWithShortStatements) { " if (false) return -1;\n" " else if (1 == 2) return -2;\n" "}", - nullptr, "input.cc", None, Options)); + nullptr, "input.cc", std::nullopt, Options)); } TEST(BracesAroundStatementsCheckTest, For) { diff --git a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp index 5c5a0943c6cf8..e1ebad73bb73d 100644 --- a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp @@ -214,7 +214,7 @@ Optional<RewriteRuleWith<std::string>> needsObjC(const LangOptions &LangOpts, const ClangTidyCheck::OptionsView &Options) { if (!LangOpts.ObjC) - return None; + return std::nullopt; return makeRule(clang::ast_matchers::functionDecl(), change(cat("void changed() {}")), cat("no message")); } @@ -240,7 +240,7 @@ Optional<RewriteRuleWith<std::string>> noSkip(const LangOptions &LangOpts, const ClangTidyCheck::OptionsView &Options) { if (Options.get("Skip", "false") == "true") - return None; + return std::nullopt; return makeRule(clang::ast_matchers::functionDecl(), changeTo(cat("void nothing();")), cat("no message")); } @@ -259,11 +259,11 @@ TEST(TransformerClangTidyCheckTest, DisableByConfig) { Options.CheckOptions["test-check-0.Skip"] = "true"; EXPECT_EQ(Input, test::runCheckOnCode<ConfigurableCheck>( - Input, nullptr, "input.cc", None, Options)); + Input, nullptr, "input.cc", std::nullopt, Options)); Options.CheckOptions["test-check-0.Skip"] = "false"; EXPECT_EQ(Expected, test::runCheckOnCode<ConfigurableCheck>( - Input, nullptr, "input.cc", None, Options)); + Input, nullptr, "input.cc", std::nullopt, Options)); } RewriteRuleWith<std::string> replaceCall(IncludeFormat Format) { @@ -346,19 +346,19 @@ int h(int x) { return 5; })cc"; std::map<StringRef, StringRef> PathsToContent = {{"input.h", "\n"}}; Options.CheckOptions["test-check-0.IncludeStyle"] = "llvm"; EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>( - Input, nullptr, "inputTest.cpp", None, - Options, PathsToContent)); + Input, nullptr, "inputTest.cpp", + std::nullopt, Options, PathsToContent)); EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>( - Input, nullptr, "input_test.cpp", None, - Options, PathsToContent)); + Input, nullptr, "input_test.cpp", + std::nullopt, Options, PathsToContent)); Options.CheckOptions["test-check-0.IncludeStyle"] = "google"; - EXPECT_EQ(TreatsAsNormalHeader, - test::runCheckOnCode<IncludeOrderCheck>( - Input, nullptr, "inputTest.cc", None, Options, PathsToContent)); + EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>( + Input, nullptr, "inputTest.cc", + std::nullopt, Options, PathsToContent)); EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>( - Input, nullptr, "input_test.cc", None, - Options, PathsToContent)); + Input, nullptr, "input_test.cc", + std::nullopt, Options, PathsToContent)); } TEST(TransformerClangTidyCheckTest, AddIncludeObeysSortStyleGlobalOption) { @@ -378,19 +378,19 @@ int h(int x) { return 5; })cc"; std::map<StringRef, StringRef> PathsToContent = {{"input.h", "\n"}}; Options.CheckOptions["IncludeStyle"] = "llvm"; EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>( - Input, nullptr, "inputTest.cpp", None, - Options, PathsToContent)); + Input, nullptr, "inputTest.cpp", + std::nullopt, Options, PathsToContent)); EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>( - Input, nullptr, "input_test.cpp", None, - Options, PathsToContent)); + Input, nullptr, "input_test.cpp", + std::nullopt, Options, PathsToContent)); Options.CheckOptions["IncludeStyle"] = "google"; - EXPECT_EQ(TreatsAsNormalHeader, - test::runCheckOnCode<IncludeOrderCheck>( - Input, nullptr, "inputTest.cc", None, Options, PathsToContent)); + EXPECT_EQ(TreatsAsNormalHeader, test::runCheckOnCode<IncludeOrderCheck>( + Input, nullptr, "inputTest.cc", + std::nullopt, Options, PathsToContent)); EXPECT_EQ(TreatsAsLibraryHeader, test::runCheckOnCode<IncludeOrderCheck>( - Input, nullptr, "input_test.cc", None, - Options, PathsToContent)); + Input, nullptr, "input_test.cc", + std::nullopt, Options, PathsToContent)); } } // namespace diff --git a/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp b/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp index 9072befa6caa1..c27a1f0b132ed 100644 --- a/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp @@ -61,7 +61,7 @@ std::string runChecker(StringRef Code, unsigned ExpectedWarningCount) { std::vector<ClangTidyError> errors; std::string result = - test::runCheckOnCode<Check>(Code, &errors, "foo.cc", None, + test::runCheckOnCode<Check>(Code, &errors, "foo.cc", std::nullopt, ClangTidyOptions(), AdditionalFileContents); EXPECT_EQ(ExpectedWarningCount, errors.size()); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits