[clang] [clang] Enforce 1-based indexing for command line source locations (PR #139457)
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Wed May 14 21:49:53 PDT 2025
================
@@ -0,0 +1,19 @@
+// Related to #139457
+// Clang uses 1-based indexing for source locations given from the command-line.
+// Verify that `clang-refactor` rejects 0 as an invalid value for line or column number.
+
+// For range start:
+// RUN: not clang-refactor local-rename -selection=%s:0:1-1:1 -new-name=test %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-DIAG %s
+// RUN: not clang-refactor local-rename -selection=%s:1:0-1:1 -new-name=test %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-DIAG %s
+
+// For range end:
+// RUN: not clang-refactor local-rename -selection=%s:1:1-0:1 -new-name=test %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-DIAG %s
+// RUN: not clang-refactor local-rename -selection=%s:1:1-1:0 -new-name=test %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-DIAG %s
+
+// CHECK-DIAG: error: '-selection' option must be specified using <file>:<line>:<column>
----------------
MaskRay wrote:
If the diagnostic is on one line, use a single CHECK.
Multiple CHECK accepts output that we don't expect.
We don't rigidly require line wrapping for tests.
https://github.com/llvm/llvm-project/pull/139457
More information about the cfe-commits
mailing list