Author: Kazu Hirata Date: 2022-06-20T10:51:34-07:00 New Revision: 452db157c963b2897a0882e3bb05ef845b9e4015
URL: https://github.com/llvm/llvm-project/commit/452db157c963b2897a0882e3bb05ef845b9e4015 DIFF: https://github.com/llvm/llvm-project/commit/452db157c963b2897a0882e3bb05ef845b9e4015.diff LOG: [clang] Don't use Optional::hasValue (NFC) Added: Modified: clang/include/clang/APINotes/Types.h clang/include/clang/AST/ASTContext.h clang/include/clang/AST/TypeProperties.td clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h clang/lib/ARCMigrate/Transforms.cpp clang/lib/AST/ComputeDependence.cpp clang/lib/AST/Interp/ByteCodeExprGen.h clang/lib/ASTMatchers/Dynamic/Parser.cpp clang/lib/Analysis/ReachableCode.cpp clang/lib/CodeGen/BackendUtil.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/CodeGen/CoverageMappingGen.cpp clang/lib/DirectoryWatcher/DirectoryScanner.cpp clang/lib/Driver/ToolChains/AVR.cpp clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/PPMacroExpansion.cpp clang/lib/Lex/TokenLexer.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaCUDA.cpp clang/lib/Sema/SemaCodeComplete.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclObjC.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Serialization/ASTWriter.cpp clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp clang/lib/StaticAnalyzer/Checkers/StringChecker.cpp clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp clang/lib/StaticAnalyzer/Core/BugReporter.cpp clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp clang/lib/StaticAnalyzer/Core/CallDescription.cpp clang/lib/StaticAnalyzer/Core/CallEvent.cpp clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp clang/lib/StaticAnalyzer/Core/RegionStore.cpp clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp clang/lib/Tooling/Transformer/Stencil.cpp clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp clang/utils/TableGen/ClangDiagnosticsEmitter.cpp clang/utils/TableGen/RISCVVEmitter.cpp Removed: ################################################################################ diff --git a/clang/include/clang/APINotes/Types.h b/clang/include/clang/APINotes/Types.h index 0df710152e7a9..f00e41b7c9558 100644 --- a/clang/include/clang/APINotes/Types.h +++ b/clang/include/clang/APINotes/Types.h @@ -676,7 +676,7 @@ class TagInfo : public CommonTypeInfo { if (!HasFlagEnum && HasFlagEnum) setFlagEnum(RHS.isFlagEnum()); - if (!EnumExtensibility.hasValue()) + if (!EnumExtensibility) EnumExtensibility = RHS.EnumExtensibility; return *this; @@ -706,7 +706,7 @@ class TypedefInfo : public CommonTypeInfo { TypedefInfo &operator|=(const TypedefInfo &RHS) { static_cast<CommonTypeInfo &>(*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 fe22930e0fb11..7db6af9cb87d6 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -2554,7 +2554,7 @@ class ASTContext : public RefCountedBase<ASTContext> { 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 54d89d43a66a7..c46b0bd68cadc 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 e4878d4e01564..250ba4f528968 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h @@ -129,7 +129,7 @@ class SMTConstraintManager : public clang::ento::SimpleConstraintManager { // Constraints are unsatisfiable Optional<bool> isSat = Solver->check(); - if (!isSat.hasValue() || !isSat.getValue()) + if (!isSat || !*isSat) return nullptr; // Model does not assign interpretation @@ -146,7 +146,7 @@ class SMTConstraintManager : public clang::ento::SimpleConstraintManager { Solver->addConstraint(NotExp); Optional<bool> 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 a08b0d084bb68..90b2b32b6b1be 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 2a2b98776e650..1f573346b4410 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 124a6ff03f186..82aa413dabbc6 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.h +++ b/clang/lib/AST/Interp/ByteCodeExprGen.h @@ -284,7 +284,7 @@ template <class Emitter> class LocalScope : public VariableScope<Emitter> { ~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 @@ template <class Emitter> class LocalScope : public VariableScope<Emitter> { } 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 732c783acaf6c..ec14f7abfdccf 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<DynTypedMatcher> 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 5be8180113da8..5efd3ad968871 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 4b294c254e476..86eaadc16c9c9 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 5232edd6a4afc..515d365b9ee2a 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -80,7 +80,7 @@ class OMPLexicalScope : public CodeGenFunction::LexicalScope { 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 d1cbe109a6cf8..61137f5d3e3a0 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -392,7 +392,7 @@ class CoverageMappingBuilder { 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<SourceLocation> EndLoc = None, Optional<Counter> 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 1bc286236a0e7..fc4b493e7b4c7 100644 --- a/clang/lib/DirectoryWatcher/DirectoryScanner.cpp +++ b/clang/lib/DirectoryWatcher/DirectoryScanner.cpp @@ -31,7 +31,7 @@ std::vector<std::string> 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 54a9168788585..58f78c1d483de 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<std::string> 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 70d001fbaec77..ca6cb08302108 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -295,7 +295,7 @@ static Optional<StringRef> 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<StringRef> 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 063199b0e6ce5..31d6aa0dd4d02 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -1311,7 +1311,7 @@ static void EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS, 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 @@ static void EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS, 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 e71a65f031e43..efda6d0046fa1 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 4641721d97e27..04055dff55c7f 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 18f9dd7fb532d..a3b15fe7e90b6 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 ae2e71dcd5dac..ec735183e25f3 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 d167010cfa922..a5870efdfa303 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<OMPDeclareTargetDeclAttr::DevTypeTy> 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 aa0034e616f27..a574a55393308 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 429d5c5910f7f..76e92baf525b1 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -3540,7 +3540,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> { !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 d1bc5373c5339..4a35701ef67e1 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 61be9265db0cc..1787909bb6f77 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 5bf05033a9a0c..0e273771498cc 100644 --- a/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp @@ -260,7 +260,7 @@ SVal GTestChecker::getAssertionResultSuccessFieldValue( Optional<Loc> FieldLoc = State->getLValue(SuccessField, Instance).getAs<Loc>(); - 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 6461b9bb6a1c5..9870746cbe0ca 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<StmtPoint> Point = Succ->getLocation().getAs<StmtPoint>(); - if (!Point.hasValue()) + if (!Point) return nullptr; auto *LiteralExpr = dyn_cast<ObjCStringLiteral>(Point->getStmt()); diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index b23edb127322a..552d042483393 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<MallocChecker::CheckKind> 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<MallocChecker::CheckKind> 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<MallocChecker::CheckKind> 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<MallocChecker::CheckKind> 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<MallocChecker::CheckKind> 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<MallocChecker::CheckKind> 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<MallocChecker::CheckKind> 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<MallocChecker::CheckKind> 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 0d745f5d8d6f4..2dc9e29ca9068 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<Loc>(); - 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 c5d86f6b9a204..9da44d5c0d394 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 771ed2578f6dc..a2efe14f10453 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 f02a1739a286f..8d928d141aca1 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 d4d7672e0959b..39c8e69612ddd 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 58963b87d0d3d..acde10b353799 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<SVal> 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 92104d628711a..93c19a688b9a8 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<StringRef> ExpansionText = getExpandedMacro(MacroExpansionLoc, CTU, MacroExpansions, SM); - if (!MacroName.hasValue() || !ExpansionText.hasValue()) + if (!MacroName || !ExpansionText) continue; Indent(o, indent) << "<dict>\n"; diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp index b432247bad7d8..826ebc5438a7e 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 16e6ac59e85fe..e7d1375c83f0b 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp @@ -240,7 +240,7 @@ class DependencyScanningAction : public tooling::ToolAction { std::unique_ptr<FrontendAction> Action; - if (ModuleName.hasValue()) + if (ModuleName) Action = std::make_unique<GetDependenciesByModuleNameAction>(*ModuleName); else Action = std::make_unique<ReadPCHAndPreprocessAction>(); @@ -317,7 +317,7 @@ llvm::Error DependencyScanningWorker::computeDependencies( Files ? Files : new FileManager(FileSystemOptions(), RealFS); Optional<std::vector<std::string>> 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 348d04dbaf4a3..82dd4a2587b5f 100644 --- a/clang/lib/Tooling/Transformer/Stencil.cpp +++ b/clang/lib/Tooling/Transformer/Stencil.cpp @@ -278,7 +278,7 @@ class AccessStencil : public StencilInterface { return llvm::make_error<StringError>(errc::invalid_argument, "Id not bound: " + BaseId); llvm::Optional<std::string> S = tooling::buildAccess(*E, *Match.Context); - if (!S.hasValue()) + if (!S) return llvm::make_error<StringError>( 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 8d9d2791f6d0e..50fe2257bc1d5 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<StringRef> 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 f8b14c5d33e23..62ac6afa32f2f 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 8b008e0eec72b..5c94e0e33df50 100644 --- a/clang/utils/TableGen/RISCVVEmitter.cpp +++ b/clang/utils/TableGen/RISCVVEmitter.cpp @@ -467,7 +467,7 @@ void RVVEmitter::createRVVIntrinsics( Optional<RVVTypes> 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); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits