forked from OSchip/llvm-project
[clang-tidy] Fix misc-unused-using-decls false positives in presence of compile errors
llvm-svn: 294578
This commit is contained in:
parent
ebfe994142
commit
28239b166f
|
@ -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())
|
||||||
|
|
|
@ -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]
|
||||||
|
}
|
Loading…
Reference in New Issue