Author: Kazu Hirata Date: 2022-06-26T18:51:54-07:00 New Revision: ca05cc206478245292cb769f826dbe12f59605be
URL: https://github.com/llvm/llvm-project/commit/ca05cc206478245292cb769f826dbe12f59605be DIFF: https://github.com/llvm/llvm-project/commit/ca05cc206478245292cb769f826dbe12f59605be.diff LOG: [clang] Don't use Optional::hasValue (NFC) This patch replaces x.hasValue() with x where x is contextually convertible to bool. Added: Modified: clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h clang/include/clang/Support/RISCVVIntrinsicUtils.h clang/lib/Driver/Driver.cpp clang/lib/Lex/MacroInfo.cpp clang/lib/Parse/ParseOpenMP.cpp clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp Removed: ################################################################################ diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h index 11c60b6895627..4b6cbd516628a 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h @@ -53,14 +53,10 @@ class ConditionTruthVal { } /// Return true if the constraint is perfectly constrained to 'true'. - bool isConstrainedTrue() const { - return Val.hasValue() && Val.getValue(); - } + bool isConstrainedTrue() const { return Val && Val.getValue(); } /// Return true if the constraint is perfectly constrained to 'false'. - bool isConstrainedFalse() const { - return Val.hasValue() && !Val.getValue(); - } + bool isConstrainedFalse() const { return Val && !Val.getValue(); } /// Return true if the constrained is perfectly constrained. bool isConstrained() const { diff --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h b/clang/include/clang/Support/RISCVVIntrinsicUtils.h index 0e9fe97ab735e..3b6f205f9f220 100644 --- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h +++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h @@ -209,8 +209,8 @@ class RVVType { } bool isValid() const { return Valid; } - bool isScalar() const { return Scale.hasValue() && Scale.getValue() == 0; } - bool isVector() const { return Scale.hasValue() && Scale.getValue() != 0; } + bool isScalar() const { return Scale && Scale.getValue() == 0; } + bool isVector() const { return Scale && Scale.getValue() != 0; } bool isVector(unsigned Width) const { return isVector() && ElementBitwidth == Width; } diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index d83142286e7d6..c34da3a67a2e0 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3325,8 +3325,8 @@ class OffloadingActionBuilder final { A = C.getDriver().ConstructPhaseAction(C, Args, CurPhase, A, AssociatedOffloadKind); - if (CompileDeviceOnly && CurPhase == FinalPhase && - BundleOutput.hasValue() && BundleOutput.getValue()) { + if (CompileDeviceOnly && CurPhase == FinalPhase && BundleOutput && + BundleOutput.getValue()) { for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) { OffloadAction::DeviceDependences DDep; DDep.add(*CudaDeviceActions[I], *ToolChains.front(), GpuArchList[I], diff --git a/clang/lib/Lex/MacroInfo.cpp b/clang/lib/Lex/MacroInfo.cpp index 19ab9bcb972dd..310b95f36771d 100644 --- a/clang/lib/Lex/MacroInfo.cpp +++ b/clang/lib/Lex/MacroInfo.cpp @@ -213,8 +213,7 @@ MacroDirective::DefInfo MacroDirective::getDefinition() { isPublic = VisMD->isPublic(); } - return DefInfo(nullptr, UndefLoc, - !isPublic.hasValue() || isPublic.getValue()); + return DefInfo(nullptr, UndefLoc, !isPublic || isPublic.getValue()); } const MacroDirective::DefInfo diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index dbb0ca66f4976..43a69a8e94e14 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2313,9 +2313,9 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl( Sema::DeclareTargetContextInfo DTCI(DKind, DTLoc); if (HasClauses) ParseOMPDeclareTargetClauses(DTCI); - bool HasImplicitMappings = - DKind == OMPD_begin_declare_target || !HasClauses || - (DTCI.ExplicitlyMapped.empty() && DTCI.Indirect.hasValue()); + bool HasImplicitMappings = DKind == OMPD_begin_declare_target || + !HasClauses || + (DTCI.ExplicitlyMapped.empty() && DTCI.Indirect); // Skip the last annot_pragma_openmp_end. ConsumeAnyToken(); diff --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp b/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp index 4c5efa7504048..7c50453abe509 100644 --- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp @@ -40,9 +40,8 @@ isAnnotationDirectlyAfterStatement(const Stmt *Stmt, unsigned AnnotationBegin, auto NextToken = Lexer::findNextToken(Stmt->getEndLoc(), SourceManager, LangOptions); - while (NextToken.hasValue() && - SourceManager.getFileOffset(NextToken->getLocation()) < - AnnotationBegin) { + while (NextToken && SourceManager.getFileOffset(NextToken->getLocation()) < + AnnotationBegin) { if (NextToken->isNot(tok::semi)) return false; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits