[PATCH] Driver tests: don't assume the clang binary is called 'clang'

Kenneth Camann kjcamann.lists at gmail.com
Mon Apr 20 16:45:31 PDT 2015


Hi mcrosier,

There are approximately 20 tests in tests/Driver that assume the clang binary is called "clang(.*)"; I would like to remove that assumption

Why is this a good idea?

Several modifications to clang require changing in-tree source files, for example, the clang internals manual has a section on how to add a new expressions and statements (http://clang.llvm.org/docs/InternalsManual.html#how-to-add-an-expression-or-statement).

Not everyone who wants to do this is making a change that can be contributed back upstream. I maintain a code generator which works by adding extensions to the language. This isn't the kind of thing either party would want in the official LLVM, so it is best implemented as a fork of clang (sadly it can't be a libtooling plugin, because in-tree files like StmtNodes.def need to be changed).

So that users can install such tools safely alongside clang, I think its a good idea to change the name of the executables and the intrinsics header directory. To avoid confusion, I think calling any such tool "clang" anywhere in the file name is a bad idea. I was pleasently surprised by how little of the build system I needed to change to get this to work. The system is pretty flexible, except for this part:

There are quite a few driver test files that assume a "%clang" driver invocation's -### printout expands into calls to "{{[^"]*}}clang{{[^"]*}}" "-cc1" or something similar. However, that's not the case in some other driver tests, where it just starts matching at "-cc1". For example, in test/Driver/freebsd.c:5 we just try to match "-cc1" <other stuff>, whereas in test/Driver/netbsd.c:102, we try to match a clang substring, then "-cc1", then <other stuff>. This patch would introduce a single way of doing it, one which is also friendlier to "renamed clang" tools. Changing these tests will ensure that this behavior doesn't get copy-and-pasted back, as people write new driver tests.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D9133

Files:
  test/Driver/android-standalone.cpp
  test/Driver/bitrig.c
  test/Driver/darwin-xarch.c
  test/Driver/dragonfly.c
  test/Driver/linux-header-search.cpp
  test/Driver/linux-ld.c
  test/Driver/mips-eleb.c
  test/Driver/nacl-direct.c
  test/Driver/netbsd.c
  test/Driver/netbsd.cpp
  test/Driver/no-canonical-prefixes.c
  test/Driver/openbsd.c
  test/Driver/pth.c
  test/Driver/rewrite-legacy-objc.m
  test/Driver/rewrite-objc.m

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9133.24076.patch
Type: text/x-patch
Size: 54588 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150420/66f9592c/attachment.bin>


More information about the cfe-commits mailing list