Skip to content

[libc++] Get the GCC build mostly clean of warnings #96604

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

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcxx/include/__atomic/atomic_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define ATOMIC_FLAG_INIT {false}
#define ATOMIC_VAR_INIT(__v) {__v}

#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
#if _LIBCPP_STD_VER >= 20 && defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this if we have -Wno-deprecated-declarations below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This suppresses a -Wunknown-pragma.

# pragma clang deprecated(ATOMIC_VAR_INIT)
#endif

Expand Down
18 changes: 9 additions & 9 deletions libcxx/src/barrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ class __barrier_algorithm_base {
} __tickets[64];
};

ptrdiff_t& __expected;
unique_ptr<__state_t[]> __state;
ptrdiff_t& __expected_;
unique_ptr<__state_t[]> __state_;

_LIBCPP_HIDDEN __barrier_algorithm_base(ptrdiff_t& __expected) : __expected(__expected) {
_LIBCPP_HIDDEN __barrier_algorithm_base(ptrdiff_t& __expected) : __expected_(__expected) {
size_t const __count = (__expected + 1) >> 1;
__state = unique_ptr<__state_t[]>(new __state_t[__count]);
__state_ = unique_ptr<__state_t[]>(new __state_t[__count]);
}
_LIBCPP_HIDDEN bool __arrive(__barrier_phase_t __old_phase) {
__barrier_phase_t const __half_step = __old_phase + 1, __full_step = __old_phase + 2;
size_t __current_expected = __expected,
__current = hash<thread::id>()(this_thread::get_id()) % ((__expected + 1) >> 1);
size_t __current_expected = __expected_,
__current = hash<thread::id>()(this_thread::get_id()) % ((__expected_ + 1) >> 1);
for (int __round = 0;; ++__round) {
if (__current_expected <= 1)
return true;
Expand All @@ -41,14 +41,14 @@ class __barrier_algorithm_base {
__current = 0;
__barrier_phase_t expect = __old_phase;
if (__current == __last_node && (__current_expected & 1)) {
if (__state[__current].__tickets[__round].__phase.compare_exchange_strong(
if (__state_[__current].__tickets[__round].__phase.compare_exchange_strong(
expect, __full_step, memory_order_acq_rel))
break; // I'm 1 in 1, go to next __round
} else if (__state[__current].__tickets[__round].__phase.compare_exchange_strong(
} else if (__state_[__current].__tickets[__round].__phase.compare_exchange_strong(
expect, __half_step, memory_order_acq_rel)) {
return false; // I'm 1 in 2, done with arrival
} else if (expect == __half_step) {
if (__state[__current].__tickets[__round].__phase.compare_exchange_strong(
if (__state_[__current].__tickets[__round].__phase.compare_exchange_strong(
expect, __full_step, memory_order_acq_rel))
break; // I'm 2 in 2, go to next __round
}
Expand Down
4 changes: 2 additions & 2 deletions libcxx/src/filesystem/operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ path __weakly_canonical(const path& p, error_code* ec) {
vector<string_view_t> DNEParts;

error_code m_ec;
while (PP.State != PathParser::PS_BeforeBegin) {
while (PP.State_ != PathParser::PS_BeforeBegin) {
tmp.assign(createView(p.native().data(), &PP.RawEntry.back()));
file_status st = __status(tmp, &m_ec);
if (!status_known(st)) {
Expand All @@ -949,7 +949,7 @@ path __weakly_canonical(const path& p, error_code* ec) {
DNEParts.push_back(*PP);
--PP;
}
if (PP.State == PathParser::PS_BeforeBegin) {
if (PP.State_ == PathParser::PS_BeforeBegin) {
result = __canonical("", &m_ec);
if (m_ec) {
return err.report(m_ec);
Expand Down
28 changes: 14 additions & 14 deletions libcxx/src/filesystem/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,48 +45,48 @@ path& path::replace_extension(path const& replacement) {

string_view_t path::__root_name() const {
auto PP = PathParser::CreateBegin(__pn_);
if (PP.State == PathParser::PS_InRootName)
if (PP.State_ == PathParser::PS_InRootName)
return *PP;
return {};
}

string_view_t path::__root_directory() const {
auto PP = PathParser::CreateBegin(__pn_);
if (PP.State == PathParser::PS_InRootName)
if (PP.State_ == PathParser::PS_InRootName)
++PP;
if (PP.State == PathParser::PS_InRootDir)
if (PP.State_ == PathParser::PS_InRootDir)
return *PP;
return {};
}

string_view_t path::__root_path_raw() const {
auto PP = PathParser::CreateBegin(__pn_);
if (PP.State == PathParser::PS_InRootName) {
if (PP.State_ == PathParser::PS_InRootName) {
auto NextCh = PP.peek();
if (NextCh && isSeparator(*NextCh)) {
++PP;
return createView(__pn_.data(), &PP.RawEntry.back());
}
return PP.RawEntry;
}
if (PP.State == PathParser::PS_InRootDir)
if (PP.State_ == PathParser::PS_InRootDir)
return *PP;
return {};
}

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

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

string_view_t path::__relative_path() const {
Expand Down Expand Up @@ -248,7 +248,7 @@ path path::lexically_relative(const path& base) const {
auto PP = PathParser::CreateBegin(__pn_);
auto PPBase = PathParser::CreateBegin(base.__pn_);
auto CheckIterMismatchAtBase = [&]() {
return PP.State != PPBase.State && (PP.inRootPath() || PPBase.inRootPath());
return PP.State_ != PPBase.State_ && (PP.inRootPath() || PPBase.inRootPath());
};
if (PP.inRootName() && PPBase.inRootName()) {
if (*PP != *PPBase)
Expand All @@ -267,7 +267,7 @@ path path::lexically_relative(const path& base) const {
// Find the first mismatching element
auto PP = PathParser::CreateBegin(__pn_);
auto PPBase = PathParser::CreateBegin(base.__pn_);
while (PP && PPBase && PP.State == PPBase.State && *PP == *PPBase) {
while (PP && PPBase && PP.State_ == PPBase.State_ && *PP == *PPBase) {
++PP;
++PPBase;
}
Expand Down Expand Up @@ -380,7 +380,7 @@ path::iterator path::begin() const {
auto PP = PathParser::CreateBegin(__pn_);
iterator it;
it.__path_ptr_ = this;
it.__state_ = static_cast<path::iterator::_ParserState>(PP.State);
it.__state_ = static_cast<path::iterator::_ParserState>(PP.State_);
it.__entry_ = PP.RawEntry;
it.__stashed_elem_.__assign_view(*PP);
return it;
Expand All @@ -396,7 +396,7 @@ path::iterator path::end() const {
path::iterator& path::iterator::__increment() {
PathParser PP(__path_ptr_->native(), __entry_, __state_);
++PP;
__state_ = static_cast<_ParserState>(PP.State);
__state_ = static_cast<_ParserState>(PP.State_);
__entry_ = PP.RawEntry;
__stashed_elem_.__assign_view(*PP);
return *this;
Expand All @@ -405,7 +405,7 @@ path::iterator& path::iterator::__increment() {
path::iterator& path::iterator::__decrement() {
PathParser PP(__path_ptr_->native(), __entry_, __state_);
--PP;
__state_ = static_cast<_ParserState>(PP.State);
__state_ = static_cast<_ParserState>(PP.State_);
__entry_ = PP.RawEntry;
__stashed_elem_.__assign_view(*PP);
return *this;
Expand Down
28 changes: 14 additions & 14 deletions libcxx/src/filesystem/path_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ struct PathParser {

const string_view_t Path;
string_view_t RawEntry;
ParserState State;
ParserState State_;

private:
PathParser(string_view_t P, ParserState State) noexcept : Path(P), State(State) {}
PathParser(string_view_t P, ParserState State) noexcept : Path(P), State_(State) {}

public:
PathParser(string_view_t P, string_view_t E, unsigned char S)
: Path(P), RawEntry(E), State(static_cast<ParserState>(S)) {
: Path(P), RawEntry(E), State_(static_cast<ParserState>(S)) {
// S cannot be '0' or PS_BeforeBegin.
}

Expand All @@ -84,7 +84,7 @@ struct PathParser {
if (Start == End)
return makeState(PS_AtEnd);

switch (State) {
switch (State_) {
case PS_BeforeBegin: {
PosPtr TkEnd = consumeRootName(Start, End);
if (TkEnd)
Expand Down Expand Up @@ -125,7 +125,7 @@ struct PathParser {
if (RStart == REnd) // we're decrementing the begin
return makeState(PS_BeforeBegin);

switch (State) {
switch (State_) {
case PS_AtEnd: {
// Try to consume a trailing separator or root directory first.
if (PosPtr SepEnd = consumeAllSeparators(RStart, REnd)) {
Expand Down Expand Up @@ -169,7 +169,7 @@ struct PathParser {
/// \brief Return a view with the "preferred representation" of the current
/// element. For example trailing separators are represented as a '.'
string_view_t operator*() const noexcept {
switch (State) {
switch (State_) {
case PS_BeforeBegin:
case PS_AtEnd:
return PATHSTR("");
Expand All @@ -187,7 +187,7 @@ struct PathParser {
__libcpp_unreachable();
}

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

PathParser& operator++() noexcept {
increment();
Expand All @@ -199,21 +199,21 @@ struct PathParser {
return *this;
}

bool atEnd() const noexcept { return State == PS_AtEnd; }
bool atEnd() const noexcept { return State_ == PS_AtEnd; }

bool inRootDir() const noexcept { return State == PS_InRootDir; }
bool inRootDir() const noexcept { return State_ == PS_InRootDir; }

bool inRootName() const noexcept { return State == PS_InRootName; }
bool inRootName() const noexcept { return State_ == PS_InRootName; }

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

private:
void makeState(ParserState NewState, PosPtr Start, PosPtr End) noexcept {
State = NewState;
State_ = NewState;
RawEntry = string_view_t(Start, End - Start);
}
void makeState(ParserState NewState) noexcept {
State = NewState;
State_ = NewState;
RawEntry = {};
}

Expand All @@ -224,7 +224,7 @@ struct PathParser {
/// \brief Return a pointer to the first character after the currently
/// lexed element.
PosPtr getNextTokenStartPos() const noexcept {
switch (State) {
switch (State_) {
case PS_BeforeBegin:
return Path.data();
case PS_InRootName:
Expand All @@ -241,7 +241,7 @@ struct PathParser {
/// \brief Return a pointer to the first character in the currently lexed
/// element.
PosPtr getCurrentTokenStartPos() const noexcept {
switch (State) {
switch (State_) {
case PS_BeforeBegin:
case PS_InRootName:
return &Path.front();
Expand Down
4 changes: 2 additions & 2 deletions libcxx/src/locale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ locale::locale(const locale& other, const locale& one, category c)

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

void locale::__install_ctor(const locale& other, facet* f, long id) {
void locale::__install_ctor(const locale& other, facet* f, long facet_id) {
if (f)
__locale_ = new __imp(*other.__locale_, f, id);
__locale_ = new __imp(*other.__locale_, f, facet_id);
else
__locale_ = other.__locale_;
__locale_->acquire();
Expand Down
6 changes: 6 additions & 0 deletions runtimes/cmake/Modules/WarningFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ function(cxx_add_warning_flags target enable_werror enable_pedantic)
-Wno-c++14-compat
-Wno-noexcept-type
-Wno-suggest-override
-Wno-alloc-size-larger-than
-Wno-deprecated-declarations
-Wno-dangling-reference
-Wno-strict-overflow
-Wno-maybe-uninitialized
-Wno-strict-aliasing
)

endif()
Expand Down
Loading