Skip to content

[clang][Driver] Don't warn when -nostdinc and -nostdinc++ are both specified #77130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

jonathonpenix
Copy link
Contributor

When -nostdinc and -nostdinc++ are both specified and the Baremetal toolchain is used, an unused command line argument warning for -nostdinc++ is produced. This doesn't seem particularly meaningful as -nostdinc++ would have been claimed/used had the check in AddClangCXXStdlibIncludeArgs not short-circuited. So, just claim all arguments in this check.

I believe this is consistent with what was done for the GNU toolchain (see 6fe7de9), so hopefully this is appropriate here as well.

…ecified

When -nostdinc and -nostdinc++ are both specified and the Baremetal toolchain is
used, an unused command line argument warning for -nostdinc++ is produced. This
doesn't seem particularly meaningful as -nostdinc++ would have been claimed/used
had the check in AddClangCXXStdlibIncludeArgs not short-circuited. So, just
claim all arguments in this check.

I belive this is consistent with what was done for the GNU toolchain
(see 6fe7de9), so hopefully this is appropriate
here as well.
@jonathonpenix jonathonpenix added the clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' label Jan 5, 2024
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jan 5, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 5, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Jonathon Penix (jonathonpenix)

Changes

When -nostdinc and -nostdinc++ are both specified and the Baremetal toolchain is used, an unused command line argument warning for -nostdinc++ is produced. This doesn't seem particularly meaningful as -nostdinc++ would have been claimed/used had the check in AddClangCXXStdlibIncludeArgs not short-circuited. So, just claim all arguments in this check.

I believe this is consistent with what was done for the GNU toolchain (see 6fe7de9), so hopefully this is appropriate here as well.


Full diff: https://github.com/llvm/llvm-project/pull/77130.diff

2 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/BareMetal.cpp (+2-3)
  • (modified) clang/test/Driver/nostdincxx.cpp (+1)
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 42c8336e626c7b..391c47f88bde2b 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -293,9 +293,8 @@ void BareMetal::addClangTargetOptions(const ArgList &DriverArgs,
 
 void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
                                              ArgStringList &CC1Args) const {
-  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
-      DriverArgs.hasArg(options::OPT_nostdlibinc) ||
-      DriverArgs.hasArg(options::OPT_nostdincxx))
+  if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc,
+                        options::OPT_nostdincxx))
     return;
 
   const Driver &D = getDriver();
diff --git a/clang/test/Driver/nostdincxx.cpp b/clang/test/Driver/nostdincxx.cpp
index ef5702a19c037f..94d74f230eb16c 100644
--- a/clang/test/Driver/nostdincxx.cpp
+++ b/clang/test/Driver/nostdincxx.cpp
@@ -2,6 +2,7 @@
 // RUN: not %clangxx -nostdinc++ %s 2>&1 | FileCheck %s
 // RUN: not %clangxx -nostdlibinc %s 2>&1 | FileCheck %s
 // RUN: not %clangxx --target=x86_64-unknown-unknown-gnu -fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck /dev/null --implicit-check-not=-Wunused-command-line-argument
+// RUN: not %clangxx --target=riscv64-unknown-elf -fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck /dev/null --implicit-check-not=-Wunused-command-line-argument
 // CHECK: 'vector' file not found
 #include <vector>
 

@jonathonpenix jonathonpenix merged commit f1d75d0 into llvm:main Jan 5, 2024
@jonathonpenix jonathonpenix deleted the baremetal_claim_nostdincxx branch January 5, 2024 21:56
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
…ecified (llvm#77130)

When -nostdinc and -nostdinc++ are both specified and the Baremetal
toolchain is used, an unused command line argument warning for
-nostdinc++ is produced. This doesn't seem particularly meaningful as
-nostdinc++ would have been claimed/used had the check in
AddClangCXXStdlibIncludeArgs not short-circuited. So, just claim all
arguments in this check.

I believe this is consistent with what was done for the GNU toolchain
(see 6fe7de9), so hopefully this is
appropriate here as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants