[libc-commits] [libc] [libc][clang-tidy] Add llvm-header-guard to get consistant naming and prevent file copy/paste issues. (PR #66477)

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Wed Sep 20 04:30:29 PDT 2023


gchatelet wrote:

> We are not uniform, but I think we should follow this:
> 
> `__LLVM_LIBC_<FILE_NAME_IN_UPPER_SNAKE_CASE>_H__`

`llvm-header-guard` derives from `header-guard` and [forbids header guards starting with underscores](https://github.com/llvm/llvm-project/blob/797cad9d32885ca7a0ccfa657eba5c739f189e98/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp#L282-L285).
```
std::string HeaderGuardCheck::sanitizeHeaderGuard(StringRef Guard) {
  // Only reserved identifiers are allowed to start with an '_'.
  return Guard.drop_while([](char C) { return C == '_'; }).str();
}
```

If we drop this requirement, `llvm-header-guard` can already be used as is and doesn't need to be adapted to llvm libc.

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


More information about the libc-commits mailing list