summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-03-03 01:21:32 +0000
committerTed Kremenek <kremenek@apple.com>2011-03-03 01:21:32 +0000
commit8cfe207861b4f7c529861bc309e8aa90776e20f6 (patch)
treee24637f65537cc697d041e21f42532d29d0911e6 /clang/lib
parent1676a042e30b62c09f5493929e8130170e6a3fcd (diff)
downloadbcm5719-llvm-8cfe207861b4f7c529861bc309e8aa90776e20f6.tar.gz
bcm5719-llvm-8cfe207861b4f7c529861bc309e8aa90776e20f6.zip
Teach CFGImplicitDtor::getDestructorDecl() about arrays of objects with destructors.
llvm-svn: 126910
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Analysis/CFG.cpp10
-rw-r--r--clang/lib/Sema/AnalysisBasedWarnings.cpp2
2 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index fc50071a32c..6d8d5c53f60 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -2772,7 +2772,8 @@ CFG* CFG::buildCFG(const Decl *D, Stmt* Statement, ASTContext *C,
return Builder.buildCFG(D, Statement, C, BO);
}
-const CXXDestructorDecl *CFGImplicitDtor::getDestructorDecl() const {
+const CXXDestructorDecl *
+CFGImplicitDtor::getDestructorDecl(ASTContext &astContext) const {
switch (getKind()) {
case CFGElement::Invalid:
case CFGElement::Statement:
@@ -2783,6 +2784,9 @@ const CXXDestructorDecl *CFGImplicitDtor::getDestructorDecl() const {
const VarDecl *var = cast<CFGAutomaticObjDtor>(this)->getVarDecl();
QualType ty = var->getType();
ty = ty.getNonReferenceType();
+ if (const ArrayType *arrayType = astContext.getAsArrayType(ty)) {
+ ty = arrayType->getElementType();
+ }
const RecordType *recordType = ty->getAs<RecordType>();
const CXXRecordDecl *classDecl =
cast<CXXRecordDecl>(recordType->getDecl());
@@ -2804,8 +2808,8 @@ const CXXDestructorDecl *CFGImplicitDtor::getDestructorDecl() const {
return 0;
}
-bool CFGImplicitDtor::isNoReturn() const {
- if (const CXXDestructorDecl *cdecl = getDestructorDecl()) {
+bool CFGImplicitDtor::isNoReturn(ASTContext &astContext) const {
+ if (const CXXDestructorDecl *cdecl = getDestructorDecl(astContext)) {
QualType ty = cdecl->getType();
return cast<FunctionType>(ty)->getNoReturnAttr();
}
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 84efbd50d1a..710f5ef70fc 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -137,7 +137,7 @@ static ControlFlowKind CheckFallThrough(AnalysisContext &AC) {
// FIXME: The right solution is to just sever the edges in the
// CFG itself.
if (const CFGImplicitDtor *iDtor = ri->getAs<CFGImplicitDtor>())
- if (iDtor->isNoReturn()) {
+ if (iDtor->isNoReturn(AC.getASTContext())) {
hasNoReturnDtor = true;
HasFakeEdge = true;
break;
OpenPOWER on IntegriCloud