This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Improve check cert-dcl58-cpp.
ClosedPublic

Authored by balazske on Jul 8 2022, 1:23 AM.

Details

Summary

Detect template specializations that should be handled specially.
In some cases it is allowed to extend the std namespace with
template specializations.

Diff Detail

Event Timeline

balazske created this revision.Jul 8 2022, 1:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2022, 1:23 AM
balazske requested review of this revision.Jul 8 2022, 1:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2022, 1:23 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aaron.ballman added inline comments.Jul 8 2022, 7:54 AM
clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp
29

Might as well give this a better name so it's less similar to List.

92

This one is missing the system header check, but I wonder if that can be handled once in the call to addMatcher() instead of needing to be sprinkled here?

135

You should add the newline back.

balazske updated this revision to Diff 443609.Jul 11 2022, 5:29 AM
balazske marked 2 inline comments as done.

address review comments

aaron.ballman accepted this revision.Jul 11 2022, 9:05 AM

LGTM with some minor nits.

clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp
80–81

This one can go as well, right?

clang-tools-extra/test/clang-tidy/checkers/cert/dcl58-cpp.cpp
209

Can you add a comment above this to mention that an alias declaration is the same as a typedef, and does not introduce a user-defined type, which is why the below fails.

256

Same mention here about an alias declaration not being a user-defined type.

This revision is now accepted and ready to land.Jul 11 2022, 9:05 AM
balazske updated this revision to Diff 444165.Jul 13 2022, 12:01 AM
balazske marked 3 inline comments as done.

Added comments, removed unneeded AST matcher code.

balazske marked an inline comment as done.Jul 13 2022, 11:36 PM
This revision was automatically updated to reflect the committed changes.

This appears to be causing a crash with friend declarations. The crash happens during matching, see https://github.com/llvm/llvm-project/issues/56902