diff options
author | Kazu Hirata <kazu@google.com> | 2022-07-13 08:47:41 +0300 |
---|---|---|
committer | Kazu Hirata <kazu@google.com> | 2022-07-13 08:47:41 +0300 |
commit | 53daa177f86b3abbc21222d8093fc2ac0aa62035 (patch) | |
tree | 964376c5cce02adbc953522d790aa44164d9810d /clang-tools-extra | |
parent | 3361a364e64c815ede2fe6dfe4e8016637c16b0b (diff) |
[clang, clang-tools-extra] Use has_value instead of hasValue (NFC)
Diffstat (limited to 'clang-tools-extra')
14 files changed, 53 insertions, 53 deletions
diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp index 1bf876102f99..6ceff5611572 100644 --- a/clang-tools-extra/clangd/AST.cpp +++ b/clang-tools-extra/clangd/AST.cpp @@ -745,7 +745,7 @@ public: if (Callee) { handleCall(Callee, E->arguments()); } - return !Info.hasValue(); + return !Info.has_value(); } bool VisitCXXConstructExpr(CXXConstructExpr *E) { @@ -753,7 +753,7 @@ public: if (Callee) { handleCall(Callee, E->arguments()); } - return !Info.hasValue(); + return !Info.has_value(); } // The expanded parameter pack to be resolved diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp index 2da83c05e970..4e2156bb85be 100644 --- a/clang-tools-extra/clangd/CodeComplete.cpp +++ b/clang-tools-extra/clangd/CodeComplete.cpp @@ -394,7 +394,7 @@ struct CodeCompletionBuilder { std::stable_partition(Completion.Includes.begin(), Completion.Includes.end(), [](const CodeCompletion::IncludeCandidate &I) { - return !I.Insertion.hasValue(); + return !I.Insertion.has_value(); }); } diff --git a/clang-tools-extra/clangd/ConfigCompile.cpp b/clang-tools-extra/clangd/ConfigCompile.cpp index 2de8816f9f08..8f207aba29bf 100644 --- a/clang-tools-extra/clangd/ConfigCompile.cpp +++ b/clang-tools-extra/clangd/ConfigCompile.cpp @@ -358,8 +358,8 @@ struct FragmentCompiler { } #endif // Make sure exactly one of the Sources is set. - unsigned SourceCount = External.File.hasValue() + - External.Server.hasValue() + *External.IsNone; + unsigned SourceCount = External.File.has_value() + + External.Server.has_value() + *External.IsNone; if (SourceCount != 1) { diag(Error, "Exactly one of File, Server or None must be set.", BlockRange); diff --git a/clang-tools-extra/clangd/index/YAMLSerialization.cpp b/clang-tools-extra/clangd/index/YAMLSerialization.cpp index 79c9e1dfd991..1ac74338298a 100644 --- a/clang-tools-extra/clangd/index/YAMLSerialization.cpp +++ b/clang-tools-extra/clangd/index/YAMLSerialization.cpp @@ -354,23 +354,23 @@ template <> struct MappingTraits<CompileCommandYAML> { template <> struct MappingTraits<VariantEntry> { static void mapping(IO &IO, VariantEntry &Variant) { - if (IO.mapTag("!Symbol", Variant.Symbol.hasValue())) { + if (IO.mapTag("!Symbol", Variant.Symbol.has_value())) { if (!IO.outputting()) Variant.Symbol.emplace(); MappingTraits<Symbol>::mapping(IO, *Variant.Symbol); - } else if (IO.mapTag("!Refs", Variant.Refs.hasValue())) { + } else if (IO.mapTag("!Refs", Variant.Refs.has_value())) { if (!IO.outputting()) Variant.Refs.emplace(); MappingTraits<RefBundle>::mapping(IO, *Variant.Refs); - } else if (IO.mapTag("!Relations", Variant.Relation.hasValue())) { + } else if (IO.mapTag("!Relations", Variant.Relation.has_value())) { if (!IO.outputting()) Variant.Relation.emplace(); MappingTraits<Relation>::mapping(IO, *Variant.Relation); - } else if (IO.mapTag("!Source", Variant.Source.hasValue())) { + } else if (IO.mapTag("!Source", Variant.Source.has_value())) { if (!IO.outputting()) Variant.Source.emplace(); MappingTraits<IncludeGraphNode>::mapping(IO, *Variant.Source); - } else if (IO.mapTag("!Cmd", Variant.Cmd.hasValue())) { + } else if (IO.mapTag("!Cmd", Variant.Cmd.has_value())) { if (!IO.outputting()) Variant.Cmd.emplace(); MappingTraits<CompileCommandYAML>::mapping( diff --git a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp index ddf6f4f5fb1f..35c6fd4c89a0 100644 --- a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp +++ b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp @@ -163,9 +163,9 @@ Index: ASSERT_THAT(Diags.Diagnostics, IsEmpty()); ASSERT_EQ(Results.size(), 1u); ASSERT_TRUE(Results[0].Index.External); - EXPECT_FALSE(Results[0].Index.External.getValue()->File.hasValue()); - EXPECT_FALSE(Results[0].Index.External.getValue()->MountPoint.hasValue()); - EXPECT_FALSE(Results[0].Index.External.getValue()->Server.hasValue()); + EXPECT_FALSE(Results[0].Index.External.getValue()->File.has_value()); + EXPECT_FALSE(Results[0].Index.External.getValue()->MountPoint.has_value()); + EXPECT_FALSE(Results[0].Index.External.getValue()->Server.has_value()); EXPECT_THAT(*Results[0].Index.External.getValue()->IsNone, testing::Eq(true)); } diff --git a/clang-tools-extra/clangd/unittests/FSTests.cpp b/clang-tools-extra/clangd/unittests/FSTests.cpp index 575111e841dc..81129fec98c2 100644 --- a/clang-tools-extra/clangd/unittests/FSTests.cpp +++ b/clang-tools-extra/clangd/unittests/FSTests.cpp @@ -28,10 +28,10 @@ TEST(FSTests, PreambleStatusCache) { EXPECT_TRUE(ProduceFS->status("y")); EXPECT_TRUE(ProduceFS->status("main")); - EXPECT_TRUE(StatCache.lookup(testPath("x")).hasValue()); - EXPECT_TRUE(StatCache.lookup(testPath("y")).hasValue()); + EXPECT_TRUE(StatCache.lookup(testPath("x")).has_value()); + EXPECT_TRUE(StatCache.lookup(testPath("y")).has_value()); // Main file is not cached. - EXPECT_FALSE(StatCache.lookup(testPath("main")).hasValue()); + EXPECT_FALSE(StatCache.lookup(testPath("main")).has_value()); llvm::vfs::Status S("fake", llvm::sys::fs::UniqueID(123, 456), std::chrono::system_clock::now(), 0, 0, 1024, diff --git a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp index f7a3f2ae16ad..e335c78a7364 100644 --- a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp +++ b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp @@ -331,7 +331,7 @@ TEST(GlobalCompilationDatabaseTest, CompileFlagsDirectory) { FS.Files[testPath("x/compile_flags.txt")] = "-DFOO"; DirectoryBasedGlobalCompilationDatabase CDB(FS); auto Commands = CDB.getCompileCommand(testPath("x/y.cpp")); - ASSERT_TRUE(Commands.hasValue()); + ASSERT_TRUE(Commands.has_value()); EXPECT_THAT(Commands.getValue().CommandLine, Contains("-DFOO")); // Make sure we pick the right working directory. EXPECT_EQ(testPath("x"), Commands.getValue().Directory); diff --git a/clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp b/clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp index b2d7a7ee7724..97c10544a8a2 100644 --- a/clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp +++ b/clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp @@ -33,11 +33,11 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) { FS.Files[Invalid]; Optional<Path> PathResult = getCorrespondingHeaderOrSource(FooCpp, FS.view(llvm::None)); - EXPECT_TRUE(PathResult.hasValue()); + EXPECT_TRUE(PathResult.has_value()); ASSERT_EQ(PathResult.getValue(), FooH); PathResult = getCorrespondingHeaderOrSource(FooH, FS.view(llvm::None)); - EXPECT_TRUE(PathResult.hasValue()); + EXPECT_TRUE(PathResult.has_value()); ASSERT_EQ(PathResult.getValue(), FooCpp); // Test with header file in capital letters and different extension, source @@ -48,7 +48,7 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) { FS.Files[FooC]; FS.Files[FooHH]; PathResult = getCorrespondingHeaderOrSource(FooC, FS.view(llvm::None)); - EXPECT_TRUE(PathResult.hasValue()); + EXPECT_TRUE(PathResult.has_value()); ASSERT_EQ(PathResult.getValue(), FooHH); // Test with both capital letters @@ -57,7 +57,7 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) { FS.Files[Foo2C]; FS.Files[Foo2HH]; PathResult = getCorrespondingHeaderOrSource(Foo2C, FS.view(llvm::None)); - EXPECT_TRUE(PathResult.hasValue()); + EXPECT_TRUE(PathResult.has_value()); ASSERT_EQ(PathResult.getValue(), Foo2HH); // Test with source file as capital letter and .hxx header file @@ -67,13 +67,13 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) { FS.Files[Foo3C]; FS.Files[Foo3HXX]; PathResult = getCorrespondingHeaderOrSource(Foo3C, FS.view(llvm::None)); - EXPECT_TRUE(PathResult.hasValue()); + EXPECT_TRUE(PathResult.has_value()); ASSERT_EQ(PathResult.getValue(), Foo3HXX); // Test if asking for a corresponding file that doesn't exist returns an empty // string. PathResult = getCorrespondingHeaderOrSource(Invalid, FS.view(llvm::None)); - EXPECT_FALSE(PathResult.hasValue()); + EXPECT_FALSE(PathResult.has_value()); } MATCHER_P(declNamed, Name, "") { diff --git a/clang-tools-extra/clangd/unittests/LSPBinderTests.cpp b/clang-tools-extra/clangd/unittests/LSPBinderTests.cpp index 8b9363ba0865..97067b538259 100644 --- a/clang-tools-extra/clangd/unittests/LSPBinderTests.cpp +++ b/clang-tools-extra/clangd/unittests/LSPBinderTests.cpp @@ -93,10 +93,10 @@ TEST(LSPBinderTest, IncomingCalls) { auto &RawPlusOne = RawHandlers.MethodHandlers["plusOne"]; RawPlusOne(1, capture(Reply)); - ASSERT_TRUE(Reply.hasValue()); + ASSERT_TRUE(Reply.has_value()); EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(2)); RawPlusOne("foo", capture(Reply)); - ASSERT_TRUE(Reply.hasValue()); + ASSERT_TRUE(Reply.has_value()); EXPECT_THAT_EXPECTED( Reply.getValue(), llvm::FailedWithMessage( @@ -104,7 +104,7 @@ TEST(LSPBinderTest, IncomingCalls) { auto &RawFail = RawHandlers.MethodHandlers["fail"]; RawFail(2, capture(Reply)); - ASSERT_TRUE(Reply.hasValue()); + ASSERT_TRUE(Reply.has_value()); EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::FailedWithMessage("X=2")); auto &RawNotify = RawHandlers.NotificationHandlers["notify"]; @@ -117,7 +117,7 @@ TEST(LSPBinderTest, IncomingCalls) { auto &RawCmdPlusOne = RawHandlers.CommandHandlers["cmdPlusOne"]; RawCmdPlusOne(1, capture(Reply)); - ASSERT_TRUE(Reply.hasValue()); + ASSERT_TRUE(Reply.has_value()); EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(2)); // None of this generated any outgoing traffic. @@ -139,7 +139,7 @@ TEST(LSPBinderTest, OutgoingCalls) { llvm::Optional<llvm::Expected<Foo>> Reply; Echo(Foo{2}, capture(Reply)); EXPECT_THAT(RawOutgoing.take("echo"), ElementsAre(llvm::json::Value(2))); - ASSERT_TRUE(Reply.hasValue()); + ASSERT_TRUE(Reply.has_value()); EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(Foo{2})); // JSON response is integer, can't be parsed as string. @@ -147,14 +147,14 @@ TEST(LSPBinderTest, OutgoingCalls) { WrongSignature(Foo{2}, capture(WrongTypeReply)); EXPECT_THAT(RawOutgoing.take("wrongSignature"), ElementsAre(llvm::json::Value(2))); - ASSERT_TRUE(Reply.hasValue()); + ASSERT_TRUE(Reply.has_value()); EXPECT_THAT_EXPECTED(WrongTypeReply.getValue(), llvm::FailedWithMessage( HasSubstr("failed to decode wrongSignature reply"))); Fail(Foo{2}, capture(Reply)); EXPECT_THAT(RawOutgoing.take("fail"), ElementsAre(llvm::json::Value(2))); - ASSERT_TRUE(Reply.hasValue()); + ASSERT_TRUE(Reply.has_value()); EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::FailedWithMessage("Params=2")); } diff --git a/clang-tools-extra/clangd/unittests/TidyProviderTests.cpp b/clang-tools-extra/clangd/unittests/TidyProviderTests.cpp index df3dcac0aa51..ece7f52d04d4 100644 --- a/clang-tools-extra/clangd/unittests/TidyProviderTests.cpp +++ b/clang-tools-extra/clangd/unittests/TidyProviderTests.cpp @@ -37,18 +37,18 @@ TEST(TidyProvider, NestedDirectories) { TidyProvider Provider = provideClangTidyFiles(FS); auto BaseOptions = getTidyOptionsForFile(Provider, testPath("File.cpp")); - ASSERT_TRUE(BaseOptions.Checks.hasValue()); + ASSERT_TRUE(BaseOptions.Checks.has_value()); EXPECT_EQ(*BaseOptions.Checks, "llvm-*"); EXPECT_EQ(BaseOptions.CheckOptions.lookup("TestKey").Value, "1"); auto Sub1Options = getTidyOptionsForFile(Provider, testPath("sub1/File.cpp")); - ASSERT_TRUE(Sub1Options.Checks.hasValue()); + ASSERT_TRUE(Sub1Options.Checks.has_value()); EXPECT_EQ(*Sub1Options.Checks, "misc-*"); EXPECT_EQ(Sub1Options.CheckOptions.lookup("TestKey").Value, "2"); auto Sub2Options = getTidyOptionsForFile(Provider, testPath("sub1/sub2/File.cpp")); - ASSERT_TRUE(Sub2Options.Checks.hasValue()); + ASSERT_TRUE(Sub2Options.Checks.has_value()); EXPECT_EQ(*Sub2Options.Checks, "misc-*,bugprone-*"); EXPECT_EQ(Sub2Options.CheckOptions.lookup("TestKey").Value, "3"); } diff --git a/clang-tools-extra/pseudo/lib/GLR.cpp b/clang-tools-extra/pseudo/lib/GLR.cpp index 831271f1b1d4..166408972519 100644 --- a/clang-tools-extra/pseudo/lib/GLR.cpp +++ b/clang-tools-extra/pseudo/lib/GLR.cpp @@ -499,7 +499,7 @@ private: FamilySequences.emplace_back(Sequences.top().first.Rule, *Push.Seq); for (const GSS::Node *Base : Push.LastPop->parents()) { auto NextState = Lang.Table.getGoToState(Base->State, F.Symbol); - assert(NextState.hasValue() && "goto must succeed after reduce!"); + assert(NextState.has_value() && "goto must succeed after reduce!"); FamilyBases.emplace_back(*NextState, Base); } @@ -555,7 +555,7 @@ private: const GSS::Node *Head = Heads->back(); llvm::Optional<RuleID> RID; for (RuleID R : Lang.Table.getReduceRules(Head->State)) { - if (RID.hasValue()) + if (RID.has_value()) return false; RID = R; } @@ -577,7 +577,7 @@ private: const ForestNode *Parsed = &Params.Forest.createSequence(Rule.Target, *RID, TempSequence); auto NextState = Lang.Table.getGoToState(Base->State, Rule.Target); - assert(NextState.hasValue() && "goto must succeed after reduce!"); + assert(NextState.has_value() && "goto must succeed after reduce!"); Heads->push_back(Params.GSStack.addNode(*NextState, Parsed, {Base})); return true; } @@ -642,7 +642,7 @@ const ForestNode &glrParse(const ParseParams &Params, SymbolID StartSymbol, // The parse was successful if we're in state `_ := start-symbol .` auto AcceptState = Lang.Table.getGoToState(StartState, StartSymbol); - assert(AcceptState.hasValue() && "goto must succeed after start symbol!"); + assert(AcceptState.has_value() && "goto must succeed after start symbol!"); auto SearchForAccept = [&](llvm::ArrayRef<const GSS::Node *> Heads) { const ForestNode *Result = nullptr; for (const auto *Head : Heads) { diff --git a/clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp b/clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp index b8f50bf34bed..f3b885f8b406 100644 --- a/clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp +++ b/clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp @@ -95,8 +95,8 @@ void CheckBaseInfo(Info *Expected, Info *Actual) { void CheckSymbolInfo(SymbolInfo *Expected, SymbolInfo *Actual) { CheckBaseInfo(Expected, Actual); - EXPECT_EQ(Expected->DefLoc.hasValue(), Actual->DefLoc.hasValue()); - if (Expected->DefLoc && Actual->DefLoc.hasValue()) { + EXPECT_EQ(Expected->DefLoc.has_value(), Actual->DefLoc.has_value()); + if (Expected->DefLoc && Actual->DefLoc.has_value()) { EXPECT_EQ(Expected->DefLoc->LineNumber, Actual->DefLoc->LineNumber); EXPECT_EQ(Expected->DefLoc->Filename, Actual->DefLoc->Filename); } diff --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp index 3558b5f346a2..5dcec035c476 100644 --- a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp @@ -129,14 +129,14 @@ TEST(ParseConfiguration, MergeConfigurations) { EXPECT_EQ("check1,check2,check3,check4", *Options.Checks); EXPECT_EQ("filter2", *Options.HeaderFilterRegex); EXPECT_EQ("user2", *Options.User); - ASSERT_TRUE(Options.ExtraArgs.hasValue()); + ASSERT_TRUE(Options.ExtraArgs.has_value()); EXPECT_EQ("arg1,arg2,arg3,arg4", llvm::join(Options.ExtraArgs->begin(), Options.ExtraArgs->end(), ",")); - ASSERT_TRUE(Options.ExtraArgsBefore.hasValue()); + ASSERT_TRUE(Options.ExtraArgsBefore.has_value()); EXPECT_EQ("arg-before1,arg-before2,arg-before3,arg-before4", llvm::join(Options.ExtraArgsBefore->begin(), Options.ExtraArgsBefore->end(), ",")); - ASSERT_TRUE(Options.UseColor.hasValue()); + ASSERT_TRUE(Options.UseColor.has_value()); EXPECT_TRUE(*Options.UseColor); } @@ -325,9 +325,9 @@ TEST(CheckOptionsValidation, ValidIntOptions) { CHECK_VAL(TestCheck.getIntLocal("IntExpected"), 1); CHECK_VAL(TestCheck.getIntGlobal("GlobalIntExpected"), 1); - EXPECT_FALSE(TestCheck.getIntLocal("IntInvalid1").hasValue()); - EXPECT_FALSE(TestCheck.getIntLocal("IntInvalid2").hasValue()); - EXPECT_FALSE(TestCheck.getIntGlobal("GlobalIntInvalid").hasValue()); + EXPECT_FALSE(TestCheck.getIntLocal("IntInvalid1").has_value()); + EXPECT_FALSE(TestCheck.getIntLocal("IntInvalid2").has_value()); + EXPECT_FALSE(TestCheck.getIntGlobal("GlobalIntInvalid").has_value()); ASSERT_EQ(TestCheck.getIntLocal("DefaultedIntInvalid", 1), 1); CHECK_VAL(TestCheck.getIntLocal<bool>("BoolITrueValue"), true); @@ -395,14 +395,14 @@ TEST(ValidConfiguration, ValidEnumOptions) { /*IgnoreCase*/ true), Colours::Violet); - EXPECT_FALSE(TestCheck.getIntLocal<Colours>("ValidWrongCase").hasValue()); - EXPECT_FALSE(TestCheck.getIntLocal<Colours>("NearMiss").hasValue()); - EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalInvalid").hasValue()); + EXPECT_FALSE(TestCheck.getIntLocal<Colours>("ValidWrongCase").has_value()); + EXPECT_FALSE(TestCheck.getIntLocal<Colours>("NearMiss").has_value()); + EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalInvalid").has_value()); EXPECT_FALSE( - TestCheck.getIntGlobal<Colours>("GlobalValidWrongCase").hasValue()); - EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalNearMiss").hasValue()); + TestCheck.getIntGlobal<Colours>("GlobalValidWrongCase").has_value()); + EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalNearMiss").has_value()); - EXPECT_FALSE(TestCheck.getIntLocal<Colours>("Invalid").hasValue()); + EXPECT_FALSE(TestCheck.getIntLocal<Colours>("Invalid").has_value()); EXPECT_THAT( DiagConsumer.take(), UnorderedElementsAre( diff --git a/clang-tools-extra/unittests/clang-tidy/OptionsProviderTest.cpp b/clang-tools-extra/unittests/clang-tidy/OptionsProviderTest.cpp index b99d0781e3f7..5aa3730ac5cc 100644 --- a/clang-tools-extra/unittests/clang-tidy/OptionsProviderTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/OptionsProviderTest.cpp @@ -53,9 +53,9 @@ TEST(ClangTidyOptionsProvider, InMemoryFileSystems) { ClangTidyOptions File3Options = FileOpt.getOptions("ProjectRoot/SubDir1/SubDir2/SubDir3/File.cpp"); - ASSERT_TRUE(File1Options.Checks.hasValue()); + ASSERT_TRUE(File1Options.Checks.has_value()); EXPECT_EQ(*File1Options.Checks, "-*,clang-diagnostic-*,readability-*"); - ASSERT_TRUE(File2Options.Checks.hasValue()); + ASSERT_TRUE(File2Options.Checks.has_value()); EXPECT_EQ(*File2Options.Checks, "bugprone-*,misc-*,clang-diagnostic-*"); // 2 and 3 should use the same config so these should also be the same. |