This revision was automatically updated to reflect the committed changes. Closed by commit rGcf1f1b7240a3: [analyzer][NFC] Uplift checkers after D126801 (authored by steakhal).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D126802/new/ https://reviews.llvm.org/D126802 Files: clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp Index: clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp @@ -101,7 +101,7 @@ /// 'self' contains. This keeps the "self flags" assigned to the 'self' /// object before the call so we can assign them to the new object that 'self' /// points to after the call. -REGISTER_TRAIT_WITH_PROGRAMSTATE(PreCallSelfFlags, unsigned) +REGISTER_TRAIT_WITH_PROGRAMSTATE(PreCallSelfFlags, SelfFlagEnum) static SelfFlagEnum getSelfFlags(SVal val, ProgramStateRef state) { if (SymbolRef sym = val.getAsSymbol()) @@ -251,11 +251,12 @@ for (unsigned i = 0; i < NumArgs; ++i) { SVal argV = CE.getArgSVal(i); if (isSelfVar(argV, C)) { - unsigned selfFlags = getSelfFlags(state->getSVal(argV.castAs<Loc>()), C); + SelfFlagEnum selfFlags = + getSelfFlags(state->getSVal(argV.castAs<Loc>()), C); C.addTransition(state->set<PreCallSelfFlags>(selfFlags)); return; } else if (hasSelfFlag(argV, SelfFlag_Self, C)) { - unsigned selfFlags = getSelfFlags(argV, C); + SelfFlagEnum selfFlags = getSelfFlags(argV, C); C.addTransition(state->set<PreCallSelfFlags>(selfFlags)); return; } Index: clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp @@ -68,13 +68,7 @@ /// Store a MemRegion that contains the 'errno' integer value. /// The value is null if the 'errno' value was not recognized in the AST. -REGISTER_TRAIT_WITH_PROGRAMSTATE(ErrnoRegion, const void *) - -/// An internal function accessing the errno region. -/// Returns null if there isn't any associated memory region. -static const MemRegion *getErrnoRegion(ProgramStateRef State) { - return reinterpret_cast<const MemRegion *>(State->get<ErrnoRegion>()); -} +REGISTER_TRAIT_WITH_PROGRAMSTATE(ErrnoRegion, const MemRegion *) /// Search for a variable called "errno" in the AST. /// Return nullptr if not found. @@ -185,7 +179,7 @@ if (ErrnoLocationCalls.contains(Call)) { ProgramStateRef State = C.getState(); - const MemRegion *ErrnoR = getErrnoRegion(State); + const MemRegion *ErrnoR = State->get<ErrnoRegion>(); if (!ErrnoR) return false; @@ -201,7 +195,7 @@ void ErrnoModeling::checkLiveSymbols(ProgramStateRef State, SymbolReaper &SR) const { // The special errno region should never garbage collected. - if (const auto *ErrnoR = getErrnoRegion(State)) + if (const MemRegion *ErrnoR = State->get<ErrnoRegion>()) SR.markLive(ErrnoR); } @@ -210,7 +204,7 @@ namespace errno_modeling { Optional<SVal> getErrnoValue(ProgramStateRef State) { - const MemRegion *ErrnoR = getErrnoRegion(State); + const MemRegion *ErrnoR = State->get<ErrnoRegion>(); if (!ErrnoR) return {}; QualType IntTy = State->getAnalysisManager().getASTContext().IntTy; @@ -219,7 +213,7 @@ ProgramStateRef setErrnoValue(ProgramStateRef State, const LocationContext *LCtx, SVal Value) { - const MemRegion *ErrnoR = getErrnoRegion(State); + const MemRegion *ErrnoR = State->get<ErrnoRegion>(); if (!ErrnoR) return State; return State->bindLoc(loc::MemRegionVal{ErrnoR}, Value, LCtx); @@ -227,7 +221,7 @@ ProgramStateRef setErrnoValue(ProgramStateRef State, CheckerContext &C, uint64_t Value) { - const MemRegion *ErrnoR = getErrnoRegion(State); + const MemRegion *ErrnoR = State->get<ErrnoRegion>(); if (!ErrnoR) return State; return State->bindLoc(
Index: clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp @@ -101,7 +101,7 @@ /// 'self' contains. This keeps the "self flags" assigned to the 'self' /// object before the call so we can assign them to the new object that 'self' /// points to after the call. -REGISTER_TRAIT_WITH_PROGRAMSTATE(PreCallSelfFlags, unsigned) +REGISTER_TRAIT_WITH_PROGRAMSTATE(PreCallSelfFlags, SelfFlagEnum) static SelfFlagEnum getSelfFlags(SVal val, ProgramStateRef state) { if (SymbolRef sym = val.getAsSymbol()) @@ -251,11 +251,12 @@ for (unsigned i = 0; i < NumArgs; ++i) { SVal argV = CE.getArgSVal(i); if (isSelfVar(argV, C)) { - unsigned selfFlags = getSelfFlags(state->getSVal(argV.castAs<Loc>()), C); + SelfFlagEnum selfFlags = + getSelfFlags(state->getSVal(argV.castAs<Loc>()), C); C.addTransition(state->set<PreCallSelfFlags>(selfFlags)); return; } else if (hasSelfFlag(argV, SelfFlag_Self, C)) { - unsigned selfFlags = getSelfFlags(argV, C); + SelfFlagEnum selfFlags = getSelfFlags(argV, C); C.addTransition(state->set<PreCallSelfFlags>(selfFlags)); return; } Index: clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp @@ -68,13 +68,7 @@ /// Store a MemRegion that contains the 'errno' integer value. /// The value is null if the 'errno' value was not recognized in the AST. -REGISTER_TRAIT_WITH_PROGRAMSTATE(ErrnoRegion, const void *) - -/// An internal function accessing the errno region. -/// Returns null if there isn't any associated memory region. -static const MemRegion *getErrnoRegion(ProgramStateRef State) { - return reinterpret_cast<const MemRegion *>(State->get<ErrnoRegion>()); -} +REGISTER_TRAIT_WITH_PROGRAMSTATE(ErrnoRegion, const MemRegion *) /// Search for a variable called "errno" in the AST. /// Return nullptr if not found. @@ -185,7 +179,7 @@ if (ErrnoLocationCalls.contains(Call)) { ProgramStateRef State = C.getState(); - const MemRegion *ErrnoR = getErrnoRegion(State); + const MemRegion *ErrnoR = State->get<ErrnoRegion>(); if (!ErrnoR) return false; @@ -201,7 +195,7 @@ void ErrnoModeling::checkLiveSymbols(ProgramStateRef State, SymbolReaper &SR) const { // The special errno region should never garbage collected. - if (const auto *ErrnoR = getErrnoRegion(State)) + if (const MemRegion *ErrnoR = State->get<ErrnoRegion>()) SR.markLive(ErrnoR); } @@ -210,7 +204,7 @@ namespace errno_modeling { Optional<SVal> getErrnoValue(ProgramStateRef State) { - const MemRegion *ErrnoR = getErrnoRegion(State); + const MemRegion *ErrnoR = State->get<ErrnoRegion>(); if (!ErrnoR) return {}; QualType IntTy = State->getAnalysisManager().getASTContext().IntTy; @@ -219,7 +213,7 @@ ProgramStateRef setErrnoValue(ProgramStateRef State, const LocationContext *LCtx, SVal Value) { - const MemRegion *ErrnoR = getErrnoRegion(State); + const MemRegion *ErrnoR = State->get<ErrnoRegion>(); if (!ErrnoR) return State; return State->bindLoc(loc::MemRegionVal{ErrnoR}, Value, LCtx); @@ -227,7 +221,7 @@ ProgramStateRef setErrnoValue(ProgramStateRef State, CheckerContext &C, uint64_t Value) { - const MemRegion *ErrnoR = getErrnoRegion(State); + const MemRegion *ErrnoR = State->get<ErrnoRegion>(); if (!ErrnoR) return State; return State->bindLoc(
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits