[clang] [clang] Fix crash with -lstdc++ in -ccc-print-phases (#160046) (PR #160047)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 22 01:12:36 PDT 2025
https://github.com/pzzp created https://github.com/llvm/llvm-project/pull/160047
None
>From 42684cfbd295cefb5c4ace1584345028b65d5f5c Mon Sep 17 00:00:00 2001
From: zhoupeng12 <zhoupeng12 at baidu.com>
Date: Mon, 22 Sep 2025 15:55:57 +0800
Subject: [PATCH] [clang] fix crash of `clang -ccc-print-phases -lstdc++`
---
clang/lib/Driver/Driver.cpp | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f110dbab3e5a5..2c977131aeeec 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2668,7 +2668,15 @@ static unsigned PrintActions1(const Compilation &C, Action *A,
int SibKind = HeadSibAction;
os << Action::getClassName(A->getKind()) << ", ";
if (InputAction *IA = dyn_cast<InputAction>(A)) {
- os << "\"" << IA->getInputArg().getValue() << "\"";
+ llvm::StringRef InputValue{};
+ const auto &Opt = IA->getInputArg().getOption();
+ if (Opt.matches(options::OPT_Z_reserved_lib_stdcxx))
+ InputValue = "stdc++";
+ else if(Opt.matches(options::OPT_Z_reserved_lib_cckext))
+ InputValue = "cc_kext";
+ else
+ InputValue = IA->getInputArg().getValue();
+ os << "\"" << InputValue << "\"";
} else if (BindArchAction *BIA = dyn_cast<BindArchAction>(A)) {
os << '"' << BIA->getArchName() << '"' << ", {"
<< PrintActions1(C, *BIA->input_begin(), Ids, SibIndent, SibKind) << "}";
More information about the cfe-commits
mailing list