Author: dergachev Date: Wed Aug 28 14:19:58 2019 New Revision: 370263 URL: http://llvm.org/viewvc/llvm-project?rev=370263&view=rev Log: [analyzer] Fix more analyzer warnings on analyzer and libAnalysis.
Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp cfe/trunk/lib/Analysis/CFG.cpp cfe/trunk/lib/Analysis/CocoaConventions.cpp cfe/trunk/lib/Analysis/RetainSummaryManager.cpp Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=370263&r1=370262&r2=370263&view=diff ============================================================================== --- cfe/trunk/lib/Analysis/BodyFarm.cpp (original) +++ cfe/trunk/lib/Analysis/BodyFarm.cpp Wed Aug 28 14:19:58 2019 @@ -408,8 +408,8 @@ static Stmt *create_call_once(ASTContext // reference. for (unsigned int ParamIdx = 2; ParamIdx < D->getNumParams(); ParamIdx++) { const ParmVarDecl *PDecl = D->getParamDecl(ParamIdx); - if (PDecl && - CallbackFunctionType->getParamType(ParamIdx - 2) + assert(PDecl); + if (CallbackFunctionType->getParamType(ParamIdx - 2) .getNonReferenceType() .getCanonicalType() != PDecl->getType().getNonReferenceType().getCanonicalType()) { Modified: cfe/trunk/lib/Analysis/CFG.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=370263&r1=370262&r2=370263&view=diff ============================================================================== --- cfe/trunk/lib/Analysis/CFG.cpp (original) +++ cfe/trunk/lib/Analysis/CFG.cpp Wed Aug 28 14:19:58 2019 @@ -2480,10 +2480,8 @@ CFGBlock *CFGBuilder::VisitBreakStmt(Bre static bool CanThrow(Expr *E, ASTContext &Ctx) { QualType Ty = E->getType(); - if (Ty->isFunctionPointerType()) - Ty = Ty->getAs<PointerType>()->getPointeeType(); - else if (Ty->isBlockPointerType()) - Ty = Ty->getAs<BlockPointerType>()->getPointeeType(); + if (Ty->isFunctionPointerType() || Ty->isBlockPointerType()) + Ty = Ty->getPointeeType(); const FunctionType *FT = Ty->getAs<FunctionType>(); if (FT) { @@ -4906,9 +4904,13 @@ CFGImplicitDtor::getDestructorDecl(ASTCo while (const ArrayType *arrayType = astContext.getAsArrayType(ty)) { ty = arrayType->getElementType(); } - const RecordType *recordType = ty->getAs<RecordType>(); - const CXXRecordDecl *classDecl = - cast<CXXRecordDecl>(recordType->getDecl()); + + // The situation when the type of the lifetime-extending reference + // does not correspond to the type of the object is supposed + // to be handled by now. In particular, 'ty' is now the unwrapped + // record type. + const CXXRecordDecl *classDecl = ty->getAsCXXRecordDecl(); + assert(classDecl); return classDecl->getDestructor(); } case CFGElement::DeleteDtor: { @@ -4933,12 +4935,6 @@ CFGImplicitDtor::getDestructorDecl(ASTCo llvm_unreachable("getKind() returned bogus value"); } -bool CFGImplicitDtor::isNoReturn(ASTContext &astContext) const { - if (const CXXDestructorDecl *DD = getDestructorDecl(astContext)) - return DD->isNoReturn(); - return false; -} - //===----------------------------------------------------------------------===// // CFGBlock operations. //===----------------------------------------------------------------------===// Modified: cfe/trunk/lib/Analysis/CocoaConventions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CocoaConventions.cpp?rev=370263&r1=370262&r2=370263&view=diff ============================================================================== --- cfe/trunk/lib/Analysis/CocoaConventions.cpp (original) +++ cfe/trunk/lib/Analysis/CocoaConventions.cpp Wed Aug 28 14:19:58 2019 @@ -38,8 +38,8 @@ bool cocoa::isRefType(QualType RetTy, St return false; // Is the type void*? - const PointerType* PT = RetTy->getAs<PointerType>(); - if (!(PT->getPointeeType().getUnqualifiedType()->isVoidType())) + const PointerType* PT = RetTy->castAs<PointerType>(); + if (!PT || !PT->getPointeeType().getUnqualifiedType()->isVoidType()) return false; // Does the name start with the prefix? Modified: cfe/trunk/lib/Analysis/RetainSummaryManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RetainSummaryManager.cpp?rev=370263&r1=370262&r2=370263&view=diff ============================================================================== --- cfe/trunk/lib/Analysis/RetainSummaryManager.cpp (original) +++ cfe/trunk/lib/Analysis/RetainSummaryManager.cpp Wed Aug 28 14:19:58 2019 @@ -504,7 +504,7 @@ RetainSummaryManager::generateSummary(co FName = FName.substr(FName.find_first_not_of('_')); // Inspect the result type. Strip away any typedefs. - const auto *FT = FD->getType()->getAs<FunctionType>(); + const auto *FT = FD->getType()->castAs<FunctionType>(); QualType RetTy = FT->getReturnType(); if (TrackOSObjects) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits