[cfe-commits] r160174 - in /cfe/trunk: lib/AST/Decl.cpp test/CodeGenCXX/visibility-inlines-hidden.cpp
John McCall
rjmccall at apple.com
Fri Jul 13 13:36:27 PDT 2012
On Jul 13, 2012, at 7:25 AM, Rafael Espindola wrote:
> Author: rafael
> Date: Fri Jul 13 09:25:36 2012
> New Revision: 160174
>
> URL: http://llvm.org/viewvc/llvm-project?rev=160174&view=rev
> Log:
> Use -fvisibility-inlines-hidden in inline functions too. This matches gcc
> behavior since gcc pr30066. Thanks to Benjamin Kramer for pointing it out.
>
> Modified:
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden.cpp
>
> Modified: cfe/trunk/lib/AST/Decl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=160174&r1=160173&r2=160174&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Fri Jul 13 09:25:36 2012
> @@ -168,6 +168,35 @@
> return !d->hasAttr<VisibilityAttr>() || d->isExplicitSpecialization();
> }
>
> +static bool useInlineVisibilityHidden(const NamedDecl *D) {
> + // FIXME: we should warn if -fvisibility-inlines-hidden is used with c.
> + ASTContext &Context = D->getASTContext();
> + if (!Context.getLangOpts().CPlusPlus)
> + return false;
> +
> + const FunctionDecl *FD = dyn_cast<FunctionDecl>(D);
> + if (!FD)
> + return false;
> +
> + TemplateSpecializationKind TSK = TSK_Undeclared;
> + if (FunctionTemplateSpecializationInfo *spec
> + = FD->getTemplateSpecializationInfo()) {
> + TSK = spec->getTemplateSpecializationKind();
> + } else if (MemberSpecializationInfo *MSI =
> + FD->getMemberSpecializationInfo()) {
> + TSK = MSI->getTemplateSpecializationKind();
> + }
> +
> + const FunctionDecl *Def = 0;
> + // InlineVisibilityHidden only applies to definitions, and
> + // isInlined() only gives meaningful answers on definitions
> + // anyway.
> + return TSK != TSK_ExplicitInstantiationDeclaration &&
> + TSK != TSK_ExplicitInstantiationDefinition &&
> + FD->getASTContext().getLangOpts().InlineVisibilityHidden &&
Check this *before* doing all the work above it, please.
John.
More information about the cfe-commits
mailing list