[Lldb-commits] [clang] [lldb] [Clang][LLDB] Refactor trap reason demangling out of LLDB and into Clang (PR #165996)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Mon Nov 3 00:40:15 PST 2025
================
@@ -378,3 +379,31 @@ clang::CreateLLVMCodeGen(DiagnosticsEngine &Diags, llvm::StringRef ModuleName,
HeaderSearchOpts, PreprocessorOpts, CGO, C,
CoverageInfo);
}
+
+namespace clang {
+namespace CodeGen {
+std::optional<std::pair<StringRef, StringRef>>
+DemangleTrapReasonInDebugInfo(StringRef FuncName) {
+ static auto TrapRegex =
+ llvm::Regex(llvm::formatv("^{0}\\$(.*)\\$(.*)$", ClangTrapPrefix).str());
+ llvm::SmallVector<llvm::StringRef, 3> Matches;
+ std::string *ErrorPtr = nullptr;
+#ifndef NDEBUG
+ std::string Error;
+ ErrorPtr = &Error;
+#endif
+ if (!TrapRegex.match(FuncName, &Matches, ErrorPtr)) {
+ assert(ErrorPtr && ErrorPtr->empty() && "Invalid regex pattern");
+ return {};
+ }
+
+ if (Matches.size() != 3) {
+ assert(0 && "Expected 3 matches from Regex::match");
----------------
Michael137 wrote:
Ah yes, missed the fact that we're asserting on consistency of the regex itself, not the input. So yea, seems fine!
https://github.com/llvm/llvm-project/pull/165996
More information about the lldb-commits
mailing list