This is an archive of the discontinued LLVM Phabricator instance.

[lit] Move some of LLD and Clang's configuration code into LLVM shared configuration
ClosedPublic

Authored by zturner on Sep 15 2017, 5:15 PM.

Details

Summary

The goal here is to allow re-use of this functionality from debuginfo-tests. It's going to need to do a lot of similar configuration for clang and lld and enable similar substitutions. Moving some of this common functionality into the lit.llvm module reduces the amount of boilerplate for setting this up in debug info tests (which will come in a later patch)

Diff Detail

Repository
rL LLVM

Event Timeline

zturner created this revision.Sep 15 2017, 5:15 PM
dlj added inline comments.Sep 18 2017, 10:20 PM
llvm/test/lit.cfg.py
153 ↗(On Diff #115523)

pre=JUNKCHARS for consistency?

llvm/utils/lit/lit/llvm/__init__.py
27 ↗(On Diff #115523)

(Minor nit) I really hate to bikeshed ... but I would expect this to do something like check for 'name' literally, without any regex matching. So I won't suggest changing the name to "is_regex" ;-) , but are there any other names that might make it more clear that the first argument will be interpreted as a well-formed regex?

30 ↗(On Diff #115523)

I think re.escape will do what you need:
https://docs.python.org/2/library/re.html#re.escape

44 ↗(On Diff #115523)

It might make more sense to factor out the regex construction, then you can assign self.regex all at once:

def not_in(patterns, where=''):
  if not patterns:
    return ''
  pattern_str = '|'.join(re.escape(x) for x in patterns)
  return r'(?{where}!({pattern_str}))'.format(
      where=where, pattern_str=pattern_str)

self.regex = not_in(pre, where='<') + '\b' + name + '\b' + not_in(post)

(Not sure if that's actually clearer, but there might be some useful tidbits...)

llvm/utils/lit/lit/llvm/config.py
174 ↗(On Diff #115523)

Nit: 'dir' is a Python builtin, this shadows it.

This revision was automatically updated to reflect the committed changes.