-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
[CLANG-CL] ignores wpadded #130182
Merged
efriedma-quic
merged 12 commits into
llvm:main
from
theomagellan:clang-cl-ignores-Wpadded
Apr 2, 2025
Merged
[CLANG-CL] ignores wpadded #130182
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
09572af
chore(clang-format): formatted clang/lib/AST/RecordLayoutBuilder.cpp
theomagellan 60ddbaf
fix(clang-cl): added -Wpadded and -Wpadded-bitfield warning
theomagellan 0504894
Revert "chore(clang-format): formatted clang/lib/AST/RecordLayoutBuil…
theomagellan 93ee1dd
test(clang-cl): bitfield & struct padding
theomagellan a259c2b
refacto: made CheckFieldPadding a static helper
theomagellan ec85ec2
test(clang-cl): anonymous bitfield, union, alignas, derived padding
theomagellan b969498
refacto: removed inaccurate comment
theomagellan f722c6e
refacto(tests): moved folder and combined test files when possible
theomagellan 6c79da3
test(clang-cl): more bitfield padding tests
theomagellan ca61588
chore: clang-format
theomagellan 721da29
chore: updated clang release notes
theomagellan b7a0a65
Merge branch 'main' into clang-cl-ignores-Wpadded
theomagellan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: %clang_cc1 -triple x86_64-windows-msvc -fsyntax-only -verify -Wpadded %s | ||
|
||
struct __attribute__((ms_struct)) BitfieldStruct { // expected-warning {{padding size of 'BitfieldStruct' with 3 bytes to alignment boundary}} | ||
char c : 1; | ||
int : 0; // expected-warning {{padding struct 'BitfieldStruct' with 31 bits to align anonymous bit-field}} | ||
char i; | ||
}; | ||
|
||
struct __attribute__((ms_struct)) SevenBitfieldStruct { // expected-warning {{padding size of 'SevenBitfieldStruct' with 3 bytes to alignment boundary}} | ||
char c : 7; | ||
int : 0; // expected-warning {{padding struct 'SevenBitfieldStruct' with 25 bits to align anonymous bit-field}} | ||
char i; | ||
}; | ||
|
||
struct __attribute__((ms_struct)) SameUnitSizeBitfield { | ||
char c : 7; | ||
char : 1; // Same unit size attributes fall in the same unit + they fill the unit -> no padding | ||
char i; | ||
}; | ||
|
||
struct __attribute__((ms_struct)) DifferentUnitSizeBitfield { // expected-warning {{padding size of 'DifferentUnitSizeBitfield' with 3 bytes to alignment boundary}} | ||
char c : 7; | ||
int : 1; // expected-warning {{padding struct 'DifferentUnitSizeBitfield' with 25 bits to align anonymous bit-field}} | ||
char i; // expected-warning {{padding struct 'DifferentUnitSizeBitfield' with 31 bits to align 'i'}} | ||
}; | ||
|
||
int main() { | ||
BitfieldStruct b; | ||
SevenBitfieldStruct s; | ||
SameUnitSizeBitfield su; | ||
DifferentUnitSizeBitfield du; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// RUN: %clang_cc1 -triple x86_64-windows-msvc -fsyntax-only -verify -Wpadded %s | ||
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -Wpadded %s | ||
|
||
struct __attribute__((ms_struct)) Foo { // expected-warning {{padding size of 'Foo' with 3 bytes to alignment boundary}} | ||
int b : 1; | ||
char a; // expected-warning {{padding struct 'Foo' with 31 bits to align 'a'}} | ||
}; | ||
|
||
struct __attribute__((ms_struct)) AlignedStruct { // expected-warning {{padding size of 'AlignedStruct' with 4 bytes to alignment boundary}} | ||
char c; | ||
alignas(8) int i; // expected-warning {{padding struct 'AlignedStruct' with 7 bytes to align 'i'}} | ||
}; | ||
|
||
|
||
struct Base { | ||
int b; | ||
}; | ||
|
||
struct Derived : public Base { // expected-warning {{padding size of 'Derived' with 3 bytes to alignment boundary}} | ||
char c; | ||
}; | ||
|
||
union __attribute__((ms_struct)) Union { | ||
char c; | ||
long long u; | ||
}; | ||
|
||
struct __attribute__((ms_struct)) StructWithUnion { // expected-warning {{padding size of 'StructWithUnion' with 6 bytes to alignment boundary}} | ||
char c; | ||
int : 0; | ||
Union t; // expected-warning {{padding struct 'StructWithUnion' with 7 bytes to align 't'}} | ||
short i; | ||
}; | ||
|
||
int main() { | ||
Foo f; | ||
AlignedStruct a; | ||
Derived d; | ||
StructWithUnion swu; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be that RemainingBitsInField is not always initialized here?
When I add some printouts and compare a failing and passing build I see that when it fails RemainingBitsInField is 2767481344 which looks a bit odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, this is also my main suspicion. I will fix this later today.
Thank you for your thoroughness, I did not think to check with other compilers or do a valgrind check. Sorry for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you both! In line with our patch reversion policy https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy I've gone ahead and reverted so that the issue can be fixed without undue time pressure, and so bots can go green again in the meanwhile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know why the failed bots didn't show up as comments in this PR or is that something someone/somewhere should look into?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see an obvious reason why that didn't happen here - I've filed a bug on llvm-zorg llvm/llvm-zorg#427
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, there was an obvious reason. The GitHub PR reporting only kicks in if a builder built with this as the only commit that changed since the last build. The failing builders had more PRs than just this one in their changelist, so no comment on GitHub.