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

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

pre=JUNKCHARS for consistency?

llvm/utils/lit/lit/llvm/__init__.py
27

(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

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

44

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

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

This revision was automatically updated to reflect the committed changes.