summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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";