[PATCH] D122569: [lit] Support %if ... %else syntax for RUN lines

Andrew Savonichev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 10 14:49:10 PDT 2022


asavonic added inline comments.


================
Comment at: llvm/utils/lit/lit/TestRunner.py:1301
+        # RUN: foo %if feature {if_branch} %else {else_branch}
+        # Stack: [['foo', [token_if, 'feature', 'if_branch', 'else_branch']]]
+        #
----------------
MaskRay wrote:
> It's conventional to use tuples instead of lists to represent immutable objects (stack elements here).
Expression lists are mutable. When we pop the stack, all items are evaluated and the resulting value is appended to the last expression on the previous stack level. For example:

    foo-%if feature { bar }
                          ^~~ cursor
    stack: [ ['foo-', [token_if, 'feature']],
             [' bar '] ] 

When we reach the closing brace, 'bar' is poped out and appended to the 'if' expression:

    stack: [ ['foo-', [token_if, 'feature', ' bar ']] ] 



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122569/new/

https://reviews.llvm.org/D122569



More information about the llvm-commits mailing list