[cfe-commits] r135610 - in /cfe/trunk: lib/Analysis/UninitializedValues.cpp test/SemaCXX/uninit-variables.cpp

Ted Kremenek kremenek at apple.com
Wed Jul 20 12:49:47 PDT 2011


Author: kremenek
Date: Wed Jul 20 14:49:47 2011
New Revision: 135610

URL: http://llvm.org/viewvc/llvm-project?rev=135610&view=rev
Log:
Fix -Wuninitialized regression involving functions invalidating parameters passed by reference.

Modified:
    cfe/trunk/lib/Analysis/UninitializedValues.cpp
    cfe/trunk/test/SemaCXX/uninit-variables.cpp

Modified: cfe/trunk/lib/Analysis/UninitializedValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/UninitializedValues.cpp?rev=135610&r1=135609&r2=135610&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/UninitializedValues.cpp (original)
+++ cfe/trunk/lib/Analysis/UninitializedValues.cpp Wed Jul 20 14:49:47 2011
@@ -441,8 +441,10 @@
   // 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) {

Modified: cfe/trunk/test/SemaCXX/uninit-variables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/uninit-variables.cpp?rev=135610&r1=135609&r2=135610&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/uninit-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/uninit-variables.cpp Wed Jul 20 14:49:47 2011
@@ -66,6 +66,16 @@
  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: 





More information about the cfe-commits mailing list