[PATCH] D36777: [Sema] Don't emit -Wunguarded-availability for switch cases

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 17 04:17:53 PDT 2017


arphaman added a comment.

Thanks! There are two issues that I see:



================
Comment at: lib/Sema/SemaDeclAttr.cpp:7519
+    // to any useful diagnostics.
+    for (Stmt *Child : llvm::drop_begin(CS->children(), 1))
+      if (!Base::TraverseStmt(Child))
----------------
GNU case statements can also have a RHS expression in a range. You should avoid using children completely and just traverse the sub stmt instead.


================
Comment at: lib/Sema/SemaDeclAttr.cpp:7520
+    for (Stmt *Child : llvm::drop_begin(CS->children(), 1))
+      if (!Base::TraverseStmt(Child))
+        return false;
----------------
You should call `TraverseStmt` instead because we have special logic for tracking the statement stack for a fixit. We can produce an incorrect multi-statement fixit if the case's sub statement is a compound statement when we call `Base::TraverseStmt`.


https://reviews.llvm.org/D36777





More information about the cfe-commits mailing list