================
@@ -946,6 +948,44 @@ lldb::ExpressionVariableSP
ClangUserExpression::GetResultAfterDematerialization(
return m_result_delegate.GetVariable();
}
+void ClangUserExpression::FixupParseErrorDiagnostics(
+ DiagnosticManager &diagnostic_manager) const {
+ const bool is_fixable_cvr_error = llvm::any_of(
+ diagnostic_manager.Diagnostics(),
+ [](std::unique_ptr<Diagnostic> const &diag) {
+ switch (diag->GetCompilerID()) {
+ case clang::diag::err_member_function_call_bad_cvr:
+ return true;
+ case clang::diag::err_typecheck_assign_const:
+ // FIXME: can we split this particular error into a separate
+ // diagnostic ID so we don't need to scan the error message?
+ return diag->GetDetail().message.find(
+ "within const member function") != std::string::npos;
+ default:
+ return false;
+ }
+ });
+
+ // Nothing to report.
+ if (!is_fixable_cvr_error)
+ return;
+
+ // If the user already tried ignoring function qualifiers but
+ // the expression still failed, we don't want to suggest the hint again.
+ if (m_options.GetIgnoreConstContext()) {
+ // Hard to prove that we don't get here so don't emit a diagnostic n
+ // non-asserts builds. But we do want a signal in asserts builds.
+ assert(false && "IgnoreConstContexts didn't resolve compiler diagnostic.");
+ return;
+ }
+
+ diagnostic_manager.AddDiagnostic(
+ "Possibly trying to mutate object in a const context. Try "
----------------
adrian-prantl wrote:
I was thinking about something even more direct, such as "trying to mutate
object, but `this` is marked `const`" maybe?
https://github.com/llvm/llvm-project/pull/177927
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits