]> granicus.if.org Git - clang/commitdiff
Properly match instantiations of member function templates to the function templates...
authorDouglas Gregor <dgregor@apple.com>
Mon, 28 Sep 2009 06:34:35 +0000 (06:34 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 28 Sep 2009 06:34:35 +0000 (06:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82969 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiateDecl.cpp

index b7548415aa3edf721f4ad0ccdcf979ca85066fed..53252ec3f70ec8b8d6872c0fd53de7a525e7c617 100644 (file)
@@ -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<ClassTemplateDecl>(Other))
     return isInstantiationOf(cast<ClassTemplateDecl>(D), Temp);
 
+  if (FunctionTemplateDecl *Temp = dyn_cast<FunctionTemplateDecl>(Other))
+    return isInstantiationOf(cast<FunctionTemplateDecl>(D), Temp);
+
   if (FieldDecl *Field = dyn_cast<FieldDecl>(Other)) {
     if (!Field->getDeclName()) {
       // This is an unnamed field.