Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lit] Don't expand escapes until all substitutions have been applied
Otherwise, if a Lit script contains escaped substitutions (like %%p in this test https://github.com/llvm/llvm-project/blob/master/compiler-rt/test/asan/TestCases/Darwin/asan-symbolize-partial-report-with-module-map.cpp#L10), they are unescaped during recursive application of substitutions, and the results are unexpected. We solve it using the fact that double percent signs are first replaced with #_MARKER_#, and only after all the other substitutions have been applied, #_MARKER_# is replaced with a single percent sign. The only change is that instead of replacing #_MARKER_# at each recursion step, we replace it once after the last recursion step. Differential Revision: https://reviews.llvm.org/D83894
- Loading branch information
1 parent
7c18266
commit 4dd5c2b
Showing
4 changed files
with
27 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
llvm/utils/lit/tests/Inputs/shtest-recursive-substitution/escaping/lit.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import lit.formats | ||
config.name = 'escaping' | ||
config.suffixes = ['.py'] | ||
config.test_format = lit.formats.ShTest() | ||
config.test_source_root = None | ||
config.test_exec_root = None | ||
|
||
config.substitutions = [("%rec1", "%%s"), ("%rec2", "%rec1")] | ||
|
||
config.recursiveExpansionLimit = 5 |
1 change: 1 addition & 0 deletions
1
llvm/utils/lit/tests/Inputs/shtest-recursive-substitution/escaping/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# RUN: echo %rec2 %%s %%%%s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters