]> granicus.if.org Git - clang/commitdiff
Fast-path an arity check when performing template argument deduction that compares...
authorDouglas Gregor <dgregor@apple.com>
Wed, 5 Jan 2011 23:23:17 +0000 (23:23 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 5 Jan 2011 23:23:17 +0000 (23:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122928 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateDeduction.cpp

index e762d341176b26dedf26d995a0d64f2bd8225d33..603a7efea5f100126ac74d42703a53fc4b0d10e6 100644 (file)
@@ -541,8 +541,12 @@ DeduceTemplateArguments(Sema &S,
                         TemplateDeductionInfo &Info,
                       llvm::SmallVectorImpl<DeducedTemplateArgument> &Deduced,
                         unsigned TDF) {
-  // FIXME: Fast-path check with NumParams != NumArgs and there are no
-  // pack expansions around.
+  // Fast-path check to see if we have too many/too few arguments.
+  if (NumParams != NumArgs &&
+      !(NumParams && isa<PackExpansionType>(Params[NumParams - 1])) &&
+      !(NumArgs && isa<PackExpansionType>(Args[NumArgs - 1])))
+    return NumArgs < NumParams ? Sema::TDK_TooFewArguments 
+                               : Sema::TDK_TooManyArguments;
   
   // C++0x [temp.deduct.type]p10:
   //   Similarly, if P has a form that contains (T), then each parameter type