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())
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())
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits