aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Format/remove-duplicate-includes.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2016-08-10 09:32:23 +0000
committerEric Liu <ioeric@google.com>2016-08-10 09:32:23 +0000
commita992afe80977bedcbe85a1140efcc8fd28878df1 (patch)
tree5b34c4e69094e79437a4629efb4484e28a3c5e36 /clang/test/Format/remove-duplicate-includes.cpp
parente4195dc8039d0a9e422dd64e44021b05c05a541e (diff)
downloadllvm-a992afe80977bedcbe85a1140efcc8fd28878df1.zip
llvm-a992afe80977bedcbe85a1140efcc8fd28878df1.tar.gz
llvm-a992afe80977bedcbe85a1140efcc8fd28878df1.tar.bz2
Make clang-format remove duplicate headers when sorting #includes.
Summary: When sorting #includes, #include directives that have the same text will be deduplicated when sorting #includes, and only the first #include in the duplicate #includes remains. If the `Cursor` is provided and put on a deleted #include, it will be put on the remaining #include in the duplicate #includes. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D23274 llvm-svn: 278206
Diffstat (limited to 'clang/test/Format/remove-duplicate-includes.cpp')
-rw-r--r--clang/test/Format/remove-duplicate-includes.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/test/Format/remove-duplicate-includes.cpp b/clang/test/Format/remove-duplicate-includes.cpp
new file mode 100644
index 0000000..dedb1f4
--- /dev/null
+++ b/clang/test/Format/remove-duplicate-includes.cpp
@@ -0,0 +1,14 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s \
+// RUN: | clang-format -style="{BasedOnStyle: LLVM, SortIncludes: true}" -lines=1:5 \
+// RUN: | FileCheck -strict-whitespace %s
+// CHECK: {{^#include\ <a>$}}
+#include <a>
+// CHECK: {{^#include\ <b>$}}
+#include <b>
+#include <a>
+#include <b>
+#include <b>
+{
+// CHECK: {{^\ \ int x\ \ ;$}}
+ int x ;
+}