Update to Big Sur 15.5.2 / Clang 12.0.5. Improved handing of avaiability
attributes and boolean values.
This commit is contained in:
@@ -89,6 +89,8 @@ func Parse(fullline string) Node {
|
||||
return parseBlockPointerType(line)
|
||||
case "BreakStmt":
|
||||
return parseBreakStmt(line)
|
||||
case "BuiltinAttr":
|
||||
return parseBuiltinAttr(line)
|
||||
case "BuiltinType":
|
||||
return parseBuiltinType(line)
|
||||
case "CallExpr":
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package ast
|
||||
|
||||
// BuiltinAttr is a type of attribute that is optionally attached to a variable
|
||||
// or struct field definition.
|
||||
type BuiltinAttr struct {
|
||||
Addr Address
|
||||
Pos Position
|
||||
ChildNodes []Node
|
||||
Implicit bool
|
||||
Inherited bool
|
||||
Value string
|
||||
}
|
||||
|
||||
func parseBuiltinAttr(line string) Node {
|
||||
groups := groupsFromRegex(
|
||||
`<(?P<position>.*)>
|
||||
(?P<inherited> Inherited)?
|
||||
(?P<implicit> Implicit)?
|
||||
(?P<value> \d+)?
|
||||
`,
|
||||
line,
|
||||
)
|
||||
if groups == nil {
|
||||
return &Unknown{}
|
||||
}
|
||||
|
||||
return &BuiltinAttr{
|
||||
Addr: ParseAddress(groups["address"]),
|
||||
Pos: NewPositionFromString(groups["position"]),
|
||||
ChildNodes: []Node{},
|
||||
Inherited: len(groups["inherited"]) > 0,
|
||||
Implicit: len(groups["implicit"]) > 0,
|
||||
Value: groups["value"],
|
||||
}
|
||||
}
|
||||
|
||||
// AddChild adds a new child node. Child nodes can then be accessed with the
|
||||
// Children attribute.
|
||||
func (n *BuiltinAttr) AddChild(node Node) {
|
||||
n.ChildNodes = append(n.ChildNodes, node)
|
||||
}
|
||||
|
||||
// Address returns the numeric address of the node. See the documentation for
|
||||
// the Address type for more information.
|
||||
func (n *BuiltinAttr) Address() Address {
|
||||
return n.Addr
|
||||
}
|
||||
|
||||
// Children returns the child nodes. If this node does not have any children or
|
||||
// this node does not support children it will always return an empty slice.
|
||||
func (n *BuiltinAttr) Children() []Node {
|
||||
return n.ChildNodes
|
||||
}
|
||||
|
||||
// Position returns the position in the original source code.
|
||||
func (n *BuiltinAttr) Position() Position {
|
||||
return n.Pos
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBuiltinAttr(t *testing.T) {
|
||||
nodes := map[string]testNode{
|
||||
`0x7fa1488273a0 <line:7:4, line:11:4>`: testNode{&BuiltinAttr{
|
||||
Addr: 0x7fa1488273a0,
|
||||
Pos: NewPositionFromString("line:7:4, line:11:4"),
|
||||
ChildNodes: []Node{},
|
||||
Inherited: false,
|
||||
Implicit: false,
|
||||
},
|
||||
0x7fa1488273a0,
|
||||
NewPositionFromString("line:7:4, line:11:4"),
|
||||
[]Node{},
|
||||
},
|
||||
`0x5605ceaf4b88 <col:12> Implicit`: testNode{&BuiltinAttr{
|
||||
Addr: 0x5605ceaf4b88,
|
||||
Pos: NewPositionFromString("col:12"),
|
||||
ChildNodes: []Node{},
|
||||
Inherited: false,
|
||||
Implicit: true,
|
||||
},
|
||||
0x5605ceaf4b88,
|
||||
NewPositionFromString("col:12"),
|
||||
[]Node{},
|
||||
},
|
||||
`0x4153c50 </usr/include/unistd.h:779:46> Inherited`: testNode{&BuiltinAttr{
|
||||
Addr: 0x4153c50,
|
||||
Pos: NewPositionFromString("/usr/include/unistd.h:779:46"),
|
||||
ChildNodes: []Node{},
|
||||
Inherited: true,
|
||||
Implicit: false,
|
||||
},
|
||||
0x4153c50,
|
||||
NewPositionFromString("/usr/include/unistd.h:779:46"),
|
||||
[]Node{},
|
||||
},
|
||||
`0x1038b8828 <col:20> Inherited Implicit`: testNode{&BuiltinAttr{
|
||||
Addr: 0x1038b8828,
|
||||
Pos: NewPositionFromString("col:20"),
|
||||
ChildNodes: []Node{},
|
||||
Inherited: true,
|
||||
Implicit: true,
|
||||
},
|
||||
0x1038b8828,
|
||||
NewPositionFromString("col:20"),
|
||||
[]Node{},
|
||||
},
|
||||
}
|
||||
|
||||
runNodeTests(t, nodes)
|
||||
}
|
||||
@@ -18,8 +18,8 @@ type ObjCInterfaceDecl struct {
|
||||
func parseObjCInterfaceDecl(line string) Node {
|
||||
groups := groupsFromRegex(
|
||||
`(?:prev (?P<prev>0x[0-9a-f]+) )?
|
||||
<(?P<position><invalid sloc>|.*)>
|
||||
(?P<position2> <invalid sloc>| col:\d+| line:\d+:\d+)
|
||||
<(?P<position><invalid sloc>|[^>]*)>
|
||||
(?P<position2>( <invalid sloc>| col:\d+| line:\d+:\d+| <scratch space>:\d+:\d+))
|
||||
(?P<implicit> implicit)?
|
||||
(?P<name> \w+)?`,
|
||||
line,
|
||||
|
||||
@@ -15,7 +15,7 @@ type ObjCMethodDecl struct {
|
||||
Parameters []string
|
||||
Type string
|
||||
Type2 string
|
||||
Attr string
|
||||
Attr []string
|
||||
ChildNodes []Node
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func parseObjCMethodDecl(line string) Node {
|
||||
(?P<implicit> implicit)?
|
||||
(?P<methodtype> \+| \-)
|
||||
(?P<names>.*?)
|
||||
'(?P<type>[^']*?)'
|
||||
'(?P<type>.*?)'
|
||||
(:'(?P<type2>.*?)')?
|
||||
(?P<attr> .*)?`,
|
||||
line,
|
||||
@@ -43,6 +43,8 @@ func parseObjCMethodDecl(line string) Node {
|
||||
params = parts[:len(parts)-1]
|
||||
}
|
||||
|
||||
attrs := strings.Split(strings.TrimSpace(groups["attr"]), " ")
|
||||
|
||||
return &ObjCMethodDecl{
|
||||
Addr: ParseAddress(groups["address"]),
|
||||
Pos: NewPositionFromString(groups["position"]),
|
||||
@@ -53,7 +55,7 @@ func parseObjCMethodDecl(line string) Node {
|
||||
Parameters: params,
|
||||
Type: strings.TrimSpace(groups["type"]),
|
||||
//Type2: strings.TrimSpace(groups["type2"]),
|
||||
Attr: strings.TrimSpace(groups["attr"]),
|
||||
Attr: attrs,
|
||||
ChildNodes: []Node{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ func TestObjCMethodDecl(t *testing.T) {
|
||||
ClassMethod: false,
|
||||
Parameters: []string{"isEqual"},
|
||||
Implicit: false,
|
||||
Attr: []string{""},
|
||||
ChildNodes: []Node{},
|
||||
},
|
||||
0x7f92a58a7570,
|
||||
@@ -32,6 +33,7 @@ func TestObjCMethodDecl(t *testing.T) {
|
||||
ClassMethod: false,
|
||||
Parameters: []string{},
|
||||
Implicit: false,
|
||||
Attr: []string{""},
|
||||
ChildNodes: []Node{},
|
||||
},
|
||||
0x7f92a58a7978,
|
||||
@@ -48,6 +50,7 @@ func TestObjCMethodDecl(t *testing.T) {
|
||||
ClassMethod: false,
|
||||
Parameters: []string{"respondsToSelector"},
|
||||
Implicit: false,
|
||||
Attr: []string{""},
|
||||
ChildNodes: []Node{},
|
||||
},
|
||||
0x7f92a58a82b0,
|
||||
@@ -64,6 +67,7 @@ func TestObjCMethodDecl(t *testing.T) {
|
||||
ClassMethod: true,
|
||||
Parameters: []string{"instancesRespondToSelector"},
|
||||
Implicit: false,
|
||||
Attr: []string{""},
|
||||
ChildNodes: []Node{},
|
||||
},
|
||||
0x7f92a58a82b0,
|
||||
@@ -80,6 +84,7 @@ func TestObjCMethodDecl(t *testing.T) {
|
||||
ClassMethod: false,
|
||||
Parameters: []string{"performSelector", "withObject", "withObject"},
|
||||
Implicit: false,
|
||||
Attr: []string{""},
|
||||
ChildNodes: []Node{},
|
||||
},
|
||||
0x7f92a58a7cd8,
|
||||
@@ -96,6 +101,7 @@ func TestObjCMethodDecl(t *testing.T) {
|
||||
ClassMethod: false,
|
||||
Parameters: []string{},
|
||||
Implicit: true,
|
||||
Attr: []string{""},
|
||||
ChildNodes: []Node{},
|
||||
},
|
||||
0x7f92a4459318,
|
||||
|
||||
Reference in New Issue
Block a user