summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolodymyr Sapsai <vsapsai@gmail.com>2016-09-18 21:08:27 -0700
committerVolodymyr Sapsai <vsapsai@gmail.com>2016-10-30 14:51:09 -0700
commit136736fca90ad10e20b2ef728f0d52286e93ca46 (patch)
tree8976f35dc9b862ee8d19e1f6c875c368051a4984
parentae763c4be4a0a9d6797e5d1993ab33a38f377f0e (diff)
On macOS search for libc++ headers in command-line tools and Xcode (fix issue #247).clang_3.9clang_3.9
PR https://github.com/include-what-you-use/include-what-you-use/pull/360
-rw-r--r--iwyu_driver.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/iwyu_driver.cc b/iwyu_driver.cc
index eb877ab..0d7bb65 100644
--- a/iwyu_driver.cc
+++ b/iwyu_driver.cc
@@ -21,6 +21,7 @@
#include "llvm/ADT/ArrayRef.h" // IWYU pragma: keep
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/FileSystem.h"
@@ -211,6 +212,20 @@ CompilerInstance* CreateCompilerInstance(int argc, const char **argv) {
args_start, args_end, diagnostics);
invocation->getFrontendOpts().DisableFree = false;
+ // Use libc++ headers bundled with Xcode.app on macOS.
+ llvm::Triple triple(invocation->getTargetOpts().Triple);
+ if (triple.isOSDarwin() && invocation->getHeaderSearchOpts().UseLibcxx) {
+ invocation->getHeaderSearchOpts().AddPath(
+ "/Library/Developer/CommandLineTools/usr/include/c++/v1/",
+ clang::frontend::CXXSystem,
+ /*IsFramework=*/false, /*IgnoreSysRoot=*/true);
+ invocation->getHeaderSearchOpts().AddPath(
+ "/Applications/Xcode.app/Contents/Developer/Toolchains/"
+ "XcodeDefault.xctoolchain/usr/include/c++/v1",
+ clang::frontend::CXXSystem,
+ /*IsFramework=*/false, /*IgnoreSysRoot=*/true);
+ }
+
// Show the invocation, with -v.
if (invocation->getHeaderSearchOpts().Verbose) {
errs() << "clang invocation:\n";