Skip to content

Commit bf9dfe2

Browse files
Merge pull request #8806 from adrian-prantl/healthy-clang
Log clang errors to swift-healthcheck
2 parents fda5ca9 + 9c35d1e commit bf9dfe2

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lldb/source/Plugins/TypeSystem/Swift/StoringDiagnosticConsumer.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define liblldb_StoringDiagnosticConsumer_h_
1515

1616
#include "Plugins/ExpressionParser/Swift/SwiftDiagnostic.h"
17-
17+
#include "Plugins/Language/Swift/LogChannelSwift.h"
1818
#include "lldb/Utility/LLDBLog.h"
1919
#include "lldb/Utility/StreamString.h"
2020

@@ -216,8 +216,15 @@ class StoringDiagnosticConsumer : public swift::DiagnosticConsumer {
216216
if (m_raw_clang_diagnostics.empty() ||
217217
m_raw_clang_diagnostics.back() != diagnostic) {
218218
m_raw_clang_diagnostics.push_back(std::move(diagnostic));
219-
if (info.Kind == swift::DiagnosticKind::Error)
219+
if (info.Kind == swift::DiagnosticKind::Error) {
220220
m_num_clang_errors++;
221+
// Any errors from clang could be related module import
222+
// issues which shoud be surfaced in the health log channel.
223+
LLDB_LOG(GetLog(LLDBLog::Types), "{0} Clang error: {1}",
224+
m_ast_context.GetDescription(), formatted_text);
225+
LLDB_LOG(lldb_private::GetSwiftHealthLog(), "{0} Clang error: {1}",
226+
m_ast_context.GetDescription(), formatted_text);
227+
}
221228
}
222229
} else {
223230
m_raw_swift_diagnostics.push_back(std::move(diagnostic));

lldb/test/API/lang/swift/clangimporter/clang_errorhandling/TestSwiftClangErrorHandling.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,10 @@ def test_extra_clang_flags(self):
2626
'"-DBREAK_STUFF"')
2727
lldbutil.run_to_source_breakpoint(self, "break here",
2828
lldb.SBFileSpec('main.swift'))
29+
log = self.getBuildArtifact("types.log")
30+
self.runCmd('log enable lldb types -f "%s"' % log)
31+
2932
self.expect("expr 0", error=True,
3033
substrs=['failed to import bridging header'])
34+
self.filecheck('platform shell cat "%s"' % log, __file__)
35+
# CHECK: Clang error: {{.*}}bridging-header.h

0 commit comments

Comments
 (0)