[PATCH] D67213: [clang-tidy] Fix definitions in headers check to respect qualifiers

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 5 01:11:35 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL371022: [clang-tidy] Fix definitions in headers check to respect qualifiers (authored by kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67213?vs=218851&id=218855#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67213/new/

https://reviews.llvm.org/D67213

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
@@ -180,3 +180,15 @@
 constexpr int k = 1; // OK: constexpr variable has internal linkage.
 
 constexpr int f10() { return 0; } // OK: constexpr function definition.
+
+const int f11() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: function 'f11' defined in a header file;
+// CHECK-FIXES: inline const int f11() { return 0; }
+
+template <typename T>
+const T f12();
+
+template <>
+const int f12() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: full function template specialization 'f12<int>' defined in a header file;
+// CHECK-FIXES: inline const int f12() { return 0; }
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
@@ -132,8 +132,7 @@
         << IsFullSpec << FD;
     diag(FD->getLocation(), /*FixDescription=*/"make as 'inline'",
          DiagnosticIDs::Note)
-        << FixItHint::CreateInsertion(FD->getReturnTypeSourceRange().getBegin(),
-                                      "inline ");
+        << FixItHint::CreateInsertion(FD->getInnerLocStart(), "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())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67213.218855.patch
Type: text/x-patch
Size: 1749 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190905/cbd245c5/attachment-0001.bin>


More information about the cfe-commits mailing list