diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp index 0cf7056a0783..21c4bbc60264 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -1006,12 +1006,9 @@ ProgramStateRef CStringChecker::InvalidateBuffer(CheckerContext &C, bool CStringChecker::SummarizeRegion(raw_ostream &os, ASTContext &Ctx, const MemRegion *MR) { - const TypedValueRegion *TVR = dyn_cast(MR); - switch (MR->getKind()) { case MemRegion::FunctionCodeRegionKind: { - const NamedDecl *FD = cast(MR)->getDecl(); - if (FD) + if (const auto *FD = cast(MR)->getDecl()) os << "the address of the function '" << *FD << '\''; else os << "the address of a function"; @@ -1025,16 +1022,20 @@ bool CStringChecker::SummarizeRegion(raw_ostream &os, ASTContext &Ctx, return true; case MemRegion::CXXThisRegionKind: case MemRegion::CXXTempObjectRegionKind: - os << "a C++ temp object of type " << TVR->getValueType().getAsString(); + os << "a C++ temp object of type " + << cast(MR)->getValueType().getAsString(); return true; case MemRegion::VarRegionKind: - os << "a variable of type" << TVR->getValueType().getAsString(); + os << "a variable of type" + << cast(MR)->getValueType().getAsString(); return true; case MemRegion::FieldRegionKind: - os << "a field of type " << TVR->getValueType().getAsString(); + os << "a field of type " + << cast(MR)->getValueType().getAsString(); return true; case MemRegion::ObjCIvarRegionKind: - os << "an instance variable of type " << TVR->getValueType().getAsString(); + os << "an instance variable of type " + << cast(MR)->getValueType().getAsString(); return true; default: return false;