[PATCH] [LNT] Be less strict about argument ordering in FakeCompiler

Charlie Turner charlie.turner at arm.com
Wed Jun 10 10:05:47 PDT 2015


Hi jmolloy, cmatthews, kristof.beyls,

Modify the `FakeCompiler` driver to be less strict about argument order.

The existing checks in the driver would fail when called from `compilers.py` if any extra cflags had been given on the lnt command line.

Instead, settle for looser definitions of what constitutes the trigger conditions for printing out version info:

  * I moved `dumpmachine` to the first checked option, because in the official driver, this option overrules all others if given anywhere on the command-line.
  * If both `-v` and `-###` occur in any order in the command line, dump the verbose information.
  * If `-Wa,-v` occurs anywhere, dump the assembler version.
  * If `-Wl,-v` occurs anywhere, dump the linker version.
  * If all of `-S`, `-flto`, `-o`, `-`, `/dev/null` are in the command-line, in any order, then dump the target information.

http://reviews.llvm.org/D10363

Files:
  tests/SharedInputs/FakeCompilers/fakecompiler.py

Index: tests/SharedInputs/FakeCompilers/fakecompiler.py
===================================================================
--- tests/SharedInputs/FakeCompilers/fakecompiler.py
+++ tests/SharedInputs/FakeCompilers/fakecompiler.py
@@ -166,22 +166,23 @@
     # Instantiate the compiler class.
     compiler_instance = compiler_class()
 
-    # Pattern match on the arguments to determine what kind of response to fake.
+    def args_contained_in(a, b):
+        """Return true if every element of tuple b is contained in
+        tuple a"""
+        return all([bi in a for bi in b])
+    
+    # Search in the arguments to determine what kind of response to fake.
     args = tuple(sys.argv[1:])
-    if args == ('-v', '-E', '-x', 'c', '/dev/null', '-###'):
+    if '-dumpmachine' in args:
+        compiler_instance.print_dumpmachine()
+    elif args_contained_in(args, ('-v', '-###')):
         compiler_instance.print_verbose_info()
-    elif args == ('-dumpmachine',):
-        compiler_instance.print_dumpmachine()
-    elif args == ('-c', '-Wa,-v', '-o', '/dev/null', '-x', 'assembler',
-                  '/dev/null'):
+    elif 'Wa,-v' in args:
         compiler_instance.print_as_version()
-    elif args == ('-S', '-flto', '-o', '-', '-x', 'c', '/dev/null'):
+    elif 'Wl,-v' in args:
+        compiler_instance.print_ld_version()
+    elif args_contained_in(args, ('-S', '-flto', '-o', '-', '/dev/null')):
         compiler_instance.print_llvm_target()
-    elif len(args) == 4 and \
-            args[0] == '-Wl,-v' and \
-            args[1] == '-o' and \
-            args[2] == '/dev/null':
-        compiler_instance.print_ld_version()
     else:
         raise SystemExit("unrecognized argument vector: %r" % (
                 args,))

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10363.27450.patch
Type: text/x-patch
Size: 1753 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150610/2ea13177/attachment.bin>


More information about the llvm-commits mailing list