[clang-tools-extra] Symbol tags in SymbolInformation, WorkspaceSymbol, CallHierarchyItem and TypeHierarchyItem (PR #170103)

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 19 01:51:33 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r origin/main...HEAD clang-tools-extra/clangd/benchmarks/gen_callhierarchy_code.py
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- gen_callhierarchy_code.py	2026-03-19 08:43:07.000000 +0000
+++ gen_callhierarchy_code.py	2026-03-19 08:50:54.807114 +0000
@@ -36,10 +36,11 @@
 import sys
 from pathlib import Path
 
 
 # ─── helpers ─────────────────────────────────────────────────────────────────
+
 
 def _header(out, description: str):
     out.append("// AUTO-GENERATED by gen_callhierarchy_code.py")
     out.append(f"// Topology: {description}")
     out.append("// Compile with: clangd-indexer <file> -- > <file>.dex")
@@ -57,10 +58,11 @@
     out.append("    return 0;")
     out.append("}")
 
 
 # ─── topologies ──────────────────────────────────────────────────────────────
+
 
 def gen_chain(n: int) -> tuple[str, list[str]]:
     """f0 -> f1 -> ... -> f(n-1).  Target: f(n//2)."""
     lines: list[str] = []
     _header(lines, f"chain  size={n}  target=f{n // 2}")
@@ -156,13 +158,14 @@
 
 
 def gen_mixed(n_callers: int, n_callees: int) -> tuple[str, list[str]]:
     """hub_function is called by N callers AND calls M callees."""
     lines: list[str] = []
-    _header(lines,
-            f"mixed  callers={n_callers}  callees={n_callees}  "
-            f"target=hub_function")
+    _header(
+        lines,
+        f"mixed  callers={n_callers}  callees={n_callees}  " f"target=hub_function",
+    )
 
     for i in range(n_callers):
         lines.append(f"void caller{i}();")
     for i in range(n_callees):
         lines.append(f"void callee{i}();")
@@ -187,12 +190,14 @@
     return "hub_function", lines
 
 
 # ─── multi-TU scenario ────────────────────────────────────────────────────────
 
-def gen_multi_tu(n_modules: int, callers_per_module: int,
-                 out_dir: Path) -> tuple[str, list[Path]]:
+
+def gen_multi_tu(
+    n_modules: int, callers_per_module: int, out_dir: Path
+) -> tuple[str, list[Path]]:
     """
     Generate N separate .cpp files each containing <callers_per_module>
     callers that all call a common hub_function declared in a shared header.
     Returns the target function name and the list of generated file paths.
     """
@@ -205,65 +210,86 @@
     files.append(hdr)
 
     # hub implementation
     impl = out_dir / "hub.cpp"
     impl.write_text(
-        '// AUTO-GENERATED\n'
+        "// AUTO-GENERATED\n"
         '#include "hub.h"\n'
-        'extern void __sink(int);\n'
-        'void hub_function() { __sink(99); }\n'
+        "extern void __sink(int);\n"
+        "void hub_function() { __sink(99); }\n"
     )
     files.append(impl)
 
     # N caller modules
     for m in range(n_modules):
         src = out_dir / f"module{m}.cpp"
         lines = [
-            '// AUTO-GENERATED',
+            "// AUTO-GENERATED",
             '#include "hub.h"',
-            '',
+            "",
         ]
         for i in range(callers_per_module):
-            lines.append(
-                f'void module{m}_caller{i}() {{ hub_function(); }}'
-            )
-        src.write_text('\n'.join(lines) + '\n')
+            lines.append(f"void module{m}_caller{i}() {{ hub_function(); }}")
+        src.write_text("\n".join(lines) + "\n")
         files.append(src)
 
     return "hub_function", files
 
 
 # ─── main ─────────────────────────────────────────────────────────────────────
+
 
 def main():
     p = argparse.ArgumentParser(
         description=__doc__,
         formatter_class=argparse.RawDescriptionHelpFormatter,
     )
     p.add_argument(
-        "--topology", "-t",
+        "--topology",
+        "-t",
         choices=["chain", "hub", "fanout", "tree", "mixed", "multi-tu"],
         default="hub",
         help="Call graph shape (default: hub)",
     )
-    p.add_argument("--size", "-n", type=int, default=1000,
-                   help="Generic size parameter (chain length / tree nodes)")
-    p.add_argument("--callers", type=int, default=500,
-                   help="Number of callers  (hub / mixed / multi-tu)")
-    p.add_argument("--callees", type=int, default=500,
-                   help="Number of callees  (fanout / mixed)")
-    p.add_argument("--depth", "-d", type=int, default=10,
-                   help="Tree depth (tree topology)")
-    p.add_argument("--modules", "-m", type=int, default=10,
-                   help="Number of translation units (multi-tu topology)")
-    p.add_argument("--output", "-o", default="-",
-                   help="Output .cpp file path, or directory for multi-tu "
-                        "(default: stdout)")
+    p.add_argument(
+        "--size",
+        "-n",
+        type=int,
+        default=1000,
+        help="Generic size parameter (chain length / tree nodes)",
+    )
+    p.add_argument(
+        "--callers",
+        type=int,
+        default=500,
+        help="Number of callers  (hub / mixed / multi-tu)",
+    )
+    p.add_argument(
+        "--callees", type=int, default=500, help="Number of callees  (fanout / mixed)"
+    )
+    p.add_argument(
+        "--depth", "-d", type=int, default=10, help="Tree depth (tree topology)"
+    )
+    p.add_argument(
+        "--modules",
+        "-m",
+        type=int,
+        default=10,
+        help="Number of translation units (multi-tu topology)",
+    )
+    p.add_argument(
+        "--output",
+        "-o",
+        default="-",
+        help="Output .cpp file path, or directory for multi-tu " "(default: stdout)",
+    )
     args = p.parse_args()
 
     if args.topology == "multi-tu":
-        out_dir = Path(args.output) if args.output != "-" else Path("/tmp/bench_multi_tu")
+        out_dir = (
+            Path(args.output) if args.output != "-" else Path("/tmp/bench_multi_tu")
+        )
         target, files = gen_multi_tu(
             n_modules=args.modules,
             callers_per_module=args.callers,
             out_dir=out_dir,
         )
@@ -277,12 +303,14 @@
         print(f"  for f in {cpp_files}; do")
         print(f"      clangd-indexer $f -- -I{out_dir} >> {out_dir}/combined.dex")
         print(f"  done")
         print()
         print("Then benchmark:")
-        print(f"  CallHierarchyBenchmark {out_dir}/combined.dex {target} "
-              "--benchmark_min_time=0.1s")
+        print(
+            f"  CallHierarchyBenchmark {out_dir}/combined.dex {target} "
+            "--benchmark_min_time=0.1s"
+        )
         return
 
     # Single-file topologies
     if args.topology == "chain":
         target, lines = gen_chain(args.size)
@@ -306,11 +334,13 @@
         print(f"Written {len(lines)} lines to {args.output}")
         print(f"Target function : {target}")
         print()
         print("Next steps:")
         print(f"  clangd-indexer {args.output} -- > {args.output}.dex")
-        print(f"  CallHierarchyBenchmark {args.output}.dex {target} "
-              "--benchmark_min_time=0.1s")
+        print(
+            f"  CallHierarchyBenchmark {args.output}.dex {target} "
+            "--benchmark_min_time=0.1s"
+        )
 
 
 if __name__ == "__main__":
     main()

``````````

</details>


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


More information about the cfe-commits mailing list