[PATCH] D142123: [clang-tidy] Add check to suggest use of #pragma once

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 19 10:25:34 PST 2023


aaron.ballman added a comment.

In D142123#4066023 <https://reviews.llvm.org/D142123#4066023>, @KyleFromKitware wrote:

> We have this check in a custom clang-tidy module that runs on CMake's CI system. Other people <https://stackoverflow.com/questions/61404441/how-can-i-tell-clang-tidy-to-check-for-pragma-once-instead-of-llvm-style-header> have also sought out such a check, and I figured it made sense to upstream it instead of keeping it stuck in our CI. Even though it's not standard, other people might still want to use it. Perhaps there's a better category for it than `modernize`?

Okay, so it's basically that folks want a check for header guards but want to control the style of guard. I think a generic check for header guards is valuable (where the user can configure which style to prefer but we probably default to the standard include guards), but a check for one specific form is less helpful IMO. Once we have a generic check, we could make the llvm header guard check into an alias of the generic check.

In terms of what module, I think a generic check would make sense in `readability` because this isn't about correctness so much as style.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142123/new/

https://reviews.llvm.org/D142123



More information about the cfe-commits mailing list