This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] check for flagging using declarations in headers
Needs ReviewPublic

Authored by Naysh on Dec 6 2018, 9:34 PM.

Details

Summary

This patch adds an "Alias Free Headers" check, based off the guidelines at http://google.github.io/styleguide/cppguide.html#Aliases, to the abseil module.

The purpose of the check is to eliminate using declarations from header files.

Diff Detail

Event Timeline

Naysh created this revision.Dec 6 2018, 9:34 PM
JonasToth added a project: Restricted Project.

Please upload with full context.

Would it make sense to make this a generic non-abseil check?

lebedev.ri added inline comments.
clang-tidy/abseil/AliasFreeHeadersCheck.cpp
22

Relevant:

$ clang-tidy -dump-config | grep -i extension -A1
  - key:             cert-dcl59-cpp.HeaderFileExtensions
    value:           ',h,hh,hpp,hxx'
--
  - key:             google-build-namespaces.HeaderFileExtensions
    value:           h,hh,hpp,hxx,
  - key:             google-global-names-in-headers.HeaderFileExtensions
    value:           h,hh,hpp,hxx,
--
  - key:             misc-definitions-in-headers.HeaderFileExtensions
    value:           h,hh,hpp,hxx,
  - key:             misc-definitions-in-headers.UseHeaderFileExtension
    value:           '1'

The list of header suffixes should be configurable.

29

https

clang-tidy/abseil/AliasFreeHeadersCheck.h
19

Hm

docs/clang-tidy/checks/list.rst
155

Many unrelated movements.

Eugene.Zelenko added inline comments.
docs/ReleaseNotes.rst
73

Please highlight using with ``.

docs/clang-tidy/checks/abseil-alias-free-headers.rst
6

Please highlight using with ``. Same in other places.

Eugene.Zelenko added inline comments.Dec 7 2018, 10:51 AM
docs/clang-tidy/checks/abseil-alias-free-headers.rst
13

Missing link to guidelines,

Have you run this check over any large code bases to see what its false positive rate looks like? I have to imagine we're going to need some escape hatch for system headers (we shouldn't complain about using declarations outside of the user's control).

clang-tidy/abseil/AliasFreeHeadersCheck.cpp
28

What is a "convenience alias" and why is it dangerous? The diagnostic should explain what's wrong with the user's code.

29

No links in diagnostics, whether http or https. ;-)

Also, why should this be a separate check from the other positional one in D55411?

Naysh added inline comments.Dec 10 2018, 5:19 PM
docs/clang-tidy/checks/abseil-alias-free-headers.rst
13

@Eugene.Zelenko: Sorry, I'm not sure what you mean. Could you clarify what guidelines you're referring to?

Eugene.Zelenko added inline comments.Dec 10 2018, 5:26 PM
docs/clang-tidy/checks/abseil-alias-free-headers.rst
13

Please see documentation in other using-related checks.

aaron.ballman added inline comments.Dec 11 2018, 12:09 PM
docs/clang-tidy/checks/abseil-alias-free-headers.rst
13

I think he's talking about the fact that this is text and not a hyperlink. It should look something more like

The `Abseil Style Guide <http://google.github.io/styleguide/cppguide.html#Aliases>`_ discusses this issue in more detail.
Naysh marked an inline comment as done.Dec 12 2018, 8:50 AM
Naysh added inline comments.
docs/clang-tidy/checks/abseil-alias-free-headers.rst
13

Ah okay, that makes sense. Thanks for your help!