2012-03-14 07:40:48 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
|
|
|
|
|
2013-08-10 01:20:05 +08:00
|
|
|
struct MyClass {
|
|
|
|
template <int i> int add(int j) {
|
|
|
|
return i + j;
|
|
|
|
}
|
2013-08-29 07:06:52 +08:00
|
|
|
virtual void func() {
|
|
|
|
}
|
2012-03-14 07:40:48 +08:00
|
|
|
};
|
|
|
|
|
2013-08-10 01:20:05 +08:00
|
|
|
int add2(int x) {
|
|
|
|
return MyClass().add<2>(x);
|
|
|
|
}
|
2012-03-14 07:40:48 +08:00
|
|
|
|
2013-08-10 01:20:05 +08:00
|
|
|
inline int add3(int x) {
|
|
|
|
return MyClass().add<3>(x); // even though add<3> is ODR used, don't emit it since we don't codegen it
|
|
|
|
}
|
|
|
|
|
2013-08-30 07:19:58 +08:00
|
|
|
// CHECK: [[FOO_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTS3foo"} ; [ DW_TAG_structure_type ] [foo]
|
|
|
|
// CHECK: [[FOO_MEM]] = metadata !{metadata [[FOO_FUNC:![0-9]*]]}
|
|
|
|
// CHECK: [[FOO_FUNC]] = {{.*}}, metadata !"_ZN3foo4funcEN5outerIS_E5innerE", i32 {{[0-9]*}}, metadata [[FOO_FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [func]
|
|
|
|
// CHECK: [[FOO_FUNC_TYPE]] = {{.*}}, metadata [[FOO_FUNC_PARAMS:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
|
|
|
|
// CHECK: [[FOO_FUNC_PARAMS]] = metadata !{null, metadata !{{[0-9]*}}, metadata [[OUTER_FOO_INNER:![0-9]*]]}
|
|
|
|
// CHECK: [[OUTER_FOO_INNER]] = {{.*}} ; [ DW_TAG_structure_type ] [inner]
|
|
|
|
|
PR17046, PR17092: Debug Info assert-on-valid due to member loss when context creation recreates the item the context is created for
By removing the possibility of strange partial definitions with no
members that older GCC's produced for the otherwise unreferenced outer
types of referenced inner types, we can simplify debug info generation
and correct this bug. Newer (4.8.1 and ToT) GCC's don't produce this
quirky debug info, and instead produce the full definition for the outer
type (except in the case where that type is dynamic and its vtable is
not emitted in this TU).
During the creation of the context for a type, we may revisit that type
(due to the need to visit template parameters, among other things) and
used to end up visiting it first there. Then when we would reach the
original code attempting to define that type, we would lose debug info
by overwriting its members.
By avoiding the possibility of latent "defined with no members" types,
we can be sure than whenever we already have a type in a cache (either a
definition or declaration), we can just return that. In the case of a
full definition, our work is done. In the case of a partial definition,
we must already be in the process of completing it. And in the case of a
declaration, the completed/vtable/etc callbacks can handle converting it
to a definition.
llvm-svn: 190122
2013-09-06 14:45:04 +08:00
|
|
|
// CHECK: metadata [[VIRT_MEM:![0-9]*]], i32 0, metadata !{{[0-9]*}}, metadata [[VIRT_TEMP_PARAM:![0-9]*]], metadata !"_ZTS4virtI4elemE"} ; [ DW_TAG_structure_type ] [virt<elem>] {{.*}} [def]
|
|
|
|
// CHECK: [[ELEM:![0-9]*]] = {{.*}}, metadata [[ELEM_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTS4elem"} ; [ DW_TAG_structure_type ] [elem] {{.*}} [def]
|
|
|
|
// CHECK: [[ELEM_MEM]] = metadata !{metadata [[ELEM_X:![0-9]*]]}
|
|
|
|
// CHECK: [[ELEM_X]] = {{.*}} ; [ DW_TAG_member ] [x] {{.*}} [static] [from virt<elem>]
|
|
|
|
// CHECK: [[VIRT_TEMP_PARAM]] = metadata !{metadata [[VIRT_T:![0-9]*]]}
|
|
|
|
// CHECK: [[VIRT_T]] = {{.*}}, metadata !"T", metadata [[ELEM]], {{.*}} ; [ DW_TAG_template_type_parameter ]
|
|
|
|
|
2013-08-30 07:19:58 +08:00
|
|
|
// CHECK: [[C:![0-9]*]] = {{.*}}, metadata [[C_MEM:![0-9]*]], i32 0, metadata [[C]], null, metadata !"_ZTS7MyClass"} ; [ DW_TAG_structure_type ] [MyClass]
|
2013-08-29 07:06:52 +08:00
|
|
|
// CHECK: [[C_MEM]] = metadata !{metadata [[C_VPTR:![0-9]*]], metadata [[C_ADD:![0-9]*]], metadata [[C_FUNC:![0-9]*]], metadata [[C_CTOR:![0-9]*]]}
|
|
|
|
// CHECK: [[C_VPTR]] = {{.*}} ; [ DW_TAG_member ] [_vptr$MyClass]
|
2013-08-30 07:19:58 +08:00
|
|
|
|
2013-08-29 07:06:52 +08:00
|
|
|
// CHECK: [[C_ADD]] = {{.*}} ; [ DW_TAG_subprogram ] [line 4] [add<2>]
|
|
|
|
// CHECK: [[C_FUNC]] = {{.*}} ; [ DW_TAG_subprogram ] [line 7] [func]
|
|
|
|
// CHECK: [[C_CTOR]] = {{.*}} ; [ DW_TAG_subprogram ] [line 0] [MyClass]
|
2013-08-19 01:36:19 +08:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
struct outer {
|
|
|
|
struct inner {
|
|
|
|
int i;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct foo {
|
|
|
|
void func(outer<foo>::inner);
|
|
|
|
};
|
|
|
|
|
|
|
|
inline void func() {
|
|
|
|
// require 'foo' to be complete before the emission of 'inner' so that, when
|
|
|
|
// constructing the context chain for 'x' we emit the full definition of
|
|
|
|
// 'foo', which requires the definition of 'inner' again
|
|
|
|
foo f;
|
|
|
|
}
|
|
|
|
|
|
|
|
outer<foo>::inner x;
|
|
|
|
|
2013-08-30 07:19:58 +08:00
|
|
|
// CHECK: metadata [[OUTER_FOO_INNER]], i32 {{[0-9]*}}, i32 {{[0-9]*}}, %"struct.outer<foo>::inner"* @x, {{.*}} ; [ DW_TAG_variable ] [x]
|
PR17046, PR17092: Debug Info assert-on-valid due to member loss when context creation recreates the item the context is created for
By removing the possibility of strange partial definitions with no
members that older GCC's produced for the otherwise unreferenced outer
types of referenced inner types, we can simplify debug info generation
and correct this bug. Newer (4.8.1 and ToT) GCC's don't produce this
quirky debug info, and instead produce the full definition for the outer
type (except in the case where that type is dynamic and its vtable is
not emitted in this TU).
During the creation of the context for a type, we may revisit that type
(due to the need to visit template parameters, among other things) and
used to end up visiting it first there. Then when we would reach the
original code attempting to define that type, we would lose debug info
by overwriting its members.
By avoiding the possibility of latent "defined with no members" types,
we can be sure than whenever we already have a type in a cache (either a
definition or declaration), we can just return that. In the case of a
full definition, our work is done. In the case of a partial definition,
we must already be in the process of completing it. And in the case of a
declaration, the completed/vtable/etc callbacks can handle converting it
to a definition.
llvm-svn: 190122
2013-09-06 14:45:04 +08:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct virt {
|
|
|
|
T* values;
|
|
|
|
virtual ~virt();
|
|
|
|
};
|
|
|
|
struct elem {
|
|
|
|
static virt<elem> x; // ensure that completing 'elem' will require/completing 'virt<elem>'
|
|
|
|
};
|
|
|
|
inline void f1() {
|
|
|
|
elem e; // ensure 'elem' is required to be complete when it is emitted as a template argument for 'virt<elem>'
|
|
|
|
};
|
|
|
|
void f2() {
|
|
|
|
virt<elem> d; // emit 'virt<elem>'
|
|
|
|
}
|
|
|
|
|