[clang-tidy] hasErrorOccurred() -> hasUncompilableErrorOccurred()

hasErrorOccurred() -> hasUncompilableErrorOccurred(), since we only care about
errors that lead to invalid AST.

llvm-svn: 294467
This commit is contained in:
Alexander Kornienko 2017-02-08 16:11:22 +00:00
parent 0b2cc8190d
commit 385c2a3134
3 changed files with 18 additions and 4 deletions

View File

@ -72,7 +72,7 @@ void DefinitionsInHeadersCheck::registerMatchers(MatchFinder *Finder) {
void DefinitionsInHeadersCheck::check(const MatchFinder::MatchResult &Result) {
// Don't run the check in failing TUs.
if (Result.Context->getDiagnostics().hasErrorOccurred())
if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred())
return;
// C++ [basic.def.odr] p6:

View File

@ -30,7 +30,7 @@ void SuspiciousSemicolonCheck::registerMatchers(MatchFinder *Finder) {
}
void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult &Result) {
if (Result.Context->getDiagnostics().hasErrorOccurred())
if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred())
return;
const auto *Semicolon = Result.Nodes.getNodeAs<NullStmt>("semi");

View File

@ -1,4 +1,10 @@
// RUN: clang-tidy %s -checks="-*,misc-suspicious-semicolon" -- 2>&1 | FileCheck %s
// RUN: clang-tidy %s -checks="-*,misc-suspicious-semicolon" -- -DERROR 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-ERROR \
// RUN: -implicit-check-not="{{warning|error}}:"
// RUN: clang-tidy %s -checks="-*,misc-suspicious-semicolon,clang-diagnostic*" \
// RUN: -- -DWERROR -Wno-everything -Werror=unused-variable 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-WERROR \
// RUN: -implicit-check-not="{{warning|error}}:"
// Note: This test verifies that, the checker does not emit any warning for
// files that do not compile.
@ -7,6 +13,14 @@ bool g();
void f() {
if (g());
// CHECK-NOT: [misc-suspicious-semicolon]
// CHECK-WERROR: :[[@LINE-1]]:11: warning: potentially unintended semicolon [misc-suspicious-semicolon]
#if ERROR
int a
// CHECK-ERROR: :[[@LINE-1]]:8: error: expected ';' at end of declaration [clang-diagnostic-error]
#elif WERROR
int a;
// CHECK-WERROR: :[[@LINE-1]]:7: error: unused variable 'a' [clang-diagnostic-unused-variable]
#else
#error "One of ERROR or WERROR should be defined.
#endif
}