You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Substitutions can be added in a couple different ways; they can
be added via the calling python scripts by adding entries to the
config.substitutions dictionary, or via DEFINE lines in the
scripts themselves.
The substitution strings passed to Python's re classes are
interpreted so that backslashes expand to escape sequences, and
literal backslashes need to be escaped.
On Unix, the script defined substitutions don't (usually, so
far) contain backslashes - but on Windows, they often do, due to
paths containing backslashes. This lead to a Windows specific
escaping of backslashes before doing Python re substitutions -
since 7c9eab8. There's nothing
inherently Windows specific about this though - any intended
literal backslashes in the substitution strings need to be escaped;
this is how the Python re API works.
The DEFINE lines were added later, and in order to cope with
backslashes, escaping of backslashes was added in the
SubstDirective class in TestRunner, applying to DEFINE lines in
the tests only.
The fact that the escaping right before passing to the Python re
API was done conditionally on Windows led to two inconsistencies:
- DEFINE lines in the tests that contain backslashes got double
backslashes on Windows. (This was visible as a FIXME in
llvm/utils/lit/tests/Inputs/shtest-define/value-escaped.txt.)
- Script provided substitutions containing backslashes did not
work on Unix, but they did work on Windows.
By removing the escaping from SubstDirective and escaping it
unconditionally in the processLine function, before feeding the
substitutions to Python's re classes, we should have
consistent behaviour across platforms, and get rid of the FIXME
in the lit test.
This fixes issues with substitutions containing backslashes on
Unix platforms, as encountered in PR llvm#86649.
0 commit comments