You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I tried to parse C++ code, but always exception raised.
Excluded almost everything, I found file it causes - std string from msvc.
You can reproduce the error using following code string file = "C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.40.33807\\include\\string"; CppCompilation compilation = CppParser.ParseFiles(new List<string>() { file }, null);
Stack trace
at CppAst.CppModelBuilder.GetOrCreateDeclarationContainer(CXCursor cursor, Void* data) in D:\Projects.....\CppAst.NET\src\CppAst\CppModelBuilder.cs:line 142
Parsing at:
{Line 625, Column 9 in C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt.h to Line 629, Column 2 in C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt.h}
Clang doesn't provide support by default for MSVC header files, so you will have to setup this yourselve. There is a helper method CppParserOptions.ConfigureForWindowsMsvc that should help with this.
No, it's not a msvc-relative problem. At cppast 0.8.0-alpha001/clang 12 everything works fine without options manipulations. It seems, problem is in struct parsing (_Mbstatet {...} in this case), old version gets SemanticParent of kind CXCursorKind.CXCursor_UnexposedDecl = CXCursor_FirstDecl and container for structure set as _rootContainerContext.
New version work with SemanticParent = CXCursor_LinkageSpec and it falls at default Unhandled(cursor);
As far I understand one of this versions handle struct incorrectly.
I haven't been able to reproduce it in Debug with latest repository. Though, I found a problem in debug that should be fixed via c2cbfe5.
0.8.0 is extremely old and lots of things have changed regarding template parameter/argument parsing. I personally don't use/care about C++ parsing so you will have to investigate this further within the existing codebase.
Activity
xoofx commentedon Aug 19, 2024
Clang doesn't provide support by default for MSVC header files, so you will have to setup this yourselve. There is a helper method
CppParserOptions.ConfigureForWindowsMsvcthat should help with this.CppAst.NET/src/CppAst/CppParserOptions.cs
Lines 170 to 214 in 2eaee79
Braidon commentedon Aug 19, 2024
No, it's not a msvc-relative problem. At cppast 0.8.0-alpha001/clang 12 everything works fine without options manipulations. It seems, problem is in struct parsing (_Mbstatet {...} in this case), old version gets SemanticParent of kind CXCursorKind.CXCursor_UnexposedDecl = CXCursor_FirstDecl and container for structure set as _rootContainerContext.
New version work with SemanticParent = CXCursor_LinkageSpec and it falls at default Unhandled(cursor);
As far I understand one of this versions handle struct incorrectly.
Fix access to cppClass.FullName in debug that could fail (#106)
xoofx commentedon Aug 20, 2024
I haven't been able to reproduce it in Debug with latest repository. Though, I found a problem in debug that should be fixed via c2cbfe5.
0.8.0 is extremely old and lots of things have changed regarding template parameter/argument parsing. I personally don't use/care about C++ parsing so you will have to investigate this further within the existing codebase.
Add coverage roadmap tests and parser fixes (#86 #88 #106 #116)
xoofx commentedon Jun 7, 2026
Fixed via commit 320bc7e