[PATCH] D129348: [clang-format] Fix an assertion failure on -lines=0:n
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 8 23:41:38 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG615f838f7380: [clang-format] Fix an assertion failure on -lines=0:n (authored by owenpan).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129348/new/
https://reviews.llvm.org/D129348
Files:
clang/test/Format/line-ranges.cpp
clang/tools/clang-format/ClangFormat.cpp
Index: clang/tools/clang-format/ClangFormat.cpp
===================================================================
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -246,8 +246,12 @@
errs() << "error: invalid <start line>:<end line> pair\n";
return true;
}
+ if (FromLine < 1) {
+ errs() << "error: start line should be at least 1\n";
+ return true;
+ }
if (FromLine > ToLine) {
- errs() << "error: start line should be less than end line\n";
+ errs() << "error: start line should not exceed end line\n";
return true;
}
SourceLocation Start = Sources.translateLineCol(ID, FromLine, 1);
Index: clang/test/Format/line-ranges.cpp
===================================================================
--- clang/test/Format/line-ranges.cpp
+++ clang/test/Format/line-ranges.cpp
@@ -9,3 +9,11 @@
// CHECK: {{^int\ \*i;$}}
int * i;
+
+// RUN: not clang-format -lines=0:1 < %s 2>&1 \
+// RUN: | FileCheck -strict-whitespace -check-prefix=CHECK0 %s
+// CHECK0: error: start line should be at least 1
+
+// RUN: not clang-format -lines=2:1 < %s 2>&1 \
+// RUN: | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
+// CHECK1: error: start line should not exceed end line
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129348.443416.patch
Type: text/x-patch
Size: 1310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220709/f0b49163/attachment.bin>
More information about the cfe-commits
mailing list