[clang] [clang][AST][NFC] Add '[[fallthrough]]' to cases fall through (PR #85921)

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 21 11:31:44 PDT 2024


Sirraide wrote:

> Yeah, I'm also not opposed to this (an attribute is better than a comment because the attribute can be analyzed)

That was my main line of reasoning here as well.

> more just wondering if we want to remove the comment rather than add the attribute.

I was wondering about that too, yeah, but I’m not familiar enough w/ the surrounding code to know whether a comment/annotation is needed (or would help) here.

> I think what we want to aim for is using [[fallthrough]] annotations whenever the cases are not adjacent to one another (ignoring comments and whitespace) and not using comments except when they're explaining why the fallthrough happens.

That is pretty much what I’m used to as well (adjacent case labels w/ nothing inbetween make it pretty clear that fallthrough was intended, after all—and we also don’t diagnose cases like that for that exact reason).

So in this case, I suppose, I’ll leave it to someone more familiar w/ codegen than me to approve/reject this pr for good.

https://github.com/llvm/llvm-project/pull/85921


More information about the cfe-commits mailing list