[llvm] [lit][docs] Document %if conditional substitution in lit CommandGuide (PR #225683)

Ingo Müller via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 03:57:44 PDT 2026


https://github.com/ingomueller-net created https://github.com/llvm/llvm-project/pull/225683

`%if ... %else` conditional substitutions (implemented in `TestRunner.py` and mentioned in `TestingGuide.md`) were missing from the `SUBSTITUTIONS` table and `available_features` description in `llvm/docs/CommandGuide/lit.md`. Add `%if` to the base substitutions table and note that `available_features` can be used in `%if` conditions.

>From 5d709c953222e2170d2256442b9c7790f7b34bf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ingo=20M=C3=BCller?= <ingomueller at google.com>
Date: Wed, 23 Sep 2026 12:55:05 +0200
Subject: [PATCH] [lit][docs] Document %if conditional substitution in lit
 CommandGuide
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

`%if ... %else` conditional substitutions (implemented in `TestRunner.py`
and mentioned in `TestingGuide.md`) were missing from the `SUBSTITUTIONS`
table and `available_features` description in `llvm/docs/CommandGuide/lit.md`.
Add `%if` to the base substitutions table and note that `available_features`
can be used in `%if` conditions.

Signed-off-by: Ingo Müller <ingomueller at google.com>
---
 llvm/docs/CommandGuide/lit.rst | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/llvm/docs/CommandGuide/lit.rst b/llvm/docs/CommandGuide/lit.rst
index b52a09eb088a1d..a041d4d95faad5 100644
--- a/llvm/docs/CommandGuide/lit.rst
+++ b/llvm/docs/CommandGuide/lit.rst
@@ -619,7 +619,7 @@ executed, two important global variables are predefined:
  makes the test fail only if the last command in the pipe fails.
 
  **available_features** A set of features that can be used in `XFAIL`,
- `REQUIRES`, and `UNSUPPORTED` directives.
+ `REQUIRES`, and `UNSUPPORTED` directives and `%if` substitions.
 
 TEST DISCOVERY
 ~~~~~~~~~~~~~~
@@ -700,6 +700,9 @@ TestRunner.py:
  %:t                     On Windows, %/t but a ``:`` is removed if its the second character.
                          Otherwise, %t but with a single leading ``/`` removed.
  %{readfile:<filename>}  Reads the file specified.
+ %if \<cond> %{...%}     Conditional substitution
+                         (`%if <cond> %{<if-branch>%} [%else %{<else-branch>%}]`);
+                         `<cond>` uses `available_features`.
  ======================= ==============
 
 Other substitutions are provided that are variations on this base set and



More information about the llvm-commits mailing list