llcppsigfetch:qualified name refer

This commit is contained in:
luoliwoshang
2024-08-22 18:07:01 +08:00
parent eb4d721175
commit 319e746a55
3 changed files with 118 additions and 0 deletions

View File

@@ -507,6 +507,20 @@ func (ct *Converter) ProcessElaboratedType(t clang.Type) ast.Expr {
} }
} }
// qualified name
// 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{ return &ast.Ident{
Name: typeName, Name: typeName,
} }

View File

@@ -207,6 +207,101 @@ TestScope Case 5:
} }
} }
TestScope Case 6:
{
"temp.h": {
"decls": [{
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": {
"X": {
"Name": "c"
},
"Parent": {
"X": {
"Name": "b"
},
"Parent": {
"Name": "a"
}
}
},
"Name": {
"Name": "c"
},
"Type": {
"Tag": 3,
"Fields": {
"List": []
},
"Methods": [{
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": {
"X": {
"Name": "c"
},
"Parent": {
"X": {
"Name": "b"
},
"Parent": {
"Name": "a"
}
}
},
"Name": {
"Name": "foo"
},
"Type": {
"Params": {
"List": []
},
"Ret": {
"Kind": 0,
"Flags": 0
}
}
}]
}
}, {
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": null,
"Name": {
"Name": "C"
},
"Type": {
"X": {
"Name": "c"
},
"Parent": {
"X": {
"Name": "b"
},
"Parent": {
"Name": "a"
}
}
}
}],
"includes": [],
"macros": []
}
}
#stderr #stderr

View File

@@ -25,6 +25,15 @@ func TestScope() {
void foo(); void foo();
}; };
}`, }`,
`namespace a {
namespace b {
class c {
void foo();
};
}
}
typedef a::b::c C;`,
} }
test.RunTest("TestScope", testCases) test.RunTest("TestScope", testCases)
} }