summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/UninitializedValues.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-06-16 23:34:14 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-06-16 23:34:14 +0000
commita8d4f229a645a232f7226a843c977f0772bbf9d8 (patch)
treeb5b7bba8e0d0127fe8b8fbef4fc97f92288902d4 /clang/lib/Analysis/UninitializedValues.cpp
parentd0b767f849ded7197bb9fa7b9a4e23f51e43b005 (diff)
downloadbcm5719-llvm-a8d4f229a645a232f7226a843c977f0772bbf9d8.tar.gz
bcm5719-llvm-a8d4f229a645a232f7226a843c977f0772bbf9d8.zip
-Wuninitialized bugfix: when entering the scope of a variable with no
initializer, it is uninitialized, even if we may be coming from somewhere where it was initialized. llvm-svn: 158611
Diffstat (limited to 'clang/lib/Analysis/UninitializedValues.cpp')
-rw-r--r--clang/lib/Analysis/UninitializedValues.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Analysis/UninitializedValues.cpp b/clang/lib/Analysis/UninitializedValues.cpp
index 57dfab36fdd..fbfa46c443c 100644
--- a/clang/lib/Analysis/UninitializedValues.cpp
+++ b/clang/lib/Analysis/UninitializedValues.cpp
@@ -625,6 +625,18 @@ void TransferFunctions::VisitDeclStmt(DeclStmt *ds) {
// the use of the uninitialized value (which visiting the
// initializer).
vals[vd] = Initialized;
+ } else {
+ // No initializer: the variable is now uninitialized. This matters
+ // for cases like:
+ // while (...) {
+ // int n;
+ // use(n);
+ // n = 0;
+ // }
+ // FIXME: Mark the variable as uninitialized whenever its scope is
+ // left, since its scope could be re-entered by a jump over the
+ // declaration.
+ vals[vd] = Uninitialized;
}
}
}
OpenPOWER on IntegriCloud