[PATCH] D91602: [clang-tidy] Make clang-format and include-order-check coherent

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 17 01:31:02 PST 2020


kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
kadircet requested review of this revision.

LLVM style puts both gtest and gmock to the end of the include list.
But llvm-include-order-check was only moving gtest headers to the end, resulting
in a false tidy-warning.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91602

Files:
  clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
@@ -3,6 +3,7 @@
 // CHECK-MESSAGES: [[@LINE+2]]:1: warning: #includes are not sorted properly
 #include "j.h"
 #include "gtest/foo.h"
+#include "gmock/foo.h"
 #include "i.h"
 #include <s.h>
 #include "llvm/a.h"
@@ -16,6 +17,7 @@
 // CHECK-FIXES-NEXT: #include "clang/b.h"
 // CHECK-FIXES-NEXT: #include "llvm-c/d.h" // -c
 // CHECK-FIXES-NEXT: #include "llvm/a.h"
+// CHECK-FIXES-NEXT: #include "gmock/foo.h"
 // CHECK-FIXES-NEXT: #include "gtest/foo.h"
 // CHECK-FIXES-NEXT: #include <s.h>
 
Index: clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -67,7 +67,8 @@
     return 2;
 
   // System headers are sorted to the end.
-  if (IsAngled || Filename.startswith("gtest/"))
+  if (IsAngled || Filename.startswith("gtest/") ||
+      Filename.startswith("gmock/"))
     return 3;
 
   // Other headers are inserted between the main module header and LLVM headers.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91602.305698.patch
Type: text/x-patch
Size: 1343 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201117/3bc106da/attachment.bin>


More information about the cfe-commits mailing list