diff options
author | George Burgess IV <george.burgess.iv@gmail.com> | 2017-06-27 21:31:31 +0000 |
---|---|---|
committer | George Burgess IV <george.burgess.iv@gmail.com> | 2017-06-27 21:31:31 +0000 |
commit | 563c0ec65e052e93085d4e3b7fede21da5ea768f (patch) | |
tree | 2240ccca03e6b33513c7bf55eb6e5cd74b0d3fdc /test/CodeGen | |
parent | f255da2ab7a0fd98b7d34b160e640c96cce25560 (diff) |
[Sema] Allow unmarked overloadable functions.
This patch extends the `overloadable` attribute to allow for one
function with a given name to not be marked with the `overloadable`
attribute. The overload without the `overloadable` attribute will not
have its name mangled.
So, the following code is now legal:
void foo(void) __attribute__((overloadable));
void foo(int);
void foo(float) __attribute__((overloadable));
In addition, this patch fixes a bug where we'd accept code with
`__attribute__((overloadable))` inconsistently applied. In other words,
we used to accept:
void foo(void);
void foo(void) __attribute__((overloadable));
But we will do this no longer, since it defeats the original purpose of
requiring `__attribute__((overloadable))` on all redeclarations of a
function.
This breakage seems to not be an issue in practice, since the only code
I could find that had this pattern often looked like:
void foo(void);
void foo(void) __attribute__((overloadable)) __asm__("foo");
void foo(int) __attribute__((overloadable));
...Which can now be simplified by simply removing the asm label and
overloadable attribute from the redeclaration of `void foo(void);`
Differential Revision: https://reviews.llvm.org/D32332
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306467 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen')
-rw-r--r-- | test/CodeGen/mangle-ms.c | 9 | ||||
-rw-r--r-- | test/CodeGen/mangle.c | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/test/CodeGen/mangle-ms.c b/test/CodeGen/mangle-ms.c index 0ad43d5e06..042c72e6d7 100644 --- a/test/CodeGen/mangle-ms.c +++ b/test/CodeGen/mangle-ms.c @@ -2,3 +2,12 @@ // CHECK: define void @"\01?f@@$$J0YAXP6AX@Z@Z" __attribute__((overloadable)) void f(void (*x)()) {} + +// CHECK: define void @f +void f(void (*x)(int)) {} + +// CHECK: define void @g +void g(void (*x)(int)) {} + +// CHECK: define void @"\01?g@@$$J0YAXP6AX@Z@Z" +__attribute__((overloadable)) void g(void (*x)()) {} diff --git a/test/CodeGen/mangle.c b/test/CodeGen/mangle.c index 46ef512f69..f94139bc5e 100644 --- a/test/CodeGen/mangle.c +++ b/test/CodeGen/mangle.c @@ -9,6 +9,10 @@ void __attribute__((__overloadable__)) f0(int a) {} // CHECK: @_Z2f0l void __attribute__((__overloadable__)) f0(long b) {} +// Unless it's unmarked. +// CHECK: @f0 +void f0(float b) {} + // CHECK: @bar // These should get merged. |