This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rL295048: [clang-tidy] Improve diagnostic message for 
misc-definitions-in-header. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D29928?vs=88336&id=88350#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29928

Files:
  clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp


Index: clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
@@ -28,7 +28,7 @@
 
 template <>
 int CA::f3() {
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function 'f3<int>' defined in a 
header file;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: full function template 
specialization 'f3<int>' defined in a header file;
 // CHECK-FIXES: inline int CA::f3() {
   int a = 1;
   return a;
@@ -92,7 +92,7 @@
 
 template <>
 int f3() {
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3<int>' defined in a 
header file;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: full function template 
specialization 'f3<int>' defined in a header file;
 // CHECK-FIXES: inline int f3() {
   int a = 1;
   return a;
Index: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -122,10 +122,12 @@
       }
     }
 
+    bool is_full_spec = FD->getTemplateSpecializationKind() != TSK_Undeclared;
     diag(FD->getLocation(),
-         "function %0 defined in a header file; "
-         "function definitions in header files can lead to ODR violations")
-        << FD << FixItHint::CreateInsertion(
+         "%select{function|full function template specialization}0 %1 defined "
+         "in a header file; function definitions in header files can lead to "
+         "ODR violations")
+        << is_full_spec << FD << FixItHint::CreateInsertion(
                      FD->getReturnTypeSourceRange().getBegin(), "inline ");
   } else if (const auto *VD = dyn_cast<VarDecl>(ND)) {
     // Static data members of a class template are allowed.


Index: clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
@@ -28,7 +28,7 @@
 
 template <>
 int CA::f3() {
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function 'f3<int>' defined in a header file;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: full function template specialization 'f3<int>' defined in a header file;
 // CHECK-FIXES: inline int CA::f3() {
   int a = 1;
   return a;
@@ -92,7 +92,7 @@
 
 template <>
 int f3() {
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3<int>' defined in a header file;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: full function template specialization 'f3<int>' defined in a header file;
 // CHECK-FIXES: inline int f3() {
   int a = 1;
   return a;
Index: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -122,10 +122,12 @@
       }
     }
 
+    bool is_full_spec = FD->getTemplateSpecializationKind() != TSK_Undeclared;
     diag(FD->getLocation(),
-         "function %0 defined in a header file; "
-         "function definitions in header files can lead to ODR violations")
-        << FD << FixItHint::CreateInsertion(
+         "%select{function|full function template specialization}0 %1 defined "
+         "in a header file; function definitions in header files can lead to "
+         "ODR violations")
+        << is_full_spec << FD << FixItHint::CreateInsertion(
                      FD->getReturnTypeSourceRange().getBegin(), "inline ");
   } else if (const auto *VD = dyn_cast<VarDecl>(ND)) {
     // Static data members of a class template are allowed.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to