diff --git a/lldb/lit/Expr/Inputs/basic.cpp b/lldb/lit/Expr/Inputs/basic.cpp new file mode 100644 index 000000000000..80a79379a2ec --- /dev/null +++ b/lldb/lit/Expr/Inputs/basic.cpp @@ -0,0 +1,12 @@ +class Patatino { +private: + long tinky; + +public: + Patatino(long tinky) { this->tinky = tinky; } +}; + +int main(void) { + Patatino *a = new Patatino(26); + return 0; +} diff --git a/lldb/lit/Expr/TestCallCppSym.test b/lldb/lit/Expr/TestCallCppSym.test new file mode 100644 index 000000000000..ac48c6f5160a --- /dev/null +++ b/lldb/lit/Expr/TestCallCppSym.test @@ -0,0 +1,6 @@ +# RUN: %cxx %p/Inputs/basic.cpp -g -o %t && %lldb -b -s %s -- %t 2>&1 | FileCheck %s + +breakpoint set --file basic.cpp --line 12 +run +call (int)_Znwm(23) +# CHECK: error: use of undeclared identifier '_Znwm' diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 07ff2e97aac7..093be6c898af 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -2072,6 +2072,15 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context, return; } } else if (symbol) { + // Don't insert a generic function decl for C++ symbol names. + // Creating a generic function decl is almost surely going to cause troubles + // as it breaks Clang/Sema invariants and causes crashes in clang while + // we're trying to evaluate the expression. + // This means users can't call C++ functions by mangled name when there + // are no debug info (as it happens for C symbol, e.g. printf()). + if (CPlusPlusLanguage::IsCPPMangledName( + symbol->GetMangled().GetMangledName().GetCString())) + return; fun_address = symbol->GetAddress(); function_decl = context.AddGenericFunDecl(); is_indirect_function = symbol->IsIndirect();