[clang-tidy] Fix description for misc-definitions-in-headers.
authorHaojian Wu <hokein@google.com>
Tue, 28 May 2019 14:50:42 +0000 (14:50 +0000)
committerHaojian Wu <hokein@google.com>
Tue, 28 May 2019 14:50:42 +0000 (14:50 +0000)
Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D62524

llvm-svn: 361834

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

index a36f307..a496e3b 100644 (file)
@@ -124,13 +124,16 @@ void DefinitionsInHeadersCheck::check(const MatchFinder::MatchResult &Result) {
       }
     }
 
-    bool is_full_spec = FD->getTemplateSpecializationKind() != TSK_Undeclared;
+    bool IsFullSpec = FD->getTemplateSpecializationKind() != TSK_Undeclared;
     diag(FD->getLocation(),
          "%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 ");
+        << IsFullSpec << FD;
+    diag(FD->getLocation(), /*FixDescription=*/"make as 'inline'",
+         DiagnosticIDs::Note)
+        << FixItHint::CreateInsertion(FD->getReturnTypeSourceRange().getBegin(),
+                                      "inline ");
   } else if (const auto *VD = dyn_cast<VarDecl>(ND)) {
     // Static data members of a class template are allowed.
     if (VD->getDeclContext()->isDependentContext() && VD->isStaticDataMember())
index 5e83e68..662b061 100644 (file)
@@ -2,6 +2,7 @@
 
 int f() {
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f' defined in a header file; function definitions in header files can lead to ODR violations [misc-definitions-in-headers]
+// CHECK-MESSAGES: :[[@LINE-2]]:5: note: make as 'inline'
 // CHECK-FIXES: inline int f() {
   return 1;
 }