summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CFG.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-03-02 20:32:29 +0000
committerTed Kremenek <kremenek@apple.com>2011-03-02 20:32:29 +0000
commite06a55c6b9a278705d723da399eb72eb6a23ddc2 (patch)
tree0ccdc1be6a0ca716bf7e046ebbbd527a5338f1f0 /clang/lib/Analysis/CFG.cpp
parentbd6f7f9770728a425388c8d4d9b1aec4a5fac5e1 (diff)
downloadbcm5719-llvm-e06a55c6b9a278705d723da399eb72eb6a23ddc2.tar.gz
bcm5719-llvm-e06a55c6b9a278705d723da399eb72eb6a23ddc2.zip
Introduce CFGImplicitDtor::isNoReturn() to query whether a destructor actually returns. Use this for -Wreturn-type to prune false positives reported in PR 6884.
llvm-svn: 126875
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r--clang/lib/Analysis/CFG.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 13576539348..2818cf6d620 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -2773,7 +2773,40 @@ CFG* CFG::buildCFG(const Decl *D, Stmt* Statement, ASTContext *C,
}
const CXXDestructorDecl *CFGImplicitDtor::getDestructorDecl() const {
- return 0;
+ switch (getKind()) {
+ case CFGElement::Invalid:
+ case CFGElement::Statement:
+ case CFGElement::Initializer:
+ llvm_unreachable("getDestructorDecl should only be used with "
+ "ImplicitDtors");
+ case CFGElement::AutomaticObjectDtor: {
+ const VarDecl *var = cast<CFGAutomaticObjDtor>(this)->getVarDecl();
+ QualType ty = var->getType();
+ const RecordType *recordType = ty->getAs<RecordType>();
+ const CXXRecordDecl *classDecl =
+ cast<CXXRecordDecl>(recordType->getDecl());
+ return classDecl->getDestructor();
+ }
+ case CFGElement::TemporaryDtor: {
+ const CXXBindTemporaryExpr *bindExpr =
+ cast<CFGTemporaryDtor>(this)->getBindTemporaryExpr();
+ const CXXTemporary *temp = bindExpr->getTemporary();
+ return temp->getDestructor();
+ }
+ case CFGElement::BaseDtor:
+ case CFGElement::MemberDtor:
+
+ // Not yet supported.
+ return 0;
+ }
+}
+
+bool CFGImplicitDtor::isNoReturn() const {
+ if (const CXXDestructorDecl *cdecl = getDestructorDecl()) {
+ QualType ty = cdecl->getType();
+ return cast<FunctionType>(ty)->getNoReturnAttr();
+ }
+ return false;
}
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud