@@ -83,7 +83,7 @@ namespace {
83
83
void handleImport (const clang::Module *imported) {
84
84
if (!imported)
85
85
return ;
86
- ModuleDecl *nativeImported = Impl.finishLoadingClangModule (Importer, imported,
86
+ ModuleDecl *nativeImported = Impl.finishLoadingClangModule (imported,
87
87
/* preferAdapter=*/ true );
88
88
Impl.ImportedHeaderExports .push_back ({ /* filter=*/ {}, nativeImported });
89
89
}
@@ -835,7 +835,7 @@ ClangImporter::create(ASTContext &ctx,
835
835
// Set up the imported header module.
836
836
auto *importedHeaderModule = ModuleDecl::create (ctx.getIdentifier (" __ObjC" ), ctx);
837
837
importer->Impl .ImportedHeaderUnit =
838
- new (ctx) ClangModuleUnit (*importedHeaderModule, * importer, nullptr );
838
+ new (ctx) ClangModuleUnit (*importedHeaderModule, importer-> Impl , nullptr );
839
839
importedHeaderModule->addFile (*importer->Impl .ImportedHeaderUnit );
840
840
841
841
importer->Impl .IsReadingBridgingPCH = false ;
@@ -1234,12 +1234,11 @@ ModuleDecl *ClangImporter::loadModule(
1234
1234
if (!clangModule)
1235
1235
return nullptr ;
1236
1236
1237
- return Impl.finishLoadingClangModule (* this , clangModule,
1237
+ return Impl.finishLoadingClangModule (clangModule,
1238
1238
/* preferAdapter=*/ false );
1239
1239
}
1240
1240
1241
1241
ModuleDecl *ClangImporter::Implementation::finishLoadingClangModule (
1242
- ClangImporter &owner,
1243
1242
const clang::Module *clangModule,
1244
1243
bool findAdapter) {
1245
1244
assert (clangModule);
@@ -1269,7 +1268,7 @@ ModuleDecl *ClangImporter::Implementation::finishLoadingClangModule(
1269
1268
result->setTestingEnabled ();
1270
1269
1271
1270
wrapperUnit =
1272
- new (SwiftContext) ClangModuleUnit (*result, owner , clangModule);
1271
+ new (SwiftContext) ClangModuleUnit (*result, * this , clangModule);
1273
1272
result->addFile (*wrapperUnit);
1274
1273
cacheEntry.setPointerAndInt (wrapperUnit, true );
1275
1274
@@ -1280,7 +1279,7 @@ ModuleDecl *ClangImporter::Implementation::finishLoadingClangModule(
1280
1279
}
1281
1280
1282
1281
if (clangModule->isSubModule ()) {
1283
- finishLoadingClangModule (owner, clangModule->getTopLevelModule (), true );
1282
+ finishLoadingClangModule (clangModule->getTopLevelModule (), true );
1284
1283
} else {
1285
1284
ModuleDecl *&loaded = SwiftContext.LoadedModules [result->getName ()];
1286
1285
if (!loaded)
@@ -1381,7 +1380,6 @@ ClangImporter::Implementation::~Implementation() {
1381
1380
}
1382
1381
1383
1382
ClangModuleUnit *ClangImporter::Implementation::getWrapperForModule (
1384
- ClangImporter &importer,
1385
1383
const clang::Module *underlying) {
1386
1384
auto &cacheEntry = ModuleWrappers[underlying];
1387
1385
if (ClangModuleUnit *cached = cacheEntry.getPointer ())
@@ -1393,7 +1391,7 @@ ClangModuleUnit *ClangImporter::Implementation::getWrapperForModule(
1393
1391
// Silence error messages about testably importing a Clang module.
1394
1392
wrapper->setTestingEnabled ();
1395
1393
1396
- auto file = new (SwiftContext) ClangModuleUnit (*wrapper, importer ,
1394
+ auto file = new (SwiftContext) ClangModuleUnit (*wrapper, * this ,
1397
1395
underlying);
1398
1396
wrapper->addFile (*file);
1399
1397
cacheEntry.setPointer (file);
@@ -1414,9 +1412,7 @@ ClangModuleUnit *ClangImporter::Implementation::getClangModuleForDecl(
1414
1412
// ClangModuleUnit.
1415
1413
auto *M = maybeModule.getValue ()->getTopLevelModule ();
1416
1414
1417
- auto &importer =
1418
- static_cast <ClangImporter &>(*SwiftContext.getClangModuleLoader ());
1419
- return getWrapperForModule (importer, M);
1415
+ return getWrapperForModule (M);
1420
1416
}
1421
1417
1422
1418
#pragma mark Source locations
@@ -1988,9 +1984,9 @@ void ClangModuleUnit::lookupVisibleDecls(ModuleDecl::AccessPathTy accessPath,
1988
1984
}
1989
1985
1990
1986
// Find the corresponding lookup table.
1991
- if (auto lookupTable = owner.Impl . findLookupTable (clangModule)) {
1987
+ if (auto lookupTable = owner.findLookupTable (clangModule)) {
1992
1988
// Search it.
1993
- owner.Impl . lookupVisibleDecls (*lookupTable, *actualConsumer);
1989
+ owner.lookupVisibleDecls (*lookupTable, *actualConsumer);
1994
1990
}
1995
1991
}
1996
1992
@@ -2021,14 +2017,14 @@ void ClangModuleUnit::getTopLevelDecls(SmallVectorImpl<Decl*> &results) const {
2021
2017
actualConsumer = &blacklistConsumer;
2022
2018
2023
2019
// Find the corresponding lookup table.
2024
- if (auto lookupTable = owner.Impl . findLookupTable (topLevelModule)) {
2020
+ if (auto lookupTable = owner.findLookupTable (topLevelModule)) {
2025
2021
// Search it.
2026
- owner.Impl . lookupVisibleDecls (*lookupTable, *actualConsumer);
2022
+ owner.lookupVisibleDecls (*lookupTable, *actualConsumer);
2027
2023
2028
2024
// Add the extensions produced by importing categories.
2029
2025
for (auto category : lookupTable->categories ()) {
2030
2026
if (auto extension = cast_or_null<ExtensionDecl>(
2031
- owner.Impl . importDecl (category, owner. Impl .CurrentVersion )))
2027
+ owner.importDecl (category, owner.CurrentVersion )))
2032
2028
results.push_back (extension);
2033
2029
}
2034
2030
@@ -2040,7 +2036,7 @@ void ClangModuleUnit::getTopLevelDecls(SmallVectorImpl<Decl*> &results) const {
2040
2036
for (auto entry : lookupTable->allGlobalsAsMembers ()) {
2041
2037
auto decl = entry.get <clang::NamedDecl *>();
2042
2038
auto importedDecl =
2043
- owner.Impl . importDecl (decl, owner. Impl .CurrentVersion );
2039
+ owner.importDecl (decl, owner.CurrentVersion );
2044
2040
if (!importedDecl) continue ;
2045
2041
2046
2042
auto ext = dyn_cast<ExtensionDecl>(importedDecl->getDeclContext ());
@@ -2125,9 +2121,9 @@ void ClangModuleUnit::lookupValue(ModuleDecl::AccessPathTy accessPath,
2125
2121
}
2126
2122
2127
2123
// Find the corresponding lookup table.
2128
- if (auto lookupTable = owner.Impl . findLookupTable (clangModule)) {
2124
+ if (auto lookupTable = owner.findLookupTable (clangModule)) {
2129
2125
// Search it.
2130
- owner.Impl . lookupValue (*lookupTable, name, *consumer);
2126
+ owner.lookupValue (*lookupTable, name, *consumer);
2131
2127
}
2132
2128
}
2133
2129
@@ -2265,9 +2261,9 @@ ClangModuleUnit::lookupClassMember(ModuleDecl::AccessPathTy accessPath,
2265
2261
VectorDeclConsumer consumer (results);
2266
2262
2267
2263
// Find the corresponding lookup table.
2268
- if (auto lookupTable = owner.Impl . findLookupTable (clangModule)) {
2264
+ if (auto lookupTable = owner.findLookupTable (clangModule)) {
2269
2265
// Search it.
2270
- owner.Impl . lookupObjCMembers (*lookupTable, name, consumer);
2266
+ owner.lookupObjCMembers (*lookupTable, name, consumer);
2271
2267
}
2272
2268
}
2273
2269
@@ -2278,9 +2274,9 @@ void ClangModuleUnit::lookupClassMembers(ModuleDecl::AccessPathTy accessPath,
2278
2274
return ;
2279
2275
2280
2276
// Find the corresponding lookup table.
2281
- if (auto lookupTable = owner.Impl . findLookupTable (clangModule)) {
2277
+ if (auto lookupTable = owner.findLookupTable (clangModule)) {
2282
2278
// Search it.
2283
- owner.Impl . lookupAllObjCMembers (*lookupTable, consumer);
2279
+ owner.lookupAllObjCMembers (*lookupTable, consumer);
2284
2280
}
2285
2281
}
2286
2282
@@ -2292,12 +2288,12 @@ void ClangModuleUnit::lookupObjCMethods(
2292
2288
return ;
2293
2289
2294
2290
// Map the selector into a Clang selector.
2295
- auto clangSelector = owner.Impl . exportSelector (selector);
2291
+ auto clangSelector = owner.exportSelector (selector);
2296
2292
if (clangSelector.isNull ()) return ;
2297
2293
2298
2294
// Collect all of the Objective-C methods with this selector.
2299
2295
SmallVector<clang::ObjCMethodDecl *, 8 > objcMethods;
2300
- auto &clangSema = owner.Impl . getClangSema ();
2296
+ auto &clangSema = owner.getClangSema ();
2301
2297
clangSema.CollectMultipleMethodsInGlobalPool (clangSelector,
2302
2298
objcMethods,
2303
2299
/* InstanceFirst=*/ true ,
@@ -2319,23 +2315,23 @@ void ClangModuleUnit::lookupObjCMethods(
2319
2315
2320
2316
// If we found a property accessor, import the property.
2321
2317
if (objcMethod->isPropertyAccessor ())
2322
- (void )owner.Impl . importDecl (objcMethod->findPropertyDecl (true ),
2323
- owner. Impl .CurrentVersion );
2318
+ (void )owner.importDecl (objcMethod->findPropertyDecl (true ),
2319
+ owner.CurrentVersion );
2324
2320
2325
2321
// Import it.
2326
2322
// FIXME: Retrying a failed import works around recursion bugs in the Clang
2327
2323
// importer.
2328
2324
auto imported =
2329
- owner.Impl . importDecl (objcMethod, owner. Impl .CurrentVersion );
2325
+ owner.importDecl (objcMethod, owner.CurrentVersion );
2330
2326
if (!imported)
2331
- imported = owner.Impl . importDecl (objcMethod, owner. Impl .CurrentVersion );
2327
+ imported = owner.importDecl (objcMethod, owner.CurrentVersion );
2332
2328
if (!imported) continue ;
2333
2329
2334
2330
if (auto func = dyn_cast<AbstractFunctionDecl>(imported))
2335
2331
results.push_back (func);
2336
2332
2337
2333
// If there is an alternate declaration, also look at it.
2338
- for (auto alternate : owner.Impl . getAlternateDecls (imported)) {
2334
+ for (auto alternate : owner.getAlternateDecls (imported)) {
2339
2335
if (auto func = dyn_cast<AbstractFunctionDecl>(alternate))
2340
2336
results.push_back (func);
2341
2337
}
@@ -2435,7 +2431,8 @@ void ClangImporter::verifyAllModules() {
2435
2431
// ClangModule Implementation
2436
2432
// ===----------------------------------------------------------------------===//
2437
2433
2438
- ClangModuleUnit::ClangModuleUnit (ModuleDecl &M, ClangImporter &owner,
2434
+ ClangModuleUnit::ClangModuleUnit (ModuleDecl &M,
2435
+ ClangImporter::Implementation &owner,
2439
2436
const clang::Module *clangModule)
2440
2437
: LoadedFile(FileUnitKind::ClangModule, M), owner(owner),
2441
2438
clangModule(clangModule) {
@@ -2468,7 +2465,7 @@ ModuleDecl *ClangModuleUnit::getAdapterModule() const {
2468
2465
if (!isTopLevel ()) {
2469
2466
// FIXME: Is this correct for submodules?
2470
2467
auto topLevel = clangModule->getTopLevelModule ();
2471
- auto wrapper = owner.Impl . getWrapperForModule (owner, topLevel);
2468
+ auto wrapper = owner.getWrapperForModule (topLevel);
2472
2469
return wrapper->getAdapterModule ();
2473
2470
}
2474
2471
@@ -2504,8 +2501,8 @@ void ClangModuleUnit::getImportedModules(
2504
2501
if (!clangModule) {
2505
2502
// This is the special "imported headers" module.
2506
2503
if (filter != ModuleDecl::ImportFilter::Private) {
2507
- imports.append (owner.Impl . ImportedHeaderExports .begin (),
2508
- owner.Impl . ImportedHeaderExports .end ());
2504
+ imports.append (owner.ImportedHeaderExports .begin (),
2505
+ owner.ImportedHeaderExports .end ());
2509
2506
}
2510
2507
return ;
2511
2508
}
@@ -2541,7 +2538,7 @@ void ClangModuleUnit::getImportedModules(
2541
2538
}
2542
2539
2543
2540
for (auto importMod : imported) {
2544
- auto wrapper = owner.Impl . getWrapperForModule (owner, importMod);
2541
+ auto wrapper = owner.getWrapperForModule (importMod);
2545
2542
2546
2543
auto actualMod = wrapper->getAdapterModule ();
2547
2544
if (!actualMod) {
@@ -2550,8 +2547,7 @@ void ClangModuleUnit::getImportedModules(
2550
2547
auto importTopLevel = importMod->getTopLevelModule ();
2551
2548
if (importTopLevel != importMod &&
2552
2549
importTopLevel != clangModule->getTopLevelModule ()) {
2553
- auto topLevelWrapper = owner.Impl .getWrapperForModule (owner,
2554
- importTopLevel);
2550
+ auto topLevelWrapper = owner.getWrapperForModule (importTopLevel);
2555
2551
imports.push_back ({ ModuleDecl::AccessPathTy (),
2556
2552
topLevelWrapper->getParentModule () });
2557
2553
}
@@ -2570,8 +2566,8 @@ void ClangModuleUnit::getImportedModulesForLookup(
2570
2566
2571
2567
if (!clangModule) {
2572
2568
// This is the special "imported headers" module.
2573
- imports.append (owner.Impl . ImportedHeaderExports .begin (),
2574
- owner.Impl . ImportedHeaderExports .end ());
2569
+ imports.append (owner.ImportedHeaderExports .begin (),
2570
+ owner.ImportedHeaderExports .end ());
2575
2571
return ;
2576
2572
}
2577
2573
@@ -2608,7 +2604,7 @@ void ClangModuleUnit::getImportedModulesForLookup(
2608
2604
2609
2605
// Don't continue looking through submodules of modules that have
2610
2606
// overlays. The overlay might shadow things.
2611
- auto wrapper = owner.Impl . getWrapperForModule (owner, nextTopLevel);
2607
+ auto wrapper = owner.getWrapperForModule (nextTopLevel);
2612
2608
if (wrapper->getAdapterModule ())
2613
2609
continue ;
2614
2610
}
@@ -2626,7 +2622,7 @@ void ClangModuleUnit::getImportedModulesForLookup(
2626
2622
}
2627
2623
2628
2624
for (auto importMod : topLevelImported) {
2629
- auto wrapper = owner.Impl . getWrapperForModule (owner, importMod);
2625
+ auto wrapper = owner.getWrapperForModule (importMod);
2630
2626
2631
2627
auto actualMod = wrapper->getAdapterModule ();
2632
2628
if (!actualMod || actualMod == topLevelAdapter)
0 commit comments