[llvm-branch-commits] [clang-doc][NFC] Make test resilient to line changes (PR #119811)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Dec 12 20:27:23 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tools-extra

Author: Paul Kirth (ilovepi)

<details>
<summary>Changes</summary>

This just reorganizes the test code, so its easy to use @<!-- -->LINE directives
in the test, and avoid needing to update all the line numbers when making
unrelated changes.


---
Full diff: https://github.com/llvm/llvm-project/pull/119811.diff


1 Files Affected:

- (modified) clang-tools-extra/test/clang-doc/templates.cpp (+14-10) 


``````````diff
diff --git a/clang-tools-extra/test/clang-doc/templates.cpp b/clang-tools-extra/test/clang-doc/templates.cpp
index d5a9e7d201e1e5..1adfbe0cf18282 100644
--- a/clang-tools-extra/test/clang-doc/templates.cpp
+++ b/clang-tools-extra/test/clang-doc/templates.cpp
@@ -6,22 +6,17 @@
 // RUN: cat %t/docs/index.yaml | FileCheck %s --check-prefix=YAML
 // RUN: rm -rf %t
 
-template<typename T, int U = 1>
-void function(T x) {}
-
-template<>
-void function<bool, 0>(bool x) {}
+// YAML: ---
+// YAML-NEXT: USR:             '{{([0-9A-F]{40})}}'
 
 template<class... T>
 void ParamPackFunction(T... args);
 
-// YAML: ---
-// YAML-NEXT: USR:             '{{([0-9A-F]{40})}}'
 // YAML-NEXT: ChildFunctions:
 // YAML-NEXT:  - USR:             '{{([0-9A-F]{40})}}'
 // YAML-NEXT:    Name:            'ParamPackFunction'
 // YAML-NEXT:    Location:
-// YAML-NEXT:      - LineNumber:      16
+// YAML-NEXT:      - LineNumber:      [[# @LINE - 6]]
 // YAML-NEXT:        Filename:        '{{.*}}'
 // YAML-NEXT:    Params:
 // YAML-NEXT:      - Type:
@@ -35,10 +30,14 @@ void ParamPackFunction(T... args);
 // YAML-NEXT:    Template:
 // YAML-NEXT:      Params:
 // YAML-NEXT:        - Contents:        'class... T'
+
+template<typename T, int U = 1>
+void function(T x) {}
+
 // YAML-NEXT:   - USR:             '{{([0-9A-F]{40})}}'
 // YAML-NEXT:     Name:            'function'
 // YAML-NEXT:     DefLocation:
-// YAML-NEXT:       LineNumber:      10
+// YAML-NEXT:       LineNumber:      [[# @LINE - 5]]
 // YAML-NEXT:       Filename:        '{{.*}}'
 // YAML-NEXT:     Params:
 // YAML-NEXT:       - Type:
@@ -53,10 +52,14 @@ void ParamPackFunction(T... args);
 // YAML-NEXT:       Params:
 // YAML-NEXT:         - Contents:        'typename T'
 // YAML-NEXT:         - Contents:        'int U = 1'
+
+template<>
+void function<bool, 0>(bool x) {}
+
 // YAML-NEXT:   - USR:             '{{([0-9A-F]{40})}}'
 // YAML-NEXT:     Name:            'function'
 // YAML-NEXT:     DefLocation:
-// YAML-NEXT:       LineNumber:      12
+// YAML-NEXT:       LineNumber:      [[# @LINE - 6]]
 // YAML-NEXT:       Filename:        '{{.*}}'
 // YAML-NEXT:     Params:
 // YAML-NEXT:       - Type:
@@ -74,3 +77,4 @@ void ParamPackFunction(T... args);
 // YAML-NEXT:           - Contents:        'bool'
 // YAML-NEXT:           - Contents:        '0'
 // YAML-NEXT: ...
+

``````````

</details>


https://github.com/llvm/llvm-project/pull/119811


More information about the llvm-branch-commits mailing list