[PATCH] D68851: [Utils] Allow update_test_checks to scrub attribute annotations

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 18:35:55 PDT 2019


jdoerfert created this revision.
jdoerfert added reviewers: lebedev.ri, greened, spatel, xbolva00, RKSimon, mehdi_amini.
Herald added a subscriber: bollu.
Herald added a project: LLVM.

Attribute annotations, e.g., #0, are not useful on their own. This
patch adds a flag to update_test_checks to scrub them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68851

Files:
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/update_test_checks.py


Index: llvm/utils/update_test_checks.py
===================================================================
--- llvm/utils/update_test_checks.py
+++ llvm/utils/update_test_checks.py
@@ -68,9 +68,15 @@
                       help='Do not scrub IR names')
   parser.add_argument('--function-signature', action='store_true',
                       help='Keep function signature information around for the check line')
+  parser.add_argument('--scrub-attributes', action='store_true',
+                      help='Remove attribute annotations (#0) from the end of check line')
   parser.add_argument('tests', nargs='+')
   args = parser.parse_args()
 
+  # If requested we scrub trailing attribute annotations, e.g., '#0', together with whitespaces
+  if args.scrub_attributes:
+    common.SCRUB_TRAILING_WHITESPACE_RE = common.SCRUB_TRAILING_WHITESPACE_AND_ATTRIBUTES_RE
+
   script_name = os.path.basename(__file__)
   autogenerated_note = (ADVERT + 'utils/' + script_name)
 
Index: llvm/utils/UpdateTestChecks/common.py
===================================================================
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -68,6 +68,7 @@
 SCRUB_LEADING_WHITESPACE_RE = re.compile(r'^(\s+)')
 SCRUB_WHITESPACE_RE = re.compile(r'(?!^(|  \w))[ \t]+', flags=re.M)
 SCRUB_TRAILING_WHITESPACE_RE = re.compile(r'[ \t]+$', flags=re.M)
+SCRUB_TRAILING_WHITESPACE_AND_ATTRIBUTES_RE = re.compile(r'([ \t]|(#[0-9]+))+$', flags=re.M)
 SCRUB_KILL_COMMENT_RE = re.compile(r'^ *#+ +kill:.*\n')
 SCRUB_LOOP_COMMENT_RE = re.compile(
     r'# =>This Inner Loop Header:.*|# in Loop:.*', flags=re.M)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68851.224523.patch
Type: text/x-patch
Size: 1630 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191011/e5ae1f52/attachment-0001.bin>


More information about the llvm-commits mailing list