Skip to content

Commit 618dafe

Browse files
committed
Recommend the --dump-preprocessed-input flag in CONTRIBUTING.md
It is both more correct and easier than using clang manually.
1 parent d910f34 commit 618dafe

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

CONTRIBUTING.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,21 @@ With those two things in hand, running `creduce` looks like this:
272272

273273
### Isolating Your Test Case
274274

275-
Use the `-save-temps` flag to make Clang spit out its intermediate
276-
representations when compiling the test case into an object file.
275+
If you're using `bindgen` as a command line tool, pass
276+
`--dump-preprocessed-input` flag.
277277

278-
$ clang[++ -x c++ --std=c++14] -save-temps -c my_test_case.h
278+
If you're using `bindgen` as a Rust library, invoke the
279+
`bindgen::Builder::dump_preprocessed_input` method where you call
280+
`bindgen::Builder::generate`.
279281

280-
There should now be a `my_test_case.ii` file, which is the results after the C
281-
pre-processor has processed all the `#include`s, `#define`s, and `#ifdef`s. This
282-
is generally what we're looking for.
282+
Afterwards, there should be a `__bindgen.i` or `__bindgen.ii` file containing
283+
the combined and preprocessed input headers, which is usable as an isolated,
284+
standalone test case.
285+
286+
Note that the preprocessor likely removed all comments, so if the bug you're
287+
trying to pin down involves source annotations (for example, `/** <div
288+
rustbindgen opaque> */`), then you will have to manually reapply them to the
289+
preprocessed file.
283290

284291
### Writing a Predicate Script
285292

0 commit comments

Comments
 (0)