[clang-tools-extra] r262615 - [clang-tidy] Do not emit warnings from misc-suspicious-semicolon when the compilation fails.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 3 05:42:43 PST 2016
On Thu, Mar 3, 2016 at 2:08 PM, Gabor Horvath via cfe-commits <
cfe-commits at lists.llvm.org> wrote:
> Author: xazax
> Date: Thu Mar 3 07:08:11 2016
> New Revision: 262615
>
> URL: http://llvm.org/viewvc/llvm-project?rev=262615&view=rev
> Log:
> [clang-tidy] Do not emit warnings from misc-suspicious-semicolon when the
> compilation fails.
>
> Added:
>
> clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-semicolon-fail.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.cpp
>
> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-semicolon.rst
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.cpp?rev=262615&r1=262614&r2=262615&view=diff
>
> ==============================================================================
> --- clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/misc/SuspiciousSemicolonCheck.cpp
> Thu Mar 3 07:08:11 2016
> @@ -7,8 +7,8 @@
> //
>
> //===----------------------------------------------------------------------===//
>
> -#include "../utils/LexerUtils.h"
> #include "SuspiciousSemicolonCheck.h"
> +#include "../utils/LexerUtils.h"
> #include "clang/AST/ASTContext.h"
> #include "clang/ASTMatchers/ASTMatchFinder.h"
>
> @@ -30,6 +30,9 @@ void SuspiciousSemicolonCheck::registerM
> }
>
> void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult
> &Result) {
> + if (Result.Context->getDiagnostics().hasErrorOccurred())
> + return;
> +
> const auto *Semicolon = Result.Nodes.getNodeAs<NullStmt>("semi");
> SourceLocation LocStart = Semicolon->getLocStart();
>
>
> Modified:
> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-semicolon.rst
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-semicolon.rst?rev=262615&r1=262614&r2=262615&view=diff
>
> ==============================================================================
> ---
> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-semicolon.rst
> (original)
> +++
> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-semicolon.rst
> Thu Mar 3 07:08:11 2016
> @@ -11,7 +11,7 @@ intentional.
>
> .. code-block:: c++
>
> - if(x < y);
> + if (x < y);
> {
> x++;
> }
> @@ -22,7 +22,7 @@ the first line, and `x` will be incremen
>
> .. code-block:: c++
>
> - while((line = readLine(file)) != NULL);
> + while ((line = readLine(file)) != NULL);
> processLine(line);
>
> As a result of this code, `processLine()` will only be called once, when
> the
> @@ -32,7 +32,7 @@ the code indicates the intention of the
>
> .. code-block:: c++
>
> - if(x >= y);
> + if (x >= y);
> x -= y;
>
> While the indentation does not imply any nesting, there is simply no valid
> @@ -45,7 +45,7 @@ line. For example:
>
> .. code-block:: c++
>
> - while(readWhitespace());
> + while (readWhitespace());
> Token t = readNextToken();
>
> Here the second line is indented in a way that suggests that it is meant
> to be
> @@ -56,14 +56,14 @@ Either remove the indentation from the s
>
> .. code-block:: c++
>
> - while(readWhitespace());
> + while (readWhitespace());
> Token t = readNextToken();
>
> ... or move the semicolon from the end of the first line to a new line:
>
> .. code-block:: c++
>
> - while(readWhitespace())
> + while (readWhitespace())
> ;
>
> Token t = readNextToken();
>
> Added:
> clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-semicolon-fail.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-semicolon-fail.cpp?rev=262615&view=auto
>
> ==============================================================================
> ---
> clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-semicolon-fail.cpp
> (added)
> +++
> clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-semicolon-fail.cpp
> Thu Mar 3 07:08:11 2016
> @@ -0,0 +1,13 @@
> +// RUN: clang-tidy %s -checks="-*,misc-suspicious-semicolon" -- 2>&1 > %t
> +// RUN: FileCheck --input-file=%t %s
>
Please pipe the output to FileCheck instead of redirecting it to a
temporary file.
> +
> +// Note: This test verifies that, the checker does not emit any warning
> for
> +// files that do not compile.
> +
> +bool g();
> +
> +void f() {
> + if (g());
> + // CHECK-NOT: :[[@LINE-1]]:11: warning: potentially unintended
> semicolon [misc-suspicious-semicolon]
>
Please make the check line more broad for more tolerance to bugs and
changes to the check. Just match the core of the message or even just the
check name.
> + int a
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160303/ebe3f5bb/attachment-0001.html>
More information about the cfe-commits
mailing list