Make DiagnosticsManager functions take StringRefs.
llvm-svn: 286730
diff --git a/lldb/source/Expression/DiagnosticManager.cpp b/lldb/source/Expression/DiagnosticManager.cpp
index 37a9df7..ad06600 100644
--- a/lldb/source/Expression/DiagnosticManager.cpp
+++ b/lldb/source/Expression/DiagnosticManager.cpp
@@ -67,15 +67,15 @@
size_t result = ss.PrintfVarArg(format, args);
va_end(args);
- AddDiagnostic(ss.GetData(), severity, eDiagnosticOriginLLDB);
+ AddDiagnostic(ss.GetString(), severity, eDiagnosticOriginLLDB);
return result;
}
-size_t DiagnosticManager::PutCString(DiagnosticSeverity severity,
- const char *cstr) {
- if (!cstr)
+size_t DiagnosticManager::PutString(DiagnosticSeverity severity,
+ llvm::StringRef str) {
+ if (str.empty())
return 0;
- AddDiagnostic(cstr, severity, eDiagnosticOriginLLDB);
- return strlen(cstr);
+ AddDiagnostic(str, severity, eDiagnosticOriginLLDB);
+ return str.size();
}
diff --git a/lldb/source/Expression/FunctionCaller.cpp b/lldb/source/Expression/FunctionCaller.cpp
index 805afda..f218ccb 100644
--- a/lldb/source/Expression/FunctionCaller.cpp
+++ b/lldb/source/Expression/FunctionCaller.cpp
@@ -1,5 +1,4 @@
-//===-- FunctionCaller.cpp ---------------------------------------*- C++
-//-*-===//
+//===-- FunctionCaller.cpp ---------------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -130,9 +129,9 @@
// All the information to reconstruct the struct is provided by the
// StructExtractor.
if (!m_struct_valid) {
- diagnostic_manager.PutCString(eDiagnosticSeverityError,
- "Argument information was not correctly "
- "parsed, so the function cannot be called.");
+ diagnostic_manager.PutString(eDiagnosticSeverityError,
+ "Argument information was not correctly "
+ "parsed, so the function cannot be called.");
return false;
}
@@ -243,7 +242,7 @@
// FIXME: Use the errors Stream for better error reporting.
Thread *thread = exe_ctx.GetThreadPtr();
if (thread == NULL) {
- diagnostic_manager.PutCString(
+ diagnostic_manager.PutString(
eDiagnosticSeverityError,
"Can't call a function without a valid thread.");
return NULL;
diff --git a/lldb/source/Expression/LLVMUserExpression.cpp b/lldb/source/Expression/LLVMUserExpression.cpp
index 78207df..379dd98 100644
--- a/lldb/source/Expression/LLVMUserExpression.cpp
+++ b/lldb/source/Expression/LLVMUserExpression.cpp
@@ -97,7 +97,7 @@
llvm::Function *function = m_execution_unit_sp->GetFunction();
if (!module || !function) {
- diagnostic_manager.PutCString(
+ diagnostic_manager.PutString(
eDiagnosticSeverityError,
"supposed to interpret, but nothing is there");
return lldb::eExpressionSetupError;
@@ -153,7 +153,7 @@
StreamString ss;
if (!call_plan_sp || !call_plan_sp->ValidatePlan(&ss)) {
- diagnostic_manager.PutCString(eDiagnosticSeverityError, ss.GetData());
+ diagnostic_manager.PutString(eDiagnosticSeverityError, ss.GetData());
return lldb::eExpressionSetupError;
}
@@ -198,8 +198,8 @@
"Execution was interrupted, reason: %s.",
error_desc);
else
- diagnostic_manager.PutCString(eDiagnosticSeverityError,
- "Execution was interrupted.");
+ diagnostic_manager.PutString(eDiagnosticSeverityError,
+ "Execution was interrupted.");
if ((execution_result == lldb::eExpressionInterrupted &&
options.DoesUnwindOnError()) ||
@@ -220,7 +220,7 @@
return execution_result;
} else if (execution_result == lldb::eExpressionStoppedForDebug) {
- diagnostic_manager.PutCString(
+ diagnostic_manager.PutString(
eDiagnosticSeverityRemark,
"Execution was halted at the first instruction of the expression "
"function because \"debug\" was requested.\n"
@@ -243,7 +243,7 @@
return lldb::eExpressionResultUnavailable;
}
} else {
- diagnostic_manager.PutCString(
+ diagnostic_manager.PutString(
eDiagnosticSeverityError,
"Expression can't be run, because there is no JIT compiled function");
return lldb::eExpressionSetupError;
@@ -298,7 +298,7 @@
lldb::StackFrameSP frame;
if (!LockAndCheckContext(exe_ctx, target, process, frame)) {
- diagnostic_manager.PutCString(
+ diagnostic_manager.PutString(
eDiagnosticSeverityError,
"The context has changed before we could JIT the expression!");
return false;