[clang] 53c98d8 - [Driver] Suppress libstdc++/libc++ path with -nostdinc
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 28 11:30:31 PDT 2021
Author: Fangrui Song
Date: 2021-03-28T11:30:27-07:00
New Revision: 53c98d85a8a609552448043d5512e70313b1eb1b
URL: https://github.com/llvm/llvm-project/commit/53c98d85a8a609552448043d5512e70313b1eb1b
DIFF: https://github.com/llvm/llvm-project/commit/53c98d85a8a609552448043d5512e70313b1eb1b.diff
LOG: [Driver] Suppress libstdc++/libc++ path with -nostdinc
This follows GCC. Having libstdc++/libc++ include paths is not useful
anyway because libstdc++/libc++ header files cannot find features.h.
While here, suppress -stdlib++-isystem with -nostdlibinc.
Added:
Modified:
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/nostdincxx.cpp
clang/test/Driver/stdlibxx-isystem.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 217ba56c3351..6b747f06439f 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -916,7 +916,8 @@ void ToolChain::AddClangCXXStdlibIsystemArgs(
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {
DriverArgs.ClaimAllArgs(options::OPT_stdlibxx_isystem);
- if (!DriverArgs.hasArg(options::OPT_nostdincxx))
+ if (!DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdincxx,
+ options::OPT_nostdlibinc))
for (const auto &P :
DriverArgs.getAllArgValues(options::OPT_stdlibxx_isystem))
addSystemInclude(DriverArgs, CC1Args, P);
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 7136df94c528..0fe3916b008e 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2876,8 +2876,9 @@ void Generic_GCC::AddMultilibIncludeArgs(const ArgList &DriverArgs,
void Generic_GCC::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
- if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
- DriverArgs.hasArg(options::OPT_nostdincxx))
+ if (DriverArgs.hasArg(options::OPT_nostdinc) ||
+ DriverArgs.hasArg(options::OPT_nostdincxx) ||
+ DriverArgs.hasArg(options::OPT_nostdlibinc))
return;
switch (GetCXXStdlibType(DriverArgs)) {
diff --git a/clang/test/Driver/nostdincxx.cpp b/clang/test/Driver/nostdincxx.cpp
index dc87336ece54..3fc7a5e76842 100644
--- a/clang/test/Driver/nostdincxx.cpp
+++ b/clang/test/Driver/nostdincxx.cpp
@@ -1,4 +1,6 @@
+// RUN: not %clangxx -nostdinc %s 2>&1 | FileCheck %s
// RUN: not %clangxx -nostdinc++ %s 2>&1 | FileCheck %s
+// RUN: not %clangxx -nostdlibinc %s 2>&1 | FileCheck %s
// CHECK: file not found
#include <vector>
diff --git a/clang/test/Driver/stdlibxx-isystem.cpp b/clang/test/Driver/stdlibxx-isystem.cpp
index 827cdf9a7c71..cadfa25c0db9 100644
--- a/clang/test/Driver/stdlibxx-isystem.cpp
+++ b/clang/test/Driver/stdlibxx-isystem.cpp
@@ -43,11 +43,19 @@
// RUN: FileCheck -check-prefix=NOCC1 %s
// NOCC1-NOT: "-stdlib++-isystem" "/tmp"
-// It should respect -nostdinc++.
+// It should respect -nostdinc++
// RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %t/bin \
// RUN: -stdlib++-isystem /tmp/foo -stdlib++-isystem /tmp/bar -nostdinc++ \
// RUN: -fsyntax-only %s -### 2>&1 | FileCheck -check-prefix=NOSTDINCXX %s
// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %t/bin \
// RUN: -stdlib++-isystem /tmp/foo -stdlib++-isystem /tmp/bar -nostdinc++ \
// RUN: -fsyntax-only %s -### 2>&1 | FileCheck -check-prefix=NOSTDINCXX %s
+
+// ... and -nostdinc and -nostdlibinc.
+// RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %t/bin \
+// RUN: -stdlib++-isystem /tmp/foo -stdlib++-isystem /tmp/bar -nostdinc \
+// RUN: -fsyntax-only %s -### 2>&1 | FileCheck --check-prefix=NOSTDINCXX %s
+// RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %t/bin \
+// RUN: -stdlib++-isystem /tmp/foo -stdlib++-isystem /tmp/bar -nostdlibinc \
+// RUN: -fsyntax-only %s -### 2>&1 | FileCheck --check-prefix=NOSTDINCXX %s
// NOSTDINCXX-NOT: "-internal-isystem" "/tmp/foo" "-internal-isystem" "/tmp/bar"
More information about the cfe-commits
mailing list