[cfe-commits] r84057 - /cfe/trunk/lib/AST/DeclCXX.cpp

Douglas Gregor dgregor at apple.com
Tue Oct 13 16:45:19 PDT 2009


Author: dgregor
Date: Tue Oct 13 18:45:19 2009
New Revision: 84057

URL: http://llvm.org/viewvc/llvm-project?rev=84057&view=rev
Log:
Member function templates (and instantiations/specializations thereof)
are never copy constructors or copy assignment operators.

Modified:
    cfe/trunk/lib/AST/DeclCXX.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=84057&r1=84056&r2=84057&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Tue Oct 13 18:45:19 2009
@@ -192,7 +192,8 @@
     const CXXMethodDecl* Method = cast<CXXMethodDecl>(*Op);
     if (Method->isStatic())
       continue;
-    // TODO: Skip templates? Or is this implicitly done due to parameter types?
+    if (Method->getPrimaryTemplate())
+      continue;
     const FunctionProtoType *FnType =
       Method->getType()->getAs<FunctionProtoType>();
     assert(FnType && "Overloaded operator has no prototype.");
@@ -259,6 +260,11 @@
   const FunctionProtoType *FnType = OpDecl->getType()->getAs<FunctionProtoType>();
   assert(FnType && "Overloaded operator has no proto function type.");
   assert(FnType->getNumArgs() == 1 && !FnType->isVariadic());
+  
+  // Copy assignment operators must be non-templates.
+  if (OpDecl->getPrimaryTemplate() || OpDecl->getDescribedFunctionTemplate())
+    return;
+  
   QualType ArgType = FnType->getArgType(0);
   if (const LValueReferenceType *Ref = ArgType->getAs<LValueReferenceType>())
     ArgType = Ref->getPointeeType();
@@ -694,7 +700,9 @@
   //   const volatile X&, and either there are no other parameters
   //   or else all other parameters have default arguments (8.3.6).
   if ((getNumParams() < 1) ||
-      (getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()))
+      (getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) ||
+      (getPrimaryTemplate() != 0) ||
+      (getDescribedFunctionTemplate() != 0))
     return false;
 
   const ParmVarDecl *Param = getParamDecl(0);





More information about the cfe-commits mailing list