Fix parsing of cc

This commit is contained in:
Guus Waals 2025-06-01 22:27:11 +08:00
parent 15ec7bd1f1
commit f2606cd72f
1 changed files with 13 additions and 2 deletions

View File

@ -217,8 +217,19 @@ CallingConvention getCallingConvention(TSNode node, const char *source_code) {
TSNode child = ts_node_child(node, i); TSNode child = ts_node_child(node, i);
const char *type = ts_node_type(child); const char *type = ts_node_type(child);
// Look for identifiers that might be calling conventions // Handle Microsoft calling convention modifiers (tree-sitter specific)
if (strcmp(type, "identifier") == 0) { if (strcmp(type, "ms_call_modifier") == 0) {
std::string text = extractNodeText(child, source_code);
if (text == "__fastcall" || text == "__FASTCALL") {
return CallingConvention::Fastcall;
} else if (text == "__stdcall" || text == "__STDCALL") {
return CallingConvention::Stdcall;
} else if (text == "__cdecl" || text == "__CDECL") {
return CallingConvention::Cdecl;
}
}
// Look for identifiers that might be calling conventions (fallback)
else if (strcmp(type, "identifier") == 0) {
std::string text = extractNodeText(child, source_code); std::string text = extractNodeText(child, source_code);
if (text == "__fastcall" || text == "__FASTCALL") { if (text == "__fastcall" || text == "__FASTCALL") {
return CallingConvention::Fastcall; return CallingConvention::Fastcall;