Index: llvm/utils/lit/lit/llvm/subst.py =================================================================== --- llvm/utils/lit/lit/llvm/subst.py +++ llvm/utils/lit/lit/llvm/subst.py @@ -1,5 +1,6 @@ import os import re +import sys import lit.util @@ -118,8 +119,25 @@ command_str = str(self.command) if command_str: + args = [command_str] if self.extra_args: - command_str = ' '.join([command_str] + self.extra_args) + args = args + self.extra_args + + # This isn't intended to be perfect, as doing so is more trouble + # than it's worth. We just want to catch strings with unquoted + # spaces, since that is the use case that comes up the most + # frequently. However, as the user might explicitly quote them, + # we do try to avoid quoting already quoted strings. + def quote(x): + if ' ' not in x: + return x + quote_ch = '"' if sys.platform == 'win32' else "'" + if x[0] != quote_ch: + x = quote_ch + x + if x[-1] != quote_ch: + x = x + quote_ch + return x + command_str = ' '.join(quote(x) for x in args) else: if self.unresolved == 'warn': # Warn, but still provide a substitution.