summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Analysis/BodyFarm.cpp4
-rw-r--r--clang/lib/Analysis/CFG.cpp22
-rw-r--r--clang/lib/Analysis/CocoaConventions.cpp4
-rw-r--r--clang/lib/Analysis/RetainSummaryManager.cpp2
4 files changed, 14 insertions, 18 deletions
diff --git a/clang/lib/Analysis/BodyFarm.cpp b/clang/lib/Analysis/BodyFarm.cpp
index 576f8651601..43f9e715b3d 100644
--- a/clang/lib/Analysis/BodyFarm.cpp
+++ b/clang/lib/Analysis/BodyFarm.cpp
@@ -408,8 +408,8 @@ static Stmt *create_call_once(ASTContext &C, const FunctionDecl *D) {
// 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()) {
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 33c47b24a9a..e4ed0f86b91 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -2480,10 +2480,8 @@ CFGBlock *CFGBuilder::VisitBreakStmt(BreakStmt *B) {
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(ASTContext &astContext) const {
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(ASTContext &astContext) const {
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.
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/Analysis/CocoaConventions.cpp b/clang/lib/Analysis/CocoaConventions.cpp
index b2ef426dead..571d72e1a84 100644
--- a/clang/lib/Analysis/CocoaConventions.cpp
+++ b/clang/lib/Analysis/CocoaConventions.cpp
@@ -38,8 +38,8 @@ bool cocoa::isRefType(QualType RetTy, StringRef Prefix,
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?
diff --git a/clang/lib/Analysis/RetainSummaryManager.cpp b/clang/lib/Analysis/RetainSummaryManager.cpp
index 132053fd2c2..6f46917b2df 100644
--- a/clang/lib/Analysis/RetainSummaryManager.cpp
+++ b/clang/lib/Analysis/RetainSummaryManager.cpp
@@ -504,7 +504,7 @@ RetainSummaryManager::generateSummary(const FunctionDecl *FD,
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)
OpenPOWER on IntegriCloud