Make modernize-use-default tolerant of delayed template parsing; this code was previously causing failed assertions because dyn_cast was being passed a null pointer due to the delay-parsed body.

llvm-svn: 258356
This commit is contained in:
Aaron Ballman 2016-01-20 22:14:10 +00:00
parent 9fb70f53ce
commit b61829887d
2 changed files with 9 additions and 0 deletions

View File

@ -272,6 +272,7 @@ void UseDefaultCheck::check(const MatchFinder::MatchResult &Result) {
// that are not user-provided (automatically generated).
if (SpecialFunctionDecl->isDeleted() ||
SpecialFunctionDecl->isExplicitlyDefaulted() ||
SpecialFunctionDecl->isLateTemplateParsed() ||
!SpecialFunctionDecl->isUserProvided() || !SpecialFunctionDecl->hasBody())
return;

View File

@ -0,0 +1,8 @@
// RUN: clang-tidy %s -checks=-*,modernize-use-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0
// Note: this test expects no diagnostics, but FileCheck cannot handle that,
// hence the use of | count 0.
template <typename Ty>
struct S {
S<Ty>& operator=(const S<Ty>&) { return *this; }
};