-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc][clang-tidy] Add llvm-header-guard to get consistant naming and prevent file copy/paste issues. #66477
[libc][clang-tidy] Add llvm-header-guard to get consistant naming and prevent file copy/paste issues. #66477
Conversation
I'll fix the bad headers as well if you agree with this patch. |
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 |
Thx for the review @sivachandra . Unfortunately some of the files under Two questions:
|
It seems like |
We are not uniform, but I think we should follow this:
For header files in nested directories:
Just putting the file name as is, including the double-underscores, seems fine to me. The header guards don't really come in the way of almost anything. |
So Looking at the
instead of using the proper Example command line from
I may not fully grasp how the header inclusion mechanism works but I believe that -for the purpose of Also looking more closely at the above example command line, it seems to me that there are too many includes
@sivachandra do we expect that many includes? On the other hand, the Bazel generated command line seems much more reasonable to me
|
Your conclusion is correct! We should specify
A lot of it is not required. We should only require:
Anything else seems like unnecessary at this point, but there could some land-mines hiding somewhere. I feel we can take them out with some cleanup. |
Alright so it took me a while but some of these includes come from the main llvm CMakeLists llvm-project/llvm/CMakeLists.txt#L1115.
I don't quite know how to deal with this. We could remove them globally when entering EDIT: I'm working on a fix, I'll report when I have something that works. |
We want to activate `llvm-header-guard` (#66477) but the current CMake configuration includes paths that should be `isystem`. This PR restricts the number of `-I` passed to the clang command line and correctly marks the llvm libc include path as `isystem`.
We want to activate `llvm-header-guard` (llvm#66477) but the current CMake configuration includes paths that should be `isystem`. This PR restricts the number of `-I` passed to the clang command line and correctly marks the llvm libc include path as `isystem`. This is a reland of llvm#66783 a35a3b7 fixing the benchmark breakage.
… prevent file copy/paste issues.
If we drop this requirement, |
cb0a4d9
to
ca5c23c
Compare
@@ -6,8 +6,8 @@ | |||
// | |||
//===----------------------------------------------------------------------===// | |||
|
|||
#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_BYTE_H | |||
#define LLVM_LIBC_SRC_SUPPORT_CPP_BYTE_H | |||
#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_CSTDDEF_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a real error for instance
@@ -6,8 +6,8 @@ | |||
// | |||
//===----------------------------------------------------------------------===// | |||
|
|||
#ifndef LLVM_LIBC_SRC_STDLIB_ABS_UTILS_H | |||
#define LLVM_LIBC_SRC_STDLIB_ABS_UTILS_H | |||
#ifndef LLVM_LIBC_SRC___SUPPORT_INTEGER_OPERATIONS_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is a real error as well.
@@ -6,6 +6,9 @@ | |||
// | |||
//===----------------------------------------------------------------------===// | |||
|
|||
#ifndef LLVM_LIBC_SRC___SUPPORT_THREADS_CALLONCE_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was missing a header
@@ -6,6 +6,9 @@ | |||
// | |||
//===----------------------------------------------------------------------===// | |||
|
|||
#ifndef LLVM_LIBC_SRC_STDLIB_BSEARCH_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing guard as well
#ifndef LLVM_LIBC_SRC_STDLIB_DIV_H | ||
#define LLVM_LIBC_SRC_STDLIB_DIV_H | ||
|
||
#include <stdlib.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard not at the correct location, same for the following ones.
@@ -6,13 +6,13 @@ | |||
// | |||
//===----------------------------------------------------------------------===// | |||
|
|||
#ifndef LLVM_LIBC_SRC_STRING_STRCASECMP_H | |||
#define LLVM_LIBC_SRC_STRING_STRCASECMP_H | |||
#ifndef LLVM_LIBC_SRC_STRING_STRCASESTR_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This header is a copy/paste error from libc/src/string/strncasecmp.h
Clang's freestanding headers use a guard with What is the goal here? Is to use clang-tidy to catch header-guard errors in |
The goal of this particular patch is to enable EDIT: Question, the |
If
This is only for the |
No description provided.