Skip to content
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 include/gsl/span
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ namespace details
if (n != 0) Expects(begin_ && current_ && end_);
if (n > 0) Expects(current_ - begin_ >= n);
if (n < 0) Expects(end_ - current_ >= -n);
GSL_SUPPRESS(bounds .1)
GSL_SUPPRESS(bounds.1)
current_ -= n;
return *this;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/notnull_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ struct NonCopyableNonMovable
namespace
{
// clang-format off
GSL_SUPPRESS(f .4) // NO-FORMAT: attribute
GSL_SUPPRESS(f.4) // NO-FORMAT: attribute
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Most lines with GSL_SUPPRESS have a trailing // NO-FORMAT: attribute. I have left it here, but when we remove the NO-FORMAT, the VS formatting already fixes the f .4 to f.4.

I not only don't see a reason to write NO-FORMAT, I also think it makes things worse. I vote to remove all NO-FORMAT on GSL_SUPPRESS and revisit the necessity of CommentPragmas: '^ NO-FORMAT:' in .clang-format. If you agree, I can do that in another PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

VS formatting already fixes the f .4 to f.4.

Does this happen with older toolsets? Specifically, when GSL_SUPPRESS(abc.123) expands to [[gsl::suppress(abc.123)]] instead of [[gsl::suppress("abc.123)]]?

revisit the necessity of CommentPragmas: '^ NO-FORMAT:' in .clang-format

I'm not running clang-format on every change. Seems like we are not compliant with what clang-format wants either:

PS C:\Users\carsonradtke\src\GSL\include\gsl> clang-format -i *
is a directory
is a directory
PS C:\Users\carsonradtke\src\GSL\include\gsl> git diff --stat
 include/gsl/byte     |  32 +++++++++-------
 include/gsl/gsl      |  14 +++----
 include/gsl/narrow   |  29 +++++++--------
 include/gsl/pointers | 101 ++++++++++++++++++++++++++++++---------------------
 include/gsl/span     |  17 ++++++---
 include/gsl/util     |  28 +++++++++-----
 include/gsl/zstring  |   2 +-
 7 files changed, 130 insertions(+), 93 deletions(-)
PS C:\Users\carsonradtke\src\GSL\include\gsl> 

If you agree, I can do that in another PR.

Sounds good to me. In addition to the CommentPragmas change, maybe also add a GitHub action that requires $ clang-format -i --dry-run include/gsl/* tests/*.{cpp,h} to exit successfully? This adds friction to people submitting PRs, but at least we have an agreed upon style. Your choice.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this happen with older toolsets?

I'll validate this afternoon and if all is good, I'll approve and merge.

Copy link
Copy Markdown
Member

@carsonRadtke carsonRadtke May 27, 2026

Choose a reason for hiding this comment

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

Er - on older toolsets this wouldn't matter because abc.123 would be parsed the same way as abc. 123. However, I'm surprised that clang-format makes this change when the macro is expanded with the argument as a string. This type of refactor changes the meaning of the program. In the case of GSL_SUPPRESS the reactor is safe, but not in general. Anyway, merging now.

Edit: typo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great, #1251 is work in progress.

// clang-format on
bool helper(not_null<int*> p) { return *p == 12; }
// clang-format off
GSL_SUPPRESS(f .4) // NO-FORMAT: attribute
GSL_SUPPRESS(f.4) // NO-FORMAT: attribute
// clang-format on
bool helper_const(not_null<const int*> p) { return *p == 12; }

Expand Down
2 changes: 1 addition & 1 deletion tests/owner_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

using namespace gsl;

GSL_SUPPRESS(f .23) // NO-FORMAT: attribute
GSL_SUPPRESS(f.23) // NO-FORMAT: attribute
void f(int* i) { *i += 1; }

TEST(owner_tests, basic_test)
Expand Down
Loading