diff --git a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp index 1efd88d7cbb9..b2579e9ea615 100644 --- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp @@ -817,7 +817,7 @@ void NotNullTerminatedResultCheck::check( ++It; } - if (AreSafeFunctionsWanted.hasValue()) + if (AreSafeFunctionsWanted) UseSafeFunctions = AreSafeFunctionsWanted.getValue(); } diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp index 3bade14f86b9..edafb40ff2b7 100644 --- a/clang-tools-extra/clangd/ClangdLSPServer.cpp +++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -663,7 +663,7 @@ void ClangdLSPServer::onDocumentDidOpen( void ClangdLSPServer::onDocumentDidChange( const DidChangeTextDocumentParams &Params) { auto WantDiags = WantDiagnostics::Auto; - if (Params.wantDiagnostics.hasValue()) + if (Params.wantDiagnostics) WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes : WantDiagnostics::No; diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp index fa6c70b4acbc..4d9db8888c77 100644 --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -411,7 +411,7 @@ void ClangdServer::codeComplete(PathRef File, Position Pos, clang::clangd::trace::Span Tracer("Completion results callback"); CB(std::move(Result)); } - if (SpecFuzzyFind && SpecFuzzyFind->NewReq.hasValue()) { + if (SpecFuzzyFind && SpecFuzzyFind->NewReq) { std::lock_guard Lock(CachedCompletionFuzzyFindRequestMutex); CachedCompletionFuzzyFindRequestByFile[File] = SpecFuzzyFind->NewReq.getValue(); diff --git a/clang-tools-extra/clangd/FeatureModule.cpp b/clang-tools-extra/clangd/FeatureModule.cpp index 85977aadd6e3..872cea144378 100644 --- a/clang-tools-extra/clangd/FeatureModule.cpp +++ b/clang-tools-extra/clangd/FeatureModule.cpp @@ -13,12 +13,12 @@ namespace clang { namespace clangd { void FeatureModule::initialize(const Facilities &F) { - assert(!Fac.hasValue() && "Initialized twice"); + assert(!Fac && "Initialized twice"); Fac.emplace(F); } FeatureModule::Facilities &FeatureModule::facilities() { - assert(Fac.hasValue() && "Not initialized yet"); + assert(Fac && "Not initialized yet"); return *Fac; } diff --git a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp index fbf07aad4cd1..f7a3f2ae16ad 100644 --- a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp +++ b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp @@ -338,7 +338,7 @@ TEST(GlobalCompilationDatabaseTest, CompileFlagsDirectory) { } MATCHER_P(hasArg, Flag, "") { - if (!arg.hasValue()) { + if (!arg) { *result_listener << "command is null"; return false; } diff --git a/clang-tools-extra/pseudo/lib/GLR.cpp b/clang-tools-extra/pseudo/lib/GLR.cpp index 1cee8f86e599..d93f682afac6 100644 --- a/clang-tools-extra/pseudo/lib/GLR.cpp +++ b/clang-tools-extra/pseudo/lib/GLR.cpp @@ -375,11 +375,11 @@ private: for (auto &A : Params.Table.getActions(Head->State, Lookahead)) { if (A.kind() != LRTable::Action::Reduce) continue; - if (RID.hasValue()) + if (RID) return false; RID = A.getReduceRule(); } - if (!RID.hasValue()) + if (!RID) return true; // no reductions available, but we've processed the head! const auto &Rule = Params.G.lookupRule(*RID); const GSS::Node *Base = Head; diff --git a/clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp b/clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp index 970ffcebd717..b8f50bf34bed 100644 --- a/clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp +++ b/clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp @@ -96,7 +96,7 @@ 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.hasValue() && Actual->DefLoc.hasValue()) { + if (Expected->DefLoc && Actual->DefLoc.hasValue()) { 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/NamespaceAliaserTest.cpp b/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp index e4cd74ede7e4..aa51231d363d 100644 --- a/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp @@ -34,7 +34,7 @@ public: assert(Call != nullptr && "Did not find node \"foo\""); auto Hint = Aliaser->createAlias(*Result.Context, *Call, "::foo::bar", {"b", "some_alias"}); - if (Hint.hasValue()) + if (Hint) diag(Call->getBeginLoc(), "Fix for testing") << Hint.getValue(); diag(Call->getBeginLoc(), "insert call") << FixItHint::CreateInsertion( diff --git a/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp b/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp index 71c71596d0d9..edd644c452d3 100644 --- a/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp @@ -37,7 +37,7 @@ public: auto Hint = Inserter->createUsingDeclaration(*Result.Context, *Call, "::foo::func"); - if (Hint.hasValue()) + if (Hint) diag(Call->getBeginLoc(), "Fix for testing") << Hint.getValue(); diag(Call->getBeginLoc(), "insert call") diff --git a/clang/include/clang/APINotes/Types.h b/clang/include/clang/APINotes/Types.h index ed5250f3d5b4..d5372902ee09 100644 --- a/clang/include/clang/APINotes/Types.h +++ b/clang/include/clang/APINotes/Types.h @@ -77,7 +77,7 @@ public: void setSwiftPrivate(llvm::Optional Private) { SwiftPrivateSpecified = Private.hasValue(); - SwiftPrivate = Private.hasValue() ? *Private : 0; + SwiftPrivate = Private ? *Private : 0; } friend bool operator==(const CommonEntityInfo &, const CommonEntityInfo &); diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 8735f4d9f4d4..aa688d9dda3c 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -24514,9 +24514,8 @@ bool DAGCombiner::mayAlias(SDNode *Op0, SDNode *Op1) const { auto &Size0 = MUC0.NumBytes; auto &Size1 = MUC1.NumBytes; if (OrigAlignment0 == OrigAlignment1 && SrcValOffset0 != SrcValOffset1 && - Size0.hasValue() && Size1.hasValue() && *Size0 == *Size1 && - OrigAlignment0 > *Size0 && SrcValOffset0 % *Size0 == 0 && - SrcValOffset1 % *Size1 == 0) { + Size0 && Size1 && *Size0 == *Size1 && OrigAlignment0 > *Size0 && + SrcValOffset0 % *Size0 == 0 && SrcValOffset1 % *Size1 == 0) { int64_t OffAlign0 = SrcValOffset0 % OrigAlignment0.value(); int64_t OffAlign1 = SrcValOffset1 % OrigAlignment1.value(); diff --git a/polly/lib/Transform/ManualOptimizer.cpp b/polly/lib/Transform/ManualOptimizer.cpp index ef705eca8740..640ae0a859af 100644 --- a/polly/lib/Transform/ManualOptimizer.cpp +++ b/polly/lib/Transform/ManualOptimizer.cpp @@ -42,7 +42,7 @@ static TransformationMode hasUnrollTransformation(MDNode *LoopID) { Optional Count = getOptionalIntLoopAttribute(LoopID, "llvm.loop.unroll.count"); - if (Count.hasValue()) + if (Count) return Count.getValue() == 1 ? TM_SuppressedByUser : TM_ForcedByUser; if (getBooleanLoopAttribute(LoopID, "llvm.loop.unroll.enable")) diff --git a/polly/lib/Transform/MatmulOptimizer.cpp b/polly/lib/Transform/MatmulOptimizer.cpp index 4a40fac0d03b..bad05dfb8ebf 100644 --- a/polly/lib/Transform/MatmulOptimizer.cpp +++ b/polly/lib/Transform/MatmulOptimizer.cpp @@ -570,19 +570,19 @@ static void getTargetCacheParameters(const llvm::TargetTransformInfo *TTI) { auto L1DCache = llvm::TargetTransformInfo::CacheLevel::L1D; auto L2DCache = llvm::TargetTransformInfo::CacheLevel::L2D; if (FirstCacheLevelSize == -1) { - if (TTI->getCacheSize(L1DCache).hasValue()) + if (TTI->getCacheSize(L1DCache)) FirstCacheLevelSize = TTI->getCacheSize(L1DCache).getValue(); else FirstCacheLevelSize = static_cast(FirstCacheLevelDefaultSize); } if (SecondCacheLevelSize == -1) { - if (TTI->getCacheSize(L2DCache).hasValue()) + if (TTI->getCacheSize(L2DCache)) SecondCacheLevelSize = TTI->getCacheSize(L2DCache).getValue(); else SecondCacheLevelSize = static_cast(SecondCacheLevelDefaultSize); } if (FirstCacheLevelAssociativity == -1) { - if (TTI->getCacheAssociativity(L1DCache).hasValue()) + if (TTI->getCacheAssociativity(L1DCache)) FirstCacheLevelAssociativity = TTI->getCacheAssociativity(L1DCache).getValue(); else @@ -590,7 +590,7 @@ static void getTargetCacheParameters(const llvm::TargetTransformInfo *TTI) { static_cast(FirstCacheLevelDefaultAssociativity); } if (SecondCacheLevelAssociativity == -1) { - if (TTI->getCacheAssociativity(L2DCache).hasValue()) + if (TTI->getCacheAssociativity(L2DCache)) SecondCacheLevelAssociativity = TTI->getCacheAssociativity(L2DCache).getValue(); else