Personally I also think [[maybe_unused]]
is preferable due to clarity
If weāre happy to change this I can write a script to perform the replacements and generate diffs in chunks of 10-20 files and start pushing up diffs for review. Iāll see if I can get an idea of how many files would need to be changed before I start in ernest.
My grep & regex skills are poor, so please help me correct the following if you can. Certainly the type list probably has a nicer experssion, at the very least. Using the rudementary grep below in the llvm-project root:
pcregrep -M -rl --include='\.cpp$' --include='\.c$' --include='\.h$' '(uint[0-9]+t|int|char|float|double|bool|unsigned)[ ]([a-zA-Z]+)[ ].*\n.*\(void\)[ ]*\g{-1}' ../ | wc -l
I get 183 source files as candidates for modification.
This would be great to have as a clang-tidy check.
Iām not sure why this is being discussed at all.
Just because weāre using C++17 does not mean we should abuse it.
Hi @s-barannikov, Iām happy to hear reasons against using the attribute and why it constitutes abuse. After all, the current idiom does function.
However, the discussion above seems to indicate a desire to move to the attribute.
The reasons have already been spelled by others, I have nothing to add.
The main point is that (void) is a well recognized idiom.
[[maybe_unused]] must have a significant advantage for it to be considered.
The number of hearts each post received indicates otherwise, if I count correctly.
There you go:
If we want consistency, then the attribute is the way to go.
I donāt mind using it on functions. I think nobody would oppose that, because the alternative is LLVM_ATTRIBUTE_UNUSED.
When it comes to variables, this becomes more sensitive, because there are many more of them. There couldnāt be more low level component of a product than a coding style. Not only the code is already written, but the habbits are developed. The Big Switch can be carried out, but I can imagine people silently asking āBut why? Iām so used to it.ā.
There is no contradiction, we can consistently use it on functions. An analogy is the āconstā qualifier. We use it, but weāre not obsessed with it.
So far Iāve seen justifications for using the attribute, but not arguments for switching to it.
I wonāt object if I see the use of the attribute in a review, but I donāt want to be forced to use it.
(The same applies to the other RFC that proposes switching to C++-style casts.)
[offtopic]
Is there a way to organize a poll to eliminate the āactive minorityā factor on either side?
Does discourse allow it, e.g. by sending a notification? This would convince me.

I wonāt object if I see the use of the attribute in a review, but I donāt want to be forced to use it.
Consistency of the codebase matters a lot to me.

Consistency of the codebase matters a lot to me.
To me, too. But is this particular case that important?
There are several different styles for function argument comments in the codebase:
/*name=*/value
/*name*/ value
/* name */value
value/*name*/
I personally prefer (1). Just becase my IDE can insert it automatically. But Iām used to it and wouldnāt want to be forced to use any other style. I consider (void) vs [[maybe_unused]] the same kind of issue.

But is this particular case that important?
Just as much as almost anything else that is in the coding guidelines?

There are several different styles for function argument comments in the codebase:
Actually we have a clang-tidy check that relies on 1 to check consistency between caller and caller (so this is more than a style issue) and I am quite sure I ask for this format in code review.
If we donāt document it I would definitely look into doing it.
There is a lot inconsistency from history in the codebase, but thatās not a good excuse to avoid standardizing the style guide IMO

Just as much as almost anything else that is in the coding guidelines?
It is not in the coding guidelines (yet). If it is standardized, Iāll be obliged to use it and wonāt complain.
Actually we have a clang-tidy check to enforce 1, and I am quite sure I ask for this format in code review.
Good to know, thanks!
There is a lot inconsistency from history in the codebase, but thatās not a good excuse to avoid standardizing the style guide IMO
I agree. However, in order to standardize it, there should be a consensus. Iām afraid there will not be one, there is just not enough data to say which option wins. Looks like Iām kind of safe for now

Consistency of the codebase matters a lot to me.
Then you should have a chat with the Flang people.
If you have specific things about flang where it does not follow the style guide we can discuss it (in another place than this thread), as far as I remember the agreement to merge flang in LLVM was that it would adhere to the LLVM coding standard.
āā Always wrap the bodies of if()
, else
, while()
, for()
, do
, &c. with braces, even when the body is a single statement or empty. The opening {
goes on the end of the line, not on the next line. Functions also put the opening {
after the formal arguments or new-style result type, not on the next line. Use {}
for empty inline constructors and destructors in classes.āā