Skip to content

[clang-tidy] misc-include-cleaner false positives #93335

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

Closed
carlosgalvezp opened this issue May 24, 2024 · 1 comment · Fixed by #94923
Closed

[clang-tidy] misc-include-cleaner false positives #93335

carlosgalvezp opened this issue May 24, 2024 · 1 comment · Fixed by #94923
Assignees
Labels
clang-tidy false-positive Warning fires when it should not

Comments

@carlosgalvezp
Copy link
Contributor

carlosgalvezp commented May 24, 2024

Take the following example code that implements the log2 function with a custom implementation:

constexpr int log2()
{
    int output = 0;
    return output;
}

clang-tidy trunk gives:

[<[source>:1:15: warning: no header providing "log2" is directly included [misc-include-cleaner]]
    1 | constexpr int log2()
      |               ^
[<source>:3:9: warning: no header providing "output" is directly included [misc-include-cleaner]]
    3 |     int output = 0;
      |         ^
2 warnings generated.

Which seems incorrect. Repro: https://godbolt.org/z/roM8E34ce

@carlosgalvezp carlosgalvezp added clang-tidy false-positive Warning fires when it should not labels May 24, 2024
@llvmbot
Copy link
Member

llvmbot commented May 24, 2024

@llvm/issue-subscribers-clang-tidy

Author: Carlos Galvez (carlosgalvezp)

Take the following example code that implements the `log2` function with a custom implementation:
#include &lt;cstdint&gt;

constexpr uint32_t log2()
{
    uint32_t output = 0;
    return output;
}

clang-tidy trunk gives:

[&lt;source&gt;:3:20: warning: no header providing "log2" is directly included [misc-include-cleaner]]
    1 | #include &lt;cstdint&gt;
    2 | 
    3 | constexpr uint32_t log2()
      |                    ^
[&lt;source&gt;:5:14: warning: no header providing "output" is directly included [misc-include-cleaner]]
    5 |     uint32_t output = 0;
      |              ^
2 warnings generated.

Which seems incorrect. Repro: https://godbolt.org/z/vWoejee9v

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-tidy false-positive Warning fires when it should not
Projects
None yet
3 participants