llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.39k stars 12.15k forks source link

[clang-tidy]llvm-header-guard false positive on #pragma once header #111475

Open mzyKi opened 1 month ago

mzyKi commented 1 month ago

a.hpp

#pragma once
int i = 0;

test.cpp

#include "a.hpp"

Result

$ clang-tidy -checks=-*,llvm-header-guard test.cpp -header-filter=.*
a.hpp:1:1: warning: header is missing header guard [llvm-header-guard]
#pragma once
^

I think this check may give one inaccurate note here. Is it necessary to make changes to this situation? I want some suggestion about revising llvm-header-guard. Do not report this bug or give another note? I am willing to fix this. @PiotrZSL Thanks for your suggestion!

llvmbot commented 1 month ago

@llvm/issue-subscribers-clang-tidy

Author: Exile (mzyKi)

a.hpp ```cpp #pragma once int i = 0; ``` test.cpp ``` #include "a.hpp" ``` Result ```bash $ clang-tidy -checks=-*,llvm-header-guard test.cpp -header-filter=.* a.hpp:1:1: warning: header is missing header guard [llvm-header-guard] #pragma once ^ ``` I think this check may give one inaccurate note here. Is it necessary to make changes to this situation? I want some suggestion about revising ```llvm-header-guard```. Do not report this bug or give another note?