forked from OSchip/llvm-project
[clang-tidy] Fix misc-definitions-in-headers misplaced fixing to fully templated function.
Reviewers: alexfh, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D22260 llvm-svn: 275263
This commit is contained in:
parent
57548a6fa6
commit
0b067c1252
|
@ -126,8 +126,8 @@ void DefinitionsInHeadersCheck::check(const MatchFinder::MatchResult &Result) {
|
||||||
diag(FD->getLocation(),
|
diag(FD->getLocation(),
|
||||||
"function %0 defined in a header file; "
|
"function %0 defined in a header file; "
|
||||||
"function definitions in header files can lead to ODR violations")
|
"function definitions in header files can lead to ODR violations")
|
||||||
<< FD << FixItHint::CreateInsertion(FD->getSourceRange().getBegin(),
|
<< FD << FixItHint::CreateInsertion(
|
||||||
"inline ");
|
FD->getReturnTypeSourceRange().getBegin(), "inline ");
|
||||||
} else if (const auto *VD = dyn_cast<VarDecl>(ND)) {
|
} else if (const auto *VD = dyn_cast<VarDecl>(ND)) {
|
||||||
// Static data members of a class template are allowed.
|
// Static data members of a class template are allowed.
|
||||||
if (VD->getDeclContext()->isDependentContext() && VD->isStaticDataMember())
|
if (VD->getDeclContext()->isDependentContext() && VD->isStaticDataMember())
|
||||||
|
|
|
@ -29,6 +29,7 @@ void CA::f2() { }
|
||||||
template <>
|
template <>
|
||||||
int CA::f3() {
|
int CA::f3() {
|
||||||
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function 'f3<int>' defined in a header file;
|
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function 'f3<int>' defined in a header file;
|
||||||
|
// CHECK-FIXES: inline int CA::f3() {
|
||||||
int a = 1;
|
int a = 1;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
@ -90,8 +91,9 @@ T f3() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: function 'f3<int>' defined in a header file;
|
|
||||||
int f3() {
|
int f3() {
|
||||||
|
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3<int>' defined in a header file;
|
||||||
|
// CHECK-FIXES: inline int f3() {
|
||||||
int a = 1;
|
int a = 1;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
@ -153,6 +155,7 @@ struct CD<int, int> {
|
||||||
|
|
||||||
int CD<int, int>::f() {
|
int CD<int, int>::f() {
|
||||||
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: function 'f' defined in a header file;
|
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: function 'f' defined in a header file;
|
||||||
|
// CHECK-FIXES: inline int CD<int, int>::f() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue