aboutsummaryrefslogtreecommitdiff
path: root/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
commit8f40dcc4ddbe4ef796dd1bf0696ac66d4e40e99a (patch)
tree882d72f180144e92dc4d7c6d3575229657d052b3 /lib/Analysis/UninitializedValues.cpp
parentd3cb28bef1e1d397b35126029465f2b7e8e8dc1f (diff)
-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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158611 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/UninitializedValues.cpp')
-rw-r--r--lib/Analysis/UninitializedValues.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp
index 57dfab36fd..fbfa46c443 100644
--- a/lib/Analysis/UninitializedValues.cpp
+++ b/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;
}
}
}