[clang] [Driver] Print C++ standard library info (PR #207798)
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 15 15:48:51 PDT 2026
================
@@ -136,6 +136,40 @@ template <typename F> static bool usesInput(const ArgList &Args, F &&Fn) {
});
}
+static StringRef getCXXStdlibName(const ToolChain &TC, const ArgList &Args) {
+ if (TC.getTriple().isWindowsMSVCEnvironment() &&
+ !Args.hasArg(options::OPT_stdlib_EQ))
+ return "msvcstl";
+
+ switch (TC.GetCXXStdlibType(Args)) {
+ case ToolChain::CST_Libcxx:
+ return "libc++";
+ case ToolChain::CST_Libstdcxx:
+ return "libstdc++";
+ }
+ llvm_unreachable("unknown C++ standard library type");
+}
+
+static bool isIncludeDirArg(StringRef Arg) {
+ return Arg == "-internal-isystem" || Arg == "-internal-externc-isystem" ||
+ Arg == "-isystem" || Arg == "-cxx-isystem" || Arg == "-idirafter";
+}
+
+static void printCXXStdlibIncludeDirs(const ToolChain &TC,
+ const ArgList &Args) {
+ ArgStringList CC1Args;
+ if (Args.hasArg(options::OPT_stdlibxx_isystem))
+ TC.AddClangCXXStdlibIsystemArgs(Args, CC1Args);
+ else
+ TC.AddClangCXXStdlibIncludeArgs(Args, CC1Args);
----------------
Artem-B wrote:
This also seems to assume that this is the only way standard library includes are specified.
What exactly is `--print-cxx-stdlib-include-dirs` supposed to print? The include paths that the driver would inject based on "standard" options like `-stdlib=...` ? Or does it need to somehow work if the user relies on out-of-tree standard library and specifies the include paths manually.
I guess the former is the best we can do, as it's hard to tell which user-supplied include paths belong to the standard library, and which ones are for something else.
But that brings the question -- what would the standard library paths be used/useful for? In my experience, they proably will not be particularly useful for the end user, as standard library include order is extremely fragile and hard to arrange outside of the driver (generally it requires arranging _all_ include paths.
Perhaps what we really want to print is the standard library location and let the user derive whatever else they want from that path.
https://github.com/llvm/llvm-project/pull/207798
More information about the cfe-commits
mailing list