aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2022-02-03 17:26:41 +0100
committerKadir Cetinkaya <kadircet@google.com>2022-02-03 17:32:43 +0100
commit0447ec2fb050eb37ed1f5991a1562dea6e228f9e (patch)
tree26a9388ba269ac98651574dffc07af58684323d3 /clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
parent2349fb031270985d28d3056685d5f76dc3942c9d (diff)
downloadllvm-0447ec2fb050eb37ed1f5991a1562dea6e228f9e.zip
llvm-0447ec2fb050eb37ed1f5991a1562dea6e228f9e.tar.gz
llvm-0447ec2fb050eb37ed1f5991a1562dea6e228f9e.tar.bz2
[clang-tidy] Fix LLVM include order check policy
Clang-format LLVM style has a custom include category for gtest/ and gmock/ headers between regular includes and angled includes. Do the same here. Fixes https://github.com/llvm/llvm-project/issues/53525. Differential Revision: https://reviews.llvm.org/D118913
Diffstat (limited to 'clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
index c962fb3..ab75e31 100644
--- a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -66,11 +66,15 @@ static int getPriority(StringRef Filename, bool IsAngled, bool IsMainModule) {
Filename.startswith("clang/") || Filename.startswith("clang-c/"))
return 2;
- // System headers are sorted to the end.
- if (IsAngled || Filename.startswith("gtest/") ||
- Filename.startswith("gmock/"))
+ // Put these between system and llvm headers to be consistent with LLVM
+ // clang-format style.
+ if (Filename.startswith("gtest/") || Filename.startswith("gmock/"))
return 3;
+ // System headers are sorted to the end.
+ if (IsAngled)
+ return 4;
+
// Other headers are inserted between the main module header and LLVM headers.
return 1;
}