FunctionDeclBitfields.NumFunctionDeclBits is not updated when DeductionCandidateKind is incremented.
CXXConstructorDeclBitfields.NumCtorInitializers is shrunk as needed.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
For context this seems to be the patch that did not increment the bit field https://reviews.llvm.org/D139837
Thanks for working on this!
Looks good to me except for a couple typos.
Can you an an entry in clang/docs/ReleaseNotes.rst (mentioning the github issue)
clang/unittests/AST/ASTImporterTest.cpp | ||
---|---|---|
7836 | ImportFunctionDeclBitShouldNotOverwriteCtorDeclBits | |
clang/unittests/AST/DeclTest.cpp | ||
356 ↗ | (On Diff #551016) |
Can you an an entry in clang/docs/ReleaseNotes.rst (mentioning the github issue)
No problem!
clang/unittests/AST/ASTImporterTest.cpp | ||
---|---|---|
7836 | I added the case into DeclTest.cpp because i think it can cover the root cause for both testcases. How about remove the somewhat repeated one in ASTImporterTest.cpp? |
I also investigated whether we could count those bits at compile time and statically assert on them,
because a small typo or missed update could spend us a lot of time to dig for the cause.
My first step is trying to count number of bits for a single bitfield, this is promising based on this but
with a restriction, it only works on struct (default public fields), not class (default to private fields).
If we can implement this bitsizeof then we could have:
enum { NumFunctionDeclBits = offsetof(FunctionDeclBitfields, SClass) + offsetof(FunctionDeclBitfields, IsInline) + ... };
This can automatically update total number of bits if any of the existing one is updated.
The second step is trying to enumerate all bit fields at compile time so that we can totally fix this kind
of issue, but it seems not possible.
Any suggestions or advices? Is it even worth it to do it like this?
It would be great to be able to stattic_assert these sort of bugs. I think @aaron did some research in this area, it might be worth asking him how far he got!
clang/unittests/AST/ASTImporterTest.cpp | ||
---|---|---|
7836 | Now that you have written it, we can leave both tests i think. |
clang/unittests/AST/ASTImporterTest.cpp | ||
---|---|---|
7836 | OK! :-) |
clang/unittests/AST/DeclTest.cpp | ||
---|---|---|
368 ↗ | (On Diff #551037) | This dump is not needed? |
clang/unittests/AST/DeclTest.cpp | ||
---|---|---|
368 ↗ | (On Diff #551037) | Yeah it's for debug only, I'll remove it. |
I was never able to find a conforming way to do it without implementing something like a "bitwidth of" operator, which is something I was planning to propose to WG14 anyway for use with _BitInt. I've not implemented the extension yet though, and even if I did, it wouldn't help us with non-Clang host compilers, so I eventually gave up trying to automatically calculate the values.
Changes LGTM!
ImportFunctionDeclBitShouldNotOverwriteCtorDeclBits