-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory usage and permissive parsing with sqlite3 #363
Comments
Here is the output of
|
Notice that I like that this project can parse |
@mingodad Most memory is used for temporary tokens and data structures during preprocessing, along with symbols in the scope chain. The AST is stored in an arena, which should be fine. I'm working on code to reduce the preprocessor memory usage, then we should see numbers similar to other C++ frontends. |
Thank you for reply !
|
Doing the above experiment I've noticed that using the code shown bellow to show where the declaration start doesn't work in all cases because the
There is a way to get the token usage location ? |
@mingodad Thanks for sharing your changes, I will have a look at them this weekend. Getting the ranges of the declarations using first/last SourceLocation should work, that is unless the declarations are generated from macro expansions, in such cases the preprocessor may assign token positions from the macro definitions, this is bug, I should probably fix this. I wrote a simple Web app to test the tokens and AST locations. Unfortunately the current JavaScript API does not have support to resolve cxx -E -P sqlite3.c -toolchain linux -o sqlite3.i then paste the content of sqlite3.i to https://robertoraggi.github.io/cplusplus/?path=/story/cxxfrontend-syntaxtree--basic |
With the latest changes I'm getting errors when trying to parse
|
Which version of sqlite are you using? I downloaded a random version, and it appears to parse correctly with gcc 11 and 14 headers, as long as I pass the |
I isolated the problem with this test:
Testing with I'm attaching (see bellow) the output of:
Also when trying to parse the preprocessed files
|
This is the parser being too strict and not allowing spaces between brackets in C++ attributes. There are instances where the preprocessor introduces spaces, which can break the parsing of the preprocessor’s output. It should be fixed in #416 You can’t parse the output preprocessed by gcc with cxx because gcc has a few built-in functions that I haven’t implemented yet (for example, (https://github.com/robertoraggi/cplusplus/blob/main/.github/workflows/ci.yml#L54) |
On the other hand, parsing the output of cxx's preprocessor with gcc might work, but it all depends on which built-in (tested with __has_builtin) gcc is expecting. You may need to pass -w to gcc to avoid reporting warning from system headers.
|
Trying to parse
sqlite3.c
with this project I found that it can parse it without showing any error/warnings but uses a bit more memory thangcc/g++
(cxx=3,000,000 allocations, g++=500,000 allocations):But renaming
sqlite3.c
tosqlite3.cpp
and fixing several errors pointed out byg++
then this project still doesn't show any warning/error whileg++
needs-fpermissive
to parse it and show several warnings:I'm attaching the files used by this test:
sqlite3-c-cpp.zip
The text was updated successfully, but these errors were encountered: