From d11e4608105b5cdd00d3e0f0cd83cd1765bab7f3 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 27 Aug 2007 16:39:17 +0000 Subject: Updated checker for "return of address of stack variable" to look for implicit casts from T to T& at the topmost part of the return-value expression. This checking may be needed within EvalAddr later on. We'll wait until test cases show this kind of logic is necessary (as more C++ features are implemented in clang). llvm-svn: 41493 --- clang/Sema/SemaChecking.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'clang/Sema/SemaChecking.cpp') diff --git a/clang/Sema/SemaChecking.cpp b/clang/Sema/SemaChecking.cpp index e03507b7968..c027fa794c9 100644 --- a/clang/Sema/SemaChecking.cpp +++ b/clang/Sema/SemaChecking.cpp @@ -410,10 +410,12 @@ Sema::CheckReturnStackAddr(Expr *RetValExp, QualType lhsType, } // Perform checking for stack values returned by reference. else if (lhsType->isReferenceType()) { - if (DeclRefExpr *DR = EvalVal(RetValExp)) - Diag(DR->getLocStart(), diag::warn_ret_stack_ref, - DR->getDecl()->getIdentifier()->getName(), - RetValExp->getSourceRange()); + // Check for an implicit cast to a reference. + if (ImplicitCastExpr *I = dyn_cast(RetValExp)) + if (DeclRefExpr *DR = EvalVal(I->getSubExpr())) + Diag(DR->getLocStart(), diag::warn_ret_stack_ref, + DR->getDecl()->getIdentifier()->getName(), + RetValExp->getSourceRange()); } } -- cgit v1.2.3