sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added a project: All.
sammccall requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140217

Files:
  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
  llvm/utils/relative_lines.py

Index: llvm/utils/relative_lines.py
===================================================================
--- /dev/null
+++ llvm/utils/relative_lines.py
@@ -0,0 +1,99 @@
+#!/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 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
+
+parser = argparse.ArgumentParser(prog = 'relative_lines',
+                                 description = __doc__,
+                                 formatter_class=argparse.RawTextHelpFormatter)
+parser.add_argument('--near', type=int, default=0,
+                    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', type=re.compile, default=[], action='append',
+                    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:
+    contents = open(file).read()
+    failures = 0
+
+    def line_number(offset):
+        return 1 + contents[:offset].count('\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 = '+' + str(target - line)
+        elif target < line:
+            delta = '-' + str(line - target)
+        else:
+            delta = ''
+
+        prefix = contents[:offset].rsplit('\n')[-1]
+        is_lit = 'RUN' in prefix or 'DEFINE' in prefix
+        text = ('%(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('\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, "w").write(contents)
Index: clang/test/CodeCompletion/variadic-template.cpp
===================================================================
--- clang/test/CodeCompletion/variadic-template.cpp
+++ clang/test/CodeCompletion/variadic-template.cpp
@@ -7,12 +7,12 @@
   // 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)
 }
Index: clang/test/CodeCompletion/using.cpp
===================================================================
--- clang/test/CodeCompletion/using.cpp
+++ clang/test/CodeCompletion/using.cpp
@@ -14,7 +14,7 @@
     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
Index: clang/test/CodeCompletion/using-namespace.cpp
===================================================================
--- clang/test/CodeCompletion/using-namespace.cpp
+++ clang/test/CodeCompletion/using-namespace.cpp
@@ -12,7 +12,7 @@
   
   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
Index: clang/test/CodeCompletion/using-enum.cpp
===================================================================
--- clang/test/CodeCompletion/using-enum.cpp
+++ clang/test/CodeCompletion/using-enum.cpp
@@ -2,6 +2,6 @@
 
 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
 };
Index: clang/test/CodeCompletion/uninstantiated_params.cpp
===================================================================
--- clang/test/CodeCompletion/uninstantiated_params.cpp
+++ clang/test/CodeCompletion/uninstantiated_params.cpp
@@ -8,6 +8,6 @@
 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()#>#})
 }
Index: clang/test/CodeCompletion/truncation.c
===================================================================
--- clang/test/CodeCompletion/truncation.c
+++ clang/test/CodeCompletion/truncation.c
@@ -7,9 +7,9 @@
 // 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
Index: clang/test/CodeCompletion/this-quals.cpp
===================================================================
--- clang/test/CodeCompletion/this-quals.cpp
+++ clang/test/CodeCompletion/this-quals.cpp
@@ -3,7 +3,7 @@
     [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 @@
     [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
   };
Index: clang/test/CodeCompletion/templates.cpp
===================================================================
--- clang/test/CodeCompletion/templates.cpp
+++ clang/test/CodeCompletion/templates.cpp
@@ -17,10 +17,10 @@
 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 @@
 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#>)
Index: clang/test/CodeCompletion/template-signature.cpp
===================================================================
--- clang/test/CodeCompletion/template-signature.cpp
+++ clang/test/CodeCompletion/template-signature.cpp
@@ -2,27 +2,27 @@
 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#>>
 
Index: clang/test/CodeCompletion/tag.cpp
===================================================================
--- clang/test/CodeCompletion/tag.cpp
+++ clang/test/CodeCompletion/tag.cpp
@@ -15,7 +15,7 @@
   
   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
Index: clang/test/CodeCompletion/tag.c
===================================================================
--- clang/test/CodeCompletion/tag.c
+++ clang/test/CodeCompletion/tag.c
@@ -7,6 +7,6 @@
 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
Index: clang/test/CodeCompletion/signatures-crash.cpp
===================================================================
--- clang/test/CodeCompletion/signatures-crash.cpp
+++ clang/test/CodeCompletion/signatures-crash.cpp
@@ -6,10 +6,10 @@
 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
 }
Index: clang/test/CodeCompletion/self-inits.cpp
===================================================================
--- clang/test/CodeCompletion/self-inits.cpp
+++ 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
Index: clang/test/CodeCompletion/qualifiers-as-written.cpp
===================================================================
--- clang/test/CodeCompletion/qualifiers-as-written.cpp
+++ clang/test/CodeCompletion/qualifiers-as-written.cpp
@@ -21,10 +21,10 @@
 
 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#>
Index: clang/test/CodeCompletion/preferred-type.cpp
===================================================================
--- clang/test/CodeCompletion/preferred-type.cpp
+++ 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.
Index: clang/test/CodeCompletion/preamble.c
===================================================================
--- clang/test/CodeCompletion/preamble.c
+++ clang/test/CodeCompletion/preamble.c
@@ -3,5 +3,5 @@
   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)
Index: clang/test/CodeCompletion/pragma-macro-token-caching.c
===================================================================
--- clang/test/CodeCompletion/pragma-macro-token-caching.c
+++ clang/test/CodeCompletion/pragma-macro-token-caching.c
@@ -7,7 +7,7 @@
     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 @@
     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
Index: clang/test/CodeCompletion/paren_locs.cpp
===================================================================
--- clang/test/CodeCompletion/paren_locs.cpp
+++ clang/test/CodeCompletion/paren_locs.cpp
@@ -3,14 +3,14 @@
 
 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 @@
     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
 }
Index: clang/test/CodeCompletion/overrides.cpp
===================================================================
--- clang/test/CodeCompletion/overrides.cpp
+++ clang/test/CodeCompletion/overrides.cpp
@@ -15,19 +15,19 @@
 };
 
 // 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 @@
 }
 
 // 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{{$}}
Index: clang/test/CodeCompletion/ordinary-name.c
===================================================================
--- clang/test/CodeCompletion/ordinary-name.c
+++ clang/test/CodeCompletion/ordinary-name.c
@@ -4,7 +4,7 @@
 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 @@
   // 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
Index: clang/test/CodeCompletion/operator.cpp
===================================================================
--- clang/test/CodeCompletion/operator.cpp
+++ clang/test/CodeCompletion/operator.cpp
@@ -8,7 +8,7 @@
   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
Index: clang/test/CodeCompletion/objc-protocol-member-access.m
===================================================================
--- clang/test/CodeCompletion/objc-protocol-member-access.m
+++ clang/test/CodeCompletion/objc-protocol-member-access.m
@@ -18,7 +18,7 @@
   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
Index: clang/test/CodeCompletion/objc-message.mm
===================================================================
--- clang/test/CodeCompletion/objc-message.mm
+++ clang/test/CodeCompletion/objc-message.mm
@@ -38,9 +38,9 @@
   [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
Index: clang/test/CodeCompletion/objc-message.m
===================================================================
--- clang/test/CodeCompletion/objc-message.m
+++ clang/test/CodeCompletion/objc-message.m
@@ -23,13 +23,13 @@
   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
Index: clang/test/CodeCompletion/objc-member-access.m
===================================================================
--- clang/test/CodeCompletion/objc-member-access.m
+++ clang/test/CodeCompletion/objc-member-access.m
@@ -15,7 +15,7 @@
   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
Index: clang/test/CodeCompletion/objc-expr.m
===================================================================
--- clang/test/CodeCompletion/objc-expr.m
+++ clang/test/CodeCompletion/objc-expr.m
@@ -4,7 +4,7 @@
   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 @@
 // 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#>)
Index: clang/test/CodeCompletion/nested-name-specifier.cpp
===================================================================
--- clang/test/CodeCompletion/nested-name-specifier.cpp
+++ clang/test/CodeCompletion/nested-name-specifier.cpp
@@ -10,7 +10,7 @@
 }
 
 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
Index: clang/test/CodeCompletion/namespace.cpp
===================================================================
--- clang/test/CodeCompletion/namespace.cpp
+++ clang/test/CodeCompletion/namespace.cpp
@@ -8,7 +8,7 @@
   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
   
Index: clang/test/CodeCompletion/namespace-alias.cpp
===================================================================
--- clang/test/CodeCompletion/namespace-alias.cpp
+++ clang/test/CodeCompletion/namespace-alias.cpp
@@ -11,7 +11,7 @@
   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
Index: clang/test/CodeCompletion/member-access.c
===================================================================
--- clang/test/CodeCompletion/member-access.c
+++ clang/test/CodeCompletion/member-access.c
@@ -6,7 +6,7 @@
 
 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 @@
   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
Index: clang/test/CodeCompletion/member-access-qualifiers.cpp
===================================================================
--- clang/test/CodeCompletion/member-access-qualifiers.cpp
+++ clang/test/CodeCompletion/member-access-qualifiers.cpp
@@ -8,6 +8,6 @@
 };
 
 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()
Index: clang/test/CodeCompletion/macros.c
===================================================================
--- clang/test/CodeCompletion/macros.c
+++ clang/test/CodeCompletion/macros.c
@@ -8,20 +8,20 @@
 };
 
 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
Index: clang/test/CodeCompletion/macros-in-modules.m
===================================================================
--- clang/test/CodeCompletion/macros-in-modules.m
+++ 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 =
Index: clang/test/CodeCompletion/macros-in-modules.c
===================================================================
--- clang/test/CodeCompletion/macros-in-modules.c
+++ 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 =
Index: clang/test/CodeCompletion/lambdas.cpp
===================================================================
--- clang/test/CodeCompletion/lambdas.cpp
+++ clang/test/CodeCompletion/lambdas.cpp
@@ -7,18 +7,18 @@
   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 @@
 
   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 @@
 
 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#]
 }
Index: clang/test/CodeCompletion/invalid-initialized-class.cpp
===================================================================
--- clang/test/CodeCompletion/invalid-initialized-class.cpp
+++ clang/test/CodeCompletion/invalid-initialized-class.cpp
@@ -3,13 +3,13 @@
 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
 }
Index: clang/test/CodeCompletion/inside-macros.cpp
===================================================================
--- clang/test/CodeCompletion/inside-macros.cpp
+++ clang/test/CodeCompletion/inside-macros.cpp
@@ -5,9 +5,9 @@
   // 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
 }
Index: clang/test/CodeCompletion/incomplete-ret-type.cpp
===================================================================
--- clang/test/CodeCompletion/incomplete-ret-type.cpp
+++ clang/test/CodeCompletion/incomplete-ret-type.cpp
@@ -6,8 +6,8 @@
 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
Index: clang/test/CodeCompletion/incomplete-member.cpp
===================================================================
--- clang/test/CodeCompletion/incomplete-member.cpp
+++ clang/test/CodeCompletion/incomplete-member.cpp
@@ -4,5 +4,5 @@
   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:
Index: clang/test/CodeCompletion/included-symlinks.cpp
===================================================================
--- clang/test/CodeCompletion/included-symlinks.cpp
+++ 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/
Index: clang/test/CodeCompletion/ignore-ns-level-decls.cpp
===================================================================
--- clang/test/CodeCompletion/ignore-ns-level-decls.cpp
+++ clang/test/CodeCompletion/ignore-ns-level-decls.cpp
@@ -10,12 +10,12 @@
 
 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: {{^}}{{$}}
 }
Index: clang/test/CodeCompletion/functions.cpp
===================================================================
--- clang/test/CodeCompletion/functions.cpp
+++ clang/test/CodeCompletion/functions.cpp
@@ -3,6 +3,6 @@
        
 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, ...#>)
Index: clang/test/CodeCompletion/function-templates.cpp
===================================================================
--- clang/test/CodeCompletion/function-templates.cpp
+++ clang/test/CodeCompletion/function-templates.cpp
@@ -17,11 +17,11 @@
 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#>)
 }
Index: clang/test/CodeCompletion/enum-switch-case.cpp
===================================================================
--- clang/test/CodeCompletion/enum-switch-case.cpp
+++ clang/test/CodeCompletion/enum-switch-case.cpp
@@ -19,7 +19,7 @@
     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
Index: clang/test/CodeCompletion/enum-switch-case.c
===================================================================
--- clang/test/CodeCompletion/enum-switch-case.c
+++ clang/test/CodeCompletion/enum-switch-case.c
@@ -25,14 +25,14 @@
     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
Index: clang/test/CodeCompletion/enum-switch-case-qualified.cpp
===================================================================
--- clang/test/CodeCompletion/enum-switch-case-qualified.cpp
+++ clang/test/CodeCompletion/enum-switch-case-qualified.cpp
@@ -21,7 +21,7 @@
 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
Index: clang/test/CodeCompletion/enum-preferred-type.cpp
===================================================================
--- clang/test/CodeCompletion/enum-preferred-type.cpp
+++ clang/test/CodeCompletion/enum-preferred-type.cpp
@@ -13,10 +13,10 @@
   // 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
Index: clang/test/CodeCompletion/end-of-ident.cpp
===================================================================
--- clang/test/CodeCompletion/end-of-ident.cpp
+++ clang/test/CodeCompletion/end-of-ident.cpp
@@ -3,18 +3,18 @@
 // 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
Index: clang/test/CodeCompletion/end-of-ident-macro.cpp
===================================================================
--- clang/test/CodeCompletion/end-of-ident-macro.cpp
+++ clang/test/CodeCompletion/end-of-ident-macro.cpp
@@ -5,12 +5,12 @@
 // 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
 // CHECK: COMPLETION: FUNCTOR : FUNCTOR
\ No newline at end of file
Index: clang/test/CodeCompletion/end-of-file.cpp
===================================================================
--- clang/test/CodeCompletion/end-of-file.cpp
+++ 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
Index: clang/test/CodeCompletion/enable-if-attr-crash.cpp
===================================================================
--- clang/test/CodeCompletion/enable-if-attr-crash.cpp
+++ clang/test/CodeCompletion/enable-if-attr-crash.cpp
@@ -2,7 +2,7 @@
 
 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
 }
Index: clang/test/CodeCompletion/documentation.m
===================================================================
--- clang/test/CodeCompletion/documentation.m
+++ clang/test/CodeCompletion/documentation.m
@@ -16,10 +16,10 @@
   [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!
Index: clang/test/CodeCompletion/documentation.cpp
===================================================================
--- clang/test/CodeCompletion/documentation.cpp
+++ clang/test/CodeCompletion/documentation.cpp
@@ -23,11 +23,11 @@
   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.
Index: clang/test/CodeCompletion/deuglify.cpp
===================================================================
--- clang/test/CodeCompletion/deuglify.cpp
+++ clang/test/CodeCompletion/deuglify.cpp
@@ -15,11 +15,11 @@
 } // 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#>)
Index: clang/test/CodeCompletion/desig-init.cpp
===================================================================
--- clang/test/CodeCompletion/desig-init.cpp
+++ clang/test/CodeCompletion/desig-init.cpp
@@ -9,14 +9,14 @@
 
 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 @@
   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 @@
 };
 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 @@
 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 @@
   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 { 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
Index: clang/test/CodeCompletion/ctor-signature.cpp
===================================================================
--- clang/test/CodeCompletion/ctor-signature.cpp
+++ clang/test/CodeCompletion/ctor-signature.cpp
@@ -5,12 +5,12 @@
 
 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 @@
 };
 
 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 @@
 };
 
 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
Index: clang/test/CodeCompletion/ctor-initializer.cpp
===================================================================
--- clang/test/CodeCompletion/ctor-initializer.cpp
+++ 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 @@
 };
 
 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(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 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 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 @@
   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 @@
   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 @@
   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
Index: clang/test/CodeCompletion/crash-null-type.cpp
===================================================================
--- clang/test/CodeCompletion/crash-null-type.cpp
+++ clang/test/CodeCompletion/crash-null-type.cpp
@@ -3,6 +3,6 @@
     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
Index: clang/test/CodeCompletion/crash-if-directive.cpp
===================================================================
--- clang/test/CodeCompletion/crash-if-directive.cpp
+++ 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
Index: clang/test/CodeCompletion/crash-func-init.cpp
===================================================================
--- clang/test/CodeCompletion/crash-func-init.cpp
+++ 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
Index: clang/test/CodeCompletion/crash-func-decl.cpp
===================================================================
--- clang/test/CodeCompletion/crash-func-decl.cpp
+++ 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
Index: clang/test/CodeCompletion/constexpr.cpp
===================================================================
--- clang/test/CodeCompletion/constexpr.cpp
+++ 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;
Index: clang/test/CodeCompletion/comments.cpp
===================================================================
--- clang/test/CodeCompletion/comments.cpp
+++ clang/test/CodeCompletion/comments.cpp
@@ -8,6 +8,6 @@
   /* <- 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
Index: clang/test/CodeCompletion/call.cpp
===================================================================
--- clang/test/CodeCompletion/call.cpp
+++ clang/test/CodeCompletion/call.cpp
@@ -17,16 +17,16 @@
 
 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 @@
 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#>)
Index: clang/test/CodeCompletion/call.c
===================================================================
--- clang/test/CodeCompletion/call.c
+++ clang/test/CodeCompletion/call.c
@@ -6,10 +6,10 @@
   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()
 }
Index: clang/test/CodeCompletion/bracket-decl.c
===================================================================
--- clang/test/CodeCompletion/bracket-decl.c
+++ clang/test/CodeCompletion/bracket-decl.c
@@ -4,6 +4,6 @@
 
 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
Index: clang/test/CodeCompletion/auto_type.c
===================================================================
--- clang/test/CodeCompletion/auto_type.c
+++ 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() {
 
 }
Index: clang/test/CodeCompletion/auto.cpp
===================================================================
--- clang/test/CodeCompletion/auto.cpp
+++ 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 =
Index: clang/test/CodeCompletion/attr.cpp
===================================================================
--- clang/test/CodeCompletion/attr.cpp
+++ 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 @@
 // 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 @@
 // 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 @@
 // 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 @@
 #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 @@
 // 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 @@
   {}
 }
 // 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
Index: clang/test/CodeCompletion/after-function-equals.cpp
===================================================================
--- clang/test/CodeCompletion/after-function-equals.cpp
+++ 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
Index: clang/test/CodeCompletion/accessibility.cpp
===================================================================
--- clang/test/CodeCompletion/accessibility.cpp
+++ clang/test/CodeCompletion/accessibility.cpp
@@ -19,25 +19,25 @@
 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 @@
 
     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 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 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)
   }
Index: clang/test/CodeCompletion/accessibility-crash.cpp
===================================================================
--- clang/test/CodeCompletion/accessibility-crash.cpp
+++ clang/test/CodeCompletion/accessibility-crash.cpp
@@ -11,7 +11,7 @@
   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)
Index: clang/test/CodeCompletion/PR9728.cpp
===================================================================
--- clang/test/CodeCompletion/PR9728.cpp
+++ clang/test/CodeCompletion/PR9728.cpp
@@ -4,6 +4,6 @@
 
 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
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to