[PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

Kim Gräsman via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 25 12:39:45 PST 2016

kimgr added a subscriber: kimgr.
kimgr added a comment.

Cool check, I like how it pays attention to indentation!

I found some minor doc nits, see inline.

Comment at: docs/clang-tidy/checks/misc-suspicious-semicolon.rst:8-9
@@ +7,4 @@
+the code. More specifically, it looks for `if`, `while`, `for` and `for-range`
+statements whose body is a single semicolon, and then analyzes the
+context of the code (e.g. indentation) in an attempt to determine whether that
+is intentional.
"context" looks like it would fit on the wrapped line.

Comment at: docs/clang-tidy/checks/misc-suspicious-semicolon.rst:20
@@ +19,3 @@
+Here the body of the `if` statement consists of only the semicolon at the end of
+the first line, and `x` will be increased regardless of the condition.

Comment at: docs/clang-tidy/checks/misc-suspicious-semicolon.rst:29
@@ +28,3 @@
+As a result of this code, `processLine()` will only be called once, when the
+`while` loop with the empty body exits with `line == NULL`. The identation of
+the code indicates the intention of the programmer.
Typo: identation

Comment at: docs/clang-tidy/checks/misc-suspicious-semicolon.rst:71
@@ +70,3 @@
+In this case the checker will assume that you know what you are doing, and will
+not raise a warning.
There's been some preference for "check" over "checker" lately.

Comment at: test/clang-tidy/misc-suspicious-semicolon.cpp:88
@@ +87,3 @@
+  char c = 'b';
+  char * s = "a";
+  if (s == "(" || s != "'" || c == '"') {
Weird pointer alignment is a little distracting here, better stick with LLVM convention and attach it to `s`?


More information about the cfe-commits mailing list