diff --git a/clang/include/clang/APINotes/Types.h b/clang/include/clang/APINotes/Types.h index 0df710152e7a..f00e41b7c955 100644 --- a/clang/include/clang/APINotes/Types.h +++ b/clang/include/clang/APINotes/Types.h @@ -676,7 +676,7 @@ public: if (!HasFlagEnum && HasFlagEnum) setFlagEnum(RHS.isFlagEnum()); - if (!EnumExtensibility.hasValue()) + if (!EnumExtensibility) EnumExtensibility = RHS.EnumExtensibility; return *this; @@ -706,7 +706,7 @@ public: TypedefInfo &operator|=(const TypedefInfo &RHS) { static_cast(*this) |= RHS; - if (!SwiftWrapper.hasValue()) + if (!SwiftWrapper) SwiftWrapper = RHS.SwiftWrapper; return *this; } diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index fe22930e0fb1..7db6af9cb87d 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -2554,7 +2554,7 @@ public: bool IsParam) const { auto SubTnullability = SubT->getNullability(*this); auto SuperTnullability = SuperT->getNullability(*this); - if (SubTnullability.hasValue() == SuperTnullability.hasValue()) { + if (SubTnullability.has_value() == SuperTnullability.has_value()) { // Neither has nullability; return true if (!SubTnullability) return true; diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 54d89d43a66a..c46b0bd68cad 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -671,7 +671,7 @@ let Class = TemplateSpecializationType in { def : Creator<[{ QualType result; - if (!underlyingType.hasValue()) { + if (!underlyingType) { result = ctx.getCanonicalTemplateSpecializationType(templateName, templateArguments); } else { diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h index e4878d4e0156..250ba4f52896 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h @@ -129,7 +129,7 @@ public: // Constraints are unsatisfiable Optional isSat = Solver->check(); - if (!isSat.hasValue() || !isSat.getValue()) + if (!isSat || !*isSat) return nullptr; // Model does not assign interpretation @@ -146,7 +146,7 @@ public: Solver->addConstraint(NotExp); Optional isNotSat = Solver->check(); - if (!isNotSat.hasValue() || isNotSat.getValue()) + if (!isNotSat || *isNotSat) return nullptr; // This is the only solution, store it diff --git a/clang/lib/ARCMigrate/Transforms.cpp b/clang/lib/ARCMigrate/Transforms.cpp index a08b0d084bb6..90b2b32b6b1b 100644 --- a/clang/lib/ARCMigrate/Transforms.cpp +++ b/clang/lib/ARCMigrate/Transforms.cpp @@ -25,7 +25,7 @@ using namespace trans; ASTTraverser::~ASTTraverser() { } bool MigrationPass::CFBridgingFunctionsDefined() { - if (!EnableCFBridgeFns.hasValue()) + if (!EnableCFBridgeFns) EnableCFBridgeFns = SemaRef.isKnownName("CFBridgingRetain") && SemaRef.isKnownName("CFBridgingRelease"); return *EnableCFBridgeFns; diff --git a/clang/lib/AST/ComputeDependence.cpp b/clang/lib/AST/ComputeDependence.cpp index 2a2b98776e65..1f573346b441 100644 --- a/clang/lib/AST/ComputeDependence.cpp +++ b/clang/lib/AST/ComputeDependence.cpp @@ -696,7 +696,7 @@ ExprDependence clang::computeDependence(CXXNewExpr *E) { E->getAllocatedTypeSourceInfo()->getType()->getDependence()); D |= toExprDependenceForImpliedType(E->getAllocatedType()->getDependence()); auto Size = E->getArraySize(); - if (Size.hasValue() && *Size) + if (Size && *Size) D |= turnTypeToValueDependence((*Size)->getDependence()); if (auto *I = E->getInitializer()) D |= turnTypeToValueDependence(I->getDependence()); diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h index 124a6ff03f18..82aa413dabbc 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.h +++ b/clang/lib/AST/Interp/ByteCodeExprGen.h @@ -284,7 +284,7 @@ public: ~LocalScope() override { this->emitDestruction(); } void addLocal(const Scope::Local &Local) override { - if (!Idx.hasValue()) { + if (!Idx) { Idx = this->Ctx->Descriptors.size(); this->Ctx->Descriptors.emplace_back(); } @@ -293,7 +293,7 @@ public: } void emitDestruction() override { - if (!Idx.hasValue()) + if (!Idx) return; this->Ctx->emitDestroy(*Idx, SourceInfo{}); } diff --git a/clang/lib/ASTMatchers/Dynamic/Parser.cpp b/clang/lib/ASTMatchers/Dynamic/Parser.cpp index 732c783acaf6..ec14f7abfdcc 100644 --- a/clang/lib/ASTMatchers/Dynamic/Parser.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Parser.cpp @@ -917,7 +917,7 @@ Parser::parseMatcherExpression(StringRef &Code, Sema *S, } llvm::Optional Result = Value.getMatcher().getSingleMatcher(); - if (!Result.hasValue()) { + if (!Result) { Error->addError(SourceRange(), Error->ET_ParserOverloadedType) << Value.getTypeAsString(); } diff --git a/clang/lib/Analysis/ReachableCode.cpp b/clang/lib/Analysis/ReachableCode.cpp index 5be8180113da..5efd3ad96887 100644 --- a/clang/lib/Analysis/ReachableCode.cpp +++ b/clang/lib/Analysis/ReachableCode.cpp @@ -345,7 +345,7 @@ static unsigned scanFromBlock(const CFGBlock *Start, if (!UB) break; - if (!TreatAllSuccessorsAsReachable.hasValue()) { + if (!TreatAllSuccessorsAsReachable) { assert(PP); TreatAllSuccessorsAsReachable = shouldTreatSuccessorsAsReachable(item, *PP); diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 4b294c254e47..86eaadc16c9c 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -741,7 +741,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline( assert(!CodeGenOpts.hasProfileCSIRUse() && "Cannot have both CSProfileUse pass and CSProfileGen pass at " "the same time"); - if (PGOOpt.hasValue()) { + if (PGOOpt) { assert(PGOOpt->Action != PGOOptions::IRInstr && PGOOpt->Action != PGOOptions::SampleUse && "Cannot run CSProfileGen pass with ProfileGen or SampleUse " diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 5232edd6a4af..515d365b9ee2 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -80,7 +80,7 @@ public: InlinedShareds(CGF) { if (EmitPreInitStmt) emitPreInitStmt(CGF, S); - if (!CapturedRegion.hasValue()) + if (!CapturedRegion) return; assert(S.hasAssociatedStmt() && "Expected associated statement for inlined directive."); diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index d1cbe109a6cf..61137f5d3e3a 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -392,7 +392,7 @@ public: else if (I.isPPIfElse() || I.isEmptyLine()) SR = {SM, LocStart, LocEnd}; - if (!SR.hasValue()) + if (!SR) continue; auto Region = CounterMappingRegion::makeSkipped( *CovFileID, SR->LineStart, SR->ColumnStart, SR->LineEnd, @@ -587,7 +587,7 @@ struct CounterCoverageMappingBuilder Optional EndLoc = None, Optional FalseCount = None) { - if (StartLoc && !FalseCount.hasValue()) { + if (StartLoc && !FalseCount) { MostRecentLocation = *StartLoc; } diff --git a/clang/lib/DirectoryWatcher/DirectoryScanner.cpp b/clang/lib/DirectoryWatcher/DirectoryScanner.cpp index 1bc286236a0e..fc4b493e7b4c 100644 --- a/clang/lib/DirectoryWatcher/DirectoryScanner.cpp +++ b/clang/lib/DirectoryWatcher/DirectoryScanner.cpp @@ -31,7 +31,7 @@ std::vector scanDirectory(StringRef Path) { End = fs::directory_iterator(); !EC && It != End; It.increment(EC)) { auto status = getFileStatus(It->path()); - if (!status.hasValue()) + if (!status) continue; Result.emplace_back(sys::path::filename(It->path())); } diff --git a/clang/lib/Driver/ToolChains/AVR.cpp b/clang/lib/Driver/ToolChains/AVR.cpp index 54a916878858..58f78c1d483d 100644 --- a/clang/lib/Driver/ToolChains/AVR.cpp +++ b/clang/lib/Driver/ToolChains/AVR.cpp @@ -390,7 +390,7 @@ void AVRToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs, // Omit if there is no avr-libc installed. Optional AVRLibcRoot = findAVRLibcInstallation(); - if (!AVRLibcRoot.hasValue()) + if (!AVRLibcRoot) return; // Add 'avr-libc/include' to clang system include paths if applicable. diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 70d001fbaec7..ca6cb0830210 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -295,7 +295,7 @@ static Optional findSimilarStr( for (StringRef C : Candidates) { size_t CurDist = LHS.edit_distance(C, true); if (CurDist <= MaxDist) { - if (!SimilarStr.hasValue()) { + if (!SimilarStr) { // The first similar string found. SimilarStr = {C, CurDist}; } else if (CurDist < SimilarStr->second) { @@ -305,7 +305,7 @@ static Optional findSimilarStr( } } - if (SimilarStr.hasValue()) { + if (SimilarStr) { return SimilarStr->first; } else { return None; diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 063199b0e6ce..31d6aa0dd4d0 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -1311,7 +1311,7 @@ already_lexed: case tok::l_paren: ++ParenDepth; - if (Result.hasValue()) + if (Result) break; if (!SuppressDiagnostic) { PP.Diag(Tok.getLocation(), diag::err_pp_nested_paren) << II; @@ -1341,7 +1341,7 @@ already_lexed: default: { // Parse the macro argument, if one not found so far. - if (Result.hasValue()) + if (Result) break; bool HasLexedNextToken = false; diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp index e71a65f031e4..efda6d0046fa 100644 --- a/clang/lib/Lex/TokenLexer.cpp +++ b/clang/lib/Lex/TokenLexer.cpp @@ -295,7 +295,7 @@ void TokenLexer::ExpandFunctionArguments() { // the closing r_paren of the __VA_OPT__. if (!Tokens[I].is(tok::r_paren) || !VCtx.sawClosingParen()) { // Lazily expand __VA_ARGS__ when we see the first __VA_OPT__. - if (!CalledWithVariadicArguments.hasValue()) { + if (!CalledWithVariadicArguments) { CalledWithVariadicArguments = ActualArgs->invokedWithVariadicArgument(Macro, PP); } diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 4641721d97e2..04055dff55c7 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -1835,7 +1835,7 @@ void Parser::ParseOMPDeclareTargetClauses( bool IsIndirectClause = getLangOpts().OpenMP >= 51 && getOpenMPClauseKind(ClauseName) == OMPC_indirect; - if (DTCI.Indirect.hasValue() && IsIndirectClause) { + if (DTCI.Indirect && IsIndirectClause) { Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(OMPD_declare_target) << getOpenMPClauseName(OMPC_indirect) << 0; @@ -1933,7 +1933,7 @@ void Parser::ParseOMPDeclareTargetClauses( ConsumeToken(); } - if (DTCI.Indirect.hasValue() && DTCI.DT != OMPDeclareTargetDeclAttr::DT_Any) + if (DTCI.Indirect && DTCI.DT != OMPDeclareTargetDeclAttr::DT_Any) Diag(DeviceTypeLoc, diag::err_omp_declare_target_indirect_device_type); // For declare target require at least 'to' or 'link' to be present. diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp index 18f9dd7fb532..a3b15fe7e90b 100644 --- a/clang/lib/Sema/SemaCUDA.cpp +++ b/clang/lib/Sema/SemaCUDA.cpp @@ -377,7 +377,7 @@ bool Sema::inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, continue; CUDAFunctionTarget BaseMethodTarget = IdentifyCUDATarget(SMOR.getMethod()); - if (!InferredTarget.hasValue()) { + if (!InferredTarget) { InferredTarget = BaseMethodTarget; } else { bool ResolutionError = resolveCalleeCUDATargetConflict( @@ -421,7 +421,7 @@ bool Sema::inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CUDAFunctionTarget FieldMethodTarget = IdentifyCUDATarget(SMOR.getMethod()); - if (!InferredTarget.hasValue()) { + if (!InferredTarget) { InferredTarget = FieldMethodTarget; } else { bool ResolutionError = resolveCalleeCUDATargetConflict( diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index ae2e71dcd5da..ec735183e25f 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -5645,7 +5645,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, // Objective-C property reference. Bail if we're performing fix-it code // completion since Objective-C properties are normally backed by ivars, // most Objective-C fix-its here would have little value. - if (AccessOpFixIt.hasValue()) { + if (AccessOpFixIt) { return false; } AddedPropertiesSet AddedProperties; @@ -5670,7 +5670,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, // Objective-C instance variable access. Bail if we're performing fix-it // code completion since Objective-C properties are normally backed by // ivars, most Objective-C fix-its here would have little value. - if (AccessOpFixIt.hasValue()) { + if (AccessOpFixIt) { return false; } ObjCInterfaceDecl *Class = nullptr; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index d167010cfa92..a5870efdfa30 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -19119,7 +19119,7 @@ Sema::FunctionEmissionStatus Sema::getEmissionStatus(FunctionDecl *FD, // be ommitted. Optional DevTy = OMPDeclareTargetDeclAttr::getDeviceType(FD->getCanonicalDecl()); - if (DevTy.hasValue()) + if (DevTy) if (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost) return FunctionEmissionStatus::OMPDiscarded; } diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index aa0034e616f2..a574a5539330 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -4537,7 +4537,7 @@ static QualType mergeTypeNullabilityForRedecl(Sema &S, SourceLocation loc, auto prevNullability = prevType->getNullability(S.Context); // Easy case: both have nullability. - if (nullability.hasValue() == prevNullability.hasValue()) { + if (nullability.has_value() == prevNullability.has_value()) { // Neither has nullability; continue. if (!nullability) return type; diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 429d5c5910f7..76e92baf525b 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -3540,7 +3540,7 @@ public: !Stack->isImplicitTaskFirstprivate(VD)) return; // Skip allocators in uses_allocators clauses. - if (Stack->isUsesAllocatorsDecl(VD).hasValue()) + if (Stack->isUsesAllocatorsDecl(VD)) return; DSAStackTy::DSAVarData DVar = Stack->getTopDSA(VD, /*FromParent=*/false); @@ -8049,7 +8049,7 @@ bool OpenMPIterationSpaceChecker::checkAndSetCond(Expr *S) { CE->getArg(1), CE->getSourceRange(), CE->getOperatorLoc()); } } - if (Res.hasValue()) + if (Res) return *Res; if (dependent() || SemaRef.CurContext->isDependentContext()) return false; @@ -22183,7 +22183,7 @@ static void checkDeclInTargetContext(SourceLocation SL, SourceRange SR, return; } } - if (MapTy.hasValue()) + if (MapTy) return; SemaRef.Diag(VD->getLocation(), diag::warn_omp_not_in_target_context); SemaRef.Diag(SL, diag::note_used_here) << SR; diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index d1bc5373c533..4a35701ef67e 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -12525,7 +12525,7 @@ Sema::resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &Pair) { // We skipped over some ambiguous declarations which might be ambiguous with // the selected result. for (FunctionDecl *Skipped : AmbiguousDecls) - if (!CheckMoreConstrained(Skipped, Result).hasValue()) + if (!CheckMoreConstrained(Skipped, Result)) return nullptr; Pair = DAP; } diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 61be9265db0c..1787909bb6f7 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -2306,7 +2306,7 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) { if (PP.isRecordingPreamble() && PP.hasRecordedPreamble()) { assert(!IsModule); auto SkipInfo = PP.getPreambleSkipInfo(); - if (SkipInfo.hasValue()) { + if (SkipInfo) { Record.push_back(true); AddSourceLocation(SkipInfo->HashTokenLoc, Record); AddSourceLocation(SkipInfo->IfTokenLoc, Record); diff --git a/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp index 5bf05033a9a0..0e273771498c 100644 --- a/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp @@ -260,7 +260,7 @@ SVal GTestChecker::getAssertionResultSuccessFieldValue( Optional FieldLoc = State->getLValue(SuccessField, Instance).getAs(); - if (!FieldLoc.hasValue()) + if (!FieldLoc) return UnknownVal(); return State->getSVal(*FieldLoc); diff --git a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp index 6461b9bb6a1c..9870746cbe0c 100644 --- a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp @@ -1005,7 +1005,7 @@ NonLocalizedStringBRVisitor::VisitNode(const ExplodedNode *Succ, return nullptr; Optional Point = Succ->getLocation().getAs(); - if (!Point.hasValue()) + if (!Point) return nullptr; auto *LiteralExpr = dyn_cast(Point->getStmt()); diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index b23edb127322..552d04248339 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -1155,7 +1155,7 @@ MallocChecker::performKernelMalloc(const CallEvent &Call, CheckerContext &C, ASTContext &Ctx = C.getASTContext(); llvm::Triple::OSType OS = Ctx.getTargetInfo().getTriple().getOS(); - if (!KernelZeroFlagVal.hasValue()) { + if (!KernelZeroFlagVal) { if (OS == llvm::Triple::FreeBSD) KernelZeroFlagVal = 0x0100; else if (OS == llvm::Triple::NetBSD) @@ -2218,7 +2218,7 @@ void MallocChecker::HandleNonHeapDealloc(CheckerContext &C, SVal ArgVal, } Optional CheckKind = getCheckIfTracked(Family); - if (!CheckKind.hasValue()) + if (!CheckKind) return; if (ExplodedNode *N = C.generateErrorNode()) { @@ -2351,7 +2351,7 @@ void MallocChecker::HandleOffsetFree(CheckerContext &C, SVal ArgVal, } Optional CheckKind = getCheckIfTracked(Family); - if (!CheckKind.hasValue()) + if (!CheckKind) return; ExplodedNode *N = C.generateErrorNode(); @@ -2408,7 +2408,7 @@ void MallocChecker::HandleUseAfterFree(CheckerContext &C, SourceRange Range, } Optional CheckKind = getCheckIfTracked(C, Sym); - if (!CheckKind.hasValue()) + if (!CheckKind) return; if (ExplodedNode *N = C.generateErrorNode()) { @@ -2447,7 +2447,7 @@ void MallocChecker::HandleDoubleFree(CheckerContext &C, SourceRange Range, } Optional CheckKind = getCheckIfTracked(C, Sym); - if (!CheckKind.hasValue()) + if (!CheckKind) return; if (ExplodedNode *N = C.generateErrorNode()) { @@ -2477,7 +2477,7 @@ void MallocChecker::HandleDoubleDelete(CheckerContext &C, SymbolRef Sym) const { } Optional CheckKind = getCheckIfTracked(C, Sym); - if (!CheckKind.hasValue()) + if (!CheckKind) return; if (ExplodedNode *N = C.generateErrorNode()) { @@ -2505,7 +2505,7 @@ void MallocChecker::HandleUseZeroAlloc(CheckerContext &C, SourceRange Range, Optional CheckKind = getCheckIfTracked(C, Sym); - if (!CheckKind.hasValue()) + if (!CheckKind) return; if (ExplodedNode *N = C.generateErrorNode()) { @@ -2537,7 +2537,7 @@ void MallocChecker::HandleFunctionPtrFree(CheckerContext &C, SVal ArgVal, } Optional CheckKind = getCheckIfTracked(Family); - if (!CheckKind.hasValue()) + if (!CheckKind) return; if (ExplodedNode *N = C.generateErrorNode()) { @@ -2750,7 +2750,7 @@ void MallocChecker::HandleLeak(SymbolRef Sym, ExplodedNode *N, Optional CheckKind = getCheckIfTracked(Family, true); - if (!CheckKind.hasValue()) + if (!CheckKind) return; assert(N); diff --git a/clang/lib/StaticAnalyzer/Checkers/StringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StringChecker.cpp index 0d745f5d8d6f..2dc9e29ca906 100644 --- a/clang/lib/StaticAnalyzer/Checkers/StringChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StringChecker.cpp @@ -69,7 +69,7 @@ void StringChecker::checkPreCall(const CallEvent &Call, if (!isCharToStringCtor(Call, C.getASTContext())) return; const auto Param = Call.getArgSVal(0).getAs(); - if (!Param.hasValue()) + if (!Param) return; // We managed to constrain the parameter to non-null. diff --git a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp index c5d86f6b9a20..9da44d5c0d39 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp @@ -211,7 +211,7 @@ void UnixAPIMisuseChecker::CheckOpenVariant(CheckerContext &C, // The definition of O_CREAT is platform specific. We need a better way // of querying this information from the checking environment. - if (!Val_O_CREAT.hasValue()) { + if (!Val_O_CREAT) { if (C.getASTContext().getTargetInfo().getTriple().getVendor() == llvm::Triple::Apple) Val_O_CREAT = 0x0200; diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 771ed2578f6d..a2efe14f1045 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -1883,7 +1883,7 @@ static bool optimizeEdges(const PathDiagnosticConstruct &C, PathPieces &path, lexicalContains(PM, s1Start, s1End)) { SourceRange EdgeRange(PieceI->getEndLocation().asLocation(), PieceI->getStartLocation().asLocation()); - if (!getLengthOnSingleLine(SM, EdgeRange).hasValue()) + if (!getLengthOnSingleLine(SM, EdgeRange)) removeEdge = true; } } diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index f02a1739a286..8d928d141aca 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -3077,7 +3077,7 @@ bool ConditionBRVisitor::printValue(const Expr *CondVarExpr, raw_ostream &Out, if (!IsAssuming) IntValue = getConcreteIntegerValue(CondVarExpr, N); - if (IsAssuming || !IntValue.hasValue()) { + if (IsAssuming || !IntValue) { if (Ty->isBooleanType()) Out << (TookTrue ? "true" : "false"); else diff --git a/clang/lib/StaticAnalyzer/Core/CallDescription.cpp b/clang/lib/StaticAnalyzer/Core/CallDescription.cpp index d4d7672e0959..39c8e69612dd 100644 --- a/clang/lib/StaticAnalyzer/Core/CallDescription.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallDescription.cpp @@ -86,7 +86,7 @@ bool ento::CallDescription::matchesImpl(const FunctionDecl *Callee, (!RequiredParams || *RequiredParams <= ParamCount); } - if (!II.hasValue()) { + if (!II) { II = &FD->getASTContext().Idents.get(getFunctionName()); } diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp index 58963b87d0d3..acde10b35379 100644 --- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -772,7 +772,7 @@ void CXXInstanceCall::getInitialStackFrameContents( // FIXME: CallEvent maybe shouldn't be directly accessing StoreManager. Optional V = StateMgr.getStoreManager().evalBaseToDerived(ThisVal, Ty); - if (!V.hasValue()) { + if (!V) { // We might have suffered some sort of placement new earlier, so // we're constructing in a completely unexpected storage. // Fall back to a generic pointer cast for this-value. @@ -1192,7 +1192,7 @@ lookupRuntimeDefinition(const ObjCInterfaceDecl *Interface, PMC[{Interface, LookupSelector, InstanceMethod}]; // Query lookupPrivateMethod() if the cache does not hit. - if (!Val.hasValue()) { + if (!Val) { Val = Interface->lookupPrivateMethod(LookupSelector, InstanceMethod); if (!*Val) { diff --git a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp index 92104d628711..93c19a688b9a 100644 --- a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -389,7 +389,7 @@ void PlistPrinter::ReportMacroExpansions(raw_ostream &o, unsigned indent) { const Optional ExpansionText = getExpandedMacro(MacroExpansionLoc, CTU, MacroExpansions, SM); - if (!MacroName.hasValue() || !ExpansionText.hasValue()) + if (!MacroName || !ExpansionText) continue; Indent(o, indent) << "\n"; diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp index b432247bad7d..826ebc5438a7 100644 --- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -2500,7 +2500,7 @@ RegionStoreManager::bindArray(RegionBindingsConstRef B, // If the init list is shorter than the array length (or the array has // variable length), set the array default value. Values that are already set // are not overwritten. - if (!Size.hasValue() || i < Size.getValue()) + if (!Size || i < *Size) NewB = setImplicitDefaultValue(NewB, R, ElementTy); return NewB; diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp index 16e6ac59e85f..e7d1375c83f0 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp @@ -240,7 +240,7 @@ public: std::unique_ptr Action; - if (ModuleName.hasValue()) + if (ModuleName) Action = std::make_unique(*ModuleName); else Action = std::make_unique(); @@ -317,7 +317,7 @@ llvm::Error DependencyScanningWorker::computeDependencies( Files ? Files : new FileManager(FileSystemOptions(), RealFS); Optional> ModifiedCommandLine; - if (ModuleName.hasValue()) { + if (ModuleName) { ModifiedCommandLine = CommandLine; InMemoryFS->addFile(*ModuleName, 0, llvm::MemoryBuffer::getMemBuffer("")); ModifiedCommandLine->emplace_back(*ModuleName); diff --git a/clang/lib/Tooling/Transformer/Stencil.cpp b/clang/lib/Tooling/Transformer/Stencil.cpp index 348d04dbaf4a..82dd4a2587b5 100644 --- a/clang/lib/Tooling/Transformer/Stencil.cpp +++ b/clang/lib/Tooling/Transformer/Stencil.cpp @@ -278,7 +278,7 @@ public: return llvm::make_error(errc::invalid_argument, "Id not bound: " + BaseId); llvm::Optional S = tooling::buildAccess(*E, *Match.Context); - if (!S.hasValue()) + if (!S) return llvm::make_error( errc::invalid_argument, "Could not construct object text from ID: " + BaseId); diff --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp index 8d9d2791f6d0..50fe2257bc1d 100644 --- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp +++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -1255,7 +1255,7 @@ static Error UnbundleArchive() { Optional OptionalCurBundleID = *CurBundleIDOrErr; // No device code in this child, skip. - if (!OptionalCurBundleID.hasValue()) + if (!OptionalCurBundleID) continue; StringRef CodeObject = *OptionalCurBundleID; diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index f8b14c5d33e2..62ac6afa32f2 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -325,7 +325,7 @@ bool InferPedantic::isOffByDefault(const Record *Diag) { bool InferPedantic::groupInPedantic(const Record *Group, bool increment) { GMap::mapped_type &V = GroupCount[Group]; // Lazily compute the threshold value for the group count. - if (!V.second.hasValue()) { + if (!V.second) { const GroupInfo &GI = DiagsInGroup[std::string(Group->getValueAsString("GroupName"))]; V.second = GI.SubGroups.size() + GI.DiagsInGroup.size(); diff --git a/clang/utils/TableGen/RISCVVEmitter.cpp b/clang/utils/TableGen/RISCVVEmitter.cpp index 8b008e0eec72..5c94e0e33df5 100644 --- a/clang/utils/TableGen/RISCVVEmitter.cpp +++ b/clang/utils/TableGen/RISCVVEmitter.cpp @@ -467,7 +467,7 @@ void RVVEmitter::createRVVIntrinsics( Optional Types = RVVType::computeTypes(BT, Log2LMUL, NF, Prototype); // Ignored to create new intrinsic if there are any illegal types. - if (!Types.hasValue()) + if (!Types) continue; auto SuffixStr = RVVIntrinsic::getSuffixStr(BT, Log2LMUL, SuffixDesc);