diff --git a/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp @@ -93,11 +93,10 @@ if (!Loc.isValid()) return; - if (isa(D) || isa(D)) { + if (isa(D)) { const NamedDecl *ND = cast(D); output << *ND; - } - else if (isa(D)) { + } else if (isa(D)) { output << "block(line:" << Loc.getLine() << ":col:" << Loc.getColumn(); } diff --git a/clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp @@ -160,7 +160,7 @@ E = E->IgnoreParenCasts(); if (const DeclRefExpr *DRE = dyn_cast(E)) { const ValueDecl *VD = DRE->getDecl(); - if (isa(VD) || isa(VD)) + if (isa(VD)) return true; } return false; @@ -199,8 +199,7 @@ static bool isBadDeallocationArgument(const MemRegion *Arg) { if (!Arg) return false; - return isa(Arg) || isa(Arg) || - isa(Arg); + return isa(Arg); } /// Given the address expression, retrieve the value it's pointing to. Assume 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 @@ -936,7 +936,7 @@ /// Did not track -> allocated. Other state (released) -> allocated. static inline bool isAllocated(const RefState *RSCurr, const RefState *RSPrev, const Stmt *Stmt) { - return (Stmt && (isa(Stmt) || isa(Stmt)) && + return (isa_and_nonnull(Stmt) && (RSCurr && (RSCurr->isAllocated() || RSCurr->isAllocatedOfSizeZero())) && (!RSPrev || @@ -949,8 +949,7 @@ const Stmt *Stmt) { bool IsReleased = (RSCurr && RSCurr->isReleased()) && (!RSPrev || !RSPrev->isReleased()); - assert(!IsReleased || - (Stmt && (isa(Stmt) || isa(Stmt))) || + assert(!IsReleased || (isa_and_nonnull(Stmt)) || (!Stmt && RSCurr->getAllocationFamily() == AF_InnerBuffer)); return IsReleased; } @@ -958,11 +957,10 @@ /// Did not track -> relinquished. Other state (allocated) -> relinquished. static inline bool isRelinquished(const RefState *RSCurr, const RefState *RSPrev, const Stmt *Stmt) { - return (Stmt && - (isa(Stmt) || isa(Stmt) || - isa(Stmt)) && - (RSCurr && RSCurr->isRelinquished()) && - (!RSPrev || !RSPrev->isRelinquished())); + return ( + isa_and_nonnull(Stmt) && + (RSCurr && RSCurr->isRelinquished()) && + (!RSPrev || !RSPrev->isRelinquished())); } /// If the expression is not a call, and the state change is @@ -972,7 +970,7 @@ static inline bool hasReallocFailed(const RefState *RSCurr, const RefState *RSPrev, const Stmt *Stmt) { - return ((!Stmt || !isa(Stmt)) && + return ((!isa_and_nonnull(Stmt)) && (RSCurr && (RSCurr->isAllocated() || RSCurr->isAllocatedOfSizeZero())) && (RSPrev && @@ -1921,7 +1919,7 @@ // Parameters, locals, statics, globals, and memory returned by // __builtin_alloca() shouldn't be freed. - if (!(isa(MS) || isa(MS))) { + if (!isa(MS)) { // FIXME: at the time this code was written, malloc() regions were // represented by conjured symbols, which are all in UnknownSpaceRegion. // This means that there isn't actually anything from HeapSpaceRegion @@ -2904,7 +2902,7 @@ // the callee could still free the memory. // TODO: This logic should be a part of generic symbol escape callback. if (const MemRegion *MR = RetVal.getAsRegion()) - if (isa(MR) || isa(MR)) + if (isa(MR)) if (const SymbolicRegion *BMR = dyn_cast(MR->getBaseRegion())) Sym = BMR->getSymbol(); @@ -3087,7 +3085,7 @@ // TODO: If we want to be more optimistic here, we'll need to make sure that // regions escape to C++ containers. They seem to do that even now, but for // mysterious reasons. - if (!(isa(Call) || isa(Call))) + if (!isa(Call)) return true; // Check Objective-C messages by selector name. diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp @@ -102,8 +102,7 @@ e = rhs; } else return; - } - else if (isa(e) || isa(e)) + } else if (isa(e)) break; else return; diff --git a/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp @@ -553,8 +553,8 @@ // For the purposes of this checker, we classify move-safe STL types // as not-"STL" types, because that's how the checker treats them. MR = unwrapRValueReferenceIndirection(MR); - bool IsLocal = - MR && isa(MR) && isa(MR->getMemorySpace()); + bool IsLocal = isa_and_nonnull(MR) && + isa(MR->getMemorySpace()); if (!RD || !RD->getDeclContext()->isStdNamespace()) return { IsLocal, SK_NonStd }; diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp --- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp @@ -73,11 +73,8 @@ static bool isNumericLiteralExpression(const Expr *E) { // FIXME: This set of cases was copied from SemaExprObjC. - return isa(E) || - isa(E) || - isa(E) || - isa(E) || - isa(E); + return isa(E); } /// If type represents a pointer to CXXRecordDecl, 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 @@ -110,7 +110,7 @@ // Don't treat functions in namespaces with the same name a Unix function // as a call to the Unix function. const DeclContext *NamespaceCtx = FD->getEnclosingNamespaceContext(); - if (NamespaceCtx && isa(NamespaceCtx)) + if (isa_and_nonnull(NamespaceCtx)) return; StringRef FName = C.getCalleeName(FD); @@ -466,7 +466,7 @@ // Don't treat functions in namespaces with the same name a Unix function // as a call to the Unix function. const DeclContext *NamespaceCtx = FD->getEnclosingNamespaceContext(); - if (NamespaceCtx && isa(NamespaceCtx)) + if (isa_and_nonnull(NamespaceCtx)) return; StringRef FName = C.getCalleeName(FD); diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -537,10 +537,10 @@ if (auto *CF = dyn_cast(I->get())) { const Stmt *Start = CF->getStartLocation().asStmt(); const Stmt *End = CF->getEndLocation().asStmt(); - if (Start && isa(Start)) { + if (isa_and_nonnull(Start)) { I = Pieces.erase(I); continue; - } else if (End && isa(End)) { + } else if (isa_and_nonnull(End)) { PathPieces::iterator Next = std::next(I); if (Next != E) { if (auto *NextCF = @@ -1314,8 +1314,7 @@ C.getActivePath().push_front(std::move(PE)); } } - } else if (isa(Term) || isa(Term) || - isa(Term)) { + } else if (isa(Term)) { PathDiagnosticLocation L(Term, SM, C.getCurrLocationContext()); addEdgeToPath(C.getActivePath(), PrevLoc, L); } @@ -1354,9 +1353,7 @@ if (!S) break; - if (isa(S) || - isa(S) || - isa(S)) + if (isa(S)) continue; break; @@ -1552,9 +1549,8 @@ // We only perform this transformation for specific branch kinds. // We don't want to do this for do..while, for example. - if (!(isa(s1Start) || isa(s1Start) || - isa(s1Start) || isa(s1Start) || - isa(s1Start))) + if (!isa(s1Start)) continue; // Is s1End the branch condition? @@ -3193,7 +3189,7 @@ P = N->getParentMap().getParent(RS); } - if (P && (isa(P) || isa(P))) + if (isa_and_nonnull(P)) populateExecutedLinesWithStmt(P, SM, *ExecutedLines); } 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 @@ -815,7 +815,7 @@ // Just keep going up to the base region. // Element regions may appear due to casts. - if (isa(R) || isa(R)) + if (isa(R)) continue; if (Sep.empty()) @@ -2735,9 +2735,8 @@ const Expr *OriginalExpr = Ex; Ex = Ex->IgnoreParenCasts(); - if (isa(Ex) || isa(Ex) || - isa(Ex) || isa(Ex) || - isa(Ex)) { + if (isa(Ex)) { // Use heuristics to determine if the expression is a macro // expanding to a literal and if so, use the macro's name. SourceLocation BeginLoc = OriginalExpr->getBeginLoc(); 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 @@ -425,9 +425,7 @@ } bool CallEvent::isCallStmt(const Stmt *S) { - return isa(S) || isa(S) - || isa(S) - || isa(S); + return isa(S); } QualType CallEvent::getDeclaredResultType(const Decl *D) { 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 @@ -38,7 +38,7 @@ } StringRef CheckerContext::getDeclDescription(const Decl *D) { - if (isa(D) || isa(D)) + if (isa(D)) return "method"; if (isa(D)) return "anonymous block"; diff --git a/clang/lib/StaticAnalyzer/Core/Environment.cpp b/clang/lib/StaticAnalyzer/Core/Environment.cpp --- a/clang/lib/StaticAnalyzer/Core/Environment.cpp +++ b/clang/lib/StaticAnalyzer/Core/Environment.cpp @@ -88,7 +88,7 @@ const Stmt *S = Entry.getStmt(); assert(!isa(S) && "Use ExprEngine::hasMoreIteration()!"); - assert((isa(S) || isa(S)) && + assert((isa(S)) && "Environment can only argue about Exprs, since only they express " "a value! Any non-expression statement stored in Environment is a " "result of a hack!"); diff --git a/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp b/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp --- a/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp @@ -50,8 +50,7 @@ bool ExplodedGraph::isInterestingLValueExpr(const Expr *Ex) { if (!Ex->isLValue()) return false; - return isa(Ex) || isa(Ex) || - isa(Ex) || isa(Ex); + return isa(Ex); } bool ExplodedGraph::shouldCollect(const ExplodedNode *node) { 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 @@ -1989,8 +1989,7 @@ if (BlockCount == AMgr.options.maxBlockVisitOnPath - 1 && AMgr.options.ShouldWidenLoops) { const Stmt *Term = nodeBuilder.getContext().getBlock()->getTerminatorStmt(); - if (!(Term && - (isa(Term) || isa(Term) || isa(Term)))) + if (!isa_and_nonnull(Term)) return; // Widen. const LocationContext *LCtx = Pred->getLocationContext(); @@ -2266,7 +2265,7 @@ continue; } if (StTrue && StFalse) - assert(!isa(Condition));; + assert(!isa(Condition)); // Process the true branch. if (builder.isFeasible(true)) { @@ -2594,7 +2593,7 @@ ProgramPoint::PostLValueKind); return; } - if (isa(D) || isa(D)) { + if (isa(D)) { // Delegate all work related to pointer to members to the surrounding // operator&. return; @@ -2671,7 +2670,7 @@ // Handle static member variables and enum constants accessed via // member syntax. - if (isa(Member) || isa(Member)) { + if (isa(Member)) { for (const auto I : CheckedSet) VisitCommonDeclRefExpr(M, Member, I, EvalSet); } else { 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 @@ -550,7 +550,7 @@ const Expr *Init = CL->getInitializer(); SVal V = State->getSVal(CL->getInitializer(), LCtx); - if (isa(Init) || isa(Init)) { + if (isa(Init)) { // No work needed. Just pass the value up to this expression. } else { assert(isa(Init)); @@ -984,8 +984,7 @@ if (const DeclRefExpr *DRE = dyn_cast(Ex)) { const ValueDecl *VD = DRE->getDecl(); - if (isa(VD) || isa(VD) || - isa(VD)) { + if (isa(VD)) { ProgramStateRef State = (*I)->getState(); const LocationContext *LCtx = (*I)->getLocationContext(); SVal SV = svalBuilder.getMemberPointer(cast(VD)); diff --git a/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp b/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp --- a/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp +++ b/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp @@ -69,7 +69,7 @@ namespace ento { static bool isLoopStmt(const Stmt *S) { - return S && (isa(S) || isa(S) || isa(S)); + return isa_and_nonnull(S); } ProgramStateRef processLoopEnd(const Stmt *LoopStmt, ProgramStateRef State) { diff --git a/clang/lib/StaticAnalyzer/Core/LoopWidening.cpp b/clang/lib/StaticAnalyzer/Core/LoopWidening.cpp --- a/clang/lib/StaticAnalyzer/Core/LoopWidening.cpp +++ b/clang/lib/StaticAnalyzer/Core/LoopWidening.cpp @@ -45,8 +45,7 @@ const LocationContext *LCtx, unsigned BlockCount, const Stmt *LoopStmt) { - assert(isa(LoopStmt) || isa(LoopStmt) || - isa(LoopStmt)); + assert((isa(LoopStmt))); // Invalidate values in the current state. // TODO Make this more conservative by only invalidating values that might diff --git a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp --- a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp +++ b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp @@ -1012,14 +1012,15 @@ sReg = getUnknownRegion(); } else { if (D->hasLocalStorage()) { - sReg = isa(D) || isa(D) - ? static_cast(getStackArgumentsRegion(STC)) - : static_cast(getStackLocalsRegion(STC)); + sReg = + isa(D) + ? static_cast(getStackArgumentsRegion(STC)) + : static_cast(getStackLocalsRegion(STC)); } else { assert(D->isStaticLocal()); const Decl *STCD = STC->getDecl(); - if (isa(STCD) || isa(STCD)) + if (isa(STCD)) sReg = getGlobalsRegion(MemRegion::StaticGlobalSpaceRegionKind, getFunctionCodeRegion(cast(STCD))); else if (const auto *BD = dyn_cast(STCD)) { @@ -1283,9 +1284,7 @@ } bool MemRegion::hasGlobalsOrParametersStorage() const { - const MemSpaceRegion *MS = getMemorySpace(); - return isa(MS) || - isa(MS); + return isa(getMemorySpace()); } // getBaseRegion strips away all elements and fields, and get the base region 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 @@ -62,8 +62,8 @@ : P(r, k), Data(offset) { assert(r && "Must have known regions."); assert(getOffset() == offset && "Failed to store offset"); - assert((r == r->getBaseRegion() || isa(r) || - isa (r)) && + assert((r == r->getBaseRegion() || + isa(r)) && "Not a base"); } public: @@ -1135,7 +1135,7 @@ if (Regions) Regions->push_back(baseR); - if (isa(baseR) || isa(baseR)) { + if (isa(baseR)) { // Invalidate the region by setting its default value to // conjured symbol. The type of the symbol is irrelevant. DefinedOrUnknownSVal V = @@ -1224,7 +1224,7 @@ // detection. SVal V = I.getData(); const MemRegion *R = V.getAsRegion(); - if (R && isa(R)) + if (isa_and_nonnull(R)) VisitBinding(V); } } 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 @@ -254,8 +254,7 @@ } DefinedSVal SValBuilder::getMemberPointer(const NamedDecl *ND) { - assert(!ND || isa(ND) || isa(ND) || - isa(ND)); + assert(!ND || (isa(ND))); if (const auto *MD = dyn_cast_or_null(ND)) { // Sema treats pointers to static member functions as have function pointer 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 @@ -84,7 +84,7 @@ // involved. Blocks can be casted to/from 'id', as they can be treated // as Objective-C objects. This could possibly be handled by enhancing // our reasoning of downcasts of symbolic objects. - if (isa(R) || isa(R)) + if (isa(R)) return R; // We don't know what to make of it. Return a NULL region, which diff --git a/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp b/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp --- a/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp @@ -425,19 +425,7 @@ // tell if anything still refers to this region. Unlike SymbolicRegions, // AllocaRegions don't have associated symbols, though, so we don't actually // have a way to track their liveness. - if (isa(MR)) - return true; - - if (isa(MR)) - return true; - - if (isa(MR)) - return true; - - if (isa(MR)) - return true; - - return false; + return isa(MR); } bool SymbolReaper::isLive(SymbolRef sym) {