File tree Expand file tree Collapse file tree 8 files changed +49
-5
lines changed Expand file tree Collapse file tree 8 files changed +49
-5
lines changed Original file line number Diff line number Diff line change @@ -391,9 +391,7 @@ void ClangImporter::Implementation::addBridgeHeaderTopLevelDecls(
391
391
BridgeHeaderTopLevelDecls.push_back (D);
392
392
}
393
393
394
- bool ClangImporter::Implementation::shouldIgnoreBridgeHeaderTopLevelDecl (
395
- clang::Decl *D) {
396
- // Ignore forward references;
394
+ bool importer::isForwardDeclOfType (const clang::Decl *D) {
397
395
if (auto *ID = dyn_cast<clang::ObjCInterfaceDecl>(D)) {
398
396
if (!ID->isThisDeclarationADefinition ())
399
397
return true ;
@@ -407,6 +405,11 @@ bool ClangImporter::Implementation::shouldIgnoreBridgeHeaderTopLevelDecl(
407
405
return false ;
408
406
}
409
407
408
+ bool ClangImporter::Implementation::shouldIgnoreBridgeHeaderTopLevelDecl (
409
+ clang::Decl *D) {
410
+ return importer::isForwardDeclOfType (D);
411
+ }
412
+
410
413
ClangImporter::ClangImporter (ASTContext &ctx,
411
414
DependencyTracker *tracker,
412
415
DWARFImporterDelegate *dwarfImporterDelegate)
Original file line number Diff line number Diff line change @@ -1462,6 +1462,10 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
1462
1462
1463
1463
namespace importer {
1464
1464
1465
+ // / Whether this is a forward declaration of a type. We ignore forward
1466
+ // / declarations in certain cases, and instead process the real declarations.
1467
+ bool isForwardDeclOfType (const clang::Decl *decl);
1468
+
1465
1469
// / Whether we should suppress the import of the given Clang declaration.
1466
1470
bool shouldSuppressDeclImport (const clang::Decl *decl);
1467
1471
Original file line number Diff line number Diff line change @@ -2039,7 +2039,12 @@ void importer::finalizeLookupTable(
2039
2039
auto decl = entry.get <clang::NamedDecl *>();
2040
2040
auto swiftName = decl->getAttr <clang::SwiftNameAttr>();
2041
2041
2042
- if (swiftName) {
2042
+ if (swiftName
2043
+ // Clang didn't previously attach SwiftNameAttrs to forward
2044
+ // declarations, but this changed and we started diagnosing spurious
2045
+ // warnings on @class declarations. Suppress them.
2046
+ // FIXME: Can we avoid processing these decls in the first place?
2047
+ && !importer::isForwardDeclOfType (decl)) {
2043
2048
clang::SourceLocation diagLoc = swiftName->getLocation ();
2044
2049
if (!diagLoc.isValid ())
2045
2050
diagLoc = decl->getLocation ();
Original file line number Diff line number Diff line change 1
1
Name: ImportAsMember
2
+ Classes:
3
+ - Name: IAMPrivateChild
4
+ SwiftName: IAMPrivateParent.Child
2
5
Globals:
3
6
- Name: IAMStruct1APINoteVar
4
7
SwiftName: Struct1.newApiNoteVar
Original file line number Diff line number Diff line change @@ -76,4 +76,9 @@ typedef int IAMBadInnerIntAPINotes;
76
76
// CHECK: ImportAsMember.h:[[@LINE-1]]:{{[0-9]+}}: warning: imported declaration 'IAMBadInnerIntAPINotes' could not be mapped to 'IAMNonexistent.Inner2'
77
77
// CHECK: ImportAsMember.h:[[@LINE-2]]:{{[0-9]+}}: note: please report this issue to the owners of 'ImportAsMember'
78
78
79
+ @interface IAMPrivateParent @end
80
+ @interface IAMPrivateChild
81
+ - (instancetype )init ;
82
+ @end
83
+
79
84
#endif // IMPORT_AS_MEMBER_H
Original file line number Diff line number Diff line change
1
+ #ifndef IMPORT_AS_MEMBER_PRIVATE_H
2
+ #define IMPORT_AS_MEMBER_PRIVATE_H
3
+
4
+ #include < ImportAsMember.h>
5
+
6
+ @class IAMPrivateChild;
7
+ // CHECK-NOT: ImportAsMember_Private.h:[[@LINE-1]]:{{[0-9]+}}: warning: imported declaration 'IAMPrivateChild' could not be mapped to 'IAMPrivateParent.Child'
8
+
9
+ #endif // IMPORT_AS_MEMBER_PRIVATE_H
Original file line number Diff line number Diff line change @@ -113,6 +113,16 @@ module ImportAsMember {
113
113
}
114
114
}
115
115
116
+ // FIXME: This probably ought to be in a module_private.map, but that causes
117
+ // hundreds of clang warnings.
118
+ module ImportAsMember_Private {
119
+ export *
120
+
121
+ module A {
122
+ header "ImportAsMember_Private.h"
123
+ }
124
+ }
125
+
116
126
module ObjCIRExtras {
117
127
header "ObjCIRExtras.h"
118
128
export *
Original file line number Diff line number Diff line change 1
1
// RUN: %empty-directory(%t.mcp)
2
- // RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -typecheck -F %S/Inputs/frameworks -I %S/Inputs/custom-modules -module-cache-path %t.mcp %s 2>&1 | %FileCheck %S/Inputs/custom-modules/ImportAsMember.h
2
+
3
+ // RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -typecheck -F %S/Inputs/frameworks -I %S/Inputs/custom-modules -module-cache-path %t.mcp %s >%t.txt 2>&1
4
+ // RUN: %FileCheck %S/Inputs/custom-modules/ImportAsMember.h <%t.txt
5
+ // RUN: %FileCheck %S/Inputs/custom-modules/ImportAsMember_Private.h <%t.txt
6
+
3
7
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -typecheck -F %S/Inputs/frameworks -I %S/Inputs/custom-modules -module-cache-path %t.mcp %s -verify
4
8
5
9
import ImportAsMember
10
+ import ImportAsMember_Private
6
11
import ImportAsMemberSubmodules
7
12
8
13
let _: IAMSOuter . Inner ?
You can’t perform that action at this time.
0 commit comments