[update_cc_test_checks.py] Pass the builtin include dir to clang
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Thu, 31 Oct 2019 21:18:32 +0000 (21:18 +0000)
committerAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Thu, 31 Oct 2019 21:18:33 +0000 (21:18 +0000)
Summary:
This is required to update tests that make use of builtin headers. To fix
this use the same command expansion as lit does for %clang_cc1. I tested
this by updating clang/test/CodeGen/arm-mve-intrinsics/scalar-shifts.c.
%clang_cc1 will now expand to `clang -cc1 -internal-isystem
$LLVM_BUILD/lib/clang/$VERSION/include -nostdsysteminc`.

Reviewers: MaskRay

Reviewed By: MaskRay

Subscribers: kristof.beyls, dmgreen, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D69611

llvm/utils/update_cc_test_checks.py

index 14d5cc3..2e1a190 100755 (executable)
@@ -117,6 +117,18 @@ def config():
     print('Please specify --llvm-bin or --clang', file=sys.stderr)
     sys.exit(1)
 
+  # Determine the builtin includes directory so that we can update tests that
+  # depend on the builtin headers. See get_clang_builtin_include_dir() and
+  # use_clang() in llvm/utils/lit/lit/llvm/config.py.
+  try:
+    builtin_include_dir = subprocess.check_output(
+      [args.clang, '-print-file-name=include']).decode().strip()
+    SUBST['%clang_cc1'] = ['-cc1', '-internal-isystem', builtin_include_dir,
+                           '-nostdsysteminc']
+  except subprocess.CalledProcessError:
+    common.warn('Could not determine clang builtins directory, some tests '
+                'might not update correctly.')
+
   if args.opt is None:
     if args.llvm_bin is None:
       args.opt = 'opt'