@@ -2465,24 +2465,34 @@ void DarwinClang::AddClangCXXStdlibIncludeArgs(
2465
2465
// Also check whether this is used for setting library search paths.
2466
2466
ToolChain::AddClangCXXStdlibIncludeArgs (DriverArgs, CC1Args);
2467
2467
2468
- if (DriverArgs.hasArg (options::OPT_nostdinc, options::OPT_nostdlibinc,
2469
- options::OPT_nostdincxx))
2468
+ if (DriverArgs.hasArg (options::OPT_nostdlibinc, options::OPT_nostdincxx))
2470
2469
return ;
2471
2470
2472
2471
llvm::SmallString<128 > Sysroot = GetEffectiveSysroot (DriverArgs);
2473
2472
2474
2473
switch (GetCXXStdlibType (DriverArgs)) {
2475
2474
case ToolChain::CST_Libcxx: {
2476
2475
// On Darwin, libc++ can be installed in one of the following two places:
2477
- // 1. Alongside the compiler in <install> /include/c++/v1
2478
- // 2. In a SDK (or a custom sysroot) in <sysroot>/usr /include/c++/v1
2476
+ // 1. In a SDK (or a custom sysroot) in <sysroot>/usr /include/c++/v1
2477
+ // 2. Alongside the compiler in <install> /include/c++/v1
2479
2478
//
2480
2479
// The precendence of paths is as listed above, i.e. we take the first path
2481
2480
// that exists. Also note that we never include libc++ twice -- we take the
2482
2481
// first path that exists and don't send the other paths to CC1 (otherwise
2483
2482
// include_next could break).
2484
2483
2485
2484
// Check for (1)
2485
+ llvm::SmallString<128 > SysrootUsr = Sysroot;
2486
+ llvm::sys::path::append (SysrootUsr, " usr" , " include" , " c++" , " v1" );
2487
+ if (getVFS ().exists (SysrootUsr)) {
2488
+ addSystemInclude (DriverArgs, CC1Args, SysrootUsr);
2489
+ return ;
2490
+ } else if (DriverArgs.hasArg (options::OPT_v)) {
2491
+ llvm::errs () << " ignoring nonexistent directory \" " << SysrootUsr
2492
+ << " \"\n " ;
2493
+ }
2494
+
2495
+ // Otherwise, check for (2)
2486
2496
// Get from '<install>/bin' to '<install>/include/c++/v1'.
2487
2497
// Note that InstallBin can be relative, so we use '..' instead of
2488
2498
// parent_path.
@@ -2497,17 +2507,6 @@ void DarwinClang::AddClangCXXStdlibIncludeArgs(
2497
2507
<< " \"\n " ;
2498
2508
}
2499
2509
2500
- // Otherwise, check for (2)
2501
- llvm::SmallString<128 > SysrootUsr = Sysroot;
2502
- llvm::sys::path::append (SysrootUsr, " usr" , " include" , " c++" , " v1" );
2503
- if (getVFS ().exists (SysrootUsr)) {
2504
- addSystemInclude (DriverArgs, CC1Args, SysrootUsr);
2505
- return ;
2506
- } else if (DriverArgs.hasArg (options::OPT_v)) {
2507
- llvm::errs () << " ignoring nonexistent directory \" " << SysrootUsr
2508
- << " \"\n " ;
2509
- }
2510
-
2511
2510
// Otherwise, don't add any path.
2512
2511
break ;
2513
2512
}
0 commit comments