]> granicus.if.org Git - clang/commitdiff
Fix -Wuninitialized regression involving functions invalidating parameters passed...
authorTed Kremenek <kremenek@apple.com>
Wed, 20 Jul 2011 19:49:47 +0000 (19:49 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 20 Jul 2011 19:49:47 +0000 (19:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135610 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/UninitializedValues.cpp
test/SemaCXX/uninit-variables.cpp

index b84b4309d9e7bdb943cd8e9202af52e798dec23e..67f0f6740ec46d5931d7c9ec2e7fbd6a1515eea1 100644 (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) {
index a0180e3d3a1507be55350995bca23dd917db1393..a850a2f92f1512a6a92867ed3c8a0b800c7fd198 100644 (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: