For header units we build the top level module directly from the header
that it represents and macros defined in this TU need to be emitted (when
such a definition is live at the end of the TU).
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
updated to remove a single-use variable.
Having some difficulty in reproducing the CI fails outside the harness, however the
code setting the removed variable could have faulted if there was no macro data for
the identifier. Set the IsHeaderUnit variable explicitly.
Maybe it's worth to add a test from: http://eel.is/c++draft/cpp.import#8
clang/include/clang/Serialization/ASTWriter.h | ||
---|---|---|
128–129 | I think the member is redundant. I thought we could use WritingModule->isHeaderUnit() to replace it. | |
clang/lib/Serialization/ASTWriter.cpp | ||
2286–2287 | We could replace the use of Mod with WritingModule too. (If I don't misread the code) | |
2356–2376 | Is it possible to merge the implementation with the following for PCH? It looks like there are some redundancies. | |
2358–2360 | How about to add comments to show the different logic of emitting macros for header unit and PCH? I guess other readers might be confusing too. |
clang/include/clang/Serialization/ASTWriter.h | ||
---|---|---|
128–129 | yeah we can do this - I added a "isHeaderUnit()" method to Module.h to do this. | |
clang/lib/Serialization/ASTWriter.cpp | ||
2356–2376 | Well, that was what I had originally, I actually split it out as it is now because the difference in the logic around which macros are written out was making the code pretty confusing to read. If there's a strong feeling about this, perhaps we can see if there's some way to factor it (perhaps with some place-holder vars). |
I feel good if we could add the test from: http://eel.is/c++draft/cpp.import#8.
clang/include/clang/Serialization/ASTWriter.h | ||
---|---|---|
21 | This is redundant too. | |
clang/lib/Serialization/ASTWriter.cpp | ||
2356–2376 | I agree with you. I tried to refactor it myself and find things didn't get better. |
I agree we should have tests based on all the relevant examples in the standard.
However, that specific example is not connected with building header units, but instead is connected with consuming various preprocessor directives etc. when building a regular module. We actually already have some of the tests in diagnosing bad imports.
So I think that (after this series is in) we should be in a position to add some more of the examples in the standard - as a follow-on patch, does that make sense?
clang/test/Modules/cxx20-hu-04.cpp | ||
---|---|---|
22 | On Windows, when the path starts with C:\Users\..., I am seeing error: 'warning' diagnostics seen but not expected: Line 1: \U used with no following hex digits; treating as '\' followed by identifier 1 error generated. Looking at this test, TDIR is only used as a FileCheck variable, can it just be removed from this line? |
clang/test/Modules/cxx20-hu-04.cpp | ||
---|---|---|
22 | Sorry about that, Yes, I think that change should be fine - I will take care of it, |
applied [C++20][Modules] Fix a testcase warning on Windows [NFC].
https://github.com/llvm/llvm-project/commit/1f0b8ba47ab0f1dc678099d4830d0cc0d10850b6
should be fixed now.
This is redundant too.