Skip to content

Commit

Permalink
warn_unused_result_attr: Add support for Inherited (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
kph authored and elliotchance committed May 4, 2018
1 parent 5f6253e commit 2c663bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ast/warn_unused_result_attr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ package ast
type WarnUnusedResultAttr struct {
Addr Address
Pos Position
Inherited bool
ChildNodes []Node
}

func parseWarnUnusedResultAttr(line string) *WarnUnusedResultAttr {
groups := groupsFromRegex(`<(?P<position>.*)>( warn_unused_result)?`, line)
groups := groupsFromRegex(`<(?P<position>.*)>(?P<inherited> Inherited)?( warn_unused_result)?`, line)

return &WarnUnusedResultAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Inherited: len(groups["inherited"]) > 0,
ChildNodes: []Node{},
}
}
Expand Down
8 changes: 8 additions & 0 deletions ast/warn_unused_result_attr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ func TestWarnUnusedResultAttr(t *testing.T) {
`0x7fa1d704d420 <col:60> warn_unused_result`: &WarnUnusedResultAttr{
Addr: 0x7fa1d704d420,
Pos: NewPositionFromString("col:60"),
Inherited: false,
ChildNodes: []Node{},
},
`0x1fac810 <line:481:52>`: &WarnUnusedResultAttr{
Addr: 0x1fac810,
Pos: NewPositionFromString("line:481:52"),
Inherited: false,
ChildNodes: []Node{},
},
`0x3794590 </home/kph/co/util-linux/libblkid/src/blkidP.h:374:19> Inherited`: &WarnUnusedResultAttr{
Addr: 0x3794590,
Pos: NewPositionFromString("/home/kph/co/util-linux/libblkid/src/blkidP.h:374:19"),
Inherited: true,
ChildNodes: []Node{},
},
}
Expand Down

0 comments on commit 2c663bc

Please sign in to comment.