Skip to content

Commit 69f6f47

Browse files
committed
[DiagnosticVerifier] ensure expansion ancestors are populated
Simply GSI->ancestors is not enough if the ancestors list has not been populated yet. Ensure this is done by calling getAncestors.
1 parent 62ba94e commit 69f6f47

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

lib/Frontend/DiagnosticVerifier.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/Basic/ColorUtils.h"
2121
#include "swift/Basic/SourceManager.h"
2222
#include "swift/Parse/Lexer.h"
23+
#include "llvm/ADT/ArrayRef.h"
2324
#include "llvm/ADT/STLExtras.h"
2425
#include "llvm/Support/FileSystem.h"
2526
#include "llvm/Support/FormatVariadic.h"
@@ -1426,9 +1427,9 @@ DiagnosticVerifier::Result DiagnosticVerifier::verifyFile(unsigned BufferID) {
14261427

14271428
// Diagnostics attached to generated sources originating in this
14281429
// buffer also count as part of this buffer for this purpose.
1429-
const GeneratedSourceInfo *GSI =
1430-
SM.getGeneratedSourceInfo(CapturedDiagIter->SourceBufferID.value());
1431-
if (!GSI || llvm::find(GSI->ancestors, BufferID) == GSI->ancestors.end()) {
1430+
unsigned scratch;
1431+
llvm::ArrayRef<unsigned> ancestors = SM.getAncestors(CapturedDiagIter->SourceBufferID.value(), scratch);
1432+
if (llvm::find(ancestors, BufferID) == ancestors.end()) {
14321433
++CapturedDiagIter;
14331434
continue;
14341435
}

test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ MAIN_ACTOR MAIN_ACTOR __attribute__((__swift_attr__("@MainActor"))) @protocol Tr
233233

234234
SENDABLE @interface SendableClass : NSObject @end
235235

236+
// expected-expansion@+3:13{{
237+
// expected-note@1 5{{conformance of 'NonSendableClass' to 'Sendable' has been explicitly marked unavailable here}}
238+
// }}
236239
NONSENDABLE @interface NonSendableClass : NSObject @end // expected-note {{class 'NonSendableClass' does not conform to the 'Sendable' protocol}}
237240

238241
ASSUME_NONSENDABLE_BEGIN

test/Macros/accessor_macros.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ struct MyBrokenStruct {
102102
/*
103103
expected-expansion@-2:25{{
104104
expected-error@1:1{{variable already has a getter}}
105+
expected-error@5:1{{variable already has a setter}}
105106
}}
106107
*/
107108
// CHECK-DIAGS: variable already has a getter

test/Macros/expand_peers_hang.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ macro HangingMacro() = #externalMacro(module: "MacroDefinition", type: "HangingM
1111
class Foo {
1212
init() {}
1313

14+
// expected-expansion@+5:32{{
15+
// expected-error@1{{unexpected token '}' in expanded member list}}
16+
// expected-error@2{{expected declaration}}
17+
// }}
1418
// expected-note@+1 2{{in expansion of macro 'HangingMacro' on property 'result' here}}
1519
@HangingMacro var result: Int // This comment makes it hang.
1620
}

0 commit comments

Comments
 (0)