[clang-tidy] Ignore template instantiations in modernize-use-using

The test I'm adding passes without the change due to the deduplication logic in
ClangTidyDiagnosticConsumer::take(). However this bug manifests in our internal
integration with clang-tidy.
I've verified the fix by locally changing LessClangTidyError to consider
replacements.

llvm-svn: 347470
This commit is contained in:
Alexander Kornienko 2018-11-22 16:10:18 +00:00
parent 840f032630
commit b34b6ffa9d
2 changed files with 23 additions and 1 deletions

View File

@ -24,7 +24,8 @@ UseUsingCheck::UseUsingCheck(StringRef Name, ClangTidyContext *Context)
void UseUsingCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus11)
return;
Finder->addMatcher(typedefDecl().bind("typedef"), this);
Finder->addMatcher(typedefDecl(unless(isInstantiated())).bind("typedef"),
this);
}
// Checks if 'typedef' keyword can be removed - we do it only if

View File

@ -162,3 +162,24 @@ typedef unsigned Map[lol];
typedef void (*fun_type)();
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
// CHECK-FIXES: using fun_type = void (*)();
namespace template_instantiations {
template <typename T>
class C {
protected:
typedef C<T> super;
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
// CHECK-FIXES: using super = C<T>;
virtual void f();
public:
virtual ~C();
};
class D : public C<D> {
void f() override { super::f(); }
};
class E : public C<E> {
void f() override { super::f(); }
};
}