Skip to content

Commit fba9426

Browse files
[NFC] Fix new warnings in the headers
The newer version of clang will issue warnings in more cases, specifically, -Winvalid-offsetof and -Wunused-but-set-variable. This cleans up the new warnings issued from header, which shows up for every TU that includes them. Fixing them should make the remaining warnings easier to read.
1 parent 8f6ad4c commit fba9426

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

include/swift/Basic/HeaderFooterLayout.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ class size_without_trailing_padding {
2222
struct ExtraByte { char _size_without_trailing_padding_probe; };
2323
struct Probe: T, ExtraByte {};
2424
public:
25+
#pragma clang diagnostic push
26+
#pragma clang diagnostic ignored "-Winvalid-offsetof"
2527
enum { value = offsetof(Probe, _size_without_trailing_padding_probe) };
28+
#pragma clang diagnostic pop
2629
};
2730

2831
namespace detail {

include/swift/SIL/InstWrappers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct LoadOperation {
6060
/// TODO: Rather than use an optional here, we should include an invalid
6161
/// representation in LoadOwnershipQualifier.
6262
std::optional<LoadOwnershipQualifier> getOwnershipQualifier() const {
63-
if (auto *lbi = value.dyn_cast<LoadBorrowInst *>()) {
63+
if (value.dyn_cast<LoadBorrowInst *>()) {
6464
return std::nullopt;
6565
}
6666

include/swift/SIL/SILInstruction.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,9 +1195,12 @@ class SingleValueInstruction : public SILInstruction, public ValueBase {
11951195
};
11961196

11971197
struct SILNodeOffsetChecker {
1198+
#pragma clang diagnostic push
1199+
#pragma clang diagnostic ignored "-Winvalid-offsetof"
11981200
static_assert(offsetof(SingleValueInstruction, kind) ==
11991201
offsetof(NonSingleValueInstruction, kind),
12001202
"wrong SILNode layout in SILInstruction");
1203+
#pragma clang diagnostic pop
12011204
};
12021205

12031206
inline SILNodePointer::SILNodePointer(const SingleValueInstruction *svi) :

0 commit comments

Comments
 (0)