Skip to content

Commit 731db06

Browse files
authored
[libc++] Get the GCC build mostly clean of warnings (#96604)
The GCC build has gotten to the point where it's often hard to find the actual error in the build log. We should look into enabling these warnings again in the future, but it looks like a lot of them are bogous.
1 parent 902952a commit 731db06

File tree

7 files changed

+48
-42
lines changed

7 files changed

+48
-42
lines changed

libcxx/include/__atomic/atomic_init.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#define ATOMIC_FLAG_INIT {false}
1919
#define ATOMIC_VAR_INIT(__v) {__v}
2020

21-
#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
21+
#if _LIBCPP_STD_VER >= 20 && defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
2222
# pragma clang deprecated(ATOMIC_VAR_INIT)
2323
#endif
2424

libcxx/src/barrier.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ class __barrier_algorithm_base {
2121
} __tickets[64];
2222
};
2323

24-
ptrdiff_t& __expected;
25-
unique_ptr<__state_t[]> __state;
24+
ptrdiff_t& __expected_;
25+
unique_ptr<__state_t[]> __state_;
2626

27-
_LIBCPP_HIDDEN __barrier_algorithm_base(ptrdiff_t& __expected) : __expected(__expected) {
27+
_LIBCPP_HIDDEN __barrier_algorithm_base(ptrdiff_t& __expected) : __expected_(__expected) {
2828
size_t const __count = (__expected + 1) >> 1;
29-
__state = unique_ptr<__state_t[]>(new __state_t[__count]);
29+
__state_ = unique_ptr<__state_t[]>(new __state_t[__count]);
3030
}
3131
_LIBCPP_HIDDEN bool __arrive(__barrier_phase_t __old_phase) {
3232
__barrier_phase_t const __half_step = __old_phase + 1, __full_step = __old_phase + 2;
33-
size_t __current_expected = __expected,
34-
__current = hash<thread::id>()(this_thread::get_id()) % ((__expected + 1) >> 1);
33+
size_t __current_expected = __expected_,
34+
__current = hash<thread::id>()(this_thread::get_id()) % ((__expected_ + 1) >> 1);
3535
for (int __round = 0;; ++__round) {
3636
if (__current_expected <= 1)
3737
return true;
@@ -41,14 +41,14 @@ class __barrier_algorithm_base {
4141
__current = 0;
4242
__barrier_phase_t expect = __old_phase;
4343
if (__current == __last_node && (__current_expected & 1)) {
44-
if (__state[__current].__tickets[__round].__phase.compare_exchange_strong(
44+
if (__state_[__current].__tickets[__round].__phase.compare_exchange_strong(
4545
expect, __full_step, memory_order_acq_rel))
4646
break; // I'm 1 in 1, go to next __round
47-
} else if (__state[__current].__tickets[__round].__phase.compare_exchange_strong(
47+
} else if (__state_[__current].__tickets[__round].__phase.compare_exchange_strong(
4848
expect, __half_step, memory_order_acq_rel)) {
4949
return false; // I'm 1 in 2, done with arrival
5050
} else if (expect == __half_step) {
51-
if (__state[__current].__tickets[__round].__phase.compare_exchange_strong(
51+
if (__state_[__current].__tickets[__round].__phase.compare_exchange_strong(
5252
expect, __full_step, memory_order_acq_rel))
5353
break; // I'm 2 in 2, go to next __round
5454
}

libcxx/src/filesystem/operations.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ path __weakly_canonical(const path& p, error_code* ec) {
934934
vector<string_view_t> DNEParts;
935935

936936
error_code m_ec;
937-
while (PP.State != PathParser::PS_BeforeBegin) {
937+
while (PP.State_ != PathParser::PS_BeforeBegin) {
938938
tmp.assign(createView(p.native().data(), &PP.RawEntry.back()));
939939
file_status st = __status(tmp, &m_ec);
940940
if (!status_known(st)) {
@@ -949,7 +949,7 @@ path __weakly_canonical(const path& p, error_code* ec) {
949949
DNEParts.push_back(*PP);
950950
--PP;
951951
}
952-
if (PP.State == PathParser::PS_BeforeBegin) {
952+
if (PP.State_ == PathParser::PS_BeforeBegin) {
953953
result = __canonical("", &m_ec);
954954
if (m_ec) {
955955
return err.report(m_ec);

libcxx/src/filesystem/path.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,48 +45,48 @@ path& path::replace_extension(path const& replacement) {
4545

4646
string_view_t path::__root_name() const {
4747
auto PP = PathParser::CreateBegin(__pn_);
48-
if (PP.State == PathParser::PS_InRootName)
48+
if (PP.State_ == PathParser::PS_InRootName)
4949
return *PP;
5050
return {};
5151
}
5252

5353
string_view_t path::__root_directory() const {
5454
auto PP = PathParser::CreateBegin(__pn_);
55-
if (PP.State == PathParser::PS_InRootName)
55+
if (PP.State_ == PathParser::PS_InRootName)
5656
++PP;
57-
if (PP.State == PathParser::PS_InRootDir)
57+
if (PP.State_ == PathParser::PS_InRootDir)
5858
return *PP;
5959
return {};
6060
}
6161

6262
string_view_t path::__root_path_raw() const {
6363
auto PP = PathParser::CreateBegin(__pn_);
64-
if (PP.State == PathParser::PS_InRootName) {
64+
if (PP.State_ == PathParser::PS_InRootName) {
6565
auto NextCh = PP.peek();
6666
if (NextCh && isSeparator(*NextCh)) {
6767
++PP;
6868
return createView(__pn_.data(), &PP.RawEntry.back());
6969
}
7070
return PP.RawEntry;
7171
}
72-
if (PP.State == PathParser::PS_InRootDir)
72+
if (PP.State_ == PathParser::PS_InRootDir)
7373
return *PP;
7474
return {};
7575
}
7676

7777
static bool ConsumeRootName(PathParser* PP) {
7878
static_assert(PathParser::PS_BeforeBegin == 1 && PathParser::PS_InRootName == 2, "Values for enums are incorrect");
79-
while (PP->State <= PathParser::PS_InRootName)
79+
while (PP->State_ <= PathParser::PS_InRootName)
8080
++(*PP);
81-
return PP->State == PathParser::PS_AtEnd;
81+
return PP->State_ == PathParser::PS_AtEnd;
8282
}
8383

8484
static bool ConsumeRootDir(PathParser* PP) {
8585
static_assert(PathParser::PS_BeforeBegin == 1 && PathParser::PS_InRootName == 2 && PathParser::PS_InRootDir == 3,
8686
"Values for enums are incorrect");
87-
while (PP->State <= PathParser::PS_InRootDir)
87+
while (PP->State_ <= PathParser::PS_InRootDir)
8888
++(*PP);
89-
return PP->State == PathParser::PS_AtEnd;
89+
return PP->State_ == PathParser::PS_AtEnd;
9090
}
9191

9292
string_view_t path::__relative_path() const {
@@ -248,7 +248,7 @@ path path::lexically_relative(const path& base) const {
248248
auto PP = PathParser::CreateBegin(__pn_);
249249
auto PPBase = PathParser::CreateBegin(base.__pn_);
250250
auto CheckIterMismatchAtBase = [&]() {
251-
return PP.State != PPBase.State && (PP.inRootPath() || PPBase.inRootPath());
251+
return PP.State_ != PPBase.State_ && (PP.inRootPath() || PPBase.inRootPath());
252252
};
253253
if (PP.inRootName() && PPBase.inRootName()) {
254254
if (*PP != *PPBase)
@@ -267,7 +267,7 @@ path path::lexically_relative(const path& base) const {
267267
// Find the first mismatching element
268268
auto PP = PathParser::CreateBegin(__pn_);
269269
auto PPBase = PathParser::CreateBegin(base.__pn_);
270-
while (PP && PPBase && PP.State == PPBase.State && *PP == *PPBase) {
270+
while (PP && PPBase && PP.State_ == PPBase.State_ && *PP == *PPBase) {
271271
++PP;
272272
++PPBase;
273273
}
@@ -380,7 +380,7 @@ path::iterator path::begin() const {
380380
auto PP = PathParser::CreateBegin(__pn_);
381381
iterator it;
382382
it.__path_ptr_ = this;
383-
it.__state_ = static_cast<path::iterator::_ParserState>(PP.State);
383+
it.__state_ = static_cast<path::iterator::_ParserState>(PP.State_);
384384
it.__entry_ = PP.RawEntry;
385385
it.__stashed_elem_.__assign_view(*PP);
386386
return it;
@@ -396,7 +396,7 @@ path::iterator path::end() const {
396396
path::iterator& path::iterator::__increment() {
397397
PathParser PP(__path_ptr_->native(), __entry_, __state_);
398398
++PP;
399-
__state_ = static_cast<_ParserState>(PP.State);
399+
__state_ = static_cast<_ParserState>(PP.State_);
400400
__entry_ = PP.RawEntry;
401401
__stashed_elem_.__assign_view(*PP);
402402
return *this;
@@ -405,7 +405,7 @@ path::iterator& path::iterator::__increment() {
405405
path::iterator& path::iterator::__decrement() {
406406
PathParser PP(__path_ptr_->native(), __entry_, __state_);
407407
--PP;
408-
__state_ = static_cast<_ParserState>(PP.State);
408+
__state_ = static_cast<_ParserState>(PP.State_);
409409
__entry_ = PP.RawEntry;
410410
__stashed_elem_.__assign_view(*PP);
411411
return *this;

libcxx/src/filesystem/path_parser.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ struct PathParser {
5050

5151
const string_view_t Path;
5252
string_view_t RawEntry;
53-
ParserState State;
53+
ParserState State_;
5454

5555
private:
56-
PathParser(string_view_t P, ParserState State) noexcept : Path(P), State(State) {}
56+
PathParser(string_view_t P, ParserState State) noexcept : Path(P), State_(State) {}
5757

5858
public:
5959
PathParser(string_view_t P, string_view_t E, unsigned char S)
60-
: Path(P), RawEntry(E), State(static_cast<ParserState>(S)) {
60+
: Path(P), RawEntry(E), State_(static_cast<ParserState>(S)) {
6161
// S cannot be '0' or PS_BeforeBegin.
6262
}
6363

@@ -84,7 +84,7 @@ struct PathParser {
8484
if (Start == End)
8585
return makeState(PS_AtEnd);
8686

87-
switch (State) {
87+
switch (State_) {
8888
case PS_BeforeBegin: {
8989
PosPtr TkEnd = consumeRootName(Start, End);
9090
if (TkEnd)
@@ -125,7 +125,7 @@ struct PathParser {
125125
if (RStart == REnd) // we're decrementing the begin
126126
return makeState(PS_BeforeBegin);
127127

128-
switch (State) {
128+
switch (State_) {
129129
case PS_AtEnd: {
130130
// Try to consume a trailing separator or root directory first.
131131
if (PosPtr SepEnd = consumeAllSeparators(RStart, REnd)) {
@@ -169,7 +169,7 @@ struct PathParser {
169169
/// \brief Return a view with the "preferred representation" of the current
170170
/// element. For example trailing separators are represented as a '.'
171171
string_view_t operator*() const noexcept {
172-
switch (State) {
172+
switch (State_) {
173173
case PS_BeforeBegin:
174174
case PS_AtEnd:
175175
return PATHSTR("");
@@ -187,7 +187,7 @@ struct PathParser {
187187
__libcpp_unreachable();
188188
}
189189

190-
explicit operator bool() const noexcept { return State != PS_BeforeBegin && State != PS_AtEnd; }
190+
explicit operator bool() const noexcept { return State_ != PS_BeforeBegin && State_ != PS_AtEnd; }
191191

192192
PathParser& operator++() noexcept {
193193
increment();
@@ -199,21 +199,21 @@ struct PathParser {
199199
return *this;
200200
}
201201

202-
bool atEnd() const noexcept { return State == PS_AtEnd; }
202+
bool atEnd() const noexcept { return State_ == PS_AtEnd; }
203203

204-
bool inRootDir() const noexcept { return State == PS_InRootDir; }
204+
bool inRootDir() const noexcept { return State_ == PS_InRootDir; }
205205

206-
bool inRootName() const noexcept { return State == PS_InRootName; }
206+
bool inRootName() const noexcept { return State_ == PS_InRootName; }
207207

208208
bool inRootPath() const noexcept { return inRootName() || inRootDir(); }
209209

210210
private:
211211
void makeState(ParserState NewState, PosPtr Start, PosPtr End) noexcept {
212-
State = NewState;
212+
State_ = NewState;
213213
RawEntry = string_view_t(Start, End - Start);
214214
}
215215
void makeState(ParserState NewState) noexcept {
216-
State = NewState;
216+
State_ = NewState;
217217
RawEntry = {};
218218
}
219219

@@ -224,7 +224,7 @@ struct PathParser {
224224
/// \brief Return a pointer to the first character after the currently
225225
/// lexed element.
226226
PosPtr getNextTokenStartPos() const noexcept {
227-
switch (State) {
227+
switch (State_) {
228228
case PS_BeforeBegin:
229229
return Path.data();
230230
case PS_InRootName:
@@ -241,7 +241,7 @@ struct PathParser {
241241
/// \brief Return a pointer to the first character in the currently lexed
242242
/// element.
243243
PosPtr getCurrentTokenStartPos() const noexcept {
244-
switch (State) {
244+
switch (State_) {
245245
case PS_BeforeBegin:
246246
case PS_InRootName:
247247
return &Path.front();

libcxx/src/locale.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,9 @@ locale::locale(const locale& other, const locale& one, category c)
557557

558558
string locale::name() const { return __locale_->name(); }
559559

560-
void locale::__install_ctor(const locale& other, facet* f, long id) {
560+
void locale::__install_ctor(const locale& other, facet* f, long facet_id) {
561561
if (f)
562-
__locale_ = new __imp(*other.__locale_, f, id);
562+
__locale_ = new __imp(*other.__locale_, f, facet_id);
563563
else
564564
__locale_ = other.__locale_;
565565
__locale_->acquire();

runtimes/cmake/Modules/WarningFlags.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ function(cxx_add_warning_flags target enable_werror enable_pedantic)
6060
-Wno-c++14-compat
6161
-Wno-noexcept-type
6262
-Wno-suggest-override
63+
-Wno-alloc-size-larger-than
64+
-Wno-deprecated-declarations
65+
-Wno-dangling-reference
66+
-Wno-strict-overflow
67+
-Wno-maybe-uninitialized
68+
-Wno-strict-aliasing
6369
)
6470

6571
endif()

0 commit comments

Comments
 (0)