AMReX-Codes / amrex

AMReX: Software Framework for Block Structured AMR
https://amrex-codes.github.io/amrex
Other
519 stars 339 forks source link

make clang-tidy recognize .H as a header #3832

Closed zingale closed 4 months ago

zingale commented 5 months ago

Summary

the output of clang-tidy --dump-config shows that .H is not recognized as a header

Additional background

Checklist

The proposed changes:

zingale commented 5 months ago

hmmm... the version of clang-tidy in the CI doesn't seem to like this. But it does fix things when I run locally with clang-tidy 17

zingale commented 5 months ago

indeed, this option was only added in clang-tidy 17: https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/ReleaseNotes.html

there must be another way to tell clang-tidy to recognize the headers for old versions. At the moment, clang-tidy is not doing all the checks cause it doesn't treat .H as a header

WeiqunZhang commented 5 months ago

We can add this to the config file for now.

CheckOptions:
    - key:             bugprone-dynamic-static-initializers.HeaderFileExtensions
      value:           ';H;h;hh;hpp;hxx'
    - key:             bugprone-suspicious-include.HeaderFileExtensions
      value:           ';H;h;hh;hpp;hxx'
    - key:             google-global-names-in-headers.HeaderFileExtensions
      value:           ';H;h;hh;hpp;hxx'
    - key:             google-build-namespaces.HeaderFileExtensions
      value:           ';H;h;hh;hpp;hxx'
    - key:             misc-definitions-in-headers.HeaderFileExtensions
      value:           ';H;h;hh;hpp;hxx'
    - key:             misc-use-anonymous-namespace.HeaderFileExtensions
      value:           ';H;h;hh;hpp;hxx'
WeiqunZhang commented 5 months ago

I tested the CheckOptions above on my local branch. it does seem to work. I now see /home/runner/work/amrex/amrex/Src/Particle/AMReX_Particle.H:16:1: error: do not use unnamed namespaces in header files [google-build-namespaces,-warnings-as-errors] namespace ^

zingale commented 5 months ago

okay. I'll update the PR

WeiqunZhang commented 5 months ago

There will be many errors to fix. Do you want me to help?

zingale commented 5 months ago

I can help. But I'm working through Castro and Microphysics first. Maybe we hold this for a little bit until the other tidy PRs are all done.

ax3l commented 4 months ago

fyi @lucafedeli88

WeiqunZhang commented 4 months ago

After #3867, we can go back to the first commit of this PR.