[clang-tidy] Fix misc-unused-using-decls false positives in presence of compile errors

llvm-svn: 294578
This commit is contained in:
Alexander Kornienko 2017-02-09 10:41:27 +00:00
parent ebfe994142
commit 28239b166f
2 changed files with 15 additions and 0 deletions

View File

@ -48,6 +48,9 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
} }
void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) { void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred())
return;
if (const auto *Using = Result.Nodes.getNodeAs<UsingDecl>("using")) { if (const auto *Using = Result.Nodes.getNodeAs<UsingDecl>("using")) {
// Ignores using-declarations defined in macros. // Ignores using-declarations defined in macros.
if (Using->getLocation().isMacroID()) if (Using->getLocation().isMacroID())

View File

@ -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]
}