clang-tidy/readability-identifier-naming: crash on DependentTemplateSpecializationType

Summary:
Previously, the added test cases crashed because the passed a null Decl
to addUsage().

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D22188

llvm-svn: 274985
This commit is contained in:
Matthias Gehre 2016-07-09 20:09:28 +00:00
parent 177553511d
commit a9e812b9cb
2 changed files with 10 additions and 3 deletions

View File

@ -656,15 +656,16 @@ void IdentifierNamingCheck::check(const MatchFinder::MatchResult &Result) {
SourceRange Range(Ref.getTemplateNameLoc(), Ref.getTemplateNameLoc());
if (const auto *ClassDecl = dyn_cast<TemplateDecl>(Decl)) {
addUsage(NamingCheckFailures, ClassDecl->getTemplatedDecl(), Range);
if (const auto *TemplDecl = ClassDecl->getTemplatedDecl())
addUsage(NamingCheckFailures, TemplDecl, Range);
return;
}
}
if (const auto &Ref =
Loc->getAs<DependentTemplateSpecializationTypeLoc>()) {
addUsage(NamingCheckFailures, Ref.getTypePtr()->getAsTagDecl(),
Loc->getSourceRange());
if (const auto *Decl = Ref.getTypePtr()->getAsTagDecl())
addUsage(NamingCheckFailures, Decl, Loc->getSourceRange());
return;
}
}

View File

@ -344,3 +344,9 @@ void MY_TEST_Macro(function) {}
// CHECK-FIXES: {{^}}void MY_TEST_MACRO(function) {}
}
}
template <typename t_t> struct a {
typename t_t::template b<> c;
};
template <template <typename> class A> struct b { A<int> c; };