This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Improve diagnostic message for misc-definitions-in-header.
ClosedPublic

Authored by hokein on Feb 14 2017, 12:53 AM.

Details

Summary

Users might get confused easily when they see the check's message on
full template function speciliations.

Add a note to the output message, which mentions these kind of function
specializations are treated as regular functions.

Event Timeline

hokein created this revision.Feb 14 2017, 12:53 AM
alexfh requested changes to this revision.Feb 14 2017, 2:04 AM
alexfh added inline comments.
clang-tidy/misc/DefinitionsInHeadersCheck.cpp
133–137

Notes are useful for pointing at related but different locations (e.g. point to the declaration of an entity when the diagnostic is issued at a reference to the entity).

Here I would suggest just issuing a different message (e.g. diag(..., "%select{function|full function template specialization}0 %1 defined in a header file ....") << (FD->getTemplateSpecializationKind() != TSK_Undeclared) << FD << ...;) or if it seems more helpful, add a note pointing to the template being specialized.

This revision now requires changes to proceed.Feb 14 2017, 2:04 AM
hokein updated this revision to Diff 88336.Feb 14 2017, 2:41 AM
hokein edited edge metadata.

Address review comment.

hokein marked an inline comment as done.Feb 14 2017, 2:43 AM
hokein added inline comments.
clang-tidy/misc/DefinitionsInHeadersCheck.cpp
133–137

SG. Didn't know %select before, thanks for pointing it out.

alexfh accepted this revision.Feb 14 2017, 4:19 AM

LG. Thank you!

This revision is now accepted and ready to land.Feb 14 2017, 4:19 AM
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.