[PATCH] D28543: Elliminates uninitialized warning for volitile varibles.

Nico Weber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 11 13:42:07 PST 2017


thakis added a comment.

Thanks for the test!



================
Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:907
     else
       DiagUninitUse(S, VD, Use, true);
   }
----------------
lethalantidote wrote:
> thakis wrote:
> > Should the check be in DiagUninitUse()? Or is there a reason this one should happen for volatiles?
> Good point. Thanks for catching that.  I hoped I understood this use case correctly, lemme know if the update makes sense. 
Is it possible to test that both branches have this early return now?


================
Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:699
   case UninitUse::Always:
+    if (VD->getType().isVolatileQualified()) {
+      return;
----------------
What about the other cases in this switch? Does a volatile still warn in those cases? Should it? (Probably not?)

Right now the approach is to add an early return when the warning is emitted. Maybe this change should instead be somewhere where we compute if a var could be uninitialized, and that should always be false for volatile variables? Then future other warnings looking at that bit would get volatiles right for free.


https://reviews.llvm.org/D28543





More information about the cfe-commits mailing list