[PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 23 09:42:14 PST 2015

hokein marked 9 inline comments as done.

Comment at: clang-tidy/google/DefinitionsInHeadersCheck.cpp:52
@@ +51,3 @@
+    // Inline function is allowed.
+    if (funDecl->isInlined())
+      return;
alexfh wrote:
> This check can be done in the matcher.
The `isInline` AST matcher seems only match the function with `inline` key words. It could not detect the member function defined within class, such as:

class A {
  int f() { return 1; }

Comment at: clang-tidy/google/DefinitionsInHeadersCheck.h:17
@@ +16,3 @@
+namespace tidy {
+namespace google {
alexfh wrote:
> This check is generic enough. It should go to the `misc` module, IMO.
Done. Move to `misc` module

Comment at: unittests/clang-tidy/GoogleModuleTest.cpp:140
@@ +139,3 @@
+                                         "}", "foo.h"));
+  EXPECT_EQ(errorMessage, runCheckOnCode("template <typename T>\n"
+                                         "T f() {\n"
alexfh wrote:
> I think, we can already use raw string literals (at least, MSVC 2013 seems to support them). Raw string literals would make the test cases more readable, imo.
The Raw string literals doesn't work well with multiple lines in macro. I try it on my local machine, it will break compilation.


More information about the cfe-commits mailing list