Skip to content

Commit 5a9f386

Browse files
committed
[clang-tidy] Make clang-format and include-order-check coherent
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. Differential Revision: https://reviews.llvm.org/D91602
1 parent 6976fef commit 5a9f386

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ static int getPriority(StringRef Filename, bool IsAngled, bool IsMainModule) {
6767
return 2;
6868

6969
// System headers are sorted to the end.
70-
if (IsAngled || Filename.startswith("gtest/"))
70+
if (IsAngled || Filename.startswith("gtest/") ||
71+
Filename.startswith("gmock/"))
7172
return 3;
7273

7374
// Other headers are inserted between the main module header and LLVM headers.

clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/gmock/foo.h

Whitespace-only changes.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: #includes are not sorted properly
44
#include "j.h"
55
#include "gtest/foo.h"
6+
#include "gmock/foo.h"
67
#include "i.h"
78
#include <s.h>
89
#include "llvm/a.h"
@@ -16,6 +17,7 @@
1617
// CHECK-FIXES-NEXT: #include "clang/b.h"
1718
// CHECK-FIXES-NEXT: #include "llvm-c/d.h" // -c
1819
// CHECK-FIXES-NEXT: #include "llvm/a.h"
20+
// CHECK-FIXES-NEXT: #include "gmock/foo.h"
1921
// CHECK-FIXES-NEXT: #include "gtest/foo.h"
2022
// CHECK-FIXES-NEXT: #include <s.h>
2123

0 commit comments

Comments
 (0)