llcppsigfetch:qualified name whith tag
This commit is contained in:
@@ -512,28 +512,12 @@ func (ct *Converter) ProcessElaboratedType(t clang.Type) ast.Expr {
|
|||||||
if tagValue, ok := tagMap[parts[0]]; ok {
|
if tagValue, ok := tagMap[parts[0]]; ok {
|
||||||
return &ast.TagExpr{
|
return &ast.TagExpr{
|
||||||
Tag: tagValue,
|
Tag: tagValue,
|
||||||
Name: &ast.Ident{Name: parts[1]},
|
Name: qualifiedExpr(parts[1]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// qualified name
|
return qualifiedExpr(typeName)
|
||||||
// todo(zzy): qualified name with tag,like struct A::B
|
|
||||||
if strings.Contains(typeName, "::") {
|
|
||||||
scopeParts := strings.Split(typeName, "::")
|
|
||||||
var expr ast.Expr = &ast.Ident{Name: scopeParts[0]}
|
|
||||||
for _, part := range scopeParts[1:] {
|
|
||||||
expr = &ast.ScopingExpr{
|
|
||||||
Parent: expr,
|
|
||||||
X: &ast.Ident{Name: part},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return expr
|
|
||||||
}
|
|
||||||
|
|
||||||
return &ast.Ident{
|
|
||||||
Name: typeName,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ct *Converter) ProcessBuiltinType(t clang.Type) *ast.BuiltinType {
|
func (ct *Converter) ProcessBuiltinType(t clang.Type) *ast.BuiltinType {
|
||||||
@@ -628,3 +612,15 @@ func toToken(tok clang.Token) token.Token {
|
|||||||
return token.Token(tok.Kind() + 1)
|
return token.Token(tok.Kind() + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func qualifiedExpr(name string) ast.Expr {
|
||||||
|
parts := strings.Split(name, "::")
|
||||||
|
var expr ast.Expr = &ast.Ident{Name: parts[0]}
|
||||||
|
for _, part := range parts[1:] {
|
||||||
|
expr = &ast.ScopingExpr{
|
||||||
|
Parent: expr,
|
||||||
|
X: &ast.Ident{Name: part},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return expr
|
||||||
|
}
|
||||||
|
|||||||
@@ -152,6 +152,23 @@ Type: a::b::c:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Type: class a::b::c:
|
||||||
|
{
|
||||||
|
"Name": {
|
||||||
|
"X": {
|
||||||
|
"Name": "c"
|
||||||
|
},
|
||||||
|
"Parent": {
|
||||||
|
"X": {
|
||||||
|
"Name": "b"
|
||||||
|
},
|
||||||
|
"Parent": {
|
||||||
|
"Name": "a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Tag": 3
|
||||||
|
}
|
||||||
|
|
||||||
#stderr
|
#stderr
|
||||||
todo: unknown builtin type: Ibm128
|
todo: unknown builtin type: Ibm128
|
||||||
|
|||||||
@@ -103,6 +103,14 @@ func TestNonBuiltinTypes() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
a::b::c`,
|
a::b::c`,
|
||||||
|
|
||||||
|
`namespace a {
|
||||||
|
namespace b {
|
||||||
|
class c {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class a::b::c`,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, t := range tests {
|
for _, t := range tests {
|
||||||
|
|||||||
Reference in New Issue
Block a user