[PATCH] D61508: [clang-tidy] misc-header-guard : a simple version of llvm-header-guard

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 6 11:07:21 PDT 2019


aaron.ballman added a comment.

In D61508#1491570 <https://reviews.llvm.org/D61508#1491570>, @JonasToth wrote:

> Hi trixirt and thanks for the patch!
>
> I would rather like to generalize the llvm check to allow different styles and then alias the general version with different configurations. Introducing this code duplication does not sound like a good idea to me.
>  The documentation fixes you make can be done in a separate patch to keep things clean.


I'd probably reverse that -- have bugprone (not misc) carry a general check for header guards with configuration options, and have the llvm check defer to the general check with specific configuration options.



================
Comment at: clang-tidy/misc/HeaderGuardCheck.cpp:25-26
+  std::string Guard = llvm::sys::path::filename(Filename);
+  std::replace(Guard.begin(), Guard.end(), '.', '_');
+  std::replace(Guard.begin(), Guard.end(), '-', '_');
+  return StringRef(Guard).upper();
----------------
This replacement may generate a header guard that exhibits UB. Consider a filename like `foo-.cpp`, which will become `foo__cpp`


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61508





More information about the cfe-commits mailing list