[clang-tools-extra] r306650 - [clang-tidy] follow-up on misc-definitions-in-header check.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 29 01:28:45 PDT 2017
Author: hokein
Date: Thu Jun 29 01:28:45 2017
New Revision: 306650
URL: http://llvm.org/viewvc/llvm-project?rev=306650&view=rev
Log:
[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
Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst?rev=306650&r1=306649&r2=306650&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst Thu Jun 29 01:28:45 2017
@@ -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
-------
Modified: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py?rev=306650&r1=306649&r2=306650&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py (original)
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py Thu Jun 29 01:28:45 2017
@@ -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.
Modified: clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp?rev=306650&r1=306649&r2=306650&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp Thu Jun 29 01:28:45 2017
@@ -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 tem
}
constexpr int k = 1; // OK: constexpr variable has internal linkage.
+
+constexpr int f10() { return 0; } // OK: constexpr function definition.
More information about the cfe-commits
mailing list