[PATCH] D21682: DeadStoresChecker: Don't warn about dead stores into volatile variables

Stephan Bergmann via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 24 06:48:45 PDT 2016


sberg created this revision.
sberg added a reviewer: zaks.anna.
sberg added a subscriber: cfe-commits.

http://reviews.llvm.org/D21682

Files:
  lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  test/Analysis/dead-stores.c

Index: test/Analysis/dead-stores.c
===================================================================
--- test/Analysis/dead-stores.c
+++ test/Analysis/dead-stores.c
@@ -569,3 +569,7 @@
 
 }
 
+void testVolatile() {
+    volatile int v;
+    v = 0; // no warning
+}
Index: lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -278,6 +278,8 @@
           RHS = RHS->IgnoreParenCasts();
 
           QualType T = VD->getType();
+          if (T.isVolatileQualified())
+            return;
           if (T->isPointerType() || T->isObjCObjectPointerType()) {
             if (RHS->isNullPointerConstant(Ctx, Expr::NPC_ValueDependentIsNull))
               return;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21682.61787.patch
Type: text/x-patch
Size: 838 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160624/7b4bc083/attachment.bin>


More information about the cfe-commits mailing list