Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/swift/AST/ClangModuleLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ class ClangModuleLoader : public ModuleLoader {
virtual SwiftLookupTable *
findLookupTable(const clang::Module *clangModule) = 0;

/// Returns the module \p Node comes from, or \c nullptr if \p Node does not
/// have a valid owning module.
///
/// Note that \p Node cannot itself be a clang::Module.
virtual const clang::Module *getClangOwningModule(ClangNode Node) const = 0;

virtual DeclName
Expand Down
6 changes: 6 additions & 0 deletions include/swift/ClangImporter/ClangImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,13 @@ class ClangImporter final : public ClangModuleLoader {
bool dumpPrecompiledModule(StringRef modulePath, StringRef outputPath);

bool runPreprocessor(StringRef inputPath, StringRef outputPath);

/// Returns the module \p Node comes from, or \c nullptr if \p Node does not
/// have a valid owning module.
///
/// Note that \p Node cannot itself be a clang::Module.
const clang::Module *getClangOwningModule(ClangNode Node) const override;

bool hasTypedef(const clang::Decl *typeDecl) const;

void verifyAllModules() override;
Expand Down
1 change: 1 addition & 0 deletions lib/ClangImporter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ add_swift_host_library(swiftClangImporter STATIC
ClangImporter.cpp
ClangImporterRequests.cpp
ClangIncludePaths.cpp
ClangLookup.cpp
ClangModuleDependencyScanner.cpp
ClangSourceBufferImporter.cpp
SwiftDeclSynthesizer.cpp
Expand Down
7 changes: 4 additions & 3 deletions lib/ClangImporter/ClangDerivedConformances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ instantiateTemplatedOperator(ClangImporter::Implementation &impl,
// behavior for the operator that we just instantiated.
auto lookupTable1 = impl.findLookupTable(classDecl);
addEntryToLookupTable(*lookupTable1, clangCallee, impl.getNameImporter());
auto owningModule = impl.getClangOwningModule(classDecl);
auto owningModule = importer::getClangOwningModule(classDecl, clangCtx);
auto lookupTable2 = impl.findLookupTable(owningModule);
if (lookupTable1 != lookupTable2)
addEntryToLookupTable(*lookupTable2, clangCallee, impl.getNameImporter());
Expand Down Expand Up @@ -412,7 +412,7 @@ static bool synthesizeCXXOperator(ClangImporter::Implementation &impl,
impl.synthesizedAndAlwaysVisibleDecls.insert(equalEqualDecl);
auto lookupTable1 = impl.findLookupTable(classDecl);
addEntryToLookupTable(*lookupTable1, equalEqualDecl, impl.getNameImporter());
auto owningModule = impl.getClangOwningModule(classDecl);
auto owningModule = importer::getClangOwningModule(classDecl, clangCtx);
auto lookupTable2 = impl.findLookupTable(owningModule);
if (lookupTable1 != lookupTable2)
addEntryToLookupTable(*lookupTable2, equalEqualDecl,
Expand Down Expand Up @@ -1259,7 +1259,8 @@ void swift::deriveAutomaticCxxConformances(
//
// We will still attempt to synthesize to account for scenarios where the
// module specification is missing altogether.
if (auto *clangModule = Impl.getClangOwningModule(result->getClangNode());
if (auto *clangModule = importer::getClangOwningModule(
result->getClangNode(), Impl.getClangASTContext());
clangModule && !requiresCPlusPlus(clangModule))
return;

Expand Down
Loading