================
Comment at: clang-tidy/misc/IncompleteSwitchCheck.cpp:11
@@ +10,3 @@
+  Finder->addMatcher(
+      switchStmt(hasDescendant(implicitCastExpr().bind("cast")),
+                 unless(hasDescendant(defaultStmt()))).bind("switch"),
----------------
This will also match casts that occur somewhere inside of the switch cases, you 
probably want to use a plain has instead of hasDescendent.

================
Comment at: clang-tidy/misc/IncompleteSwitchCheck.cpp:12
@@ +11,3 @@
+      switchStmt(hasDescendant(implicitCastExpr().bind("cast")),
+                 unless(hasDescendant(defaultStmt()))).bind("switch"),
+      this);
----------------
Similar problem, what if one switch with a default case is contained within a 
switch without one?

================
Comment at: clang-tidy/misc/IncompleteSwitchCheck.cpp:19
@@ +18,3 @@
+  const auto c = Result.Nodes.getNodeAs<ImplicitCastExpr>("cast");
+  if (c->getCastKind() == CK_IntegralCast)
+    return;
----------------
I think actually checking that you're casting from an enum would be a good 
idea, integral casts are common with integers too.

  short foo;
  switch (foo) {// Implicit int promotion.
    ...
  }

================
Comment at: test/clang-tidy/incomplete-switch.cpp:1
@@ +1,2 @@
+// RUN: clang-tidy --checks='-*,misc-incomplete-switch' %s -- | FileCheck %s
+
----------------
Please add ` -implicit-check-not="{{warning|error}}:"` here, otherwise it 
doesn't check if additional warnings are emitted.

http://reviews.llvm.org/D4784



_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to