forked from OSchip/llvm-project
[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:
parent
0b2cc8190d
commit
385c2a3134
|
@ -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:
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue