[PATCH] D34771: [clang-tidy] follow-up on misc-definitions-in-header check.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 28 12:24:23 PDT 2017
hokein created this revision.
Herald added subscribers: xazax.hun, JDevlieghere.
- add `-std=c++11` to `.hpp` file by default.
- add constexpr function to test and doc.
https://reviews.llvm.org/D34771
Files:
docs/clang-tidy/checks/misc-definitions-in-headers.rst
test/clang-tidy/check_clang_tidy.py
test/clang-tidy/misc-definitions-in-headers.hpp
Index: test/clang-tidy/misc-definitions-in-headers.hpp
===================================================================
--- test/clang-tidy/misc-definitions-in-headers.hpp
+++ test/clang-tidy/misc-definitions-in-headers.hpp
@@ -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 @@
}
constexpr int k = 1; // OK: constexpr variable has internal linkage.
+
+constexpr int f10() { return 0; } // OK: constexpr function definition.
Index: test/clang-tidy/check_clang_tidy.py
===================================================================
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -58,8 +58,8 @@
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.
Index: docs/clang-tidy/checks/misc-definitions-in-headers.rst
===================================================================
--- docs/clang-tidy/checks/misc-definitions-in-headers.rst
+++ docs/clang-tidy/checks/misc-definitions-in-headers.rst
@@ -82,6 +82,8 @@
constexpr int k = 1; // OK: constexpr variable has internal linkage.
+ constexpr int f10() { return 0; } // OK: constexpr function definition.
+
Options
-------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34771.104489.patch
Type: text/x-patch
Size: 1821 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170628/4a415595/attachment.bin>
More information about the cfe-commits
mailing list