[clang] cf9b25e - [lit] Script to automate use of %(line-n). Use in CodeComplete tests.

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 19 05:19:30 PST 2022


Author: Sam McCall
Date: 2022-12-19T14:19:21+01:00
New Revision: cf9b25e0adc42546e4dc5ff51ee8674d45bac26b

URL: https://github.com/llvm/llvm-project/commit/cf9b25e0adc42546e4dc5ff51ee8674d45bac26b
DIFF: https://github.com/llvm/llvm-project/commit/cf9b25e0adc42546e4dc5ff51ee8674d45bac26b.diff

LOG: [lit] Script to automate use of %(line-n). Use in CodeComplete tests.

Tests where the RUN-lines/CHECK-ed output refer to line numbers in the test
file are a maintenance burden, as inserting text in the appropriate place
invalidates all the subsequent line numbers.

Lit supports %(line+n) for this, and FileCheck supports [[@LINE+N]].
But many existing tests don't make use of it and still need to be modified.

This commit adds a script that can find line numbers in tests according to a
regex and replace them with the appropriate relative-line reference.
It contains some options to avoid inappropriately rewriting tests where absolute
numbers are appropriate: a "nearby" threshold and a refusal by default to
replace only some matched line numbers.

I've applied it to CodeComplete tests, this proves the concept but also are the
single worst group of tests I've seen in this respect.
These changes are likely to hit merge conflicts, but can be regenerated with:

```
find ../clang/test/CodeCompletion/ -type f | grep -v /Inputs/ | xargs ../llvm/utils/relative_lines.py --verbose --near=20 --pattern='-code-completion-at[ =]%s:(\\d+):' --pattern='requires fix-it: {(\d+):\d+-(\d+):\d+}'
````

As requested in https://reviews.llvm.org/D140044

Fixes https://github.com/llvm/llvm-project/issues/59553

Differential Revision: https://reviews.llvm.org/D140217

Added: 
    llvm/utils/relative_lines.py

Modified: 
    clang/test/CodeCompletion/PR9728.cpp
    clang/test/CodeCompletion/accessibility-crash.cpp
    clang/test/CodeCompletion/accessibility.cpp
    clang/test/CodeCompletion/after-function-equals.cpp
    clang/test/CodeCompletion/attr.cpp
    clang/test/CodeCompletion/auto.cpp
    clang/test/CodeCompletion/auto_type.c
    clang/test/CodeCompletion/bracket-decl.c
    clang/test/CodeCompletion/call.c
    clang/test/CodeCompletion/call.cpp
    clang/test/CodeCompletion/comments.cpp
    clang/test/CodeCompletion/constexpr.cpp
    clang/test/CodeCompletion/crash-func-decl.cpp
    clang/test/CodeCompletion/crash-func-init.cpp
    clang/test/CodeCompletion/crash-if-directive.cpp
    clang/test/CodeCompletion/crash-null-type.cpp
    clang/test/CodeCompletion/ctor-initializer.cpp
    clang/test/CodeCompletion/ctor-signature.cpp
    clang/test/CodeCompletion/desig-init.cpp
    clang/test/CodeCompletion/deuglify.cpp
    clang/test/CodeCompletion/documentation.cpp
    clang/test/CodeCompletion/documentation.m
    clang/test/CodeCompletion/enable-if-attr-crash.cpp
    clang/test/CodeCompletion/end-of-file.cpp
    clang/test/CodeCompletion/end-of-ident-macro.cpp
    clang/test/CodeCompletion/end-of-ident.cpp
    clang/test/CodeCompletion/enum-preferred-type.cpp
    clang/test/CodeCompletion/enum-switch-case-qualified.cpp
    clang/test/CodeCompletion/enum-switch-case.c
    clang/test/CodeCompletion/enum-switch-case.cpp
    clang/test/CodeCompletion/function-templates.cpp
    clang/test/CodeCompletion/functions.cpp
    clang/test/CodeCompletion/ignore-ns-level-decls.cpp
    clang/test/CodeCompletion/included-symlinks.cpp
    clang/test/CodeCompletion/incomplete-member.cpp
    clang/test/CodeCompletion/incomplete-ret-type.cpp
    clang/test/CodeCompletion/inside-macros.cpp
    clang/test/CodeCompletion/invalid-initialized-class.cpp
    clang/test/CodeCompletion/lambdas.cpp
    clang/test/CodeCompletion/macros-in-modules.c
    clang/test/CodeCompletion/macros-in-modules.m
    clang/test/CodeCompletion/macros.c
    clang/test/CodeCompletion/member-access-qualifiers.cpp
    clang/test/CodeCompletion/member-access.c
    clang/test/CodeCompletion/namespace-alias.cpp
    clang/test/CodeCompletion/namespace.cpp
    clang/test/CodeCompletion/nested-name-specifier.cpp
    clang/test/CodeCompletion/objc-expr.m
    clang/test/CodeCompletion/objc-member-access.m
    clang/test/CodeCompletion/objc-message.m
    clang/test/CodeCompletion/objc-message.mm
    clang/test/CodeCompletion/objc-protocol-member-access.m
    clang/test/CodeCompletion/operator.cpp
    clang/test/CodeCompletion/ordinary-name.c
    clang/test/CodeCompletion/overrides.cpp
    clang/test/CodeCompletion/paren_locs.cpp
    clang/test/CodeCompletion/pragma-macro-token-caching.c
    clang/test/CodeCompletion/preamble.c
    clang/test/CodeCompletion/preferred-type.cpp
    clang/test/CodeCompletion/qualifiers-as-written.cpp
    clang/test/CodeCompletion/self-inits.cpp
    clang/test/CodeCompletion/signatures-crash.cpp
    clang/test/CodeCompletion/tag.c
    clang/test/CodeCompletion/tag.cpp
    clang/test/CodeCompletion/template-signature.cpp
    clang/test/CodeCompletion/templates.cpp
    clang/test/CodeCompletion/this-quals.cpp
    clang/test/CodeCompletion/truncation.c
    clang/test/CodeCompletion/uninstantiated_params.cpp
    clang/test/CodeCompletion/using-enum.cpp
    clang/test/CodeCompletion/using-namespace.cpp
    clang/test/CodeCompletion/using.cpp
    clang/test/CodeCompletion/variadic-template.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/CodeCompletion/PR9728.cpp b/clang/test/CodeCompletion/PR9728.cpp
index 91f49be91fcf4..d1ee7c7f0b04a 100644
--- a/clang/test/CodeCompletion/PR9728.cpp
+++ b/clang/test/CodeCompletion/PR9728.cpp
@@ -4,6 +4,6 @@ struct SFoo;
 
 struct brokenfile_t {
   brokenfile_t (N::
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:6:20 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):20 %s -o - | FileCheck %s
   // CHECK: SFoo
 

diff  --git a/clang/test/CodeCompletion/accessibility-crash.cpp b/clang/test/CodeCompletion/accessibility-crash.cpp
index b54f7cea3e201..5d6dac3d77145 100644
--- a/clang/test/CodeCompletion/accessibility-crash.cpp
+++ b/clang/test/CodeCompletion/accessibility-crash.cpp
@@ -11,7 +11,7 @@ class Y : public X {
   int test() {
     []() {
 
-      // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:1 %s -o - \
+      // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):1 %s -o - \
       // RUN: | FileCheck %s
       // CHECK: priv (InBase,Inaccessible)
       // CHECK: prot (InBase)

diff  --git a/clang/test/CodeCompletion/accessibility.cpp b/clang/test/CodeCompletion/accessibility.cpp
index a050efc9a73d5..1ce95763db22c 100644
--- a/clang/test/CodeCompletion/accessibility.cpp
+++ b/clang/test/CodeCompletion/accessibility.cpp
@@ -19,25 +19,25 @@ class Unrelated {
 class Y : public X {
   int test() {
     this->pub = 10;
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:21:11 %s -o - \
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):11 %s -o - \
     // RUN: | FileCheck -check-prefix=THIS %s
     // THIS: priv (InBase,Inaccessible)
     // THIS: prot (InBase)
     // THIS: pub (InBase)
     //
     // Also check implicit 'this->', i.e. complete at the start of the line.
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:21:1 %s -o - \
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-8):1 %s -o - \
     // RUN: | FileCheck -check-prefix=THIS %s
 
     X().pub + 10;
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:32:9 %s -o - \
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):9 %s -o - \
     // RUN: | FileCheck -check-prefix=X-OBJ %s
     // X-OBJ: priv (Inaccessible)
     // X-OBJ: prot (Inaccessible)
     // X-OBJ: pub : [#int#]pub
     
     Y().pub + 10;
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:39:9 %s -o - \
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):9 %s -o - \
     // RUN: | FileCheck -check-prefix=Y-OBJ %s
     // Y-OBJ: priv (InBase,Inaccessible)
     // Y-OBJ: prot (InBase)
@@ -45,29 +45,29 @@ class Y : public X {
 
     this->X::pub = 10;
     X::pub = 10;
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:46:14 %s -o - \
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-2):14 %s -o - \
     // RUN: | FileCheck -check-prefix=THIS-BASE %s
     //
     // THIS-BASE: priv (Inaccessible)
     // THIS-BASE: prot : [#int#]prot
     // THIS-BASE: pub : [#int#]pub
     //
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:47:8 %s -o - \
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-8):8 %s -o - \
     // RUN: | FileCheck -check-prefix=THIS-BASE %s
     
 
     this->Unrelated::pub = 10; // a check we don't crash in this cases.
     Y().Unrelated::pub = 10; // a check we don't crash in this cases.
     Unrelated::pub = 10;
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:59:22 %s -o - \
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-3):22 %s -o - \
     // RUN: | FileCheck -check-prefix=UNRELATED %s
     // UNRELATED: priv (Inaccessible)
     // UNRELATED: prot (Inaccessible)
     // UNRELATED: pub : [#int#]pub
     //
-    // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:60:20 %s -o - \
+    // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-8):20 %s -o - \
     // RUN: | FileCheck -check-prefix=UNRELATED %s
-    // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:61:16 %s -o - \
+    // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-9):16 %s -o - \
     // RUN: | FileCheck -check-prefix=UNRELATED %s
   }
 };
@@ -83,14 +83,14 @@ class Outer {
   class Inner {
     int test() {
       Outer::pub = 10;
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:85:14 %s -o - \
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):14 %s -o - \
     // RUN: | FileCheck -check-prefix=OUTER %s
     // OUTER: priv : [#int#]priv
     // OUTER: prot : [#int#]prot
     // OUTER: pub : [#int#]pub
 
     // Also check the unqualified case.
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:85:1 %s -o - \
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-8):1 %s -o - \
     // RUN: | FileCheck -check-prefix=OUTER %s
     }
   };
@@ -110,12 +110,12 @@ class Inaccessible : private Base {
 class Test : public Accessible, public Inaccessible {
   int test() {
     this->Accessible::pub = 10;
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:112:23 %s -o - \
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):23 %s -o - \
     // RUN: | FileCheck -check-prefix=ACCESSIBLE %s
     // ACCESSIBLE: pub (InBase)
 
     this->Inaccessible::pub = 10;
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:117:25 %s -o - \
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):25 %s -o - \
     // RUN: | FileCheck -check-prefix=INACCESSIBLE %s
     // INACCESSIBLE: pub (InBase,Inaccessible)
   }

diff  --git a/clang/test/CodeCompletion/after-function-equals.cpp b/clang/test/CodeCompletion/after-function-equals.cpp
index 871c2a3f6d917..a13ba41f6ff13 100644
--- a/clang/test/CodeCompletion/after-function-equals.cpp
+++ b/clang/test/CodeCompletion/after-function-equals.cpp
@@ -1,47 +1,47 @@
 struct A {
   A() = default;
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:2:9 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):9 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: COMPLETION: default
   // CHECK-CC1-NEXT: COMPLETION: delete
 
   A(const A &) = default;
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:7:18 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):18 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
   // CHECK-CC2: COMPLETION: default
   // CHECK-CC2-NEXT: COMPLETION: delete
 
   A(const A &, int) = delete;
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:12:23 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):23 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
   // CHECK-CC3-NOT: COMPLETION: default
   // CHECK-CC3: COMPLETION: delete
 
   A(A &&);
 
   A &operator=(const A &) = default;
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:29 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):29 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
   // CHECK-CC4: COMPLETION: default
   // CHECK-CC4-NEXT: COMPLETION: delete
 
   bool operator==(const A &) const = delete;
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:24:38 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):38 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
   // CHECK-CC5-NOT: COMPLETION: default
   // CHECK-CC5: COMPLETION: delete
 
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:24:38 -std=gnu++20 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-5):38 -std=gnu++20 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
   // CHECK-CC6: COMPLETION: default
   // CHECK-CC6-NEXT: COMPLETION: delete
 
   void test() = delete;
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:33:17 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):17 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
   // CHECK-CC7-NOT: COMPLETION: default
   // CHECK-CC7: COMPLETION: delete
 };
 
 A::A(A &&) = default;
-// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:39:14 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):14 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
 // CHECK-CC8: COMPLETION: default
 // CHECK-CC8-NEXT: COMPLETION: delete
 
 void test() = delete;
-// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:44:15 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):15 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
 // CHECK-CC9-NOT: COMPLETION: default
 // CHECK-CC9: COMPLETION: delete
\ No newline at end of file

diff  --git a/clang/test/CodeCompletion/attr.cpp b/clang/test/CodeCompletion/attr.cpp
index c3f76e7f0d99d..cff0fa7224b6c 100644
--- a/clang/test/CodeCompletion/attr.cpp
+++ b/clang/test/CodeCompletion/attr.cpp
@@ -1,5 +1,5 @@
 int a [[gnu::used]];
-// RUN: %clang_cc1 -code-completion-at=%s:1:9 %s | FileCheck --check-prefix=STD %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-1):9 %s | FileCheck --check-prefix=STD %s
 // STD:     COMPLETION: Pattern : __carries_dependency__
 // STD-NOT: COMPLETION: Pattern : __convergent__
 // STD:     COMPLETION: Pattern : __gnu__::__used__
@@ -15,9 +15,9 @@ int a [[gnu::used]];
 // STD:     COMPLETION: Pattern : gnu::alias(<#Aliasee#>)
 // STD:     COMPLETION: Pattern : gnu::used
 // STD-NOT: COMPLETION: Pattern : used
-// RUN: %clang_cc1 -code-completion-at=%s:1:9 -xobjective-c++ %s | FileCheck --check-prefix=STD-OBJC %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-17):9 -xobjective-c++ %s | FileCheck --check-prefix=STD-OBJC %s
 // STD-OBJC: COMPLETION: Pattern : clang::called_once
-// RUN: %clang_cc1 -code-completion-at=%s:1:14 %s | FileCheck --check-prefix=STD-NS %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-19):14 %s | FileCheck --check-prefix=STD-NS %s
 // STD-NS-NOT: COMPLETION: Pattern : __used__
 // STD-NS-NOT: COMPLETION: Pattern : carries_dependency
 // STD-NS-NOT: COMPLETION: Pattern : clang::convergent
@@ -25,12 +25,12 @@ int a [[gnu::used]];
 // STD-NS-NOT: COMPLETION: Pattern : gnu::used
 // STD-NS:     COMPLETION: Pattern : used
 int b [[__gnu__::used]];
-// RUN: %clang_cc1 -code-completion-at=%s:27:18 %s | FileCheck --check-prefix=STD-NSU %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-1):18 %s | FileCheck --check-prefix=STD-NSU %s
 // STD-NSU:     COMPLETION: Pattern : __used__
 // STD-NSU-NOT: COMPLETION: Pattern : used
 
 int c [[using gnu: used]];
-// RUN: %clang_cc1 -code-completion-at=%s:32:15 %s | FileCheck --check-prefix=STD-USING %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-1):15 %s | FileCheck --check-prefix=STD-USING %s
 // STD-USING:     COMPLETION: __gnu__
 // STD-USING:     COMPLETION: _Clang
 // STD-USING-NOT: COMPLETION: Pattern : carries_dependency
@@ -38,10 +38,10 @@ int c [[using gnu: used]];
 // STD-USING-NOT: COMPLETION: Pattern : clang::
 // STD-USING-NOT: COMPLETION: Pattern : gnu::
 // STD-USING:     COMPLETION: gnu
-// RUN: %clang_cc1 -code-completion-at=%s:32:20 %s | FileCheck --check-prefix=STD-NS %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-9):20 %s | FileCheck --check-prefix=STD-NS %s
 
 int d __attribute__((used));
-// RUN: %clang_cc1 -code-completion-at=%s:43:22 %s | FileCheck --check-prefix=GNU %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-1):22 %s | FileCheck --check-prefix=GNU %s
 // GNU:     COMPLETION: Pattern : __carries_dependency__
 // GNU:     COMPLETION: Pattern : __convergent__
 // GNU-NOT: COMPLETION: Pattern : __gnu__::__used__
@@ -56,12 +56,12 @@ int d __attribute__((used));
 #pragma clang attribute push (__attribute__((internal_linkage)), apply_to=variable)
 int e;
 #pragma clang attribute pop
-// RUN: %clang_cc1 -code-completion-at=%s:56:46 %s | FileCheck --check-prefix=PRAGMA %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-3):46 %s | FileCheck --check-prefix=PRAGMA %s
 // PRAGMA: COMPLETION: Pattern : internal_linkage
 
 #ifdef MS_EXT
 int __declspec(thread) f;
-// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:63:16 %s | FileCheck --check-prefix=DS %s
+// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:%(line-1):16 %s | FileCheck --check-prefix=DS %s
 // DS-NOT: COMPLETION: Pattern : __convergent__
 // DS-NOT: COMPLETION: Pattern : __used__
 // DS-NOT: COMPLETION: Pattern : clang::convergent
@@ -71,7 +71,7 @@ int __declspec(thread) f;
 // DS:     COMPLETION: Pattern : uuid
 
 [uuid("123e4567-e89b-12d3-a456-426614174000")] struct g;
-// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:73:2 %s | FileCheck --check-prefix=MS %s
+// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:%(line-1):2 %s | FileCheck --check-prefix=MS %s
 // MS-NOT: COMPLETION: Pattern : __uuid__
 // MS-NOT: COMPLETION: Pattern : clang::convergent
 // MS-NOT: COMPLETION: Pattern : convergent
@@ -85,9 +85,9 @@ void foo() {
   {}
 }
 // FIXME: support for omp attributes would be nice.
-// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:84:5 %s | FileCheck --check-prefix=OMP-NS --allow-empty %s
+// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:%(line-4):5 %s | FileCheck --check-prefix=OMP-NS --allow-empty %s
 // OMP-NS-NOT: COMPLETION: omp
-// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:84:10 %s | FileCheck --check-prefix=OMP-ATTR --allow-empty %s
+// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:%(line-6):10 %s | FileCheck --check-prefix=OMP-ATTR --allow-empty %s
 // OMP-ATTR-NOT: COMPLETION: Pattern : sequence
-// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:84:19 %s | FileCheck --check-prefix=OMP-NESTED --allow-empty %s
+// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:%(line-8):19 %s | FileCheck --check-prefix=OMP-NESTED --allow-empty %s
 // OMP-NESTED-NOT: COMPLETION: Pattern : directive

diff  --git a/clang/test/CodeCompletion/auto.cpp b/clang/test/CodeCompletion/auto.cpp
index 1fc9fb035d473..07c4e849bb9e2 100644
--- a/clang/test/CodeCompletion/auto.cpp
+++ b/clang/test/CodeCompletion/auto.cpp
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 -std=c++11 -code-completion-at=%s:2:9 %s
+// RUN: %clang_cc1 -std=c++11 -code-completion-at=%s:%(line+1):9 %s
 auto i =

diff  --git a/clang/test/CodeCompletion/auto_type.c b/clang/test/CodeCompletion/auto_type.c
index 3fcfff0dcfc95..32294cf3a9de7 100644
--- a/clang/test/CodeCompletion/auto_type.c
+++ b/clang/test/CodeCompletion/auto_type.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -code-completion-at=%s:3:1 %s | FileCheck %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line+2):1 %s | FileCheck %s
 void func() {
 
 }

diff  --git a/clang/test/CodeCompletion/bracket-decl.c b/clang/test/CodeCompletion/bracket-decl.c
index cf80b424d13b2..e21cb5e6ca511 100644
--- a/clang/test/CodeCompletion/bracket-decl.c
+++ b/clang/test/CodeCompletion/bracket-decl.c
@@ -4,6 +4,6 @@ static const int len = 1234;
 
 void foo() {
   char arr[
-// RUN: %clang_cc1 -fsyntax-only -code-completion-macros -code-completion-at=%s:6:12 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-macros -code-completion-at=%s:%(line-1):12 %s -o - | FileCheck %s
 // CHECK: COMPLETION: len
 // CHECK: COMPLETION: PATHSIZE

diff  --git a/clang/test/CodeCompletion/call.c b/clang/test/CodeCompletion/call.c
index fe8644595f677..d40e5a624f8a2 100644
--- a/clang/test/CodeCompletion/call.c
+++ b/clang/test/CodeCompletion/call.c
@@ -6,10 +6,10 @@ void test() {
   f0(0, 0);
   g0(0, 0);
   f1(0, 0);
-  // RUN: %clang_cc1 -std=c89 -fsyntax-only  -code-completion-at=%s:6:6 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -std=c89 -fsyntax-only  -code-completion-at=%s:%(line-3):6 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: f0(<#float x#>, float y)
-  // RUN: %clang_cc1 -std=c89 -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -std=c89 -fsyntax-only -code-completion-at=%s:%(line-5):9 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
   // CHECK-CC2: f0(float x, <#float y#>)
-  // RUN: %clang_cc1 -std=c89 -fsyntax-only -code-completion-at=%s:8:6 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -std=c89 -fsyntax-only -code-completion-at=%s:%(line-5):6 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
   // CHECK-CC3: f1()
 }

diff  --git a/clang/test/CodeCompletion/call.cpp b/clang/test/CodeCompletion/call.cpp
index 95f66e6e0fb2e..394872612eef7 100644
--- a/clang/test/CodeCompletion/call.cpp
+++ b/clang/test/CodeCompletion/call.cpp
@@ -17,16 +17,16 @@ void f();
 
 void test() {
   f(Y(), 0, 0);
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: f(Y y, <#int ZZ#>)
   // CHECK-CC1-NEXT: f(int i, <#int j#>, int k)
   // CHECK-CC1-NEXT: f(float x, <#float y#>)
   // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-6):13 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
   // CHECK-CC2-NOT: f(Y y, int ZZ)
   // CHECK-CC2: f(int i, int j, <#int k#>)
   f({}, 0, 0);
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:28:7 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):7 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
   // CHECK-CC3: OVERLOAD: [#void#]f()
   // CHECK-CC3-NEXT: OVERLOAD: [#void#]f(<#X#>)
   // CHECK-CC3-NEXT: OVERLOAD: [#void#]f(<#int i#>, int j, int k)
@@ -37,17 +37,17 @@ void f(int, int, int, int);
 template <typename T>
 void foo(T t) {
   f(t, t, t);
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:39:5 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):5 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
   // CHECK-CC4: f()
   // CHECK-CC4-NEXT: f(<#X#>)
   // CHECK-CC4-NEXT: f(<#int i#>, int j, int k)
   // CHECK-CC4-NEXT: f(<#float x#>, float y)
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:39:8 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-6):8 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
   // CHECK-CC5-NOT: f()
   // CHECK-CC5: f(int i, <#int j#>, int k)
   // CHECK-CC5-NEXT: f(float x, <#float y#>)
   f(5, t, t);
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:49:11 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):11 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
   // CHECK-CC6-NOT: f(float x, float y)
   // CHECK-CC6: f(int, int, <#int#>, int)
   // CHECK-CC6-NEXT: f(int i, int j, <#int k#>)

diff  --git a/clang/test/CodeCompletion/comments.cpp b/clang/test/CodeCompletion/comments.cpp
index 21f1465ebc048..3b865eb46eef7 100644
--- a/clang/test/CodeCompletion/comments.cpp
+++ b/clang/test/CodeCompletion/comments.cpp
@@ -8,6 +8,6 @@ struct A {
   /* <- code completion */
 };
 
-// RUN: %clang_cc1 -I %S/Inputs -fsyntax-only -code-completion-at=%s:7:6 %s
-// RUN: %clang_cc1 -I %S/Inputs -fsyntax-only -code-completion-at=%s:8:6 %s
+// RUN: %clang_cc1 -I %S/Inputs -fsyntax-only -code-completion-at=%s:%(line-4):6 %s
+// RUN: %clang_cc1 -I %S/Inputs -fsyntax-only -code-completion-at=%s:%(line-4):6 %s
 // RUN: %clang_cc1 -I %S/Inputs -fsyntax-only -code-completion-at=%S/Inputs/comments.h:3:6 %s

diff  --git a/clang/test/CodeCompletion/constexpr.cpp b/clang/test/CodeCompletion/constexpr.cpp
index 12396c0198fa9..3d74fde9e3042 100644
--- a/clang/test/CodeCompletion/constexpr.cpp
+++ b/clang/test/CodeCompletion/constexpr.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -code-completion-at=%s:12:9 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -code-completion-at=%s:%(line+11):9 %s -o - | FileCheck %s
 
 // PR14381: need constexpr function bodies always, even if code-completing.
 template<int> struct S;

diff  --git a/clang/test/CodeCompletion/crash-func-decl.cpp b/clang/test/CodeCompletion/crash-func-decl.cpp
index 7abcdcdb271fb..393aa37e92d98 100644
--- a/clang/test/CodeCompletion/crash-func-decl.cpp
+++ b/clang/test/CodeCompletion/crash-func-decl.cpp
@@ -1,5 +1,5 @@
 // Important that BB is unknown.
 // This triggers completion in PCC_RecoveryInFunction context, with no function.
 int AA(BB cc);
-// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:12 %s | FileCheck %s
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):12 %s | FileCheck %s
 // CHECK: COMPLETION: char

diff  --git a/clang/test/CodeCompletion/crash-func-init.cpp b/clang/test/CodeCompletion/crash-func-init.cpp
index 6d84b843ea182..de2598c921475 100644
--- a/clang/test/CodeCompletion/crash-func-init.cpp
+++ b/clang/test/CodeCompletion/crash-func-init.cpp
@@ -1,4 +1,4 @@
 int (*foo(int a))(flo
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:1:21 %s -o - \
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):21 %s -o - \
 // RUN:            | FileCheck %s
 // CHECK: COMPLETION: float

diff  --git a/clang/test/CodeCompletion/crash-if-directive.cpp b/clang/test/CodeCompletion/crash-if-directive.cpp
index 0878c5c871e0c..4e0f0ac1f2b8b 100644
--- a/clang/test/CodeCompletion/crash-if-directive.cpp
+++ b/clang/test/CodeCompletion/crash-if-directive.cpp
@@ -2,5 +2,5 @@
 #if FOO(
 #elif FOO(
 #endif
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:9 %s
-// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:11 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-3):9 %s
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-3):11 %s

diff  --git a/clang/test/CodeCompletion/crash-null-type.cpp b/clang/test/CodeCompletion/crash-null-type.cpp
index c5b3d1e79390c..e93f77f5eb55b 100644
--- a/clang/test/CodeCompletion/crash-null-type.cpp
+++ b/clang/test/CodeCompletion/crash-null-type.cpp
@@ -3,6 +3,6 @@ void test() {
     loopVa
   }
 }
-// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:11 %s -o - \
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-3):11 %s -o - \
 // RUN:            | FileCheck %s
 // CHECK: COMPLETION: loopVar

diff  --git a/clang/test/CodeCompletion/ctor-initializer.cpp b/clang/test/CodeCompletion/ctor-initializer.cpp
index 97620db0b7555..e450fce6b41c2 100644
--- a/clang/test/CodeCompletion/ctor-initializer.cpp
+++ b/clang/test/CodeCompletion/ctor-initializer.cpp
@@ -1,13 +1,13 @@
 struct Base1 {
   Base1() : {}
-  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:2:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
-  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:2:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-1):12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-2):12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: COMPLETION: Pattern : member1(<#int#>)
   // CHECK-CC1: COMPLETION: Pattern : member2(<#float#>)
 
   Base1(int) : member1(123), {}
-  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:8:30 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
-  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:8:30 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-1):30 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-2):30 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
   // CHECK-CC2-NOT: COMPLETION: Pattern : member1(<#int#>)
   // CHECK-CC2: COMPLETION: Pattern : member2(<#float#>)
 
@@ -23,8 +23,8 @@ struct Derived : public Base1 {
 };
 
 Derived::Derived() : {}
-// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:25:22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:25:22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-1):22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-2):22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: COMPLETION: Pattern : Base1()
 // CHECK-CC3: COMPLETION: Pattern : Base1(<#int#>)
 // CHECK-CC3: COMPLETION: Pattern : deriv1(<#int#>)
@@ -32,34 +32,34 @@ Derived::Derived() : {}
 Derived::Derived(int) try : {
 } catch (...) {
 }
-// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:32:29 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:32:29 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-3):29 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-4):29 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
 
 Derived::Derived(float) try : Base1(),
 {
 } catch (...) {
 }
-// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:38:39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:38:39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-4):39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-5):39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
 // CHECK-CC5-NOT: COMPLETION: Pattern : Base1
 // CHECK-CC5: COMPLETION: Pattern : deriv1(<#int#>)
 
 struct A {
   A() : , member2() {}
-  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:48:9 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
-  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:48:9 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-1):9 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-2):9 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
   // CHECK-CC6: COMPLETION: Pattern : member1(<#int#>)
   int member1, member2;
 };
 
 struct B {
   B() : member2() {}
-  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:56:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
-  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:56:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-1):9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-2):9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
   // CHECK-CC7: COMPLETION: Pattern : member1(<#int#>)
   // Check in the middle and at the end of identifier too.
-  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:56:13 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
-  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:56:16 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-5):13 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-6):16 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
   // CHECK-CC8: COMPLETION: Pattern : member2(<#int#>)
   int member1, member2;
 };
@@ -70,8 +70,8 @@ struct Base2 {
 
 struct Composition1 {
   Composition1() : b2_elem(2) {}
-  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:72:28 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
-  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:72:28 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-1):28 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-2):28 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
   // CHECK-CC9: OVERLOAD: Base2(<#int#>)
   // CHECK-CC9: OVERLOAD: Base2(<#const Base2 &#>)
   // CHECK-CC9-NOT: OVERLOAD: Composition1
@@ -81,14 +81,14 @@ struct Composition1 {
 
 struct Composition2 {
   Composition2() : c1_elem(Base2(1)) {}
-  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:83:34 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
-  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:83:34 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
-  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:83:35 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
-  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:83:35 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-1):34 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-2):34 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-3):35 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-4):35 %s -o - | FileCheck -check-prefix=CHECK-CC9 %s
   Composition1 c1_elem;
 };
-// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:83:20 %s -o - | FileCheck -check-prefix=CHECK-CC10 %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:83:20 %s -o - | FileCheck -check-prefix=CHECK-CC10 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-7):20 %s -o - | FileCheck -check-prefix=CHECK-CC10 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-8):20 %s -o - | FileCheck -check-prefix=CHECK-CC10 %s
 // CHECK-CC10: Pattern : c1_elem()
 // CHECK-CC10: Pattern : c1_elem(<#Base2#>)
 
@@ -100,8 +100,8 @@ struct X : Y<T> {
   X() : Y<T>() {};
 };
 
-// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:100:9 %s -o - | FileCheck -check-prefix=CHECK-CC11 %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:100:9 %s -o - | FileCheck -check-prefix=CHECK-CC11 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:%(line-3):9 %s -o - | FileCheck -check-prefix=CHECK-CC11 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-4):9 %s -o - | FileCheck -check-prefix=CHECK-CC11 %s
 // CHECK-CC11: Pattern : Y<T>(<#Y<T>#>)
 
 // Test with incomplete init lists. (Relevant as parsing is *not* cut off).
@@ -111,7 +111,7 @@ struct Incomplete1 {
   int member1;
   int member2;
 };
-// RUN: not %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:109:19 %s -o - | FileCheck -check-prefix=CHECK-CC12 %s
+// RUN: not %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-5):19 %s -o - | FileCheck -check-prefix=CHECK-CC12 %s
 // CHECK-CC12: COMPLETION: Pattern : member1(<#int#>)
 // CHECK-CC12: COMPLETION: Pattern : member2(<#int#>)
 
@@ -121,5 +121,5 @@ struct Incomplete2 {
   int member1;
   int member2;
 };
-// RUN: not %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:119:27 %s -o - | FileCheck -check-prefix=CHECK-CC13 %s
+// RUN: not %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:%(line-5):27 %s -o - | FileCheck -check-prefix=CHECK-CC13 %s
 // CHECK-CC13: PREFERRED-TYPE: int

diff  --git a/clang/test/CodeCompletion/ctor-signature.cpp b/clang/test/CodeCompletion/ctor-signature.cpp
index 8f0cfacfc1155..d9bb2e566c51b 100644
--- a/clang/test/CodeCompletion/ctor-signature.cpp
+++ b/clang/test/CodeCompletion/ctor-signature.cpp
@@ -5,12 +5,12 @@ struct Foo<T *> { Foo(T); };
 
 void foo() {
   Foo<int>();
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: OVERLOAD: Foo()
   // CHECK-CC1: OVERLOAD: Foo(<#const Foo<int> &#>)
   // CHECK-CC1: OVERLOAD: Foo(<#Foo<int> &&#>
   Foo<int *>(3);
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:14 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):14 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
   // CHECK-CC2: OVERLOAD: Foo(<#int#>)
   // CHECK-CC2: OVERLOAD: Foo(<#const Foo<int *> &#>)
   // CHECK-CC2: OVERLOAD: Foo(<#Foo<int *> &&#>
@@ -34,12 +34,12 @@ struct Bar {
 };
 
 auto b1 = Bar{};
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:36:15 %s | FileCheck -check-prefix=CHECK-BRACED %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):15 %s | FileCheck -check-prefix=CHECK-BRACED %s
 Bar b2{};
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:38:8 %s | FileCheck -check-prefix=CHECK-BRACED %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):8 %s | FileCheck -check-prefix=CHECK-BRACED %s
 static int consumeBar(Bar) { return 0; }
 int b3 = consumeBar({});
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:41:22 %s | FileCheck -check-prefix=CHECK-BRACED %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):22 %s | FileCheck -check-prefix=CHECK-BRACED %s
 
 struct Aggregate {
   int first;
@@ -48,23 +48,23 @@ struct Aggregate {
 };
 
 Aggregate a{1, 2, 3};
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:50:13 %s | FileCheck -check-prefix=CHECK-AGGREGATE-1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):13 %s | FileCheck -check-prefix=CHECK-AGGREGATE-1 %s
 // CHECK-AGGREGATE-1: OVERLOAD: Aggregate{<#int first#>, int second, int third}
 // CHECK-AGGREGATE-1: OVERLOAD: Aggregate{<#const Aggregate &#>}
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:50:16 %s | FileCheck -check-prefix=CHECK-AGGREGATE-2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-4):16 %s | FileCheck -check-prefix=CHECK-AGGREGATE-2 %s
 // CHECK-AGGREGATE-2: OVERLOAD: Aggregate{int first, <#int second#>, int third}
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:50:18 %s | FileCheck -check-prefix=CHECK-AGGREGATE-3 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-6):18 %s | FileCheck -check-prefix=CHECK-AGGREGATE-3 %s
 // CHECK-AGGREGATE-3: OVERLOAD: Aggregate{int first, int second, <#int third#>}
 
 Aggregate d{.second=1, .first=2, 3, 4, };
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:59:13 %s | FileCheck -check-prefix=CHECK-DESIG-1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):13 %s | FileCheck -check-prefix=CHECK-DESIG-1 %s
 // CHECK-DESIG-1: OVERLOAD: Aggregate{<#int first#>, int second, int third}
 // CHECK-DESIG-1: OVERLOAD: Aggregate{<#const Aggregate &#>}
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:59:24 %s | FileCheck -check-prefix=CHECK-DESIG-2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-4):24 %s | FileCheck -check-prefix=CHECK-DESIG-2 %s
 // CHECK-DESIG-2: OVERLOAD: Aggregate{int first, int second, <#int third#>}
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:59:34 %s | FileCheck -check-prefix=CHECK-DESIG-3 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-6):34 %s | FileCheck -check-prefix=CHECK-DESIG-3 %s
 // CHECK-DESIG-3: OVERLOAD: Aggregate{int first, <#int second#>, int third}
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:59:37 %s | FileCheck -check-prefix=CHECK-DESIG-4 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-8):37 %s | FileCheck -check-prefix=CHECK-DESIG-4 %s
 // CHECK-DESIG-4: OVERLOAD: Aggregate{int first, int second, <#int third#>}
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:59:38 %s | FileCheck -check-prefix=CHECK-DESIG-5 %s --allow-empty
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-10):38 %s | FileCheck -check-prefix=CHECK-DESIG-5 %s --allow-empty
 // CHECK-DESIG-5-NOT: OVERLOAD

diff  --git a/clang/test/CodeCompletion/desig-init.cpp b/clang/test/CodeCompletion/desig-init.cpp
index 49a461dc4899e..ac250bc6d8bb3 100644
--- a/clang/test/CodeCompletion/desig-init.cpp
+++ b/clang/test/CodeCompletion/desig-init.cpp
@@ -9,14 +9,14 @@ struct Foo : public Base {
 
 void foo() {
   Foo F{.x = 2, .b.t = 0};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:11:10 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC1 %s
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:11:18 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):10 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-2):18 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: COMPLETION: b : [#Base#]b
   // CHECK-CC1-NEXT: COMPLETION: x : [#int#]x
   // CHECK-CC1-NOT: foo
   // CHECK-CC1-NOT: t
 
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:11:20 %s -o - | FileCheck -check-prefix=CHECK-NESTED %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-8):20 %s -o - | FileCheck -check-prefix=CHECK-NESTED %s
   // CHECK-NESTED: COMPLETION: t : [#int#]t
 
   Base B = {.t = 2};
@@ -24,22 +24,22 @@ void foo() {
   z({.t = 1});
   z(Base{.t = 2});
   z((Base){.t = 2});
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:22:14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:24:7 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:25:11 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:26:13 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-5):14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-4):7 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-4):11 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-4):13 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
   // CHECK-CC2: COMPLETION: t : [#int#]t
   auto zr = [](const Base &B) {};
   zr({.t = 1});
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:33:8 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-REF %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):8 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-REF %s
   // CHECK-REF: COMPLETION: t : [#int#]t
 
   Foo G1{.b = {.t = 0}};
   Foo G2{.b{.t = 0}};
   Foo G3{b: {.t = 0}};
-  // RUN: %clang_cc1 -code-completion-at=%s:37:17 -fsyntax-only -code-completion-patterns %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-NESTED-2 %s
-  // RUN: %clang_cc1 -code-completion-at=%s:38:14 -fsyntax-only -code-completion-patterns %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-NESTED-2 %s
-  // RUN: %clang_cc1 -code-completion-at=%s:39:15 -fsyntax-only -code-completion-patterns %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-NESTED-2 %s
+  // RUN: %clang_cc1 -code-completion-at=%s:%(line-3):17 -fsyntax-only -code-completion-patterns %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-NESTED-2 %s
+  // RUN: %clang_cc1 -code-completion-at=%s:%(line-3):14 -fsyntax-only -code-completion-patterns %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-NESTED-2 %s
+  // RUN: %clang_cc1 -code-completion-at=%s:%(line-3):15 -fsyntax-only -code-completion-patterns %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-NESTED-2 %s
   // CHECK-NESTED-2: COMPLETION: t : [#int#]t
 }
 
@@ -53,10 +53,10 @@ struct Test<int> {
 };
 void bar() {
   Test<char> T{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:55:17 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):17 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
   // CHECK-CC3: COMPLETION: x : [#T#]x
   Test<int> X{.x = 2};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:58:16 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):16 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC4 %s
   // CHECK-CC4: COMPLETION: x : [#int#]x
   // CHECK-CC4-NEXT: COMPLETION: y : [#char#]y
 }
@@ -64,7 +64,7 @@ void bar() {
 template <typename T>
 void aux() {
   Test<T> X{.x = T(2)};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:66:14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
 }
 
 namespace signature_regression {
@@ -75,7 +75,7 @@ namespace signature_regression {
   int rightFunction();
   int dummy = wrongFunction({1});
   int x = rightFunction();
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:77:25 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-SIGNATURE-REGRESSION %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):25 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-SIGNATURE-REGRESSION %s
   // CHECK-SIGNATURE-REGRESSION-NOT: OVERLOAD: [#int#]wrongFunction
   // CHECK-SIGNATURE-REGRESSION:     OVERLOAD: [#int#]rightFunction
   // CHECK-SIGNATURE-REGRESSION-NOT: OVERLOAD: [#int#]wrongFunction
@@ -86,6 +86,6 @@ struct WithAnon {
   struct { int inner; };
 };
 auto TestWithAnon = WithAnon { .inner = 2 };
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:88:33 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC5 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):33 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC5 %s
   // CHECK-CC5: COMPLETION: inner : [#int#]inner
   // CHECK-CC5: COMPLETION: outer : [#int#]outer

diff  --git a/clang/test/CodeCompletion/deuglify.cpp b/clang/test/CodeCompletion/deuglify.cpp
index c5f801736376c..f4d8d8876ebf9 100644
--- a/clang/test/CodeCompletion/deuglify.cpp
+++ b/clang/test/CodeCompletion/deuglify.cpp
@@ -15,11 +15,11 @@ class vector : private __vector_base<_Tp> {
 } // namespace std
 
 int x = std::vector<int>{}.at(42);
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:17:14 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):14 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: COMPLETION: __vector_base : __vector_base<<#typename Tp#>>
 // CHECK-CC1: COMPLETION: vector : vector<<#typename Tp#>>
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:17:28 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-4):28 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: COMPLETION: __stays_ugly : [#int#]__stays_ugly()
 // CHECK-CC2: COMPLETION: at : [#int &#]at(<#unsigned int index#>)[# const#]
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:17:31 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-7):31 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: OVERLOAD: [#int &#]at(<#unsigned int index#>)

diff  --git a/clang/test/CodeCompletion/documentation.cpp b/clang/test/CodeCompletion/documentation.cpp
index d7dec9af6c085..213dea4b8feb9 100644
--- a/clang/test/CodeCompletion/documentation.cpp
+++ b/clang/test/CodeCompletion/documentation.cpp
@@ -23,11 +23,11 @@ void test() {
   t2.
 }
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:21:1 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:%(line-5):1 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: COMPLETION: T1 : [#void#]T1(<#float x#>, <#float y#>) : Aaa.
 // CHECK-CC1: COMPLETION: T2 : T2 : Bbb.
 // CHECK-CC1: COMPLETION: T5 : T5:: : Eee.
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:23:6 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:%(line-8):6 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: COMPLETION: T3 : [#void#]T3() : Ccc.
 // CHECK-CC2: COMPLETION: T4 : [#int#]T4 : Ddd.

diff  --git a/clang/test/CodeCompletion/documentation.m b/clang/test/CodeCompletion/documentation.m
index 47add5b6ca0d5..03ba10be83786 100644
--- a/clang/test/CodeCompletion/documentation.m
+++ b/clang/test/CodeCompletion/documentation.m
@@ -16,10 +16,10 @@ void test(Test *obj) {
   [Test classProp];
 }
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:15:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:%(line-4):8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: instanceProp : [#id#]instanceProp : Instance!
 // CHECK-CC1: setInstanceProp: : [#void#]setInstanceProp:<#(id)#> : Instance!
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:16:9 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:%(line-7):9 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: classProp : [#id#]classProp : Class!
 // CHECK-CC2: setClassProp: : [#void#]setClassProp:<#(id)#> : Class!

diff  --git a/clang/test/CodeCompletion/enable-if-attr-crash.cpp b/clang/test/CodeCompletion/enable-if-attr-crash.cpp
index cca84b28ecfb8..bcd679671c204 100644
--- a/clang/test/CodeCompletion/enable-if-attr-crash.cpp
+++ b/clang/test/CodeCompletion/enable-if-attr-crash.cpp
@@ -2,7 +2,7 @@ int foo(bool x) __attribute__((enable_if(x, "")));
 
 int test() {
   bool fffffff;
-  // RUN: %clang_cc1 -std=c++11 -code-completion-at=%s:7:8 %s | FileCheck %s
+  // RUN: %clang_cc1 -std=c++11 -code-completion-at=%s:%(line+2):8 %s | FileCheck %s
   // CHECK: COMPLETION: fffffff : [#bool#]fffffff
   foo(ff
 }

diff  --git a/clang/test/CodeCompletion/end-of-file.cpp b/clang/test/CodeCompletion/end-of-file.cpp
index 178ef4561f56b..3591af6616fab 100644
--- a/clang/test/CodeCompletion/end-of-file.cpp
+++ b/clang/test/CodeCompletion/end-of-file.cpp
@@ -1,7 +1,7 @@
 // Check that clang does not crash when completing at the last char in the
 // buffer.
 // NOTE: This file must *NOT* have newline at the end.
-// RUN: %clang_cc1 -code-completion-at=%s:7:2 %s | FileCheck %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line+3):2 %s | FileCheck %s
 // CHECK: COMPLETION: foo
 using foo = int***;
 f
\ No newline at end of file

diff  --git a/clang/test/CodeCompletion/end-of-ident-macro.cpp b/clang/test/CodeCompletion/end-of-ident-macro.cpp
index f288979a2c4d8..986303105df98 100644
--- a/clang/test/CodeCompletion/end-of-ident-macro.cpp
+++ b/clang/test/CodeCompletion/end-of-ident-macro.cpp
@@ -5,11 +5,11 @@ using FUNCTION = int();
 // middle, or end.
 FUNC(int) a = 10;
 // ^FUNC(int)
-// RUN: %clang_cc1 -code-completion-at=%s:6:1 -code-completion-macros %s | FileCheck %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-2):1 -code-completion-macros %s | FileCheck %s
 // FU^NC(int)
-// RUN: %clang_cc1 -code-completion-at=%s:6:3 -code-completion-macros %s | FileCheck %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-4):3 -code-completion-macros %s | FileCheck %s
 // FUNC^(int)
-// RUN: %clang_cc1 -code-completion-at=%s:6:5 -code-completion-macros %s | FileCheck %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-6):5 -code-completion-macros %s | FileCheck %s
 
 // CHECK: COMPLETION: FUNC : FUNC(<#X#>)
 // CHECK: COMPLETION: FUNCTION : FUNCTION

diff  --git a/clang/test/CodeCompletion/end-of-ident.cpp b/clang/test/CodeCompletion/end-of-ident.cpp
index f1d3700ce28d2..a53c82fe8d2ba 100644
--- a/clang/test/CodeCompletion/end-of-ident.cpp
+++ b/clang/test/CodeCompletion/end-of-ident.cpp
@@ -3,18 +3,18 @@ class classifier {};
 // middle, or end.
 class cls
 // ^class cls
-// RUN: %clang_cc1 -code-completion-at=%s:4:1 %s | FileCheck --check-prefix=CHECK-CLS %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-2):1 %s | FileCheck --check-prefix=CHECK-CLS %s
 // cl^ass cls
-// RUN: %clang_cc1 -code-completion-at=%s:4:3 %s | FileCheck --check-prefix=CHECK-CLS %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-4):3 %s | FileCheck --check-prefix=CHECK-CLS %s
 // class^ cls
-// RUN: %clang_cc1 -code-completion-at=%s:4:6 %s | FileCheck --check-prefix=CHECK-CLS %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-6):6 %s | FileCheck --check-prefix=CHECK-CLS %s
 
 // CHECK-CLS: COMPLETION: class{{$}}
 // CHECK-CLS: COMPLETION: classifier : classifier
 
 // class ^cls
-// RUN: %clang_cc1 -code-completion-at=%s:4:7 %s | FileCheck --check-prefix=CHECK-NO-CLS %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-12):7 %s | FileCheck --check-prefix=CHECK-NO-CLS %s
 // class c^ls
-// RUN: %clang_cc1 -code-completion-at=%s:4:8 %s | FileCheck --check-prefix=CHECK-NO-CLS %s
+// RUN: %clang_cc1 -code-completion-at=%s:%(line-14):8 %s | FileCheck --check-prefix=CHECK-NO-CLS %s
 // CHECK-NO-CLS-NOT: COMPLETION: class{{$}}
 // CHECK-NO-CLS: COMPLETION: classifier : classifier

diff  --git a/clang/test/CodeCompletion/enum-preferred-type.cpp b/clang/test/CodeCompletion/enum-preferred-type.cpp
index 7ff4be9048bb5..6278fc9265192 100644
--- a/clang/test/CodeCompletion/enum-preferred-type.cpp
+++ b/clang/test/CodeCompletion/enum-preferred-type.cpp
@@ -13,10 +13,10 @@ void test(N::Color color) {
   // FIXME: ideally, we should not show 'Red' on the next line.
   else if (color == N::Color::Blue) {}
 
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:11 %s -o - | FileCheck %s
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:11:8 %s -o - | FileCheck %s
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:16 %s -o - | FileCheck %s
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:21 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-6):11 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-6):8 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-6):16 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-5):21 %s -o - | FileCheck %s
   // CHECK: Blue : [#N::Color#]N::Blue
   // CHECK: color : [#N::Color#]color
   // CHECK: Orange : [#N::Color#]N::Orange

diff  --git a/clang/test/CodeCompletion/enum-switch-case-qualified.cpp b/clang/test/CodeCompletion/enum-switch-case-qualified.cpp
index 0f256716bc0d5..ac279eddaddfd 100644
--- a/clang/test/CodeCompletion/enum-switch-case-qualified.cpp
+++ b/clang/test/CodeCompletion/enum-switch-case-qualified.cpp
@@ -21,7 +21,7 @@ namespace M {
 void test(enum N::C::Color color) {
   switch (color) {
   case 
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
     // CHECK-CC1: Blue : [#M::N::C::Color#]N::C::Blue
     // CHECK-CC1-NEXT: Green : [#M::N::C::Color#]N::C::Green
     // CHECK-CC1-NEXT: Indigo : [#M::N::C::Color#]N::C::Indigo

diff  --git a/clang/test/CodeCompletion/enum-switch-case.c b/clang/test/CodeCompletion/enum-switch-case.c
index 264f46a0a3607..1e24b68d92174 100644
--- a/clang/test/CodeCompletion/enum-switch-case.c
+++ b/clang/test/CodeCompletion/enum-switch-case.c
@@ -25,14 +25,14 @@ void test(enum Color color) {
     case 
   }
 
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:10 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-9):10 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
     // CHECK-CC1: Blue
     // CHECK-CC1-NEXT: Green
     // CHECK-CC1-NEXT: Indigo
     // CHECK-CC1-NEXT: Orange
     // CHECK-CC1-NEXT: Violet
 
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:25:10 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s      
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-10):10 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s      
   // CHECK-CC2: COMPLETION: Blue : [#enum Color#]Blue
   // CHECK-CC2-NEXT: COMPLETION: c2 : [#unsigned int#]c2
   // CHECK-CC2-NEXT: COMPLETION: color : [#enum Color#]color

diff  --git a/clang/test/CodeCompletion/enum-switch-case.cpp b/clang/test/CodeCompletion/enum-switch-case.cpp
index 997845afe5845..e80404fcf6159 100644
--- a/clang/test/CodeCompletion/enum-switch-case.cpp
+++ b/clang/test/CodeCompletion/enum-switch-case.cpp
@@ -19,7 +19,7 @@ void test(enum N::Color color) {
     break;
     
   case 
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:21:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
     // CHECK-CC1: Blue : [#N::Color#]N::Blue
     // CHECK-CC1-NEXT: Green : [#N::Color#]N::Green
     // CHECK-CC1-NEXT: Indigo : [#N::Color#]N::Indigo

diff  --git a/clang/test/CodeCompletion/function-templates.cpp b/clang/test/CodeCompletion/function-templates.cpp
index e7123a33133e6..07b0cfb618066 100644
--- a/clang/test/CodeCompletion/function-templates.cpp
+++ b/clang/test/CodeCompletion/function-templates.cpp
@@ -17,11 +17,11 @@ V doSomething(T t, const U &u, V *v) { return V(); }
 void f() {
   std::sort(1, 2);
   Foo().getAs<int>();
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:18:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-2):8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: dyn_cast<<#class X#>>(<#Y *Val#>)
   // CHECK-CC1: sort(<#RandomAccessIterator first#>, <#RandomAccessIterator last#>
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-4):9 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
   // CHECK-CC2: getAs<<#typename T#>>()
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-6):22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
   // CHECK-CC3: [#V#]doSomething(<#T t#>, <#const U &u#>, <#V *v#>)
 }

diff  --git a/clang/test/CodeCompletion/functions.cpp b/clang/test/CodeCompletion/functions.cpp
index aa303f29eb04f..0f241ae88e61a 100644
--- a/clang/test/CodeCompletion/functions.cpp
+++ b/clang/test/CodeCompletion/functions.cpp
@@ -3,6 +3,6 @@ void f(float x, float y...);
        
 void test() {
   ::
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:5 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):5 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: f(<#int i#>{#, <#int j = 2#>{#, <#int k = 5#>#}#})
   // CHECK-CC1: f(<#float x#>, <#float y, ...#>)

diff  --git a/clang/test/CodeCompletion/ignore-ns-level-decls.cpp b/clang/test/CodeCompletion/ignore-ns-level-decls.cpp
index 59cee6536a5dd..556183564e87f 100644
--- a/clang/test/CodeCompletion/ignore-ns-level-decls.cpp
+++ b/clang/test/CodeCompletion/ignore-ns-level-decls.cpp
@@ -10,12 +10,12 @@ namespace ns {
 
 void test() {
   ns::
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:7 %s -o - | FileCheck %s --check-prefix=CHECK-1
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):7 %s -o - | FileCheck %s --check-prefix=CHECK-1
 // CHECK-1-DAG: COMPLETION: bar : bar
 // CHECK-1-DAG: COMPLETION: baz : baz
 // CHECK-1-DAG: COMPLETION: func : [#int#]func(<#int a#>, <#bar b#>, <#baz c#>)
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:7 -no-code-completion-ns-level-decls %s -o - | FileCheck %s --allow-empty --check-prefix=CHECK-EMPTY
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-6):7 -no-code-completion-ns-level-decls %s -o - | FileCheck %s --allow-empty --check-prefix=CHECK-EMPTY
 // CHECK-EMPTY-NOT: COMPLETION: bar : bar
 // CHECK-EMPTY: {{^}}{{$}}
 }

diff  --git a/clang/test/CodeCompletion/included-symlinks.cpp b/clang/test/CodeCompletion/included-symlinks.cpp
index bccaaa6162143..7ac5e20e7fdef 100644
--- a/clang/test/CodeCompletion/included-symlinks.cpp
+++ b/clang/test/CodeCompletion/included-symlinks.cpp
@@ -6,11 +6,11 @@
 
 // Suggest symlinked header files.
 #include "foo.h"
-// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:8:13 %s | FileCheck -check-prefix=CHECK-1 %s
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:%(line-1):13 %s | FileCheck -check-prefix=CHECK-1 %s
 // CHECK-1: foo.h"
 // CHECK-1: foobar.h"
 
 // Suggest symlinked folder.
 #include "mypr"
-// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:14:13 %s | FileCheck -check-prefix=CHECK-2 %s
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:%(line-1):13 %s | FileCheck -check-prefix=CHECK-2 %s
 // CHECK-2: myproj/

diff  --git a/clang/test/CodeCompletion/incomplete-member.cpp b/clang/test/CodeCompletion/incomplete-member.cpp
index f86b48887e020..0c4a1566b40f8 100644
--- a/clang/test/CodeCompletion/incomplete-member.cpp
+++ b/clang/test/CodeCompletion/incomplete-member.cpp
@@ -4,5 +4,5 @@ void foo() {
   IncompleteType *f;
   f->x;
 }
-// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:5:6 %s -o - | FileCheck %s -allow-empty
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-2):6 %s -o - | FileCheck %s -allow-empty
 // CHECK-NOT: COMPLETION:

diff  --git a/clang/test/CodeCompletion/incomplete-ret-type.cpp b/clang/test/CodeCompletion/incomplete-ret-type.cpp
index 669105e1416a8..c9ede5ec42ca8 100644
--- a/clang/test/CodeCompletion/incomplete-ret-type.cpp
+++ b/clang/test/CodeCompletion/incomplete-ret-type.cpp
@@ -6,8 +6,8 @@ void f(in);
 IncompleteType g(in);
 // Completing should produce results even if types are incomplete.
 // Note that clang is expected to return an error code since 'in' does not resolve.
-// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:5:9 %s -o - | FileCheck %s
-// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:6:19 %s -o - | FileCheck %s
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-4):9 %s -o - | FileCheck %s
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-4):19 %s -o - | FileCheck %s
 // CHECK: COMPLETION: int{{$}}
 // CHECK: COMPLETION: int_typedef
 // CHECK: COMPLETION: int_value

diff  --git a/clang/test/CodeCompletion/inside-macros.cpp b/clang/test/CodeCompletion/inside-macros.cpp
index dc40c6ad318c0..ff3fff77d2a4e 100644
--- a/clang/test/CodeCompletion/inside-macros.cpp
+++ b/clang/test/CodeCompletion/inside-macros.cpp
@@ -5,9 +5,9 @@ void test(bool input_var) {
   // Check that input_var shows up when completing at the start, in the middle
   // and at the end of the identifier.
   //
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:6 %s -o - | FileCheck %s
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:8 %s -o - | FileCheck %s
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:15 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-4):6 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-5):8 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-6):15 %s -o - | FileCheck %s
 
   // CHECK: input_var
 }

diff  --git a/clang/test/CodeCompletion/invalid-initialized-class.cpp b/clang/test/CodeCompletion/invalid-initialized-class.cpp
index 9fb584ef5ef04..e228ab5dc166c 100644
--- a/clang/test/CodeCompletion/invalid-initialized-class.cpp
+++ b/clang/test/CodeCompletion/invalid-initialized-class.cpp
@@ -3,13 +3,13 @@ struct Foo { Foo(int); int abc; };
 void test1() {
   Foo foo;
   foo.;
-  // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:5:7 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):7 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: COMPLETION: abc
 }
 
 void test2() {
   Foo foo = garbage();
   foo.;
-  // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:12:7 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):7 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
   // CHECK-CC2: COMPLETION: abc
 }

diff  --git a/clang/test/CodeCompletion/lambdas.cpp b/clang/test/CodeCompletion/lambdas.cpp
index 3e431a330f49a..53524fc97c7b8 100644
--- a/clang/test/CodeCompletion/lambdas.cpp
+++ b/clang/test/CodeCompletion/lambdas.cpp
@@ -7,18 +7,18 @@ void test() {
   void (*x)(int, double) = nullptr;
 
   function<void(int, double)> y = {};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:7:28 %s -o - | FileCheck -check-prefix=CHECK-1 %s
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:9:35 %s -o - | FileCheck -check-prefix=CHECK-1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-3):28 %s -o - | FileCheck -check-prefix=CHECK-1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-2):35 %s -o - | FileCheck -check-prefix=CHECK-1 %s
   // CHECK-1: COMPLETION: Pattern : [<#=#>](int <#parameter#>, double <#parameter#>) { <#body#> }
 
   // == Placeholders for suffix types must be placed properly.
   function<void(void(*)(int))> z = {};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:15:36 %s -o - | FileCheck -check-prefix=CHECK-2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):36 %s -o - | FileCheck -check-prefix=CHECK-2 %s
   // CHECK-2: COMPLETION: Pattern : [<#=#>](void (* <#parameter#>)(int)) { <#body#> }
 
   // == No need for a parameter list if function has no parameters.
   function<void()> a = {};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:20:24 %s -o - | FileCheck -check-prefix=CHECK-3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):24 %s -o - | FileCheck -check-prefix=CHECK-3 %s
   // CHECK-3: COMPLETION: Pattern : [<#=#>] { <#body#> }
 }
 
@@ -31,8 +31,8 @@ void test2() {
 
   using function_typedef = function<void(vector<int>)>;
   function_typedef b = {};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:30:35 %s -o - | FileCheck -check-prefix=CHECK-4 %s
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:33:24 %s -o - | FileCheck -check-prefix=CHECK-4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-4):35 %s -o - | FileCheck -check-prefix=CHECK-4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-2):24 %s -o - | FileCheck -check-prefix=CHECK-4 %s
   // CHECK-4: COMPLETION: Pattern : [<#=#>](vector<int> <#parameter#>) { <#body#> }
 }
 
@@ -41,34 +41,34 @@ template <class T> struct unique_function {};
 
 void test3() {
   unique_function<void()> a = {};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:43:31 %s -o - | FileCheck -check-prefix=CHECK-5 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):31 %s -o - | FileCheck -check-prefix=CHECK-5 %s
   // CHECK-5: COMPLETION: Pattern : [<#=#>] { <#body#> }
 }
 
 template <class T, class U> struct weird_function {};
 void test4() {
   weird_function<void(), int> b = {};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:50:35 %s -o - | FileCheck -check-prefix=CHECK-6 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):35 %s -o - | FileCheck -check-prefix=CHECK-6 %s
   // CHECK-6-NOT: COMPLETION: Pattern : [<#=
 }
 
 void test5() {
   // Completions are only added when -code-completion-patterns are enabled.
   function<void()> b = {};
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:57:24 %s -o - | FileCheck -check-prefix=CHECK-7 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-1):24 %s -o - | FileCheck -check-prefix=CHECK-7 %s
   // CHECK-7: COMPLETION: Pattern : [<#=
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:57:24 %s -o - | FileCheck -check-prefix=CHECK-8 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-3):24 %s -o - | FileCheck -check-prefix=CHECK-8 %s
   // CHECK-8-NOT: COMPLETION: Pattern : [<#=
 }
 
 void test6() {
   auto my_lambda = [&](int a, double &b) { return 1.f; };
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:65:58 %s -o - | FileCheck -check-prefix=CHECK-9 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):58 %s -o - | FileCheck -check-prefix=CHECK-9 %s
   // CHECK-9: [#float#]my_lambda(<#int a#>, <#double &b#>)[# const#]
 }
 
 void test7() {
   auto generic_lambda = [&](auto a, const auto &b) { return a + b; };
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:71:70 %s -o - | FileCheck -check-prefix=CHECK-10 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):70 %s -o - | FileCheck -check-prefix=CHECK-10 %s
   // CHECK-10: [#auto#]generic_lambda(<#auto a#>, <#const auto &b#>)[# const#]
 }

diff  --git a/clang/test/CodeCompletion/macros-in-modules.c b/clang/test/CodeCompletion/macros-in-modules.c
index f10743af25731..82c34e0e8f6f9 100644
--- a/clang/test/CodeCompletion/macros-in-modules.c
+++ b/clang/test/CodeCompletion/macros-in-modules.c
@@ -1,8 +1,8 @@
 // RUN: rm -rf %t && mkdir %t
 // RUN: echo 'module Foo { header "foo.h" }' > %t/module.modulemap
 // RUN: echo '#define FOO_MACRO 42' > %t/foo.h
-// RUN: c-index-test -code-completion-at=%s:9:1 -I %t %s | FileCheck %s
-// RUN: c-index-test -code-completion-at=%s:9:1 -I %t -fmodules -fmodules-cache-path=%t %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:%(line+5):1 -I %t %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:%(line+4):1 -I %t -fmodules -fmodules-cache-path=%t %s | FileCheck %s
 
 #include "foo.h"
 int x =

diff  --git a/clang/test/CodeCompletion/macros-in-modules.m b/clang/test/CodeCompletion/macros-in-modules.m
index d845c26a74cb9..af6210f49b564 100644
--- a/clang/test/CodeCompletion/macros-in-modules.m
+++ b/clang/test/CodeCompletion/macros-in-modules.m
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t && mkdir %t
 // RUN: echo 'module Foo { header "foo.h" }' > %t/module.modulemap
 // RUN: echo '#define FOO_MACRO 42' > %t/foo.h
-// RUN: c-index-test -code-completion-at=%s:8:1 -I %t -fmodules-cache-path=%t -fmodules %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:%(line+4):1 -I %t -fmodules-cache-path=%t -fmodules %s | FileCheck %s
 
 @import Foo;
 int x =

diff  --git a/clang/test/CodeCompletion/macros.c b/clang/test/CodeCompletion/macros.c
index 3cbad800202ca..d2eee7888b8de 100644
--- a/clang/test/CodeCompletion/macros.c
+++ b/clang/test/CodeCompletion/macros.c
@@ -8,20 +8,20 @@ struct Point {
 };
 
 void test(struct Point *p) {
-  // RUN: %clang_cc1 -include %S/Inputs/macros.h -fsyntax-only -code-completion-macros -code-completion-at=%s:12:14 %s -o - | FileCheck -check-prefix=CC1 %s
+  // RUN: %clang_cc1 -include %S/Inputs/macros.h -fsyntax-only -code-completion-macros -code-completion-at=%s:%(line+1):14 %s -o - | FileCheck -check-prefix=CC1 %s
   switch (p->IDENTITY(color)) {
-  // RUN: %clang_cc1 -include %S/Inputs/macros.h -fsyntax-only -code-completion-macros -code-completion-at=%s:14:10 %s -o - | FileCheck -check-prefix=CC2 %s
+  // RUN: %clang_cc1 -include %S/Inputs/macros.h -fsyntax-only -code-completion-macros -code-completion-at=%s:%(line+1):10 %s -o - | FileCheck -check-prefix=CC2 %s
     case 
   }
-  // RUN: %clang_cc1 -include %S/Inputs/macros.h -fsyntax-only -code-completion-macros -code-completion-at=%s:17:8 %s -o - | FileCheck -check-prefix=CC3 %s
+  // RUN: %clang_cc1 -include %S/Inputs/macros.h -fsyntax-only -code-completion-macros -code-completion-at=%s:%(line+1):8 %s -o - | FileCheck -check-prefix=CC3 %s
 #ifdef Q
 #endif
 
   // Run the same tests, this time with macros loaded from the PCH file.
   // RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/macros.h
-  // RUN: %clang_cc1 -include-pch %t -fsyntax-only -code-completion-macros -code-completion-at=%s:12:14 %s -o - | FileCheck -check-prefix=CC1 %s
-  // RUN: %clang_cc1 -include-pch %t -fsyntax-only -code-completion-macros -code-completion-at=%s:14:10 %s -o - | FileCheck -check-prefix=CC2 %s
-  // RUN: %clang_cc1 -include-pch %t -fsyntax-only -code-completion-macros -code-completion-at=%s:17:8 %s -o - | FileCheck -check-prefix=CC3 %s
+  // RUN: %clang_cc1 -include-pch %t -fsyntax-only -code-completion-macros -code-completion-at=%s:%(line-10):14 %s -o - | FileCheck -check-prefix=CC1 %s
+  // RUN: %clang_cc1 -include-pch %t -fsyntax-only -code-completion-macros -code-completion-at=%s:%(line-9):10 %s -o - | FileCheck -check-prefix=CC2 %s
+  // RUN: %clang_cc1 -include-pch %t -fsyntax-only -code-completion-macros -code-completion-at=%s:%(line-7):8 %s -o - | FileCheck -check-prefix=CC3 %s
 
   // CC1: color
   // CC1: x

diff  --git a/clang/test/CodeCompletion/member-access-qualifiers.cpp b/clang/test/CodeCompletion/member-access-qualifiers.cpp
index 93af02c2390f1..8aa48a84c8d4e 100644
--- a/clang/test/CodeCompletion/member-access-qualifiers.cpp
+++ b/clang/test/CodeCompletion/member-access-qualifiers.cpp
@@ -8,6 +8,6 @@ struct deque : private deque_base {
 };
 
 auto x = deque().
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:18 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):18 %s -o - | FileCheck %s
 // CHECK: COMPLETION: size : [#int#]size()[# const#]
 // CHECK: COMPLETION: size (Hidden,InBase,Inaccessible) : [#int &#]deque_base::size()

diff  --git a/clang/test/CodeCompletion/member-access.c b/clang/test/CodeCompletion/member-access.c
index 545349f71731b..fc54993152815 100644
--- a/clang/test/CodeCompletion/member-access.c
+++ b/clang/test/CodeCompletion/member-access.c
@@ -6,7 +6,7 @@ struct Point {
 
 void test(struct Point *p) {
   p->
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:8:6 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):6 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: x
   // CHECK-CC1: y
   // CHECK-CC1: z
@@ -24,15 +24,15 @@ void test3(struct Point2 *p) {
   p.
 }
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:20:6 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: x (requires fix-it: {20:4-20:6} to ".")
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:%(line-7):6 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: x (requires fix-it: {[[@LINE-8]]:4-[[@LINE-8]]:6} to ".")
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:24:5 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
-// CHECK-CC3: x (requires fix-it: {24:4-24:5} to "->")
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:%(line-6):5 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: x (requires fix-it: {[[@LINE-7]]:4-[[@LINE-7]]:5} to "->")
 
 void test4(struct Point *p) {
   (int)(p)->x;
   (int)(0,1,2,3,4,p)->x;
 }
-// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:34:13 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
-// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:35:23 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:%(line-3):13 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:%(line-3):23 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s

diff  --git a/clang/test/CodeCompletion/namespace-alias.cpp b/clang/test/CodeCompletion/namespace-alias.cpp
index bd4aef4137996..d2894dfd98533 100644
--- a/clang/test/CodeCompletion/namespace-alias.cpp
+++ b/clang/test/CodeCompletion/namespace-alias.cpp
@@ -11,7 +11,7 @@ namespace N2 {
   namespace I1 { }
   
   namespace New =
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:18 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):18 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: I1
   // CHECK-CC1: I4
   // CHECK-CC1: I5

diff  --git a/clang/test/CodeCompletion/namespace.cpp b/clang/test/CodeCompletion/namespace.cpp
index 6024a3494aaa3..e3b47c1c5b335 100644
--- a/clang/test/CodeCompletion/namespace.cpp
+++ b/clang/test/CodeCompletion/namespace.cpp
@@ -8,7 +8,7 @@ namespace N2 {
   namespace I1 { }
   
   namespace 
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:13 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):13 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: I1
   // CHECK-CC1-NEXT: I5
   

diff  --git a/clang/test/CodeCompletion/nested-name-specifier.cpp b/clang/test/CodeCompletion/nested-name-specifier.cpp
index 8789635bd598c..bff8d9441efb6 100644
--- a/clang/test/CodeCompletion/nested-name-specifier.cpp
+++ b/clang/test/CodeCompletion/nested-name-specifier.cpp
@@ -10,7 +10,7 @@ namespace N {
 }
 
 N::
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:4 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):4 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: A
 // CHECK-CC1: B
 // CHECK-CC1: M

diff  --git a/clang/test/CodeCompletion/objc-expr.m b/clang/test/CodeCompletion/objc-expr.m
index 4296cc9a8c29b..e7a2fd8732b22 100644
--- a/clang/test/CodeCompletion/objc-expr.m
+++ b/clang/test/CodeCompletion/objc-expr.m
@@ -4,7 +4,7 @@ id testCompleteAfterAtSign() {
   return @"";
 }
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:4:11 %s -fno-const-strings -o - | FileCheck -check-prefix=CHECK-AT %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-3):11 %s -fno-const-strings -o - | FileCheck -check-prefix=CHECK-AT %s
 // CHECK-AT: COMPLETION: Pattern : [#NSString *#]"<#string#>"
 // CHECK-AT: COMPLETION: Pattern : [#id#](<#expression#>)
 // CHECK-AT: COMPLETION: Pattern : [#NSArray *#][<#objects, ...#>]
@@ -13,5 +13,5 @@ id testCompleteAfterAtSign() {
 // CHECK-AT: COMPLETION: Pattern : [#SEL#]selector(<#selector#>)
 // CHECK-AT: COMPLETION: Pattern : [#NSDictionary *#]{<#key#>: <#object, ...#>}
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:4:11 %s -fconst-strings -o - | FileCheck -check-prefix=CHECK-CONST-STRINGS %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:%(line-12):11 %s -fconst-strings -o - | FileCheck -check-prefix=CHECK-CONST-STRINGS %s
 // CHECK-CONST-STRINGS: COMPLETION: Pattern : [#const char[]#]encode(<#type-name#>)

diff  --git a/clang/test/CodeCompletion/objc-member-access.m b/clang/test/CodeCompletion/objc-member-access.m
index b3dbd85af91b6..0a46c6b81c5f3 100644
--- a/clang/test/CodeCompletion/objc-member-access.m
+++ b/clang/test/CodeCompletion/objc-member-access.m
@@ -15,7 +15,7 @@ int getFoo(id object) {
   return foo;
 }
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:14:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:%(line-4):19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1-NOT: [#int#]_bar
 // CHECK-CC1-NOT: [#int#]_foo
 // CHECK-CC1: [#int#]bar

diff  --git a/clang/test/CodeCompletion/objc-message.m b/clang/test/CodeCompletion/objc-message.m
index a7b111f59ed7a..05813e4643863 100644
--- a/clang/test/CodeCompletion/objc-message.m
+++ b/clang/test/CodeCompletion/objc-message.m
@@ -23,13 +23,13 @@ void func() {
   Foo *obj = [Foo new];
   [obj xx];
 }
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-3):19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: categoryClassMethod
 // CHECK-CC1: classMethod1:withKeyword:
 // CHECK-CC1: classMethod2
 // CHECK-CC1: new
 // CHECK-CC1: protocolClassMethod
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:24:8 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-8):8 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: categoryInstanceMethod
 // CHECK-CC2: instanceMethod1
 // CHECK-CC2: protocolInstanceMethod

diff  --git a/clang/test/CodeCompletion/objc-message.mm b/clang/test/CodeCompletion/objc-message.mm
index 33f392f5e0dc5..0e72b20bef82c 100644
--- a/clang/test/CodeCompletion/objc-message.mm
+++ b/clang/test/CodeCompletion/objc-message.mm
@@ -38,9 +38,9 @@ void func(const RetainPtr<id <FooTestProtocol>>& ptr)
   [ptr instanceMethod1];
 }
 
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -code-completion-at=%s:33:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -code-completion-at=%s:%(line-8):8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: categoryInstanceMethod : [#id#]categoryInstanceMethod
 // CHECK-CC1: instanceMethod1 : [#id#]instanceMethod1
 // CHECK-CC1: protocolInstanceMethod (InBase) : [#id#]protocolInstanceMethod
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -code-completion-at=%s:38:8 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -code-completion-at=%s:%(line-7):8 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: protocolInstanceMethod : [#id#]protocolInstanceMethod

diff  --git a/clang/test/CodeCompletion/objc-protocol-member-access.m b/clang/test/CodeCompletion/objc-protocol-member-access.m
index 9e769d5afa86c..245ef5e395567 100644
--- a/clang/test/CodeCompletion/objc-protocol-member-access.m
+++ b/clang/test/CodeCompletion/objc-protocol-member-access.m
@@ -18,7 +18,7 @@ int getFoo(id object) {
   return foo;
 }
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:17:25 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-4):25 %s -o - | FileCheck %s
 // CHECK: bar (InBase) : [#int#]bar
 // CHECK: foo (InBase) : [#int#]foo
 // CHECK-NOT: foobar

diff  --git a/clang/test/CodeCompletion/operator.cpp b/clang/test/CodeCompletion/operator.cpp
index 4a57f0ac58ec9..1fb46ca197641 100644
--- a/clang/test/CodeCompletion/operator.cpp
+++ b/clang/test/CodeCompletion/operator.cpp
@@ -8,7 +8,7 @@ void f() {
   typedef float Float;
   
   operator 
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: +
   // CHECK-CC1: Float
   // CHECK-CC1: Integer

diff  --git a/clang/test/CodeCompletion/ordinary-name.c b/clang/test/CodeCompletion/ordinary-name.c
index 1352b70730d80..c8181a248daa2 100644
--- a/clang/test/CodeCompletion/ordinary-name.c
+++ b/clang/test/CodeCompletion/ordinary-name.c
@@ -4,7 +4,7 @@ typedef struct t TYPEDEF;
 typedef struct t _TYPEDEF;
 void foo() {
   int y;
-  // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:%(line-1):9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1-NOT: __INTEGER_TYPE
   // CHECK-CC1: _Imaginary
   // CHECK-CC1: _MyPrivateType
@@ -15,4 +15,4 @@ void foo() {
   // CHECK-CC1: y
 
   // PR8744
-  // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:1:11 %s
+  // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:%(line-17):11 %s

diff  --git a/clang/test/CodeCompletion/overrides.cpp b/clang/test/CodeCompletion/overrides.cpp
index 543c67fac7db4..7f330904eede9 100644
--- a/clang/test/CodeCompletion/overrides.cpp
+++ b/clang/test/CodeCompletion/overrides.cpp
@@ -15,19 +15,19 @@ class C : public B {
 };
 
 // Runs completion at ^vf
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:3 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-4):3 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC1: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC1-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
 // Runs completion at vf^
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-10):5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
 // Runs completion at void ^ on line 13.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-17):8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
@@ -39,5 +39,5 @@ void func() {
 }
 
 // Runs completion at empty line on line 37.
-// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:37:1 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-5):1 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
 // CHECK-CC4: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}

diff  --git a/clang/test/CodeCompletion/paren_locs.cpp b/clang/test/CodeCompletion/paren_locs.cpp
index 303264cff7252..cfeac40a1d228 100644
--- a/clang/test/CodeCompletion/paren_locs.cpp
+++ b/clang/test/CodeCompletion/paren_locs.cpp
@@ -3,14 +3,14 @@ void foo(int a, int b, int c);
 
 void test() {
   foo(10, );
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:10 %s -o - \
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):10 %s -o - \
   // RUN: | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: OPENING_PAREN_LOC: {{.*}}paren_locs.cpp:5:6
 
 #define FOO foo(
   FOO 10, );
 #undef FOO
-  // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:11:10 %s -o - \
+  // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-2):10 %s -o - \
   // RUN: | FileCheck -check-prefix=CHECK-CC2 %s
   // CHECK-CC2: OPENING_PAREN_LOC: {{.*}}paren_locs.cpp:11:3
 
@@ -19,15 +19,15 @@ void test() {
     Foo(int a, int b, int c);
   };
   Foo a(10, );
-  // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:21:12 %s -o - \
+  // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):12 %s -o - \
   // RUN: | FileCheck -check-prefix=CHECK-CC3 %s
   // CHECK-CC3: OPENING_PAREN_LOC: {{.*}}paren_locs.cpp:21:8
   Foo(10, );
-  // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:25:10 %s -o - \
+  // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):10 %s -o - \
   // RUN: | FileCheck -check-prefix=CHECK-CC4 %s
   // CHECK-CC4: OPENING_PAREN_LOC: {{.*}}paren_locs.cpp:25:6
   new Foo(10, );
-  // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:29:15 %s -o - \
+  // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):15 %s -o - \
   // RUN: | FileCheck -check-prefix=CHECK-CC5 %s
   // CHECK-CC5: OPENING_PAREN_LOC: {{.*}}paren_locs.cpp:29:10
 }

diff  --git a/clang/test/CodeCompletion/pragma-macro-token-caching.c b/clang/test/CodeCompletion/pragma-macro-token-caching.c
index 432706e85ceb9..be53eb9c3a888 100644
--- a/clang/test/CodeCompletion/pragma-macro-token-caching.c
+++ b/clang/test/CodeCompletion/pragma-macro-token-caching.c
@@ -7,7 +7,7 @@ void completeParam(int param) {
     param;
 }
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:1 %s | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-3):1 %s | FileCheck %s
 // CHECK: param : [#int#]param
 
 void completeParamPragmaError(int param) {
@@ -15,4 +15,4 @@ void completeParamPragmaError(int param) {
     param;
 }
 
-// RUN: %clang_cc1 -fsyntax-only -verify -code-completion-at=%s:16:1 %s | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -verify -code-completion-at=%s:%(line-2):1 %s | FileCheck %s

diff  --git a/clang/test/CodeCompletion/preamble.c b/clang/test/CodeCompletion/preamble.c
index 90ed5656d176b..7a4df05cc3648 100644
--- a/clang/test/CodeCompletion/preamble.c
+++ b/clang/test/CodeCompletion/preamble.c
@@ -3,5 +3,5 @@ void foo() {
   struct X x;
   x.
 
-// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:4:5 -Xclang -code-completion-patterns  %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:%(line-2):5 -Xclang -code-completion-patterns  %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: FieldDecl:{ResultType int}{TypedText m} (35)

diff  --git a/clang/test/CodeCompletion/preferred-type.cpp b/clang/test/CodeCompletion/preferred-type.cpp
index 5048dfac8954e..1c16ee0c581a5 100644
--- a/clang/test/CodeCompletion/preferred-type.cpp
+++ b/clang/test/CodeCompletion/preferred-type.cpp
@@ -1,13 +1,13 @@
 void test(bool x) {
   if (x) {}
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:7 %s | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):7 %s | FileCheck %s
   // CHECK: PREFERRED-TYPE: _Bool
 
   while (x) {}
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:6:10 %s | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):10 %s | FileCheck %s
 
   for (; x;) {}
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:9:10 %s | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):10 %s | FileCheck %s
 
   // FIXME(ibiryukov): the condition in do-while is parsed as expression, so we
   // fail to detect it should be converted to bool.

diff  --git a/clang/test/CodeCompletion/qualifiers-as-written.cpp b/clang/test/CodeCompletion/qualifiers-as-written.cpp
index 90530ec65c97a..e5a63d2486353 100644
--- a/clang/test/CodeCompletion/qualifiers-as-written.cpp
+++ b/clang/test/CodeCompletion/qualifiers-as-written.cpp
@@ -21,10 +21,10 @@ using ns::func;
 
 void test() {
   foo().method(0, 0, 0, 0);
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:9 %s -o - | FileCheck %s --check-prefix=CHECK-1
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):9 %s -o - | FileCheck %s --check-prefix=CHECK-1
   // CHECK-1: COMPLETION: method : [#type#]method(<#type#>, <#foo::type#>, <#::foo::type#>, <#::foo::foo::type#>)
   f
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:26:3 %s -o - | FileCheck %s --check-prefix=CHECK-2
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):3 %s -o - | FileCheck %s --check-prefix=CHECK-2
   // FIXME(ibiryukov): We should get rid of CHECK-DAGs here when completion output is made deterministic (see PR35244).
   // CHECK-2-DAG: COMPLETION: func : [#int#]func(<#foo a#>, <#bar b#>, <#ns::bar c#>, <#ns::baz d#>
   // CHECK-2-DAG: COMPLETION: func : [#int#]func(<#foo::type a#>, <#bar b#>, <#baz c#>

diff  --git a/clang/test/CodeCompletion/self-inits.cpp b/clang/test/CodeCompletion/self-inits.cpp
index a64209534ae6f..1843755f1aecf 100644
--- a/clang/test/CodeCompletion/self-inits.cpp
+++ b/clang/test/CodeCompletion/self-inits.cpp
@@ -1,3 +1,3 @@
 int foo = 10;
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:1:11 %s -o - | FileCheck --check-prefix=CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):11 %s -o - | FileCheck --check-prefix=CC1 %s
 // CC1-NOT: foo

diff  --git a/clang/test/CodeCompletion/signatures-crash.cpp b/clang/test/CodeCompletion/signatures-crash.cpp
index c58ae0cc2fd93..985054a7dea2c 100644
--- a/clang/test/CodeCompletion/signatures-crash.cpp
+++ b/clang/test/CodeCompletion/signatures-crash.cpp
@@ -6,10 +6,10 @@ struct map {
 int main() {
   map *m;
   m->find(10);
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:8:11 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):11 %s -o - | FileCheck %s
   // CHECK: OVERLOAD: [#void#]find(<#int#>)
 
   // Also check when the lhs is an explicit pr-value.
   (m+0)->find(10);
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:15 %s -o - | FileCheck %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):15 %s -o - | FileCheck %s
 }

diff  --git a/clang/test/CodeCompletion/tag.c b/clang/test/CodeCompletion/tag.c
index f48ef919f0279..9d57c14150e08 100644
--- a/clang/test/CodeCompletion/tag.c
+++ b/clang/test/CodeCompletion/tag.c
@@ -7,6 +7,6 @@ void X(void);
 void test(void) {
   enum X { x };
   enum 
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:9:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: X
   // CHECK-CC1: Y

diff  --git a/clang/test/CodeCompletion/tag.cpp b/clang/test/CodeCompletion/tag.cpp
index d99ca05bda4ad..7d5468d56b269 100644
--- a/clang/test/CodeCompletion/tag.cpp
+++ b/clang/test/CodeCompletion/tag.cpp
@@ -15,7 +15,7 @@ namespace N {
   
   void test() {
     class 
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:17:11 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):11 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
     // FIXME: the redundant Y is really annoying... it needs qualification to 
     // actually be useful. Here, it just looks redundant :(
     // CHECK-CC1: A

diff  --git a/clang/test/CodeCompletion/template-signature.cpp b/clang/test/CodeCompletion/template-signature.cpp
index 4425faf24912e..571186b790d20 100644
--- a/clang/test/CodeCompletion/template-signature.cpp
+++ b/clang/test/CodeCompletion/template-signature.cpp
@@ -2,27 +2,27 @@ template <int, char y> float overloaded(int);
 template <class, int x> bool overloaded(char);
 
 auto m = overloaded<1, 2>(0);
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:21 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):21 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: OPENING_PAREN_LOC: {{.*}}4:20
 // CHECK-CC1-DAG: OVERLOAD: [#float#]overloaded<<#int#>, char y>[#()#]
 // CHECK-CC1-DAG: OVERLOAD: [#bool#]overloaded<<#class#>, int x>[#()#]
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:24 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-5):24 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2-NOT: OVERLOAD: {{.*}}int x
 // CHECK-CC2: OVERLOAD: [#float#]overloaded<int, <#char y#>>[#()#]
 
 template <class T, T... args> int n = 0;
 int val = n<int, 1, 2, 3>;
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:18 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):18 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: OVERLOAD: [#int#]n<class T, <#T ...args#>>
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:24 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-3):24 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
 // CHECK-CC4: OVERLOAD: [#int#]n<class T, T ...args>
 
 template <typename> struct Vector {};
 template <typename Element, template <typename E> class Container = Vector>
 struct Collection { Container<Element> container; };
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:22:31 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):31 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
 // CHECK-CC5: OVERLOAD: [#class#]Container<<#typename E#>>
 Collection<int, Vector> collection;
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:25:12 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):12 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
 // CHECK-CC6: OVERLOAD: [#struct#]Collection<<#typename Element#>>
 

diff  --git a/clang/test/CodeCompletion/templates.cpp b/clang/test/CodeCompletion/templates.cpp
index f9811f4464768..1c708457762d6 100644
--- a/clang/test/CodeCompletion/templates.cpp
+++ b/clang/test/CodeCompletion/templates.cpp
@@ -17,10 +17,10 @@ namespace std {
 void f() {
   std::vector<int> v;
   v.foo();
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:18:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-2):8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: allocator<<#typename T#>>
   // CHECK-CC1-NEXT: vector<<#typename T#>{#, <#typename Alloc#>#}>
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-4):5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
   // CHECK-CC2: foo
   // CHECK-CC2: in_base
   // CHECK-CC2: stop
@@ -30,6 +30,6 @@ void f() {
 template <typename> struct X;
 template <typename T> struct X<T*> { X(double); };
 X<int*> x(42);
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:32:11 %s -o - | FileCheck -check-prefix=CHECK-CONSTRUCTOR %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):11 %s -o - | FileCheck -check-prefix=CHECK-CONSTRUCTOR %s
 // CHECK-CONSTRUCTOR: OVERLOAD: X(<#double#>)
 // (rather than X<type-parameter-0-0 *>(<#double#>)

diff  --git a/clang/test/CodeCompletion/this-quals.cpp b/clang/test/CodeCompletion/this-quals.cpp
index eeaed00aa8571..bf89ba5af5f7f 100644
--- a/clang/test/CodeCompletion/this-quals.cpp
+++ b/clang/test/CodeCompletion/this-quals.cpp
@@ -3,7 +3,7 @@ class foo {
     [this]() {
 
     }();
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:1 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-2):1 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
     // CHECK-CC1: const_func
     // CHECK-CC1: mut_func
   }
@@ -12,7 +12,7 @@ class foo {
     [this]() {
 
     }();
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:1 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-2):1 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
     // CHECK-CC2-NOT: mut_func
     // CHECK-CC2: const_func
   };

diff  --git a/clang/test/CodeCompletion/truncation.c b/clang/test/CodeCompletion/truncation.c
index b6c41de024f1a..f0ce5d25fb9e1 100644
--- a/clang/test/CodeCompletion/truncation.c
+++ b/clang/test/CodeCompletion/truncation.c
@@ -7,9 +7,9 @@ struct
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s.h:4:8 -o - %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: X
 // CHECK-CC1-NEXT: Y
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:8 -o - %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-5):8 -o - %s | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: X
 // CHECK-CC2: Xa
 // CHECK-CC2: Y
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:3:3 -o - %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-12):3 -o - %s

diff  --git a/clang/test/CodeCompletion/uninstantiated_params.cpp b/clang/test/CodeCompletion/uninstantiated_params.cpp
index 643f2f72553b1..6df9d48adb859 100644
--- a/clang/test/CodeCompletion/uninstantiated_params.cpp
+++ b/clang/test/CodeCompletion/uninstantiated_params.cpp
@@ -8,6 +8,6 @@ struct unique_ptr {
 void test() {
   unique_ptr<int> x;
   x.
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:5 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):5 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: [#void#]reset({#<#pointer ptr = pointer()#>#})
 }

diff  --git a/clang/test/CodeCompletion/using-enum.cpp b/clang/test/CodeCompletion/using-enum.cpp
index dfe297a2c0681..b1ecbd1d75a6b 100644
--- a/clang/test/CodeCompletion/using-enum.cpp
+++ b/clang/test/CodeCompletion/using-enum.cpp
@@ -2,6 +2,6 @@ enum class AAA { X, Y, Z };
 
 namespace N2 {
   using enum AAA;
-  // RUN: %clang_cc1 -std=c++20 -fsyntax-only -code-completion-at=%s:4:14 %s | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -std=c++20 -fsyntax-only -code-completion-at=%s:%(line-1):14 %s | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: COMPLETION: AAA
 };

diff  --git a/clang/test/CodeCompletion/using-namespace.cpp b/clang/test/CodeCompletion/using-namespace.cpp
index 4b93d02388b53..10bf31407b452 100644
--- a/clang/test/CodeCompletion/using-namespace.cpp
+++ b/clang/test/CodeCompletion/using-namespace.cpp
@@ -12,7 +12,7 @@ namespace N2 {
   
   void foo() {
     using namespace 
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:21 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):21 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
     // CHECK-CC1: I1
     // CHECK-CC1: I4
     // CHECK-CC1: I5

diff  --git a/clang/test/CodeCompletion/using.cpp b/clang/test/CodeCompletion/using.cpp
index aaad8c976b825..e4f2955e4ff64 100644
--- a/clang/test/CodeCompletion/using.cpp
+++ b/clang/test/CodeCompletion/using.cpp
@@ -14,7 +14,7 @@ namespace N2 {
     int N3;
     
     using 
-    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:16:11 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-1):11 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
     // CHECK-CC1: I1
     // CHECK-CC1: I4
     // CHECK-CC1: I5

diff  --git a/clang/test/CodeCompletion/variadic-template.cpp b/clang/test/CodeCompletion/variadic-template.cpp
index 099ef3a6961cf..31fc55ee154f6 100644
--- a/clang/test/CodeCompletion/variadic-template.cpp
+++ b/clang/test/CodeCompletion/variadic-template.cpp
@@ -7,12 +7,12 @@ void f() {
   // Tools, including clangd, can unexpand "args" when showing this to the user.
   // The important thing is that we provide OVERLOAD signature in all those cases.
   //
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:7 %s -o - | FileCheck --check-prefix=CHECK-1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-5):7 %s -o - | FileCheck --check-prefix=CHECK-1 %s
   // CHECK-1: OVERLOAD: [#void#]fun(<#T x#>, Args args...)
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:10 %s -o - | FileCheck --check-prefix=CHECK-2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-7):10 %s -o - | FileCheck --check-prefix=CHECK-2 %s
   // CHECK-2: OVERLOAD: [#void#]fun(int x)
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:13 %s -o - | FileCheck --check-prefix=CHECK-3 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-9):13 %s -o - | FileCheck --check-prefix=CHECK-3 %s
   // CHECK-3: OVERLOAD: [#void#]fun(int x, int args)
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:16 %s -o - | FileCheck --check-prefix=CHECK-4 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:%(line-11):16 %s -o - | FileCheck --check-prefix=CHECK-4 %s
   // CHECK-4: OVERLOAD: [#void#]fun(int x, int args, int args)
 }

diff  --git a/llvm/utils/relative_lines.py b/llvm/utils/relative_lines.py
new file mode 100755
index 0000000000000..9852da1dff4bb
--- /dev/null
+++ b/llvm/utils/relative_lines.py
@@ -0,0 +1,107 @@
+#!/usr/bin/env python3
+
+"""Replaces absolute line numbers in lit-tests with relative line numbers.
+
+Writing line numbers like 152 in 'RUN: or CHECK:' makes tests hard to maintain:
+inserting lines in the middle of the test means updating all the line numbers.
+
+Encoding them relative to the current line helps, and tools support it:
+    Lit will substitute %(line+2) with the actual line number
+    FileCheck supports [[@LINE+2]]
+
+This tool takes a regex which captures a line number, and a list of test files.
+It searches for line numbers in the files and replaces them with a relative
+line number reference.
+"""
+
+USAGE = """Example usage:
+    find -type f clang/test/CodeCompletion | grep -v /Inputs/ | \\
+    xargs relative_lines.py --dry-run --verbose --near=100 \\
+    --pattern='-code-completion-at[ =]%s:(\d+)' \\
+    --pattern='requires fix-it: {(\d+):\d+-(\d+):\d+}'
+"""
+
+import argparse
+import re
+import sys
+
+def b(x):
+    return bytes(x, encoding='utf-8')
+
+parser = argparse.ArgumentParser(prog = 'relative_lines',
+                                 description = __doc__,
+                                 epilog = USAGE,
+                                 formatter_class=argparse.RawTextHelpFormatter)
+parser.add_argument('--near', type=int, default=20,
+                    help = "maximum line distance to make relative")
+parser.add_argument('--partial', action='store_true', default=False,
+                    help = "apply replacements to files even if others failed")
+parser.add_argument('--pattern', default=[], action='append',
+                    type=lambda x: re.compile(b(x)),
+                    help = "regex to match, with line numbers captured in ().")
+parser.add_argument('--verbose', action='store_true', default=False,
+                    help = "print matches applied")
+parser.add_argument('--dry-run', action='store_true', default=False,
+                    help = "don't apply replacements. Best with --verbose.")
+parser.add_argument('files', nargs = '+')
+args = parser.parse_args()
+
+for file in args.files:
+    try:
+        contents = open(file, 'rb').read()
+    except UnicodeDecodeError as e:
+        print(f"{file}: not valid UTF-8 - {e}", file=sys.stderr)
+    failures = 0
+
+    def line_number(offset):
+        return 1 + contents[:offset].count(b'\n')
+
+    def replace_one(capture, line, offset):
+        """Text to replace a capture group, e.g. 42 => %(line+1)"""
+        try:
+            target = int(capture)
+        except ValueError:
+            print(f"{file}:{line}: matched non-number '{capture}'", file=sys.stderr)
+            return capture
+
+        if args.near > 0 and abs(target - line) > args.near:
+            print(f"{file}:{line}: target line {target} is farther than {args.near}", file=sys.stderr)
+            return capture
+        if target > line:
+            delta = b('+' + str(target - line))
+        elif target < line:
+            delta = b('-' + str(line - target))
+        else:
+            delta = b''
+
+        prefix = contents[:offset].rsplit(b'\n')[-1]
+        is_lit = b'RUN' in prefix or b'DEFINE' in prefix
+        text = b(('%(line{0})' if is_lit else '[[@LINE{0}]]').format(delta))
+        if args.verbose:
+            print(f"{file}:{line}: {0} ==> {text}")
+        return text
+
+    def replace_match(m):
+        """Text to replace a whole match, e.g. --at=42:3 => --at=%(line+2):3"""
+        line = 1 + contents[:m.start()].count(b'\n')
+        result = ''
+        pos = m.start()
+        for index, capture in enumerate(m.groups()):
+            index += 1 # re groups are conventionally 1-indexed
+            result += contents[pos:m.start(index)]
+            replacement = replace_one(capture, line, m.start(index))
+            result += replacement
+            if replacement == capture:
+                global failures
+                failures += 1
+            pos = m.end(index)
+        result += contents[pos:m.end()]
+        return result
+
+    for pattern in args.pattern:
+        contents = re.sub(pattern, replace_match, contents)
+    if failures > 0 and not args.partial:
+        print(f"{file}: leaving unchanged (some failed, --partial not given)")
+        continue
+    if not args.dry_run:
+        open(file, "wb").write(contents)


        


More information about the cfe-commits mailing list