diff options
author | George Burgess IV <george.burgess.iv@gmail.com> | 2016-01-07 02:26:57 +0000 |
---|---|---|
committer | George Burgess IV <george.burgess.iv@gmail.com> | 2016-01-07 02:26:57 +0000 |
commit | 7204ed97dd930e0cb159985a5973bc9993740726 (patch) | |
tree | 3422df717a6c911af7f97fdc06baca35553b5055 /clang/test/CodeGenCXX/pass-object-size.cpp | |
parent | 103d2381d67cef5cc0febed84da7bdd01d1a2cb1 (diff) | |
download | llvm-7204ed97dd930e0cb159985a5973bc9993740726.zip llvm-7204ed97dd930e0cb159985a5973bc9993740726.tar.gz llvm-7204ed97dd930e0cb159985a5973bc9993740726.tar.bz2 |
[Sema] Teach overload resolution about unaddressable functions.
Given an expression like `(&Foo)();`, we perform overload resolution as
if we are calling `Foo` directly. This causes problems if `Foo` is a
function that can't have its address taken. This patch teaches overload
resolution to ignore functions that can't have their address taken in
such cases.
Differential Revision: http://reviews.llvm.org/D15590
llvm-svn: 257016
Diffstat (limited to 'clang/test/CodeGenCXX/pass-object-size.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/pass-object-size.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/pass-object-size.cpp b/clang/test/CodeGenCXX/pass-object-size.cpp index 254669b9..2c7f974 100644 --- a/clang/test/CodeGenCXX/pass-object-size.cpp +++ b/clang/test/CodeGenCXX/pass-object-size.cpp @@ -25,3 +25,21 @@ void Lambdas(char *ptr) { // CHECK-DAG: define internal i64 @"_ZZN7lambdas7LambdasEPcENK3$_1clEPvU17pass_object_size0" // CHECK-NOT: call i64 @llvm.objectsize } + +// This is here instead of in Sema/ because we need to check to make sure the +// proper function is called. If it's not, we'll end up with assertion errors. +namespace addrof { +void OvlFoo(void *const __attribute__((pass_object_size(0)))) {} +void OvlFoo(int *const) {} + +// CHECK: define void @_ZN6addrof4TestEv +void Test() { + // Treating parens-only calls as though they were direct is consistent with + // how we handle other implicitly unaddressable functions (e.g. builtins). + // CHECK: call void @_ZN6addrof6OvlFooEPvU17pass_object_size0 + (OvlFoo)(nullptr); + + // CHECK: call void @_ZN6addrof6OvlFooEPi + (&OvlFoo)(nullptr); +} +} |