summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2019-09-13 08:10:33 +0000
committerHans Wennborg <hans@hanshq.net>2019-09-13 08:10:33 +0000
commit9f8ce132b4a9c416d054c0ef1534d6d5b16f3189 (patch)
tree636dec817d60e1870307d131a70b0122b9939cc6
parent8c58031805e0f90d838e025026a6935e870a7e75 (diff)
Merging r371766:
------------------------------------------------------------------------ r371766 | nickdesaulniers | 2019-09-12 21:53:35 +0200 (Thu, 12 Sep 2019) | 29 lines [Clang][CodeGen] support alias attribute w/ gnu_inline 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 Reviewers: aaron.ballman, rsmith, erichkeane, andrewrk Reviewed By: andrewrk Subscribers: cfe-commits, andrewrk, hans, srhines Tags: #clang Differential Revision: https://reviews.llvm.org/D67455 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_90@371821 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/Decl.cpp3
-rw-r--r--test/CodeGen/alias.c5
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 21cf9da18a..aa74da0061 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -3332,7 +3332,8 @@ SourceRange FunctionDecl::getExceptionSpecSourceRange() const {
/// an externally visible symbol, but "extern inline" will not create an
/// externally visible symbol.
bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
- assert((doesThisDeclarationHaveABody() || willHaveBody()) &&
+ assert((doesThisDeclarationHaveABody() || willHaveBody() ||
+ hasAttr<AliasAttr>()) &&
"Must be a function definition");
assert(isInlined() && "Function must be inline");
ASTContext &Context = getASTContext();
diff --git a/test/CodeGen/alias.c b/test/CodeGen/alias.c
index 46568ee900..f5bdf3c058 100644
--- a/test/CodeGen/alias.c
+++ b/test/CodeGen/alias.c
@@ -99,3 +99,8 @@ static int test10_foo __attribute__((alias("test10")));
// CHECKGLOBALS-NOT: @test11_foo = dso_local
void test11(void) {}
static void test11_foo(void) __attribute__((alias("test11")));
+
+// Test that gnu_inline+alias work.
+// CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12
+void test12(void) {}
+inline void test12_alias(void) __attribute__((gnu_inline, alias("test12")));