llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: William Tran-Viet (smallp-o-p) <details> <summary>Changes</summary> Resolves #<!-- -->165790 - Don't add `-nobuiltininc` when `-ibuiltininc` is passed with `-nostdinc` - Add tests --- Full diff: https://github.com/llvm/llvm-project/pull/165814.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+3-1) - (added) clang/test/Driver/nostdinc-ibuiltininc.c (+10) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index e6e33e7a9a280..7e0e6ca5f564b 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -505,6 +505,7 @@ Bug Fixes to AST Handling Miscellaneous Bug Fixes ^^^^^^^^^^^^^^^^^^^^^^^ - Fixed missing diagnostics of ``diagnose_if`` on templates involved in initialization. (#GH160776) +- Fix `-ibuiltininc` compiler flag being ignored if `-nostdinc` is specified. (#GH165790) Miscellaneous Clang Crashes Fixed ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 79edc561c551f..f9a894205771a 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -6172,7 +6172,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // Pass options for controlling the default header search paths. if (Args.hasArg(options::OPT_nostdinc)) { CmdArgs.push_back("-nostdsysteminc"); - CmdArgs.push_back("-nobuiltininc"); + if (!Args.hasArg(options::OPT_ibuiltininc)) { + CmdArgs.push_back("-nobuiltininc"); + } } else { if (Args.hasArg(options::OPT_nostdlibinc)) CmdArgs.push_back("-nostdsysteminc"); diff --git a/clang/test/Driver/nostdinc-ibuiltininc.c b/clang/test/Driver/nostdinc-ibuiltininc.c new file mode 100644 index 0000000000000..d4bc885264c45 --- /dev/null +++ b/clang/test/Driver/nostdinc-ibuiltininc.c @@ -0,0 +1,10 @@ +// RUN: %clang -target x86_64-unknown-unknown -nostdinc -ibuiltininc -ffreestanding -fsyntax-only %s +// RUN: %clang -target x86_64-unknown-unknown -ibuiltininc -nostdinc -ffreestanding -fsyntax-only %s + +#if !__has_include("stddef.h") +#error "expected to be able to find compiler builtin headers!" +#endif + +#if __has_include("stdlib.h") +#error "expected to *not* be able to find standard C headers" +#endif \ No newline at end of file `````````` </details> https://github.com/llvm/llvm-project/pull/165814 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
