Thanks John! On May 11, 2011, at 12:19 AM, John McCall wrote:
> Author: rjmccall > Date: Wed May 11 02:19:11 2011 > New Revision: 131178 > > URL: http://llvm.org/viewvc/llvm-project?rev=131178&view=rev > Log: > Teach CFG building how to deal with CXXMemberCallExprs and BoundMemberTy, > then teach -Wreturn-type to handle the same. Net effect: we now correctly > handle noreturn attributes on member calls in the CFG. > > > Modified: > cfe/trunk/lib/Analysis/CFG.cpp > cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp > cfe/trunk/test/SemaCXX/attr-noreturn.cpp > > Modified: cfe/trunk/lib/Analysis/CFG.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=131178&r1=131177&r2=131178&view=diff > ============================================================================== > --- cfe/trunk/lib/Analysis/CFG.cpp (original) > +++ cfe/trunk/lib/Analysis/CFG.cpp Wed May 11 02:19:11 2011 > @@ -320,7 +320,6 @@ > AddStmtChoice asc); > CFGBlock *VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *C, > AddStmtChoice asc); > - CFGBlock *VisitCXXMemberCallExpr(CXXMemberCallExpr *C, AddStmtChoice asc); > CFGBlock *VisitCallExpr(CallExpr *C, AddStmtChoice asc); > CFGBlock *VisitCaseStmt(CaseStmt *C); > CFGBlock *VisitChooseExpr(ChooseExpr *C, AddStmtChoice asc); > @@ -868,6 +867,7 @@ > > case Stmt::CallExprClass: > case Stmt::CXXOperatorCallExprClass: > + case Stmt::CXXMemberCallExprClass: > return VisitCallExpr(cast<CallExpr>(S), asc); > > case Stmt::CaseStmtClass: > @@ -903,9 +903,6 @@ > case Stmt::CXXTemporaryObjectExprClass: > return VisitCXXTemporaryObjectExpr(cast<CXXTemporaryObjectExpr>(S), > asc); > > - case Stmt::CXXMemberCallExprClass: > - return VisitCXXMemberCallExpr(cast<CXXMemberCallExpr>(S), asc); > - > case Stmt::CXXThrowExprClass: > return VisitCXXThrowExpr(cast<CXXThrowExpr>(S)); > > @@ -1153,12 +1150,19 @@ > } > > CFGBlock *CFGBuilder::VisitCallExpr(CallExpr *C, AddStmtChoice asc) { > - // If this is a call to a no-return function, this stops the block here. > - bool NoReturn = false; > - if (getFunctionExtInfo(*C->getCallee()->getType()).getNoReturn()) { > - NoReturn = true; > + // Compute the callee type. > + QualType calleeType = C->getCallee()->getType(); > + if (calleeType == Context->BoundMemberTy) { > + QualType boundType = Expr::findBoundMemberType(C->getCallee()); > + > + // We should only get a null bound type if processing a dependent > + // CFG. Recover by assuming nothing. > + if (!boundType.isNull()) calleeType = boundType; > } > > + // If this is a call to a no-return function, this stops the block here. > + bool NoReturn = getFunctionExtInfo(*calleeType).getNoReturn(); > + > bool AddEHEdge = false; > > // Languages without exceptions are assumed to not throw. > @@ -2691,13 +2695,6 @@ > return VisitChildren(C); > } > > -CFGBlock *CFGBuilder::VisitCXXMemberCallExpr(CXXMemberCallExpr *C, > - AddStmtChoice asc) { > - autoCreateBlock(); > - appendStmt(Block, C); > - return VisitChildren(C); > -} > - > CFGBlock *CFGBuilder::VisitImplicitCastExpr(ImplicitCastExpr *E, > AddStmtChoice asc) { > if (asc.alwaysAdd(*this, E)) { > > Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=131178&r1=131177&r2=131178&view=diff > ============================================================================== > --- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original) > +++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Wed May 11 02:19:11 2011 > @@ -196,7 +196,12 @@ > continue; > } > Expr *CEE = C->getCallee()->IgnoreParenCasts(); > - if (getFunctionExtInfo(CEE->getType()).getNoReturn()) { > + QualType calleeType = CEE->getType(); > + if (calleeType == AC.getASTContext().BoundMemberTy) { > + calleeType = Expr::findBoundMemberType(CEE); > + assert(!calleeType.isNull() && "analyzing unresolved call?"); > + } > + if (getFunctionExtInfo(calleeType).getNoReturn()) { > NoReturnEdge = true; > HasFakeEdge = true; > } else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE)) { > > Modified: cfe/trunk/test/SemaCXX/attr-noreturn.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-noreturn.cpp?rev=131178&r1=131177&r2=131178&view=diff > ============================================================================== > --- cfe/trunk/test/SemaCXX/attr-noreturn.cpp (original) > +++ cfe/trunk/test/SemaCXX/attr-noreturn.cpp Wed May 11 02:19:11 2011 > @@ -1,5 +1,22 @@ > // RUN: %clang_cc1 -fsyntax-only -verify %s > > +// Reachability tests have to come first because they get suppressed > +// if any errors have occurred. > +namespace test5 { > + struct A { > + __attribute__((noreturn)) void fail(); > + void nofail(); > + } a; > + > + int &test1() { > + a.nofail(); > + } // expected-warning {{control reaches end of non-void function}} > + > + int &test2() { > + a.fail(); > + } > +} > + > // PR5620 > void f0() __attribute__((__noreturn__)); > void f1(void (*)()); > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
