diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index b7548415aa3e..53252ec3f70e 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1222,6 +1222,19 @@ static bool isInstantiationOf(ClassTemplateDecl *Pattern, return false; } +static bool isInstantiationOf(FunctionTemplateDecl *Pattern, + FunctionTemplateDecl *Instance) { + Pattern = Pattern->getCanonicalDecl(); + + do { + Instance = Instance->getCanonicalDecl(); + if (Pattern == Instance) return true; + Instance = Instance->getInstantiatedFromMemberTemplate(); + } while (Instance); + + return false; +} + static bool isInstantiationOf(CXXRecordDecl *Pattern, CXXRecordDecl *Instance) { Pattern = Pattern->getCanonicalDecl(); @@ -1309,6 +1322,9 @@ static bool isInstantiationOf(ASTContext &Ctx, NamedDecl *D, Decl *Other) { if (ClassTemplateDecl *Temp = dyn_cast(Other)) return isInstantiationOf(cast(D), Temp); + if (FunctionTemplateDecl *Temp = dyn_cast(Other)) + return isInstantiationOf(cast(D), Temp); + if (FieldDecl *Field = dyn_cast(Other)) { if (!Field->getDeclName()) { // This is an unnamed field.