hanchenye-llvm-project/clang/test/Tooling
Ilya Biryukov 44a40046c8 Move detection of libc++ include dirs to Driver on MacOS
Summary:
The intention is to make the tools replaying compilations from 'compile_commands.json'
(clang-tidy, clangd, etc.) find the same standard library as the original compiler
specified in 'compile_commands.json'.

Previously, the library detection logic was in the frontend (InitHeaderSearch.cpp) and relied
on the value of resource dir as an approximation of the compiler install dir. The new logic
uses the actual compiler install dir and is performed in the driver. This is consistent with
the C++ standard library detection on other platforms and allows to override the resource dir
in the tools using the compile_commands.json without altering the
standard library detection mechanism. The tools have to override the resource dir to make sure
they use a consistent version of the builtin headers.

There is still logic in InitHeaderSearch that attemps to add the absolute includes for the
the C++ standard library, so we keep passing the -stdlib=libc++ from the driver to the frontend
via cc1 args to avoid breaking that. In the long run, we should move this logic to the driver too,
but it could potentially break the library detection on other systems, so we don't tackle it in this
patch to keep its scope manageable.

This is a second attempt to fix the issue, first one was commited in r346652 and reverted in r346675.
The original fix relied on an ad-hoc propagation (bypassing the cc1 flags) of the install dir from the
driver to the frontend's HeaderSearchOptions. Unsurpisingly, the propagation was incomplete, it broke
the libc++ detection in clang itself, which caused LLDB tests to break.

The LLDB tests pass with new fix.

Reviewers: JDevlieghere, arphaman, EricWF

Reviewed By: arphaman

Subscribers: mclow.lists, ldionne, dexonsmith, ioeric, christof, kadircet, cfe-commits

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

llvm-svn: 348365
2018-12-05 14:24:14 +00:00
..
Inputs Move detection of libc++ include dirs to Driver on MacOS 2018-12-05 14:24:14 +00:00
auto-detect-from-source-parent-of-cwd.cpp
auto-detect-from-source-parent.cpp
auto-detect-from-source.cpp [Tooling] JSONCompilationDatabasePlugin infers compile commands for missing files 2018-09-14 12:24:09 +00:00
clang-check-analyzer.cpp
clang-check-args.cpp
clang-check-ast-dump.cpp Compound literals, enums, et al require const expr 2018-11-09 00:41:36 +00:00
clang-check-autodetect-dir.cpp
clang-check-builtin-headers.cpp
clang-check-chdir.cpp
clang-check-extra-arg.cpp [clang] - Simplify tools::SplitDebugName. 2018-12-05 11:09:10 +00:00
clang-check-mac-libcxx-abspath.cpp Move detection of libc++ include dirs to Driver on MacOS 2018-12-05 14:24:14 +00:00
clang-check-mac-libcxx-relpath.cpp Move detection of libc++ include dirs to Driver on MacOS 2018-12-05 14:24:14 +00:00
clang-check-pwd.cpp
clang-check-rel-path.cpp
clang-check-strip-o.cpp
clang-check.cpp
clang-diff-args.test
clang-diff-ast.cpp
clang-diff-basic.cpp
clang-diff-bottomup.cpp
clang-diff-html.test
clang-diff-json.cpp
clang-diff-opt.cpp
clang-diff-topdown.cpp
fixed-database.cpp
lit.local.cfg
ms-asm-no-target.cpp
multi-jobs.cpp
pch.cpp