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

Kyle Edwards via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 19 12:04:20 PST 2023


KyleFromKitware added a comment.

Basically, anything that extends `HeaderGuardCheck` (or `HeaderGuardBase` from D142121 <https://reviews.llvm.org/D142121>) is really just a fancy configuration option, rather than a separate check, and should be treated as such. My proposal is this:

1. Create a new base class called `HeaderGuardStyle` which controls all behavior that happens after a header guard or `#pragma once` is discovered, and create associated `llvm::Registry`
2. Modify `HeaderGuardCheck` to select a `HeaderGuardStyle` from the registry based on a configuration option
3. Create a class called `MacroHeaderGuardStyle` which extends `HeaderGuardStyle` and basically does what D142121 <https://reviews.llvm.org/D142121> does now
4. Rename `LLVMHeaderGuardCheck` to `LLVMHeaderGuardStyle` and modify it to extend `MacroHeaderGuardStyle` and add it to the registry
5. Add `PragmaOnceHeaderGuardStyle` which extends `HeaderGuardStyle` and add it to the registry

The refactoring that I've done in D142121 <https://reviews.llvm.org/D142121> is most of the way to being able to implement my above proposal. I just need to shift a few things around and add the new classes. @aaron.ballman if this proposal is good with you I'll get started on it.


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

https://reviews.llvm.org/D142123



More information about the cfe-commits mailing list