lethalantidote updated this revision to Diff 84026.
lethalantidote marked an inline comment as done.
lethalantidote added a comment.

Addresses moving check further up, during analysis.
Adds test to check for sometimes branch. Please review.


https://reviews.llvm.org/D28543

Files:
  clang/lib/Analysis/UninitializedValues.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/Sema/uninit-variables.c


Index: clang/test/Sema/uninit-variables.c
===================================================================
--- clang/test/Sema/uninit-variables.c
+++ clang/test/Sema/uninit-variables.c
@@ -22,7 +22,7 @@
 int test4() {
   int x; // expected-note{{initialize the variable 'x' to silence this 
warning}}
   ++x; // expected-warning{{variable 'x' is uninitialized when used here}}
-  return x; 
+  return x;
 }
 
 int test5() {
@@ -442,6 +442,21 @@
 struct { struct { void *p; } a; } test55 = { { &test55.a }}; // no-warning
 struct { struct { void *p; } a; } test56 = { { &(test56.a) }}; // no-warning
 
+int test57() {
+  volatile int x;
+  return x; // no-warning
+}
+
+int init(volatile int* num) {
+  return 1;
+}
+
+int test58() {
+  volatile int a, b, c;
+  if (init(&a) || init(&b) || init(&c)) {}
+  return a+b+c;   // no-warning
+}
+
 void uninit_in_loop() {
   int produce(void);
   void consume(int);
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===================================================================
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -80,7 +80,7 @@
       }
 
       S.Diag(L, diag) << R1 << R2;
-      
+
       SourceLocation Open = SilenceableCondVal.getBegin();
       if (Open.isValid()) {
         SourceLocation Close = SilenceableCondVal.getEnd();
Index: clang/lib/Analysis/UninitializedValues.cpp
===================================================================
--- clang/lib/Analysis/UninitializedValues.cpp
+++ clang/lib/Analysis/UninitializedValues.cpp
@@ -767,7 +767,7 @@
         // appropriately, but we need to continue to analyze subsequent uses
         // of the variable.
         vals[VD] = Uninitialized;
-      } else if (VD->getInit()) {
+      } else if (VD->getInit() || VD->getType().isVolatileQualified()) {
         // Treat the new variable as initialized.
         vals[VD] = Initialized;
       } else {


Index: clang/test/Sema/uninit-variables.c
===================================================================
--- clang/test/Sema/uninit-variables.c
+++ clang/test/Sema/uninit-variables.c
@@ -22,7 +22,7 @@
 int test4() {
   int x; // expected-note{{initialize the variable 'x' to silence this warning}}
   ++x; // expected-warning{{variable 'x' is uninitialized when used here}}
-  return x; 
+  return x;
 }
 
 int test5() {
@@ -442,6 +442,21 @@
 struct { struct { void *p; } a; } test55 = { { &test55.a }}; // no-warning
 struct { struct { void *p; } a; } test56 = { { &(test56.a) }}; // no-warning
 
+int test57() {
+  volatile int x;
+  return x; // no-warning
+}
+
+int init(volatile int* num) {
+  return 1;
+}
+
+int test58() {
+  volatile int a, b, c;
+  if (init(&a) || init(&b) || init(&c)) {}
+  return a+b+c;   // no-warning
+}
+
 void uninit_in_loop() {
   int produce(void);
   void consume(int);
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===================================================================
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -80,7 +80,7 @@
       }
 
       S.Diag(L, diag) << R1 << R2;
-      
+
       SourceLocation Open = SilenceableCondVal.getBegin();
       if (Open.isValid()) {
         SourceLocation Close = SilenceableCondVal.getEnd();
Index: clang/lib/Analysis/UninitializedValues.cpp
===================================================================
--- clang/lib/Analysis/UninitializedValues.cpp
+++ clang/lib/Analysis/UninitializedValues.cpp
@@ -767,7 +767,7 @@
         // appropriately, but we need to continue to analyze subsequent uses
         // of the variable.
         vals[VD] = Uninitialized;
-      } else if (VD->getInit()) {
+      } else if (VD->getInit() || VD->getType().isVolatileQualified()) {
         // Treat the new variable as initialized.
         vals[VD] = Initialized;
       } else {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to