[cfe-commits] r41493 - /cfe/trunk/Sema/SemaChecking.cpp
Ted Kremenek
kremenek at apple.com
Mon Aug 27 09:39:17 PDT 2007
Author: kremenek
Date: Mon Aug 27 11:39:17 2007
New Revision: 41493
URL: http://llvm.org/viewvc/llvm-project?rev=41493&view=rev
Log:
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).
Modified:
cfe/trunk/Sema/SemaChecking.cpp
Modified: cfe/trunk/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaChecking.cpp?rev=41493&r1=41492&r2=41493&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/Sema/SemaChecking.cpp Mon Aug 27 11:39:17 2007
@@ -410,10 +410,12 @@
}
// 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<ImplicitCastExpr>(RetValExp))
+ if (DeclRefExpr *DR = EvalVal(I->getSubExpr()))
+ Diag(DR->getLocStart(), diag::warn_ret_stack_ref,
+ DR->getDecl()->getIdentifier()->getName(),
+ RetValExp->getSourceRange());
}
}
More information about the cfe-commits
mailing list