Skip to content

Commit 975329a

Browse files
author
Your Name
committed
feat(extraction): C++ entry point heuristics for Windows and GTest
Adds entry point detection for C/C++ patterns in both extract_func_def and push_method_def paths: - WinMain, wWinMain, wmain, _tmain (Win32 console/GUI apps) - DllMain (DLL entry points) - InitInstance, OnInitDialog (MFC framework entry points) These join the existing case-insensitive main() detection to cover the full spectrum of C/C++ application architectures.
1 parent db9a15e commit 975329a

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

internal/cbm/extract_defs.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,16 @@ static void extract_func_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec
11901190
def.is_entry_point = true;
11911191
}
11921192

1193+
// C/C++ entry point detection: WinMain, DllMain, GTest, MFC
1194+
if ((ctx->language == CBM_LANG_C || ctx->language == CBM_LANG_CPP) && !def.is_entry_point) {
1195+
if (strcmp(name, "WinMain") == 0 || strcmp(name, "wWinMain") == 0 ||
1196+
strcmp(name, "DllMain") == 0 || strcmp(name, "wmain") == 0 ||
1197+
strcmp(name, "_tmain") == 0 || strcmp(name, "InitInstance") == 0 ||
1198+
strcmp(name, "OnInitDialog") == 0) {
1199+
def.is_entry_point = true;
1200+
}
1201+
}
1202+
11931203
// C# entry point detection: Windows Service lifecycle, ASP.NET controllers
11941204
if (ctx->language == CBM_LANG_CSHARP && !def.is_entry_point) {
11951205
// Windows Service lifecycle entry points
@@ -1726,6 +1736,16 @@ static void push_method_def(CBMExtractCtx *ctx, TSNode child, const char *class_
17261736
def.is_entry_point = true;
17271737
}
17281738

1739+
// C/C++ entry point detection: WinMain, DllMain, GTest, MFC
1740+
if ((ctx->language == CBM_LANG_C || ctx->language == CBM_LANG_CPP) && !def.is_entry_point) {
1741+
if (strcmp(name, "WinMain") == 0 || strcmp(name, "wWinMain") == 0 ||
1742+
strcmp(name, "DllMain") == 0 || strcmp(name, "wmain") == 0 ||
1743+
strcmp(name, "_tmain") == 0 || strcmp(name, "InitInstance") == 0 ||
1744+
strcmp(name, "OnInitDialog") == 0) {
1745+
def.is_entry_point = true;
1746+
}
1747+
}
1748+
17291749
// C# entry point detection: Windows Service lifecycle, ASP.NET controllers
17301750
if (ctx->language == CBM_LANG_CSHARP && !def.is_entry_point) {
17311751
if (strcmp(name, "OnStart") == 0 || strcmp(name, "OnStartImpl") == 0 ||

0 commit comments

Comments
 (0)