[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
Mon Sep 18 00:36:28 PDT 2023


gchatelet wrote:

> This SGTM. We could have done this earlier but there were a few exceptions that we had to deal with so we punted on this, example the `include` directory. But, what you are proposing is of a much lower scope (restricted to the `src` directory) so go ahead.

Thx for the review @sivachandra . Unfortunately some of the files under `src` do pull headers in `include` and so the clang-tidy tries to _fix_ them...
I've had a look at the clang-tidy itself and it already supports [customizations for subprojects](https://github.com/llvm/llvm-project/blob/d861b3183cb0baff81120874a16f22e9a4bc9e60/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp) so I think the correct way forward is to add a customization for llvm-libc as well.

Two questions:
 - What are the rules for formatting headers in `include`? (I couldn't find the documentation)
 - What should we do for directories starting with two underscores? Currently `llvm-header-guard` suggests the following edits but I think it doesn't really add any value.

```
>>>
#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H
---
#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H
<<<
```

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


More information about the libc-commits mailing list