diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h --- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h +++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h @@ -397,7 +397,7 @@ public: TrackConstraintBRVisitor(DefinedSVal constraint, bool assumption) : Constraint(constraint), Assumption(assumption), - IsZeroCheck(!Assumption && Constraint.getAs()) {} + IsZeroCheck(!Assumption && Constraint.isa()) {} void Profile(llvm::FoldingSetNodeID &ID) const override; diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h @@ -1148,7 +1148,7 @@ ElementRegion(QualType elementType, NonLoc Idx, const SubRegion *sReg) : TypedValueRegion(sReg, ElementRegionKind), ElementType(elementType), Index(Idx) { - assert((!Idx.getAs() || + assert((!Idx.isa() || Idx.castAs().getValue().isSigned()) && "The index must be signed"); assert(!elementType.isNull() && !elementType->isVoidType() && diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -722,7 +722,7 @@ if (Val.isUnknown()) return this; - assert(Val.getAs() && "Only NonLocs are supported!"); + assert(Val.isa() && "Only NonLocs are supported!"); return getStateManager().ConstraintMgr->assumeInclusiveRange( this, Val.castAs(), From, To, Assumption); @@ -735,7 +735,7 @@ if (Val.isUnknown()) return std::make_pair(this, this); - assert(Val.getAs() && "Only NonLocs are supported!"); + assert(Val.isa() && "Only NonLocs are supported!"); return getStateManager().ConstraintMgr->assumeInclusiveRangeDual( this, Val.castAs(), From, To); diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h @@ -96,6 +96,8 @@ public: explicit SVal() = default; + template bool isa() const { return llvm::isa(*this); } + /// Convert to the specified SVal type, asserting that this SVal is of /// the desired type. template T castAs() const { return llvm::cast(*this); } @@ -313,9 +315,7 @@ return (const SymExpr *) Data; } - bool isExpression() const { - return !isa(getSymbol()); - } + bool isExpression() const { return !llvm::isa(getSymbol()); } static bool classof(SVal V) { return V.getBaseKind() == NonLocKind && V.getSubKind() == SymbolValKind; diff --git a/clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp b/clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp --- a/clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp @@ -180,10 +180,10 @@ // we are doing a load/store after the last valid offset. const MemRegion *MR = rawOffset.getRegion(); DefinedOrUnknownSVal Size = getDynamicExtent(state, MR, svalBuilder); - if (!Size.getAs()) + if (!Size.isa()) break; - if (Size.getAs()) { + if (Size.isa()) { std::pair simplifiedOffsets = getSimplifiedOffsets(rawOffset.getByteOffset(), Size.castAs(), svalBuilder); @@ -275,7 +275,7 @@ // is unknown or undefined, we lazily substitute '0'. Otherwise, // return 'val'. static inline SVal getValue(SVal val, SValBuilder &svalBuilder) { - return val.getAs() ? svalBuilder.makeArrayIndex(0) : val; + return val.isUndef() ? svalBuilder.makeArrayIndex(0) : val; } // Scale a base value by a scaling factor, and return the scaled @@ -324,7 +324,7 @@ case MemRegion::ElementRegionKind: { const ElementRegion *elemReg = cast(region); SVal index = elemReg->getIndex(); - if (!index.getAs()) + if (!index.isa()) return RegionRawOffsetV2(); QualType elemType = elemReg->getElementType(); // If the element is an incomplete type, go no further. diff --git a/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp b/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp --- a/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp @@ -758,7 +758,7 @@ continue; // Ignore pointer constants. - if (msg.getArgSVal(I).getAs()) + if (msg.getArgSVal(I).isa()) continue; // Ignore pointer types annotated with 'NSObject' attribute. diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -696,7 +696,7 @@ NonLoc maxVal = svalBuilder.makeIntVal(maxValInt); SVal maxMinusRight; - if (right.getAs()) { + if (right.isa()) { maxMinusRight = svalBuilder.evalBinOpNN(state, BO_Sub, maxVal, right, sizeTy); } else { @@ -1675,7 +1675,7 @@ // amountCopied = min (size - dstLen - 1 , srcLen) SVal freeSpace = svalBuilder.evalBinOpNN(state, BO_Sub, *lenValNL, *dstStrLengthNL, sizeTy); - if (!freeSpace.getAs()) + if (!freeSpace.isa()) return; freeSpace = svalBuilder.evalBinOp(state, BO_Sub, freeSpace, diff --git a/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp @@ -248,7 +248,7 @@ DefinedOrUnknownSVal location = l.castAs(); // Check for null dereferences. - if (!location.getAs()) + if (!location.isa()) return; ProgramStateRef state = C.getState(); diff --git a/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp @@ -135,7 +135,7 @@ SVal BooleanArgVal = Call->getArgSVal(0); if (IsRef) { // The argument is a reference, so load from it to get the boolean value. - if (!BooleanArgVal.getAs()) + if (!BooleanArgVal.isa()) return; BooleanArgVal = C.getState()->getSVal(BooleanArgVal.castAs()); } @@ -270,15 +270,14 @@ ProgramStateRef GTestChecker::assumeValuesEqual(SVal Val1, SVal Val2, ProgramStateRef State, CheckerContext &C) { - if (!Val1.getAs() || - !Val2.getAs()) + if (!Val1.isa() || !Val2.isa()) return State; auto ValuesEqual = C.getSValBuilder().evalEQ(State, Val1.castAs(), Val2.castAs()); - if (!ValuesEqual.getAs()) + if (!ValuesEqual.isa()) return State; State = C.getConstraintManager().assume( diff --git a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp @@ -866,7 +866,7 @@ return; const auto WouldEscape = [](SVal V, QualType Ty) -> bool { - if (!V.getAs()) + if (!V.isa()) return false; const bool IsNonConstRef = Ty->isReferenceType() && !Ty.isConstQualified(); diff --git a/clang/lib/StaticAnalyzer/Checkers/Iterator.cpp b/clang/lib/StaticAnalyzer/Checkers/Iterator.cpp --- a/clang/lib/StaticAnalyzer/Checkers/Iterator.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/Iterator.cpp @@ -308,8 +308,8 @@ const auto comparison = SVB.evalBinOp(State, Opc, NL1, NL2, SVB.getConditionType()); - assert(comparison.getAs() && - "Symbol comparison must be a `DefinedSVal`"); + assert(comparison.isa() && + "Symbol comparison must be a `DefinedSVal`"); return !State->assume(comparison.castAs(), false); } diff --git a/clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp --- a/clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp @@ -631,7 +631,7 @@ const Expr *Iterator, OverloadedOperatorKind OK, SVal Offset) const { - if (!Offset.getAs()) + if (!Offset.isa()) return; QualType PtrType = Iterator->getType(); @@ -801,8 +801,8 @@ SVB.evalBinOp(State, BO_EQ, nonloc::SymbolVal(Sym1), nonloc::SymbolVal(Sym2), SVB.getConditionType()); - assert(comparison.getAs() && - "Symbol comparison must be a `DefinedSVal`"); + assert(comparison.isa() && + "Symbol comparison must be a `DefinedSVal`"); auto NewState = State->assume(comparison.castAs(), Equal); if (!NewState) diff --git a/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp @@ -165,7 +165,7 @@ Ctx.getState(), SuperRegion, Ctx.getSValBuilder(), CE.getArgExpr(1)->getType()->getPointeeType()); const llvm::APSInt &ArrSize = - ElementCount.getAs()->getValue(); + ElementCount.castAs().getValue(); for (size_t i = 0; i < ArrSize; ++i) { const NonLoc Idx = Ctx.getSValBuilder().makeArrayIndex(i); diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -1187,7 +1187,7 @@ const Expr *FlagsEx = Call.getArgExpr(Call.getNumArgs() - 1); const SVal V = C.getSVal(FlagsEx); - if (!V.getAs()) { + if (!V.isa()) { // The case where 'V' can be a location can only be due to a bad header, // so in this case bail out. return None; @@ -1912,12 +1912,12 @@ return nullptr; SVal ArgVal = C.getSVal(ArgExpr); - if (!ArgVal.getAs()) + if (!ArgVal.isa()) return nullptr; DefinedOrUnknownSVal location = ArgVal.castAs(); // Check for null dereferences. - if (!location.getAs()) + if (!location.isa()) return nullptr; // The explicit NULL case, no operation is performed. @@ -2587,7 +2587,7 @@ const Expr *arg0Expr = CE->getArg(0); SVal Arg0Val = C.getSVal(arg0Expr); - if (!Arg0Val.getAs()) + if (!Arg0Val.isa()) return nullptr; DefinedOrUnknownSVal arg0Val = Arg0Val.castAs(); @@ -2603,7 +2603,7 @@ SVal TotalSize = C.getSVal(Arg1); if (SuffixWithN) TotalSize = evalMulForBufferSize(C, Arg1, CE->getArg(2)); - if (!TotalSize.getAs()) + if (!TotalSize.isa()) return nullptr; // Compare the size argument to 0. @@ -2913,7 +2913,7 @@ // Check arguments for being used after free. for (unsigned I = 0, E = Call.getNumArgs(); I != E; ++I) { SVal ArgSVal = Call.getArgSVal(I); - if (ArgSVal.getAs()) { + if (ArgSVal.isa()) { SymbolRef Sym = ArgSVal.getAsSymbol(); if (!Sym) continue; diff --git a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp @@ -214,7 +214,7 @@ CheckerContext &C) const { if (!isLoad) return; - if (loc.isUndef() || !loc.getAs()) + if (loc.isUndef() || !loc.isa()) return; ASTContext &Ctx = C.getASTContext(); diff --git a/clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp @@ -161,7 +161,7 @@ assert(++CSV->begin() == CSV->end()); // FIXME: Handle (some_union){ some_other_union_val }, which turns into // a LazyCompoundVal inside a CompoundVal. - if (!V.getAs()) + if (!V.isa()) continue; // Retrieve the corresponding expression. diff --git a/clang/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp @@ -41,7 +41,7 @@ SVal V = C.getSVal(Ex); // Uninitialized value used for the mutex? - if (V.getAs()) { + if (V.isUndef()) { if (ExplodedNode *N = C.generateErrorNode()) { if (!BT_undef) BT_undef.reset(new BuiltinBug(this, "Uninitialized value used as mutex " diff --git a/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp @@ -411,7 +411,7 @@ AnalysisDeclContext *analCtx = C.getCurrentAnalysisDeclContext(); if (!analCtx->getSelfDecl()) return false; - if (!location.getAs()) + if (!location.isa()) return false; loc::MemRegionVal MRV = location.castAs(); diff --git a/clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp --- a/clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp @@ -131,7 +131,7 @@ nonloc::SymbolVal(NewPos->getOffset()), nonloc::SymbolVal(Pos->getOffset()), SVB.getConditionType()); - assert(GreaterOrEqual.getAs() && + assert(GreaterOrEqual.isa() && "Symbol comparison must be a `DefinedSVal`"); StateFound = StateFound->assume(GreaterOrEqual.castAs(), true); } @@ -153,7 +153,7 @@ nonloc::SymbolVal(NewPos->getOffset()), nonloc::SymbolVal(Pos->getOffset()), SVB.getConditionType()); - assert(Less.getAs() && + assert(Less.isa() && "Symbol comparison must be a `DefinedSVal`"); StateFound = StateFound->assume(Less.castAs(), true); } diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -254,7 +254,7 @@ return State; DefinedOrUnknownSVal L = V.castAs(); - if (!L.getAs()) + if (!L.isa()) return State; return State->assume(L, CannotBeNull); diff --git a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp @@ -330,7 +330,7 @@ SVal V = State->getSVal(FieldVal); - if (isDereferencableType(T) || V.getAs()) { + if (isDereferencableType(T) || V.isa()) { if (isDereferencableUninit(FR, LocalChain)) ContainsUninitField = true; continue; diff --git a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp --- a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp @@ -141,10 +141,10 @@ SVal V = State->getSVal(FR); assert((isDereferencableType(FR->getDecl()->getType()) || - V.getAs()) && + V.isa()) && "This method only checks dereferenceable objects!"); - if (V.isUnknown() || V.getAs()) { + if (V.isUnknown() || V.isa()) { IsAnyFieldInitialized = true; return false; } @@ -230,8 +230,8 @@ // If the static type of the field is a void pointer, or it is a // nonloc::LocAsInteger, we need to cast it back to the dynamic type before // dereferencing. - bool NeedsCastBack = isVoidPointer(FR->getDecl()->getType()) || - V.getAs(); + bool NeedsCastBack = + isVoidPointer(FR->getDecl()->getType()) || V.isa(); // The region we'd like to acquire. const auto *R = V.getAsRegion()->getAs(); diff --git a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp @@ -229,7 +229,7 @@ // Now check if oflags has O_CREAT set. const Expr *oflagsEx = CE->getArg(FlagsArgIndex); const SVal V = C.getSVal(oflagsEx); - if (!V.getAs()) { + if (!V.isa()) { // The case where 'V' can be a location can only be due to a bad header, // so in this case bail out. return; diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -919,7 +919,7 @@ const SVal V) { AnalyzerOptions &Options = N->getState()->getAnalysisManager().options; if (EnableNullFPSuppression && Options.ShouldSuppressNullReturnPaths && - V.getAs()) + V.isa()) BR.addVisitor(R->getAs(), V); } @@ -1035,14 +1035,13 @@ if (RetE->isGLValue()) { if ((LValue = V.getAs())) { SVal RValue = State->getRawSVal(*LValue, RetE->getType()); - if (RValue.getAs()) + if (RValue.isa()) V = RValue; } } // Ignore aggregate rvalues. - if (V.getAs() || - V.getAs()) + if (V.isa()) return nullptr; RetE = RetE->IgnoreParenCasts(); @@ -1057,7 +1056,7 @@ bool WouldEventBeMeaningless = false; if (State->isNull(V).isConstrainedTrue()) { - if (V.getAs()) { + if (V.isa()) { // If we have counter-suppression enabled, make sure we keep visiting // future nodes. We want to emit a path note as well, in case @@ -1087,10 +1086,7 @@ if (N->getCFG().size() == 3) WouldEventBeMeaningless = true; - if (V.getAs()) - Out << "Returning pointer"; - else - Out << "Returning value"; + Out << (V.isa() ? "Returning pointer" : "Returning value"); } } @@ -1313,7 +1309,7 @@ llvm_unreachable("Unexpected store kind"); } - if (SI.Value.getAs()) { + if (SI.Value.isa()) { OS << Action << (isObjCPointer(SI.Dest) ? "nil" : "a null pointer value"); } else if (auto CVal = SI.Value.getAs()) { @@ -1356,7 +1352,7 @@ OS << "Passing "; - if (SI.Value.getAs()) { + if (SI.Value.isa()) { OS << (isObjCPointer(Param) ? "nil object reference" : "null pointer value"); @@ -1387,7 +1383,7 @@ StoreInfo SI) { const bool HasSuffix = SI.Dest->canPrintPretty(); - if (SI.Value.getAs()) { + if (SI.Value.isa()) { OS << (isObjCPointer(SI.Dest) ? "nil object reference stored" : (HasSuffix ? "Null pointer value stored" : "Storing null pointer value")); @@ -1685,7 +1681,7 @@ SmallString<64> sbuf; llvm::raw_svector_ostream os(sbuf); - if (Constraint.getAs()) { + if (Constraint.isa()) { os << "Assuming pointer value is "; os << (Assumption ? "non-null" : "null"); } diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp --- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -672,7 +672,7 @@ return UnknownVal(); SVal ThisVal = getSVal(Base); - assert(ThisVal.isUnknownOrUndef() || ThisVal.getAs()); + assert(ThisVal.isUnknownOrUndef() || ThisVal.isa()); return ThisVal; } diff --git a/clang/lib/StaticAnalyzer/Core/CheckerContext.cpp b/clang/lib/StaticAnalyzer/Core/CheckerContext.cpp --- a/clang/lib/StaticAnalyzer/Core/CheckerContext.cpp +++ b/clang/lib/StaticAnalyzer/Core/CheckerContext.cpp @@ -127,10 +127,10 @@ if (LHSVal.isUnknownOrUndef()) return false; ProgramStateManager &Mgr = State->getStateManager(); - if (!LHSVal.getAs()) { + if (!LHSVal.isa()) { LHSVal = Mgr.getStoreManager().getBinding(State->getStore(), LHSVal.castAs()); - if (LHSVal.isUnknownOrUndef() || !LHSVal.getAs()) + if (LHSVal.isUnknownOrUndef() || !LHSVal.isa()) return false; } diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -319,7 +319,7 @@ if (!Result) { // If we don't have an explicit result expression, we're in "if needed" // mode. Only create a region if the current value is a NonLoc. - if (!InitValWithAdjustments.getAs()) { + if (!InitValWithAdjustments.isa()) { if (OutRegionWithAdjustments) *OutRegionWithAdjustments = nullptr; return State; @@ -328,7 +328,7 @@ } else { // We need to create a region no matter what. Make sure we don't try to // stuff a Loc into a non-pointer temporary region. - assert(!InitValWithAdjustments.getAs() || + assert(!InitValWithAdjustments.isa() || Loc::isLocType(Result->getType()) || Result->getType()->isMemberPointerType()); } @@ -2348,7 +2348,7 @@ llvm_unreachable("No block with label."); } - if (V.getAs() || V.getAs()) { + if (V.isa()) { // Dispatch to the first target and mark it as a sink. //ExplodedNode* N = builder.generateNode(builder.begin(), state, true); // FIXME: add checker visit. @@ -2899,7 +2899,7 @@ // If the location is not a 'Loc', it will already be handled by // the checkers. There is nothing left to do. - if (!location.getAs()) { + if (!location.isa()) { const ProgramPoint L = PostStore(StoreE, LC, /*Loc*/nullptr, /*tag*/nullptr); ProgramStateRef state = Pred->getState(); @@ -2969,7 +2969,7 @@ SVal location, const ProgramPointTag *tag, QualType LoadTy) { - assert(!location.getAs() && "location cannot be a NonLoc."); + assert(!location.isa() && "location cannot be a NonLoc."); assert(NodeEx); assert(BoundEx); // Evaluate the location (checks for bad dereferences). @@ -3100,7 +3100,7 @@ for (const Expr *O : A->outputs()) { SVal X = state->getSVal(O, Pred->getLocationContext()); - assert(!X.getAs()); // Should be an Lval, or unknown, undef. + assert(!X.isa()); // Should be an Lval, or unknown, undef. if (Optional LV = X.getAs()) state = state->bindLoc(*LV, UnknownVal(), Pred->getLocationContext()); diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp --- a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -29,8 +29,7 @@ SVal Symbol, SVal Other, Expr* Expression, SValBuilder &svalBuilder, unsigned Count, const LocationContext *LCtx) { QualType Ty = Expression->getType(); - if (Other.getAs() && - Ty->isIntegralOrEnumerationType() && + if (Other.isa() && Ty->isIntegralOrEnumerationType() && Symbol.isUnknown()) { return svalBuilder.conjureSymbolVal(Expression, LCtx, Ty, Count); } @@ -371,7 +370,7 @@ case CK_IntegralToPointer: case CK_PointerToIntegral: { SVal V = state->getSVal(Ex, LCtx); - if (V.getAs()) { + if (V.isa()) { state = state->BindExpr(CastE, LCtx, UnknownVal()); Bldr.generateNode(CastE, Pred, state); continue; diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp --- a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -129,7 +129,7 @@ static SVal adjustReturnValue(SVal V, QualType ExpectedTy, QualType ActualTy, StoreManager &StoreMgr) { // For now, the only adjustments we handle apply only to locations. - if (!V.getAs()) + if (!V.isa()) return V; // If the types already match, don't do any unnecessary work. diff --git a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp --- a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp +++ b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -216,7 +216,7 @@ } ProgramStateRef ProgramState::killBinding(Loc LV) const { - assert(!LV.getAs() && "Use invalidateRegion instead."); + assert(!LV.isa() && "Use invalidateRegion instead."); Store OldStore = getStore(); const StoreRef &newStore = diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp --- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1397,10 +1397,10 @@ /// the array). This is called by ExprEngine when evaluating casts /// from arrays to pointers. SVal RegionStoreManager::ArrayToPointer(Loc Array, QualType T) { - if (Array.getAs()) + if (Array.isa()) return Array; - if (!Array.getAs()) + if (!Array.isa()) return UnknownVal(); const SubRegion *R = @@ -1413,20 +1413,18 @@ // Loading values from regions. //===----------------------------------------------------------------------===// -SVal RegionStoreManager::getBinding(RegionBindingsConstRef B, Loc L, QualType T) { - assert(!L.getAs() && "location unknown"); - assert(!L.getAs() && "location undefined"); - +SVal RegionStoreManager::getBinding(RegionBindingsConstRef B, Loc L, + QualType T) { // For access to concrete addresses, return UnknownVal. Checks // for null dereferences (and similar errors) are done by checkers, not // the Store. // FIXME: We can consider lazily symbolicating such memory, but we really // should defer this when we can reason easily about symbolicating arrays // of bytes. - if (L.getAs()) { + if (L.isa()) { return UnknownVal(); } - if (!L.getAs()) { + if (!L.isa()) { return UnknownVal(); } @@ -2030,8 +2028,7 @@ // Lazy bindings are usually handled through getExistingLazyBinding(). // We should unify these two code paths at some point. - if (val.getAs() || - val.getAs()) + if (val.isa()) return val; llvm_unreachable("Unknown default value"); @@ -2365,7 +2362,7 @@ RegionBindingsRef RegionStoreManager::bind(RegionBindingsConstRef B, Loc L, SVal V) { - if (L.getAs()) + if (L.isa()) return B; // If we get here, the location should be a region. @@ -2450,7 +2447,7 @@ } // Handle lazy compound values. - if (Init.getAs()) + if (Init.isa()) return bindAggregate(B, R, Init); if (Init.isUnknown()) @@ -2495,13 +2492,13 @@ const VectorType *VT = T->castAs(); // Use castAs for typedefs. // Handle lazy compound values and symbolic values. - if (V.getAs() || V.getAs()) + if (V.isa()) return bindAggregate(B, R, V); // We may get non-CompoundVal accidentally due to imprecise cast logic or // that we are binding symbolic struct value. Kill the field values, and if // the value is symbolic go and bind it as a "default" binding. - if (!V.getAs()) { + if (!V.isa()) { return bindAggregate(B, R, UnknownVal()); } @@ -2590,13 +2587,13 @@ return *NewB; return bindAggregate(B, R, V); } - if (V.getAs()) + if (V.isa()) return bindAggregate(B, R, V); // We may get non-CompoundVal accidentally due to imprecise cast logic or // that we are binding symbolic struct value. Kill the field values, and if // the value is symbolic go and bind it as a "default" binding. - if (V.isUnknown() || !V.getAs()) + if (V.isUnknown() || !V.isa()) return bindAggregate(B, R, UnknownVal()); // The raw CompoundVal is essentially a symbolic InitListExpr: an (immutable) diff --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp --- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp +++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp @@ -442,8 +442,8 @@ if (lhs.isUnknown() || rhs.isUnknown()) return UnknownVal(); - if (lhs.getAs() || - rhs.getAs()) { + if (lhs.isa() || + rhs.isa()) { return UnknownVal(); } diff --git a/clang/lib/StaticAnalyzer/Core/SVals.cpp b/clang/lib/StaticAnalyzer/Core/SVals.cpp --- a/clang/lib/StaticAnalyzer/Core/SVals.cpp +++ b/clang/lib/StaticAnalyzer/Core/SVals.cpp @@ -46,7 +46,7 @@ bool SVal::hasConjuredSymbol() const { if (Optional SV = getAs()) { SymbolRef sym = SV->getSymbol(); - if (isa(sym)) + if (llvm::isa(sym)) return true; } @@ -54,7 +54,7 @@ const MemRegion *R = RV->getRegion(); if (const auto *SR = dyn_cast(R)) { SymbolRef sym = SR->getSymbol(); - if (isa(sym)) + if (llvm::isa(sym)) return true; } } diff --git a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp --- a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp +++ b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp @@ -865,7 +865,7 @@ if (Optional Result = ResultVal.getAs()) return evalCast(*Result, resultTy, QualType{}); - assert(!ResultVal.getAs() && "Loc-Loc ops should not produce Locs"); + assert(!ResultVal.isa() && "Loc-Loc ops should not produce Locs"); return UnknownVal(); } @@ -873,7 +873,7 @@ // This must come after the test if the RHS is a symbol, which is used to // build constraints. The address of any non-symbolic region is guaranteed // to be non-NULL, as is any label. - assert(rhs.getAs() || rhs.getAs()); + assert((rhs.isa())); if (lhs.isZeroConstant()) { switch (op) { default: diff --git a/clang/lib/StaticAnalyzer/Core/Store.cpp b/clang/lib/StaticAnalyzer/Core/Store.cpp --- a/clang/lib/StaticAnalyzer/Core/Store.cpp +++ b/clang/lib/StaticAnalyzer/Core/Store.cpp @@ -459,10 +459,10 @@ // FIXME: For absolute pointer addresses, we just return that value back as // well, although in reality we should return the offset added to that // value. See also the similar FIXME in getLValueFieldOrIvar(). - if (Base.isUnknownOrUndef() || Base.getAs()) + if (Base.isUnknownOrUndef() || Base.isa()) return Base; - if (Base.getAs()) + if (Base.isa()) return UnknownVal(); const SubRegion *BaseRegion = @@ -488,7 +488,7 @@ SVal BaseIdx = ElemR->getIndex(); - if (!BaseIdx.getAs()) + if (!BaseIdx.isa()) return UnknownVal(); const llvm::APSInt &BaseIdxI = @@ -497,7 +497,7 @@ // Only allow non-integer offsets if the base region has no offset itself. // FIXME: This is a somewhat arbitrary restriction. We should be using // SValBuilder here to add the two offsets without checking their types. - if (!Offset.getAs()) { + if (!Offset.isa()) { if (isa(BaseRegion->StripCasts())) return UnknownVal();