2013-12-14 12:49:06 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -verify -fexceptions -fcxx-exceptions -triple x86_64-linux-gnu | FileCheck %s
|
|
|
|
// expected-no-diagnostics
|
Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.
We have a new flavor of exception specification, EST_Uninstantiated. A function
type with this exception specification carries a pointer to a FunctionDecl, and
the exception specification for that FunctionDecl is instantiated (if needed)
and used in the place of the function type's exception specification.
When a function template declaration with a non-trivial exception specification
is instantiated, the specialization's exception specification is set to this
new 'uninstantiated' kind rather than being instantiated immediately.
Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs
on-demand. Also, any odr-use of a function triggers the instantiation of its
exception specification (the exception specification could be needed by IRGen).
In passing, fix two places where a DeclRefExpr was created but the corresponding
function was not actually marked odr-used. We used to get away with this, but
don't any more.
Also fix a bug where instantiating an exception specification which refers to
function parameters resulted in a crash. We still have the same bug in default
arguments, which I'll be looking into next.
This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to
parse (and, in very limited testing, support) all of libstdc++4.7's standard
headers.
llvm-svn: 154886
2012-04-17 08:58:00 +08:00
|
|
|
|
2012-04-18 06:30:01 +08:00
|
|
|
void h();
|
|
|
|
|
|
|
|
template<typename T> void f() noexcept(sizeof(T) == 4) { h(); }
|
2012-04-19 08:08:28 +08:00
|
|
|
template<typename T> void g() noexcept(sizeof(T) == 4);
|
2012-04-18 06:30:01 +08:00
|
|
|
|
|
|
|
template<typename T> struct S {
|
|
|
|
static void f() noexcept(sizeof(T) == 4) { h(); }
|
2012-04-19 08:08:28 +08:00
|
|
|
static void g() noexcept(sizeof(T) == 4);
|
2012-04-18 06:30:01 +08:00
|
|
|
};
|
|
|
|
|
2013-03-01 06:49:57 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIsEvv() [[NONE:#[0-9]+]] {
|
2012-04-18 06:30:01 +08:00
|
|
|
template<> void f<short>() { h(); }
|
2015-06-18 04:53:19 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIA2_sEvv() [[NUW:#[0-9]+]] personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
2012-04-18 06:30:01 +08:00
|
|
|
template<> void f<short[2]>() noexcept { h(); }
|
|
|
|
|
|
|
|
// CHECK: define {{.*}} @_ZN1SIsE1fEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
template<> void S<short>::f() { h(); }
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_ZN1SIA2_sE1fEv() [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
template<> void S<short[2]>::f() noexcept { h(); }
|
|
|
|
|
2015-01-13 06:13:53 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIDsEvv() [[NONE]] comdat {
|
2012-04-18 06:30:01 +08:00
|
|
|
template void f<char16_t>();
|
2015-06-18 04:53:19 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIA2_DsEvv() [[NUW]] comdat personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
2012-04-18 06:30:01 +08:00
|
|
|
template void f<char16_t[2]>();
|
|
|
|
|
|
|
|
// CHECK: define {{.*}} @_ZN1SIDsE1fEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
template void S<char16_t>::f();
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_ZN1SIA2_DsE1fEv() [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
template void S<char16_t[2]>::f();
|
Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.
We have a new flavor of exception specification, EST_Uninstantiated. A function
type with this exception specification carries a pointer to a FunctionDecl, and
the exception specification for that FunctionDecl is instantiated (if needed)
and used in the place of the function type's exception specification.
When a function template declaration with a non-trivial exception specification
is instantiated, the specialization's exception specification is set to this
new 'uninstantiated' kind rather than being instantiated immediately.
Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs
on-demand. Also, any odr-use of a function triggers the instantiation of its
exception specification (the exception specification could be needed by IRGen).
In passing, fix two places where a DeclRefExpr was created but the corresponding
function was not actually marked odr-used. We used to get away with this, but
don't any more.
Also fix a bug where instantiating an exception specification which refers to
function parameters resulted in a crash. We still have the same bug in default
arguments, which I'll be looking into next.
This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to
parse (and, in very limited testing, support) all of libstdc++4.7's standard
headers.
llvm-svn: 154886
2012-04-17 08:58:00 +08:00
|
|
|
|
2012-04-19 08:08:28 +08:00
|
|
|
void h() {
|
2015-06-18 04:53:19 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIiEvv() [[NUW]] comdat personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.
We have a new flavor of exception specification, EST_Uninstantiated. A function
type with this exception specification carries a pointer to a FunctionDecl, and
the exception specification for that FunctionDecl is instantiated (if needed)
and used in the place of the function type's exception specification.
When a function template declaration with a non-trivial exception specification
is instantiated, the specialization's exception specification is set to this
new 'uninstantiated' kind rather than being instantiated immediately.
Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs
on-demand. Also, any odr-use of a function triggers the instantiation of its
exception specification (the exception specification could be needed by IRGen).
In passing, fix two places where a DeclRefExpr was created but the corresponding
function was not actually marked odr-used. We used to get away with this, but
don't any more.
Also fix a bug where instantiating an exception specification which refers to
function parameters resulted in a crash. We still have the same bug in default
arguments, which I'll be looking into next.
This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to
parse (and, in very limited testing, support) all of libstdc++4.7's standard
headers.
llvm-svn: 154886
2012-04-17 08:58:00 +08:00
|
|
|
f<int>();
|
2015-01-13 06:13:53 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIA2_iEvv() [[NONE]] comdat {
|
Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.
We have a new flavor of exception specification, EST_Uninstantiated. A function
type with this exception specification carries a pointer to a FunctionDecl, and
the exception specification for that FunctionDecl is instantiated (if needed)
and used in the place of the function type's exception specification.
When a function template declaration with a non-trivial exception specification
is instantiated, the specialization's exception specification is set to this
new 'uninstantiated' kind rather than being instantiated immediately.
Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs
on-demand. Also, any odr-use of a function triggers the instantiation of its
exception specification (the exception specification could be needed by IRGen).
In passing, fix two places where a DeclRefExpr was created but the corresponding
function was not actually marked odr-used. We used to get away with this, but
don't any more.
Also fix a bug where instantiating an exception specification which refers to
function parameters resulted in a crash. We still have the same bug in default
arguments, which I'll be looking into next.
This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to
parse (and, in very limited testing, support) all of libstdc++4.7's standard
headers.
llvm-svn: 154886
2012-04-17 08:58:00 +08:00
|
|
|
f<int[2]>();
|
2012-04-18 06:30:01 +08:00
|
|
|
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_ZN1SIiE1fEv() [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
S<int>::f();
|
|
|
|
// CHECK: define {{.*}} @_ZN1SIA2_iE1fEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
S<int[2]>::f();
|
|
|
|
|
2015-06-18 04:53:19 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIfEvv() [[NUW]] comdat personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.
We have a new flavor of exception specification, EST_Uninstantiated. A function
type with this exception specification carries a pointer to a FunctionDecl, and
the exception specification for that FunctionDecl is instantiated (if needed)
and used in the place of the function type's exception specification.
When a function template declaration with a non-trivial exception specification
is instantiated, the specialization's exception specification is set to this
new 'uninstantiated' kind rather than being instantiated immediately.
Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs
on-demand. Also, any odr-use of a function triggers the instantiation of its
exception specification (the exception specification could be needed by IRGen).
In passing, fix two places where a DeclRefExpr was created but the corresponding
function was not actually marked odr-used. We used to get away with this, but
don't any more.
Also fix a bug where instantiating an exception specification which refers to
function parameters resulted in a crash. We still have the same bug in default
arguments, which I'll be looking into next.
This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to
parse (and, in very limited testing, support) all of libstdc++4.7's standard
headers.
llvm-svn: 154886
2012-04-17 08:58:00 +08:00
|
|
|
void (*f1)() = &f<float>;
|
2015-01-13 06:13:53 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIdEvv() [[NONE]] comdat {
|
Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.
We have a new flavor of exception specification, EST_Uninstantiated. A function
type with this exception specification carries a pointer to a FunctionDecl, and
the exception specification for that FunctionDecl is instantiated (if needed)
and used in the place of the function type's exception specification.
When a function template declaration with a non-trivial exception specification
is instantiated, the specialization's exception specification is set to this
new 'uninstantiated' kind rather than being instantiated immediately.
Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs
on-demand. Also, any odr-use of a function triggers the instantiation of its
exception specification (the exception specification could be needed by IRGen).
In passing, fix two places where a DeclRefExpr was created but the corresponding
function was not actually marked odr-used. We used to get away with this, but
don't any more.
Also fix a bug where instantiating an exception specification which refers to
function parameters resulted in a crash. We still have the same bug in default
arguments, which I'll be looking into next.
This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to
parse (and, in very limited testing, support) all of libstdc++4.7's standard
headers.
llvm-svn: 154886
2012-04-17 08:58:00 +08:00
|
|
|
void (*f2)() = &f<double>;
|
2012-04-18 06:30:01 +08:00
|
|
|
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_ZN1SIfE1fEv() [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
void (*f3)() = &S<float>::f;
|
|
|
|
// CHECK: define {{.*}} @_ZN1SIdE1fEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
void (*f4)() = &S<double>::f;
|
|
|
|
|
2015-06-18 04:53:19 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIA4_cEvv() [[NUW]] comdat personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.
We have a new flavor of exception specification, EST_Uninstantiated. A function
type with this exception specification carries a pointer to a FunctionDecl, and
the exception specification for that FunctionDecl is instantiated (if needed)
and used in the place of the function type's exception specification.
When a function template declaration with a non-trivial exception specification
is instantiated, the specialization's exception specification is set to this
new 'uninstantiated' kind rather than being instantiated immediately.
Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs
on-demand. Also, any odr-use of a function triggers the instantiation of its
exception specification (the exception specification could be needed by IRGen).
In passing, fix two places where a DeclRefExpr was created but the corresponding
function was not actually marked odr-used. We used to get away with this, but
don't any more.
Also fix a bug where instantiating an exception specification which refers to
function parameters resulted in a crash. We still have the same bug in default
arguments, which I'll be looking into next.
This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to
parse (and, in very limited testing, support) all of libstdc++4.7's standard
headers.
llvm-svn: 154886
2012-04-17 08:58:00 +08:00
|
|
|
(void)&f<char[4]>;
|
2015-01-13 06:13:53 +08:00
|
|
|
// CHECK: define {{.*}} @_Z1fIcEvv() [[NONE]] comdat {
|
Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.
We have a new flavor of exception specification, EST_Uninstantiated. A function
type with this exception specification carries a pointer to a FunctionDecl, and
the exception specification for that FunctionDecl is instantiated (if needed)
and used in the place of the function type's exception specification.
When a function template declaration with a non-trivial exception specification
is instantiated, the specialization's exception specification is set to this
new 'uninstantiated' kind rather than being instantiated immediately.
Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs
on-demand. Also, any odr-use of a function triggers the instantiation of its
exception specification (the exception specification could be needed by IRGen).
In passing, fix two places where a DeclRefExpr was created but the corresponding
function was not actually marked odr-used. We used to get away with this, but
don't any more.
Also fix a bug where instantiating an exception specification which refers to
function parameters resulted in a crash. We still have the same bug in default
arguments, which I'll be looking into next.
This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to
parse (and, in very limited testing, support) all of libstdc++4.7's standard
headers.
llvm-svn: 154886
2012-04-17 08:58:00 +08:00
|
|
|
(void)&f<char>;
|
2012-04-18 06:30:01 +08:00
|
|
|
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK: define {{.*}} @_ZN1SIA4_cE1fEv() [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
(void)&S<char[4]>::f;
|
|
|
|
// CHECK: define {{.*}} @_ZN1SIcE1fEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-18 06:30:01 +08:00
|
|
|
(void)&S<char>::f;
|
Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.
We have a new flavor of exception specification, EST_Uninstantiated. A function
type with this exception specification carries a pointer to a FunctionDecl, and
the exception specification for that FunctionDecl is instantiated (if needed)
and used in the place of the function type's exception specification.
When a function template declaration with a non-trivial exception specification
is instantiated, the specialization's exception specification is set to this
new 'uninstantiated' kind rather than being instantiated immediately.
Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs
on-demand. Also, any odr-use of a function triggers the instantiation of its
exception specification (the exception specification could be needed by IRGen).
In passing, fix two places where a DeclRefExpr was created but the corresponding
function was not actually marked odr-used. We used to get away with this, but
don't any more.
Also fix a bug where instantiating an exception specification which refers to
function parameters resulted in a crash. We still have the same bug in default
arguments, which I'll be looking into next.
This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to
parse (and, in very limited testing, support) all of libstdc++4.7's standard
headers.
llvm-svn: 154886
2012-04-17 08:58:00 +08:00
|
|
|
}
|
2012-04-19 08:08:28 +08:00
|
|
|
|
|
|
|
// CHECK: define {{.*}} @_Z1iv
|
|
|
|
void i() {
|
2016-04-06 02:59:37 +08:00
|
|
|
// CHECK: declare {{.*}} @_Z1gIiEvv() [[NUW2:#[0-9]+]]
|
2012-04-19 08:08:28 +08:00
|
|
|
g<int>();
|
|
|
|
// CHECK: declare {{.*}} @_Z1gIA2_iEvv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
g<int[2]>();
|
|
|
|
|
2016-04-06 02:59:37 +08:00
|
|
|
// CHECK: declare {{.*}} @_ZN1SIiE1gEv() [[NUW2]]
|
2012-04-19 08:08:28 +08:00
|
|
|
S<int>::g();
|
|
|
|
// CHECK: declare {{.*}} @_ZN1SIA2_iE1gEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
S<int[2]>::g();
|
|
|
|
|
2016-04-06 02:59:37 +08:00
|
|
|
// CHECK: declare {{.*}} @_Z1gIfEvv() [[NUW2]]
|
2012-04-19 08:08:28 +08:00
|
|
|
void (*g1)() = &g<float>;
|
|
|
|
// CHECK: declare {{.*}} @_Z1gIdEvv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
void (*g2)() = &g<double>;
|
|
|
|
|
2016-04-06 02:59:37 +08:00
|
|
|
// CHECK: declare {{.*}} @_ZN1SIfE1gEv() [[NUW2]]
|
2012-04-19 08:08:28 +08:00
|
|
|
void (*g3)() = &S<float>::g;
|
|
|
|
// CHECK: declare {{.*}} @_ZN1SIdE1gEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
void (*g4)() = &S<double>::g;
|
|
|
|
|
2016-04-06 02:59:37 +08:00
|
|
|
// CHECK: declare {{.*}} @_Z1gIA4_cEvv() [[NUW2]]
|
2012-04-19 08:08:28 +08:00
|
|
|
(void)&g<char[4]>;
|
|
|
|
// CHECK: declare {{.*}} @_Z1gIcEvv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
(void)&g<char>;
|
|
|
|
|
2016-04-06 02:59:37 +08:00
|
|
|
// CHECK: declare {{.*}} @_ZN1SIA4_cE1gEv() [[NUW2]]
|
2012-04-19 08:08:28 +08:00
|
|
|
(void)&S<char[4]>::g;
|
|
|
|
// CHECK: declare {{.*}} @_ZN1SIcE1gEv()
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
(void)&S<char>::g;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T> struct Nested {
|
|
|
|
template<bool b, typename U> void f() noexcept(sizeof(T) == sizeof(U));
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK: define {{.*}} @_Z1jv
|
|
|
|
void j() {
|
|
|
|
// CHECK: declare {{.*}} @_ZN6NestedIiE1fILb1EcEEvv(
|
2013-02-27 08:06:04 +08:00
|
|
|
// CHECK-NOT: [[NUW]]
|
2012-04-19 08:08:28 +08:00
|
|
|
Nested<int>().f<true, char>();
|
2016-04-06 02:59:37 +08:00
|
|
|
// CHECK: declare {{.*}} @_ZN6NestedIlE1fILb0ElEEvv({{.*}}) [[NUW2]]
|
2012-04-19 08:08:28 +08:00
|
|
|
Nested<long>().f<false, long>();
|
|
|
|
}
|
2013-02-20 15:22:19 +08:00
|
|
|
|
2013-03-01 06:49:57 +08:00
|
|
|
// CHECK: attributes [[NONE]] = { {{.*}} }
|
Cleanup the handling of noinline function attributes, -fno-inline,
-fno-inline-functions, -O0, and optnone.
These were really, really tangled together:
- We used the noinline LLVM attribute for -fno-inline
- But not for -fno-inline-functions (breaking LTO)
- But we did use it for -finline-hint-functions (yay, LTO is happy!)
- But we didn't for -O0 (LTO is sad yet again...)
- We had weird structuring of CodeGenOpts with both an inlining
enumeration and a boolean. They interacted in weird ways and
needlessly.
- A *lot* of set smashing went on with setting these, and then got worse
when we considered optnone and other inlining-effecting attributes.
- A bunch of inline affecting attributes were managed in a completely
different place from -fno-inline.
- Even with -fno-inline we failed to put the LLVM noinline attribute
onto many generated function definitions because they didn't show up
as AST-level functions.
- If you passed -O0 but -finline-functions we would run the normal
inliner pass in LLVM despite it being in the O0 pipeline, which really
doesn't make much sense.
- Lastly, we used things like '-fno-inline' to manipulate the pass
pipeline which forced the pass pipeline to be much more
parameterizable than it really needs to be. Instead we can *just* use
the optimization level to select a pipeline and control the rest via
attributes.
Sadly, this causes a bunch of churn in tests because we don't run the
optimizer in the tests and check the contents of attribute sets. It
would be awesome if attribute sets were a bit more FileCheck friendly,
but oh well.
I think this is a significant improvement and should remove the semantic
need to change what inliner pass we run in order to comply with the
requested inlining semantics by relying completely on attributes. It
also cleans up tho optnone and related handling a bit.
One unfortunate aspect of this is that for generating alwaysinline
routines like those in OpenMP we end up removing noinline and then
adding alwaysinline. I tried a bunch of other approaches, but because we
recompute function attributes from scratch and don't have a declaration
here I couldn't find anything substantially cleaner than this.
Differential Revision: https://reviews.llvm.org/D28053
llvm-svn: 290398
2016-12-23 09:24:49 +08:00
|
|
|
// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} }
|
2016-04-06 02:59:37 +08:00
|
|
|
// CHECK: attributes [[NUW2]] = { nounwind{{.*}} }
|
|
|
|
|
|
|
|
|
2014-08-28 01:04:39 +08:00
|
|
|
|
|
|
|
namespace PR19190 {
|
|
|
|
template <class T> struct DWFIterator { virtual void get() throw(int) = 0; };
|
|
|
|
void foo(DWFIterator<int> *foo) { foo->get(); }
|
|
|
|
}
|