diff options
author | Alexander Kornienko <alexfh@google.com> | 2017-02-09 10:41:27 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2017-02-09 10:41:27 +0000 |
commit | 28239b166f6f89d2d7d2979e10bdb1cfb2236657 (patch) | |
tree | 161d862e32cffaad70da5e105f3899a68bd77472 /clang-tools-extra | |
parent | ebfe99414205873984f59772e39940a3c6620bd3 (diff) | |
download | bcm5719-llvm-28239b166f6f89d2d7d2979e10bdb1cfb2236657.tar.gz bcm5719-llvm-28239b166f6f89d2d7d2979e10bdb1cfb2236657.zip |
[clang-tidy] Fix misc-unused-using-decls false positives in presence of compile errors
llvm-svn: 294578
Diffstat (limited to 'clang-tools-extra')
-rw-r--r-- | clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp | 3 | ||||
-rw-r--r-- | clang-tools-extra/test/clang-tidy/misc-unused-using-decls-errors.cpp | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp index 09d32346fcf..b3eabdcd048 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp @@ -48,6 +48,9 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) { } void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) { + if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred()) + return; + if (const auto *Using = Result.Nodes.getNodeAs<UsingDecl>("using")) { // Ignores using-declarations defined in macros. if (Using->getLocation().isMacroID()) diff --git a/clang-tools-extra/test/clang-tidy/misc-unused-using-decls-errors.cpp b/clang-tools-extra/test/clang-tidy/misc-unused-using-decls-errors.cpp new file mode 100644 index 00000000000..5eb380f7739 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/misc-unused-using-decls-errors.cpp @@ -0,0 +1,12 @@ +// RUN: %check_clang_tidy %s misc-unused-using-decls %t + +namespace n { +class C; +} + +using n::C; + +void f() { + for (C *p : unknown()) {} + // CHECK-MESSAGES: :[[@LINE-1]]:15: error: use of undeclared identifier 'unknown' [clang-diagnostic-error] +} |