[cfe-dev] Template specialization: why drop attributes?

Jordan Rose jordan_rose at apple.com
Fri Jun 15 13:29:56 PDT 2012

On Jun 15, 2012, at 12:00 , "Sharlet, Dillon" <dillon.sharlet at intel.com> wrote:

> Hello,
> I am working on a custom attribute for an experimental project. I’ve just finally tracked down a problem where explicit template specializations have their attributes removed by Clang. I’m suspicious of the following function:
> /// \brief Strips various properties off an implicit instantiation
> /// that has just been explicitly specialized.
> static void StripImplicitInstantiation(NamedDecl *D) {
>   // FIXME: "make check" is clean if the call to dropAttrs() is commented out.
>   D->dropAttrs();
>   if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
>     FD->setInlineSpecified(false);
>   }
> }

This function is only called when the instantiation has already been implicitly requested. This makes sense for most attributes because the use at the site of instantiation has probably already been fixed to use the default behavior. Is there a reason you can't provide your explicit specialization before its uses?


More information about the cfe-dev mailing list