[PATCH] D142123: [clang-tidy] Add header guard style to suggest use of #pragma once
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 3 06:48:20 PST 2023
aaron.ballman added inline comments.
================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability/header-guard.rst:31
+ Use ``#pragma once`` instead of macro guards. Note that ``#pragma once``
+ is not part of the C++ standard, and may not work correctly in all cases.
----------------
It's also not in the C standard, so reworded slightly.
================
Comment at: clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp:569-571
+ runPragmaOnceCheck("#ifndef BOTH_H\n"
+ "#define BOTH_H\n"
+ "#pragma once\n"
----------------
How about a test for:
```
#if !defined(HEADER_GUARD_H)
#define HEADER_GUARD_H 1
#endif
```
and a test for what happens when there's no header guard or pragma once in the file.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142123/new/
https://reviews.llvm.org/D142123
More information about the cfe-commits
mailing list