Add libclang based C++ header validation#23187
Conversation
|
Thanks for your pull request and interest in making D better, @dkorpel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#23187" |
thewilsonator
left a comment
There was a problem hiding this comment.
can we add to the tests to ensure that these specific changed do not regress in future?
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
I kinda meant to push this to another branch, but here we are. I pushed the new test target and updated the description. |
|
This is far more comprehensive than I meant to suggest. Nice! |
|
I know, this is a response to Iain's rightful complaining about the frequently broken headers (#23176 (comment)). I tried fixing frontend.h for a bit to compile, but it's a real hassle, so I figured maybe it's simpler to generate D tests from C code rather than C tests (or headers) from D code. |
Fix regressions from #23176, as well as many other mismatches found by a WIP new CI check that I hope to push soon(tm)
Update: adds a new CI check that verifies that the manually maintained C++ headers in
include/dmd/ stay in sync with the D
extern(C++)declarations in the compiler source.Checks enum constant values, field offsets and sizes, class instance sizes, vtable indices, and C++ mangled names.
A python script uses clang to walk over all .h files in the include directory, and generate D asserts for enums, fields, and functions with C++ mangling. It currently generates:
https://gist.github.com/dkorpel/f8de8ca519e8dcfc2adcd691af6203e1
Then it runs it with the D compiler and -version=IN_LLVM (to skip fields in version (MARS) blocks). Added to the C++ test targets in build.d so you can run it with: ./build.d cpp-layout-test