@@ -1093,8 +1093,8 @@ void Module::ReportWarningOptimization(
10931093 ss << file_name
10941094 << " was compiled with optimization - stepping may behave "
10951095 " oddly; variables may not be available." ;
1096- Debugger::ReportWarning ( std::string ( ss.GetString ()), debugger_id,
1097- &m_optimization_warning );
1096+ llvm::StringRef msg = ss.GetString ();
1097+ Debugger::ReportWarning (msg. str (), debugger_id, GetDiagnosticOnceFlag (msg) );
10981098}
10991099
11001100void Module::ReportWarningUnsupportedLanguage (
@@ -1104,8 +1104,8 @@ void Module::ReportWarningUnsupportedLanguage(
11041104 << Language::GetNameForLanguageType (language)
11051105 << " \" . "
11061106 " Inspection of frame variables will be limited." ;
1107- Debugger::ReportWarning ( std::string ( ss.GetString ()), debugger_id,
1108- &m_language_warning );
1107+ llvm::StringRef msg = ss.GetString ();
1108+ Debugger::ReportWarning (msg. str (), debugger_id, GetDiagnosticOnceFlag (msg) );
11091109}
11101110
11111111void Module::ReportErrorIfModifyDetected (
@@ -1125,20 +1125,29 @@ void Module::ReportErrorIfModifyDetected(
11251125 }
11261126}
11271127
1128+ std::once_flag *Module::GetDiagnosticOnceFlag (llvm::StringRef msg) {
1129+ std::lock_guard<std::recursive_mutex> guard (m_diagnostic_mutex);
1130+ auto &once_ptr = m_shown_diagnostics[llvm::stable_hash_name (msg)];
1131+ if (!once_ptr)
1132+ once_ptr = std::make_unique<std::once_flag>();
1133+ return once_ptr.get ();
1134+ }
1135+
11281136void Module::ReportError (const llvm::formatv_object_base &payload) {
11291137 StreamString strm;
11301138 GetDescription (strm.AsRawOstream (), lldb::eDescriptionLevelBrief);
1131- strm. PutChar ( ' ' );
1132- strm. PutCString (payload. str ()) ;
1133- Debugger::ReportError (strm.GetString ().str ());
1139+ std::string msg = payload. str ( );
1140+ strm << ' ' << msg ;
1141+ Debugger::ReportError (strm.GetString ().str (), {}, GetDiagnosticOnceFlag (msg) );
11341142}
11351143
11361144void Module::ReportWarning (const llvm::formatv_object_base &payload) {
11371145 StreamString strm;
11381146 GetDescription (strm.AsRawOstream (), lldb::eDescriptionLevelFull);
1139- strm.PutChar (' ' );
1140- strm.PutCString (payload.str ());
1141- Debugger::ReportWarning (std::string (strm.GetString ()));
1147+ std::string msg = payload.str ();
1148+ strm << ' ' << msg;
1149+ Debugger::ReportWarning (strm.GetString ().str (), {},
1150+ GetDiagnosticOnceFlag (msg));
11421151}
11431152
11441153void Module::LogMessage (Log *log, const llvm::formatv_object_base &payload) {
0 commit comments