2014-03-14 07:26:25 +08:00
; RUN: llc %s -o %t -filetype=obj -O0 -mtriple=x86_64-unknown-linux-gnu -dwarf-version=4
2017-09-12 07:05:20 +08:00
; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s -check-prefix=PRESENT
; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s -check-prefix=ABSENT
2014-03-14 07:26:25 +08:00
; RUN: llc %s -o %t -filetype=obj -O0 -mtriple=x86_64-apple-darwin -dwarf-version=4
2017-09-12 07:05:20 +08:00
; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s -check-prefix=DARWINP
; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s -check-prefix=DARWINA
2013-01-17 03:53:47 +08:00
; Verify that attributes we do want are PRESENT;
; verify that attributes we don't want are ABSENT.
; It's a lot easier to do this in two passes than in one.
; PR14471
2013-01-27 05:55:23 +08:00
; LLVM IR generated using: clang -emit-llvm -S -g
2013-01-17 03:53:47 +08:00
; (with the Clang part of this patch applied).
;
; class C
; {
; static int a;
2013-01-20 07:00:25 +08:00
; const static bool const_a = true;
2013-01-17 03:53:47 +08:00
; protected:
; static int b;
2013-01-20 09:18:01 +08:00
; const static float const_b = 3.14;
2013-01-17 03:53:47 +08:00
; public:
; static int c;
; const static int const_c = 18;
; int d;
; };
;
; int C::a = 4;
; int C::b = 2;
; int C::c = 1;
;
; int main()
; {
; C instance_C;
; instance_C.d = 8;
; return C::c;
; }
2016-12-22 08:45:21 +08:00
source_filename = "test/DebugInfo/X86/debug-info-static-member.ll"
2013-01-17 03:53:47 +08:00
%class.C = type { i32 }
2016-12-22 08:45:21 +08:00
@_ZN1C1aE = global i32 4 , align 4 , !dbg !0
@_ZN1C1bE = global i32 2 , align 4 , !dbg !18
@_ZN1C1cE = global i32 1 , align 4 , !dbg !20
2013-01-17 03:53:47 +08:00
2016-12-22 08:45:21 +08:00
; Function Attrs: nounwind uwtable
define i32 @main ( ) #0 !dbg !26 {
2013-01-17 03:53:47 +08:00
entry:
%retval = alloca i32 , align 4
%instance_C = alloca %class.C , align 4
store i32 0 , i32 * %retval
2016-12-22 08:45:21 +08:00
call void @llvm.dbg.declare ( metadata %class.C * %instance_C , metadata !29 , metadata !30 ) , !dbg !31
%d = getelementptr inbounds %class.C , %class.C * %instance_C , i32 0 , i32 0 , !dbg !32
store i32 8 , i32 * %d , align 4 , !dbg !32
%0 = load i32 , i32 * @_ZN1C1cE , align 4 , !dbg !33
ret i32 %0 , !dbg !33
2013-01-17 03:53:47 +08:00
}
2016-12-22 08:45:21 +08:00
; Function Attrs: nounwind readnone
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #1
attributes #0 = { nounwind uwtable }
attributes #1 = { nounwind readnone }
!llvm.dbg.cu = ! { !22 }
!llvm.module.flags = ! { !25 }
2013-01-17 03:53:47 +08:00
2017-08-31 02:06:51 +08:00
!0 = !DIGlobalVariableExpression ( var: !1 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!1 = !DIGlobalVariable ( name: "a" , linkageName: "_ZN1C1aE" , scope: null , file: !2 , line: 14 , type: !3 , isLocal: false , isDefinition: true , declaration: !4 )
!2 = !DIFile ( filename: "/usr/local/google/home/blaikie/Development/llvm/src/tools/clang/test/CodeGenCXX/debug-info-static-member.cpp" , directory: "/home/blaikie/local/Development/llvm/build/clang/x86-64/Debug/llvm" )
!3 = !DIBasicType ( name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!4 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "a" , scope: !5 , file: !2 , line: 3 , baseType: !3 , flags: D I F l a g P r i v a t e | D I F l a g S t a t i c M e m b e r )
!5 = !DICompositeType ( tag: D W _ T A G _ c l a s s _ type , name: "C" , file: !2 , line: 1 , size: 32 , align: 32 , elements: !6 )
!6 = ! { !4 , !7 , !10 , !11 , !14 , !15 , !17 }
!7 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "const_a" , scope: !5 , file: !2 , line: 4 , baseType: !8 , flags: D I F l a g P r i v a t e | D I F l a g S t a t i c M e m b e r , extraData: i1 true )
!8 = !DIDerivedType ( tag: D W _ T A G _ c o n s t _ type , baseType: !9 )
!9 = !DIBasicType ( name: "bool" , size: 8 , align: 8 , encoding: D W _ A T E _ b o o l e a n )
!10 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "b" , scope: !5 , file: !2 , line: 6 , baseType: !3 , flags: D I F l a g P r o t e c t e d | D I F l a g S t a t i c M e m b e r )
!11 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "const_b" , scope: !5 , file: !2 , line: 7 , baseType: !12 , flags: D I F l a g P r o t e c t e d | D I F l a g S t a t i c M e m b e r , extraData: float 0x40091EB860000000 )
!12 = !DIDerivedType ( tag: D W _ T A G _ c o n s t _ type , baseType: !13 )
!13 = !DIBasicType ( name: "float" , size: 32 , align: 32 , encoding: D W _ A T E _ float )
!14 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "c" , scope: !5 , file: !2 , line: 9 , baseType: !3 , flags: D I F l a g P u b l i c | D I F l a g S t a t i c M e m b e r )
!15 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "const_c" , scope: !5 , file: !2 , line: 10 , baseType: !16 , flags: D I F l a g P u b l i c | D I F l a g S t a t i c M e m b e r , extraData: i32 18 )
!16 = !DIDerivedType ( tag: D W _ T A G _ c o n s t _ type , baseType: !3 )
!17 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "d" , scope: !5 , file: !2 , line: 11 , baseType: !3 , size: 32 , align: 32 , flags: D I F l a g P u b l i c )
2017-08-31 02:06:51 +08:00
!18 = !DIGlobalVariableExpression ( var: !19 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!19 = !DIGlobalVariable ( name: "b" , linkageName: "_ZN1C1bE" , scope: null , file: !2 , line: 15 , type: !3 , isLocal: false , isDefinition: true , declaration: !10 )
2017-08-31 02:06:51 +08:00
!20 = !DIGlobalVariableExpression ( var: !21 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!21 = !DIGlobalVariable ( name: "c" , linkageName: "_ZN1C1cE" , scope: null , file: !2 , line: 16 , type: !3 , isLocal: false , isDefinition: true , declaration: !14 )
!22 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !2 , producer: "clang version 3.3 (trunk 171914)" , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !23 , retainedTypes: !23 , globals: !24 , imports: !23 )
!23 = ! { }
!24 = ! { !0 , !18 , !20 }
!25 = ! { i32 1 , !"Debug Info Version" , i32 3 }
!26 = distinct !DISubprogram ( name: "main" , scope: !2 , file: !2 , line: 18 , type: !27 , isLocal: false , isDefinition: true , scopeLine: 23 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !22 , variables: !23 )
!27 = !DISubroutineType ( types: !28 )
!28 = ! { !3 }
!29 = !DILocalVariable ( name: "instance_C" , scope: !26 , file: !2 , line: 20 , type: !5 )
!30 = !DIExpression ( )
!31 = !DILocation ( line: 20 , scope: !26 )
!32 = !DILocation ( line: 21 , scope: !26 )
!33 = !DILocation ( line: 22 , scope: !26 )
2013-01-17 03:53:47 +08:00
; PRESENT verifies that static member declarations have these attributes:
2015-03-11 06:44:45 +08:00
; external, declaration, accessibility, and either DW_AT_linkage_name
2013-01-17 03:53:47 +08:00
; (for variables) or DW_AT_const_value (for constants).
;
; PRESENT: .debug_info contents:
2014-10-24 03:12:43 +08:00
; PRESENT: DW_TAG_variable
; PRESENT-NEXT: DW_AT_specification {{.*}} "a"
; PRESENT-NEXT: DW_AT_location
; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE"
2013-01-17 03:53:47 +08:00
; PRESENT: DW_TAG_class_type
; PRESENT-NEXT: DW_AT_name {{.*}} "C"
2014-10-10 23:51:02 +08:00
; PRESENT: DW_TAG_member
2013-01-17 03:53:47 +08:00
; PRESENT-NEXT: DW_AT_name {{.*}} "a"
; PRESENT: DW_AT_external
; PRESENT: DW_AT_declaration
2014-09-05 03:39:20 +08:00
; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
2013-01-17 03:53:47 +08:00
; PRESENT: DW_TAG_member
; PRESENT-NEXT: DW_AT_name {{.*}} "const_a"
; PRESENT: DW_AT_external
; PRESENT: DW_AT_declaration
2014-09-05 03:39:20 +08:00
; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
2013-01-20 07:00:25 +08:00
; PRESENT: DW_AT_const_value {{.*}} (1)
2014-10-10 23:51:02 +08:00
; PRESENT: DW_TAG_member
2013-01-17 03:53:47 +08:00
; PRESENT-NEXT: DW_AT_name {{.*}} "b"
2014-09-05 03:39:20 +08:00
; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
2013-01-17 03:53:47 +08:00
; PRESENT: DW_TAG_member
; PRESENT-NEXT: DW_AT_name {{.*}} "const_b"
2014-09-05 03:39:20 +08:00
; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
2014-05-11 23:47:39 +08:00
; PRESENT: DW_AT_const_value [DW_FORM_udata] (1078523331)
2014-10-10 23:51:02 +08:00
; PRESENT: DW_TAG_member
2013-01-17 03:53:47 +08:00
; PRESENT-NEXT: DW_AT_name {{.*}} "c"
2014-09-05 03:39:20 +08:00
; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
2013-01-17 03:53:47 +08:00
; PRESENT: DW_TAG_member
; PRESENT-NEXT: DW_AT_name {{.*}} "const_c"
2014-09-05 03:39:20 +08:00
; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
2013-08-28 07:49:04 +08:00
; PRESENT: DW_AT_const_value {{.*}} (18)
2013-01-17 03:53:47 +08:00
; While we're here, a normal member has data_member_location and
; accessibility attributes.
; PRESENT: DW_TAG_member
; PRESENT-NEXT: DW_AT_name {{.*}} "d"
; PRESENT: DW_AT_data_member_location
2014-09-05 03:39:20 +08:00
; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
2013-01-17 03:53:47 +08:00
; PRESENT: NULL
; Definitions point back to their declarations, and have a location.
; PRESENT: DW_TAG_variable
2014-10-10 23:51:02 +08:00
; PRESENT-NEXT: DW_AT_specification {{.*}} "b"
2013-01-17 03:53:47 +08:00
; PRESENT-NEXT: DW_AT_location
2014-03-14 07:26:25 +08:00
; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE"
2013-01-17 03:53:47 +08:00
; PRESENT: DW_TAG_variable
2014-10-10 23:51:02 +08:00
; PRESENT-NEXT: DW_AT_specification {{.*}} "c"
2013-01-17 03:53:47 +08:00
; PRESENT-NEXT: DW_AT_location
2014-03-14 07:26:25 +08:00
; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE"
2013-01-17 03:53:47 +08:00
2013-02-28 07:21:02 +08:00
; For Darwin gdb:
; DARWINP: .debug_info contents:
2014-10-24 03:12:43 +08:00
; DARWINP: DW_TAG_variable
; DARWINP-NEXT: DW_AT_specification {{.*}} "a"
; DARWINP-NEXT: DW_AT_location
; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE"
2013-02-28 07:21:02 +08:00
; DARWINP: DW_TAG_class_type
; DARWINP-NEXT: DW_AT_name {{.*}} "C"
2014-10-10 23:51:02 +08:00
; DARWINP: DW_TAG_member
2013-02-28 07:21:02 +08:00
; DARWINP-NEXT: DW_AT_name {{.*}} "a"
; DARWINP: DW_AT_external
; DARWINP: DW_AT_declaration
2014-09-05 03:39:20 +08:00
; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
2013-02-28 07:21:02 +08:00
; DARWINP: DW_TAG_member
; DARWINP-NEXT: DW_AT_name {{.*}} "const_a"
; DARWINP: DW_AT_external
; DARWINP: DW_AT_declaration
2014-09-05 03:39:20 +08:00
; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
2013-02-28 07:21:02 +08:00
; DARWINP: DW_AT_const_value {{.*}} (1)
2014-10-10 23:51:02 +08:00
; DARWINP: DW_TAG_member
2013-02-28 07:21:02 +08:00
; DARWINP-NEXT: DW_AT_name {{.*}} "b"
2014-09-05 03:39:20 +08:00
; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
2013-02-28 07:21:02 +08:00
; DARWINP: DW_TAG_member
; DARWINP-NEXT: DW_AT_name {{.*}} "const_b"
2014-09-05 03:39:20 +08:00
; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
2014-05-11 23:47:39 +08:00
; DARWINP: DW_AT_const_value [DW_FORM_udata] (1078523331)
2014-10-10 23:51:02 +08:00
; DARWINP: DW_TAG_member
2013-02-28 07:21:02 +08:00
; DARWINP-NEXT: DW_AT_name {{.*}} "c"
2014-09-05 03:39:20 +08:00
; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
2013-02-28 07:21:02 +08:00
; DARWINP: DW_TAG_member
; DARWINP-NEXT: DW_AT_name {{.*}} "const_c"
2014-09-05 03:39:20 +08:00
; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
2013-08-28 07:49:04 +08:00
; DARWINP: DW_AT_const_value {{.*}} (18)
2013-02-28 07:21:02 +08:00
; While we're here, a normal member has data_member_location and
; accessibility attributes.
; DARWINP: DW_TAG_member
; DARWINP-NEXT: DW_AT_name {{.*}} "d"
; DARWINP: DW_AT_data_member_location
2014-09-05 03:39:20 +08:00
; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
2013-02-28 07:21:02 +08:00
; DARWINP: NULL
; Definitions point back to their declarations, and have a location.
; DARWINP: DW_TAG_variable
2014-10-10 23:51:02 +08:00
; DARWINP-NEXT: DW_AT_specification {{.*}} "b"
2013-02-28 07:21:02 +08:00
; DARWINP-NEXT: DW_AT_location
2014-03-14 07:26:25 +08:00
; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE"
2013-02-28 07:21:02 +08:00
; DARWINP: DW_TAG_variable
2014-10-10 23:51:02 +08:00
; DARWINP-NEXT: DW_AT_specification {{.*}} "c"
2013-02-28 07:21:02 +08:00
; DARWINP-NEXT: DW_AT_location
2014-03-14 07:26:25 +08:00
; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE"
2013-02-28 07:21:02 +08:00
2013-01-17 03:53:47 +08:00
; ABSENT verifies that static member declarations do not have either
; DW_AT_location or DW_AT_data_member_location; also, variables do not
2014-03-14 07:26:25 +08:00
; have DW_AT_const_value and constants do not have DW_AT_linkage_name.
2013-01-17 03:53:47 +08:00
;
; ABSENT: .debug_info contents:
; ABSENT: DW_TAG_member
; ABSENT: DW_AT_name {{.*}} "a"
; ABSENT-NOT: DW_AT_const_value
; ABSENT-NOT: location
; ABSENT: DW_AT_name {{.*}} "const_a"
2014-03-14 07:26:25 +08:00
; ABSENT-NOT: DW_AT_linkage_name
2013-01-17 03:53:47 +08:00
; ABSENT-NOT: location
; ABSENT: DW_AT_name {{.*}} "b"
; ABSENT-NOT: DW_AT_const_value
; ABSENT-NOT: location
; ABSENT: DW_AT_name {{.*}} "const_b"
2014-03-14 07:26:25 +08:00
; ABSENT-NOT: DW_AT_linkage_name
2013-01-17 03:53:47 +08:00
; ABSENT-NOT: location
; ABSENT: DW_AT_name {{.*}} "c"
; ABSENT-NOT: DW_AT_const_value
; ABSENT-NOT: location
; ABSENT: DW_AT_name {{.*}} "const_c"
2014-03-14 07:26:25 +08:00
; ABSENT-NOT: DW_AT_linkage_name
2013-01-17 03:53:47 +08:00
; ABSENT-NOT: location
; While we're here, a normal member does not have a linkage name, constant
; value, or DW_AT_location.
; ABSENT: DW_AT_name {{.*}} "d"
2014-03-14 07:26:25 +08:00
; ABSENT-NOT: DW_AT_linkage_name
2013-01-17 03:53:47 +08:00
; ABSENT-NOT: DW_AT_const_value
; ABSENT-NOT: DW_AT_location
; ABSENT: NULL
2013-02-28 07:21:02 +08:00
; For Darwin gdb:
; DARWINA: .debug_info contents:
; DARWINA: DW_TAG_member
; DARWINA: DW_AT_name {{.*}} "a"
; DARWINA-NOT: DW_AT_const_value
; DARWINA-NOT: location
; DARWINA: DW_AT_name {{.*}} "const_a"
2014-03-14 07:26:25 +08:00
; DARWINA-NOT: DW_AT_linkage_name
2013-02-28 07:21:02 +08:00
; DARWINA-NOT: location
; DARWINA: DW_AT_name {{.*}} "b"
; DARWINA-NOT: DW_AT_const_value
; DARWINA-NOT: location
; DARWINA: DW_AT_name {{.*}} "const_b"
2014-03-14 07:26:25 +08:00
; DARWINA-NOT: DW_AT_linkage_name
2013-02-28 07:21:02 +08:00
; DARWINA-NOT: location
; DARWINA: DW_AT_name {{.*}} "c"
; DARWINA-NOT: DW_AT_const_value
; DARWINA-NOT: location
; DARWINA: DW_AT_name {{.*}} "const_c"
2014-03-14 07:26:25 +08:00
; DARWINA-NOT: DW_AT_linkage_name
2013-02-28 07:21:02 +08:00
; DARWINA-NOT: location
; While we're here, a normal member does not have a linkage name, constant
; value, or DW_AT_location.
; DARWINA: DW_AT_name {{.*}} "d"
2014-03-14 07:26:25 +08:00
; DARWINA-NOT: DW_AT_linkage_name
2013-02-28 07:21:02 +08:00
; DARWINA-NOT: DW_AT_const_value
; DARWINA-NOT: DW_AT_location
; DARWINA: NULL