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

CJ DiMeglio via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 10 17:46:46 PST 2017


lethalantidote created this revision.
lethalantidote added a reviewer: thakis.
lethalantidote added a subscriber: cfe-commits.

Elliminates uninitialized warning for volitile variables.


https://reviews.llvm.org/D28543

Files:
  clang/lib/Sema/AnalysisBasedWarnings.cpp


Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===================================================================
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -864,7 +864,7 @@
 /// false.
 static bool DiagnoseUninitializedUse(Sema &S, const VarDecl *VD,
                                      const UninitUse &Use,
-                                     bool alwaysReportSelfInit = false) {
+                                     bool alwaysReportSelfInit = false) { 
   if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Use.getUser())) {
     // Inspect the initializer of the variable declaration which is
     // being referenced prior to its initialization. We emit
@@ -891,6 +891,11 @@
       }
     }
 
+    // If volatile, we don't raise this warning.
+    if (VD->getType().isVolatileQualified()) {
+      return false;
+    }
+
     DiagUninitUse(S, VD, Use, false);
   } else {
     const BlockExpr *BE = cast<BlockExpr>(Use.getUser());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28543.83907.patch
Type: text/x-patch
Size: 995 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170111/ba0d0f2f/attachment-0001.bin>


More information about the cfe-commits mailing list