hokein created this revision.
hokein added a reviewer: alexfh.
hokein added a subscriber: cfe-commits.

http://reviews.llvm.org/D22260

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

Index: test/clang-tidy/misc-definitions-in-headers.hpp
===================================================================
--- test/clang-tidy/misc-definitions-in-headers.hpp
+++ test/clang-tidy/misc-definitions-in-headers.hpp
@@ -29,6 +29,7 @@
 template <>
 int CA::f3() {
 // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function 'f3<int>' defined in a 
header file;
+// CHECK-FIXES: inline int CA::f3() {
   int a = 1;
   return a;
 }
@@ -90,8 +91,9 @@
 }
 
 template <>
-// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: function 'f3<int>' defined in a 
header file;
 int f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3<int>' defined in a 
header file;
+// CHECK-FIXES: inline int f3() {
   int a = 1;
   return a;
 }
@@ -153,6 +155,7 @@
 
 int CD<int, int>::f() {
 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: function 'f' defined in a header 
file;
+// CHECK-FIXES: inline int CD<int, int>::f() {
   return 0;
 }
 
Index: clang-tidy/misc/DefinitionsInHeadersCheck.cpp
===================================================================
--- clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -126,8 +126,8 @@
     diag(FD->getLocation(),
          "function %0 defined in a header file; "
          "function definitions in header files can lead to ODR violations")
-        << FD << FixItHint::CreateInsertion(FD->getSourceRange().getBegin(),
-                                            "inline ");
+        << 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.
     if (VD->getDeclContext()->isDependentContext() && VD->isStaticDataMember())


Index: test/clang-tidy/misc-definitions-in-headers.hpp
===================================================================
--- test/clang-tidy/misc-definitions-in-headers.hpp
+++ test/clang-tidy/misc-definitions-in-headers.hpp
@@ -29,6 +29,7 @@
 template <>
 int CA::f3() {
 // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function 'f3<int>' defined in a header file;
+// CHECK-FIXES: inline int CA::f3() {
   int a = 1;
   return a;
 }
@@ -90,8 +91,9 @@
 }
 
 template <>
-// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: function 'f3<int>' defined in a header file;
 int f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3<int>' defined in a header file;
+// CHECK-FIXES: inline int f3() {
   int a = 1;
   return a;
 }
@@ -153,6 +155,7 @@
 
 int CD<int, int>::f() {
 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: function 'f' defined in a header file;
+// CHECK-FIXES: inline int CD<int, int>::f() {
   return 0;
 }
 
Index: clang-tidy/misc/DefinitionsInHeadersCheck.cpp
===================================================================
--- clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -126,8 +126,8 @@
     diag(FD->getLocation(),
          "function %0 defined in a header file; "
          "function definitions in header files can lead to ODR violations")
-        << FD << FixItHint::CreateInsertion(FD->getSourceRange().getBegin(),
-                                            "inline ");
+        << 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.
     if (VD->getDeclContext()->isDependentContext() && VD->isStaticDataMember())
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to