This is an archive of the discontinued LLVM Phabricator instance.

[Clang][CodeGen] support alias attribute w/ gnu_inline
ClosedPublic

Authored by nickdesaulniers on Sep 11 2019, 11:44 AM.

Details

Summary

r369705 did not consider the addition of gnu_inline on function
declarations of alias attributed functions. This resulted in a reported
regression in the clang-9-rc4 release from the Zig developers building
glibc, which was observable as a failed assertion:

llvm-project/clang/lib/AST/Decl.cpp:3336: bool
clang::FunctionDecl::isInlineDefinitionExternallyVisible() const:
Assertion `(doesThisDeclarationHaveABody() || willHaveBody()) && "Must
be a function definition"' failed.

Alias function declarations do not have bodies, so allow us to proceed
if we have the alias function attribute but no body/definition, and add
a test case. The emitted symbols and their linkage matches GCC for the
added test case.

Link: https://bugs.llvm.org/show_bug.cgi?id=43268

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptSep 11 2019, 11:44 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
andrewrk requested changes to this revision.Sep 11 2019, 11:49 AM
andrewrk added inline comments.
clang/lib/AST/Decl.cpp
3352

It looks like the rparen is in the wrong place. I'd expect:

assert((doesThisDeclarationHaveABody() || willHaveBody() ||
     hasAttr<AliasAttr>()) && "Must be a function definition");
This revision now requires changes to proceed.Sep 11 2019, 11:49 AM
  • adjust parens
nickdesaulniers marked an inline comment as done.Sep 11 2019, 1:48 PM
andrewrk accepted this revision.Sep 11 2019, 7:18 PM
This revision is now accepted and ready to land.Sep 11 2019, 7:18 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 12 2019, 12:52 PM