-
Notifications
You must be signed in to change notification settings - Fork 116
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
When an error is encountered, provide the include trace/stack/whatever #50
Comments
It would be great to be able to report the include stack! (For what it's worth, The I suspect the most practical option is to provide documentation on using |
It seems like this may be doable simply from the source file itself, presuming https://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html gcc -E puts these directives into the output: # linenum filename flags The (space-separated) flags are:
As a result, you can simply treat "1" as "push" (with "3" setting a flag on it), "2" as "pop", and any directive with neither replaces the top-of-stack - that gives you the full include stack. Then, at each newline that does not end such a directive, increment the line number of the current top of the stack. EDIT: Oh, hm. Looks like |
Another alternative would be to use the libClang bindings, but that would be... big. However, the unified preprocessor would make some things easier (e.g. the use of |
I had no idea what those extra numbers meant. That's fascinating! In addition to changing the representation of I'd encourage you to open an issue on visq/language-c and see what that project's current maintainer thinks. Regarding libClang bindings: I tried that first, from Rust rather than Haskell, even. They are worthless for this project because they can't report the structure of expressions. It seems to me that the authors of libClang pushed it far enough to support Xcode's code completion needs and then stopped, or something along those lines. |
Already opened the ticket :P |
Also, huh, really? |
Getting the children worked fine. As I recall, what I couldn't get was "which operator is this binop?", and also "I know you're looking at a variable reference. Why are you telling me the expression type is 'unknown'?" At that point I gave up... Ah, I see you've filed visq/language-c#12. Excellent! I look forward to hearing how that goes. |
Hm, the C++ libClang seems to support that via |
I'm pretty sure it's libclang's C API that's missing that functionality, so there's nothing the Rust or Haskell bindings could do about it. At least, I couldn't find anything in the libclang documentation about it. But I didn't try, you know, asking anybody who might actually know what to do about it before I gave up and used the C parser I already understood—so you may have better luck. 😄 |
Seems upstream's implemented support; just waiting on memory impact before merge :D |
And upstream seems to have merged the change! 😄 0.7.0 is out with support for the include stack |
The error in #49 may be harder to eliminate than necessary, as I can't tell how the project arrived at the (very, very internal to the C library) header in question.
The text was updated successfully, but these errors were encountered: