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

Alexander Kornienko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 14 02:04:02 PST 2017


alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.


================
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);
----------------
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.


https://reviews.llvm.org/D29928





More information about the cfe-commits mailing list