Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(479)

Delta Between Two Patch Sets: src/cmd/cgo/gcc.go

Issue 6782097: code review 6782097: cmd/cgo: bool alignment/padding issue.
Left Patch Set: Created 11 years, 4 months ago
Right Patch Set: diff -r 2a4a89b1f36b https://code.google.com/p/go Created 11 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « misc/cgo/test/issue4417.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Annotate Ref in Prog with C types by parsing gcc debug output. 5 // Annotate Ref in Prog with C types by parsing gcc debug output.
6 // Conversion of debug output to Go types. 6 // Conversion of debug output to Go types.
7 7
8 package main 8 package main
9 9
10 import ( 10 import (
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 // gccCmd returns the gcc command line to use for compiling 764 // gccCmd returns the gcc command line to use for compiling
765 // the input. 765 // the input.
766 func (p *Package) gccCmd() []string { 766 func (p *Package) gccCmd() []string {
767 c := []string{ 767 c := []string{
768 p.gccName(), 768 p.gccName(),
769 "-Wall", // many warnings 769 "-Wall", // many warnings
770 "-Werror", // warnings are errors 770 "-Werror", // warnings are errors
771 "-o" + gccTmp(), // write object to tmp 771 "-o" + gccTmp(), // write object to tmp
772 "-gdwarf-2", // generate DWARF v2 debugg ing symbols 772 "-gdwarf-2", // generate DWARF v2 debugg ing symbols
773 "-fno-eliminate-unused-debug-types", // gets rid of e.g. untyped enum otherwise 773 "-fno-eliminate-unused-debug-types", // gets rid of e.g. untyped enum otherwise
774 » » "-c", // do not link 774 » » "-c", // do not link
775 » » "-xc", // input language is C 775 » » "-xc", // input language is C
776 } 776 }
777 c = append(c, p.GccOptions...) 777 c = append(c, p.GccOptions...)
778 c = append(c, p.gccMachine()...) 778 c = append(c, p.gccMachine()...)
779 c = append(c, "-") //read input from standard input 779 c = append(c, "-") //read input from standard input
780 return c 780 return c
781 } 781 }
782 782
783 // gccDebug runs gcc -gdwarf-2 over the C program stdin and 783 // gccDebug runs gcc -gdwarf-2 over the C program stdin and
784 // returns the corresponding DWARF data and, if present, debug data block. 784 // returns the corresponding DWARF data and, if present, debug data block.
785 func (p *Package) gccDebug(stdin []byte) (*dwarf.Data, binary.ByteOrder, []byte) { 785 func (p *Package) gccDebug(stdin []byte) (*dwarf.Data, binary.ByteOrder, []byte) {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 Len: c.intExpr(dt.Count), 1071 Len: c.intExpr(dt.Count),
1072 } 1072 }
1073 t.Go = gt // publish before recursive call 1073 t.Go = gt // publish before recursive call
1074 sub := c.Type(dt.Type, pos) 1074 sub := c.Type(dt.Type, pos)
1075 t.Align = sub.Align 1075 t.Align = sub.Align
1076 gt.Elt = sub.Go 1076 gt.Elt = sub.Go
1077 t.C.Set("typeof(%s[%d])", sub.C, dt.Count) 1077 t.C.Set("typeof(%s[%d])", sub.C, dt.Count)
1078 1078
1079 case *dwarf.BoolType: 1079 case *dwarf.BoolType:
1080 t.Go = c.bool 1080 t.Go = c.bool
1081 » » t.Align = c.ptrSize 1081 » » t.Align = 1
1082 1082
1083 case *dwarf.CharType: 1083 case *dwarf.CharType:
1084 if t.Size != 1 { 1084 if t.Size != 1 {
1085 fatalf("%s: unexpected: %d-byte char type - %s", lineno( pos), t.Size, dtype) 1085 fatalf("%s: unexpected: %d-byte char type - %s", lineno( pos), t.Size, dtype)
1086 } 1086 }
1087 t.Go = c.int8 1087 t.Go = c.int8
1088 t.Align = 1 1088 t.Align = 1
1089 1089
1090 case *dwarf.EnumType: 1090 case *dwarf.EnumType:
1091 if t.Align = t.Size; t.Align >= c.ptrSize { 1091 if t.Align = t.Size; t.Align >= c.ptrSize {
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 } 1598 }
1599 if prefix == "" { 1599 if prefix == "" {
1600 prefix = n.Name[:i+1] 1600 prefix = n.Name[:i+1]
1601 } else if prefix != n.Name[:i+1] { 1601 } else if prefix != n.Name[:i+1] {
1602 return "" 1602 return ""
1603 } 1603 }
1604 } 1604 }
1605 } 1605 }
1606 return prefix 1606 return prefix
1607 } 1607 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b