forked from OSchip/llvm-project
[clang-tidy] follow-up on misc-definitions-in-header check.
Summary: A follow-up on D34449: * add `-std=c++11` to `.hpp` file by default. * add constexpr function to test and doc. Reviewers: alexfh Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D34771 llvm-svn: 306650
This commit is contained in:
parent
42caad0257
commit
6a3f5552cc
|
@ -82,6 +82,8 @@ from multiple translation units.
|
|||
|
||||
constexpr int k = 1; // OK: constexpr variable has internal linkage.
|
||||
|
||||
constexpr int f10() { return 0; } // OK: constexpr function definition.
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
|
|
|
@ -58,8 +58,8 @@ def main():
|
|||
|
||||
clang_tidy_extra_args = extra_args
|
||||
if len(clang_tidy_extra_args) == 0:
|
||||
clang_tidy_extra_args = ['--', '--std=c++11'] if extension == '.cpp' \
|
||||
else ['--']
|
||||
clang_tidy_extra_args = ['--', '--std=c++11'] \
|
||||
if extension == '.cpp' or extension == '.hpp' else ['--']
|
||||
|
||||
# Tests should not rely on STL being available, and instead provide mock
|
||||
# implementations of relevant APIs.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %check_clang_tidy %s misc-definitions-in-headers %t -- -- -std=c++11
|
||||
// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
|
||||
|
||||
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]
|
||||
|
@ -177,3 +177,5 @@ int CD<T, int>::f() { // OK: partial template specialization.
|
|||
}
|
||||
|
||||
constexpr int k = 1; // OK: constexpr variable has internal linkage.
|
||||
|
||||
constexpr int f10() { return 0; } // OK: constexpr function definition.
|
||||
|
|
Loading…
Reference in New Issue