[cfe-commits] r163848 - /cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Sep 13 15:22:36 PDT 2012


thanks!
Testcase? :-)

On 13 September 2012 18:01, Douglas Gregor <dgregor at apple.com> wrote:
> Author: dgregor
> Date: Thu Sep 13 17:01:49 2012
> New Revision: 163848
>
> URL: http://llvm.org/viewvc/llvm-project?rev=163848&view=rev
> Log:
> Actually rebuild function types properly when adjusting the function
> type of an instantiation.
>
> Modified:
>     cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=163848&r1=163847&r2=163848&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Thu Sep 13 17:01:49 2012
> @@ -1017,10 +1017,19 @@
>  static QualType adjustFunctionTypeForInstantiation(ASTContext &Context,
>                                                     FunctionDecl *D,
>                                                     TypeSourceInfo *TInfo) {
> -  const FunctionType *OrigFunc = D->getType()->castAs<FunctionType>();
> -  const FunctionType *NewFunc = TInfo->getType()->castAs<FunctionType>();
> -  return QualType(Context.adjustFunctionType(NewFunc, OrigFunc->getExtInfo()),
> -                  0);
> +  const FunctionProtoType *OrigFunc
> +    = D->getType()->castAs<FunctionProtoType>();
> +  const FunctionProtoType *NewFunc
> +    = TInfo->getType()->castAs<FunctionProtoType>();
> +  if (OrigFunc->getExtInfo() == NewFunc->getExtInfo())
> +    return TInfo->getType();
> +
> +  FunctionProtoType::ExtProtoInfo NewEPI = NewFunc->getExtProtoInfo();
> +  NewEPI.ExtInfo = OrigFunc->getExtInfo();
> +  return Context.getFunctionType(NewFunc->getResultType(),
> +                                 NewFunc->arg_type_begin(),
> +                                 NewFunc->getNumArgs(),
> +                                 NewEPI);
>  }
>
>  /// Normal class members are of more specific types and therefore
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list