Fix -Wuninitialized regression involving functions invalidating parameters passed by reference.

llvm-svn: 135610
This commit is contained in:
Ted Kremenek 2011-07-20 19:49:47 +00:00
parent 82f64488ec
commit 81383c20e4
2 changed files with 13 additions and 1 deletions

View File

@ -441,8 +441,10 @@ void TransferFunctions::VisitDeclRefExpr(DeclRefExpr *dr) {
// Record the last DeclRefExpr seen. This is an lvalue computation.
// We use this value to later detect if a variable "escapes" the analysis.
if (const VarDecl *vd = dyn_cast<VarDecl>(dr->getDecl()))
if (isTrackedVar(vd))
if (isTrackedVar(vd)) {
ProcessUses();
lastDR = dr;
}
}
void TransferFunctions::VisitDeclStmt(DeclStmt *ds) {

View File

@ -66,6 +66,16 @@ test4_A test4() {
return a; // expected-warning{{variable 'a' is uninitialized when used here}}
}
// Test variables getting invalidated by function calls with reference arguments
// *AND* there are multiple invalidated arguments.
void test5_aux(int &, int &);
int test5() {
int x, y;
test5_aux(x, y);
return x + y; // no-warning
}
// This test previously crashed Sema.
class Rdar9188004A {
public: