Skip to content

Commit 3692f75

Browse files
authored
Merge pull request #70549 from apple/diagnostic-walker-crash
Fix a crash in ClangImporter::Implementation::DiagnosticWalker::TraverseDecl
2 parents 234e61b + 14cfebc commit 3692f75

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,6 +2458,8 @@ ClangImporter::Implementation::DiagnosticWalker::DiagnosticWalker(
24582458

24592459
bool ClangImporter::Implementation::DiagnosticWalker::TraverseDecl(
24602460
clang::Decl *D) {
2461+
if (!D)
2462+
return true;
24612463
// In some cases, diagnostic notes about types (ex: built-in types) do not
24622464
// have an obvious source location at which to display diagnostics. We
24632465
// provide the location of the closest decl as a reasonable choice.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: rm -rf %t
2+
// RUN: split-file %s %t
3+
// RUN: %target-swiftxx-frontend -typecheck -I %t/Inputs %t/test.swift -verify
4+
5+
//--- Inputs/module.modulemap
6+
module FriendClass {
7+
header "test.h"
8+
requires cplusplus
9+
export *
10+
}
11+
12+
//--- Inputs/test.h
13+
14+
template <class T>
15+
class B {
16+
~B() = delete;
17+
};
18+
19+
class D : public B<D> { // expected-note {{record 'D' is not automatically available}}
20+
friend class B<D>;
21+
};
22+
23+
//--- test.swift
24+
25+
import FriendClass
26+
27+
func test() {
28+
var v: D // expected-error {{cannot find type 'D' in scope}}
29+
}

0 commit comments

Comments
 (0)