[llvm] [UTC] Support to test annotated IR (PR #165419)

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 28 10:09:00 PDT 2025


================
@@ -1904,8 +1907,13 @@ def escape_braces(match_obj):
                         line,
                     )
                     break
-            # Ignore any comments, since the check lines will too.
-            scrubbed_line = SCRUB_IR_COMMENT_RE.sub(r"", line)
+            scrubbed_line = (
+                # Ignore any comments, since the check lines will too.
+                SCRUB_IR_COMMENT_RE.sub(r"", line)
+                if ignore_all_comments
+                # Ignore comments of predecessors only.
+                else SCRUB_PRED_COMMENT_RE.sub(r"", line)
+            )
----------------
arichardson wrote:

```suggestion
            if ignore_all_comments:
                # Ignore any comments, since the check lines will too.
                scrubbed_line = SCRUB_IR_COMMENT_RE.sub(r"", line)
            else:     
                # Ignore comments of predecessors only.
                scrubbed_line = SCRUB_PRED_COMMENT_RE.sub(r"", line)
```
Same number of lines and IMO slightly easier to read than the ternary.

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


More information about the llvm-commits mailing list