<commit_before>import os
import re

import lit.util

expr = re.compile(r"^(\\)?((\| )?)\W+b(\S+)\\b\W*$")
wordifier = re.compile(r"(\W*)(\b[^\b]+\b)")


class FindTool(object):
    def __init__(self, name):
        self.name = name

    def resolve(self, config, dirs):
        command = lit.util.which(self.name, dirs)
        if not command:
            return None

        if self.name == 'llc' and os.environ.get('LLVM_ENABLE_MACHINE_VERIFIER') == '1':
            command += ' -verify-machineinstrs'
        elif self.name == 'llvm-go':
            exe = getattr(config.config, 'go_executable', None)
            if exe:
                command += ' go=' + exe
        return command


class ToolSubst(object):
    """String-like class used to build regex substitution patterns for llvm
    tools.

    Handles things like adding word-boundary patterns, and filtering
    characters from the beginning an end of a tool name

    """

    def __init__(self, key, command=None, pre=r'.-^/\<', post='-.', verbatim=False,<commit_msg>lit: Bring back -Dtool=xxx feature lost in r313928<commit_after>import os
import re

import lit.util

expr = re.compile(r"^(\\)?((\| )?)\W+b(\S+)\\b\W*$")
wordifier = re.compile(r"(\W*)(\b[^\b]+\b)")


class FindTool(object):
    def __init__(self, name):
        self.name = name

    def resolve(self, config, dirs):
        # Check for a user explicitely overriding a tool.  This allows:
        #     llvm-lit -D llc="llc -enable-misched -verify-machineinstrs"
        command = config.lit_config.params.get(self.name)
        if command is None:
            # Then check out search paths.
            command = lit.util.which(self.name, dirs)
            if not command:
                return None

        if self.name == 'llc' and os.environ.get('LLVM_ENABLE_MACHINE_VERIFIER') == '1':
            command += ' -verify-machineinstrs'
        elif self.name == 'llvm-go':
            exe = getattr(config.config, 'go_executable', None)
            if exe:
                command += ' go=' + exe
        return command


class ToolSubst(object):
    """String-like class used to build regex substitution patterns for llvm
    tools.

    Handles things like adding word-boundary patterns, and filtering
    characters from the beginning an end of a tool name

    """

    def __init__(self, key, command=None, pre=r'.-^/\<', post='-.', verbatim=False,
{'fraction_non_alphanumeric': 0.14035087719298245, 'fraction_numerical': 0.003341687552213868, 'mean_word_length': 2.4214285714285713, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6584393', 'n_tokens_mistral': 778, 'n_tokens_neox': 748, 'n_words': 212}