[PATCH] D29928: [clang-tidy] Improve diagnostic message for misc-definitions-in-header.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 14 02:44:00 PST 2017


hokein marked an inline comment as done.
hokein added inline comments.


================
Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:131-135
+    if (FD->getTemplateSpecializationKind() != TSK_Undeclared)
+      diag(FD->getLocation(), "this is a full function template specilization "
+                              "which behaves as a regular function, so the ODR "
+                              "still applies",
+           DiagnosticIDs::Note);
----------------
alexfh wrote:
> 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.
SG. Didn't know `%select` before, thanks for pointing it out.


https://reviews.llvm.org/D29928





More information about the cfe-commits mailing list