File tree Expand file tree Collapse file tree 7 files changed +72
-1
lines changed
include/swift/ClangImporter
tools/lldb-moduleimport-test Expand file tree Collapse file tree 7 files changed +72
-1
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,9 @@ class ClangImporter final : public ClangModuleLoader {
141
141
142
142
~ClangImporter ();
143
143
144
+ // / Only to be used by lldb-moduleimport-test.
145
+ void setDWARFImporterDelegate (DWARFImporterDelegate &delegate);
146
+
144
147
// / Create a new clang::DependencyCollector customized to
145
148
// / ClangImporter's specific uses.
146
149
static std::shared_ptr<clang::DependencyCollector>
Original file line number Diff line number Diff line change @@ -176,3 +176,12 @@ void ClangImporter::Implementation::lookupTypeDeclDWARF(
176
176
receiver (importedType);
177
177
}
178
178
}
179
+
180
+ void ClangImporter::setDWARFImporterDelegate (DWARFImporterDelegate &delegate) {
181
+ Impl.setDWARFImporterDelegate (delegate);
182
+ }
183
+
184
+ void ClangImporter::Implementation::setDWARFImporterDelegate (
185
+ DWARFImporterDelegate &delegate) {
186
+ DWARFImporter = &delegate;
187
+ }
Original file line number Diff line number Diff line change @@ -606,14 +606,19 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
606
606
private:
607
607
// / The DWARF importer delegate, if installed.
608
608
DWARFImporterDelegate *DWARFImporter = nullptr ;
609
+ public:
610
+ // / Only used for testing.
611
+ void setDWARFImporterDelegate (DWARFImporterDelegate &delegate);
612
+
613
+ private:
609
614
// / The list of Clang modules found in the debug info.
610
615
llvm::DenseMap<Identifier, LoadedFile *> DWARFModuleUnits;
611
-
612
616
public:
613
617
// / "Import" a module from debug info. Because debug info types are read on
614
618
// / demand, this doesn't really do any work.
615
619
ModuleDecl *loadModuleDWARF (SourceLoc importLoc,
616
620
ArrayRef<std::pair<Identifier, SourceLoc>> path);
621
+
617
622
618
623
void recordImplicitUnwrapForDecl (ValueDecl *decl, bool isIUO) {
619
624
if (!isIUO)
Original file line number Diff line number Diff line change
1
+ module ObjCModule {
2
+ header "objc-header.h"
3
+ export *
4
+ }
Original file line number Diff line number Diff line change
1
+ struct Point {
2
+ int x, y;
3
+ };
4
+
5
+ @interface ObjCClass
6
+ - (instancetype )init ;
7
+ @end
Original file line number Diff line number Diff line change
1
+ // REQUIRES: executable_test
2
+ // REQUIRES: objc_interop
3
+
4
+ // RUN: %empty-directory(%t)
5
+
6
+ // RUN: cp %S/Inputs/objc-header.h %S/Inputs/module.modulemap %t
7
+ // RUN: %target-build-swift -emit-executable %s -g -o %t/a.out \
8
+ // RUN: -module-name basic -emit-module -I%t
9
+ // -DOBJC -module-name basic
10
+ // RUN: %lldb-moduleimport-test -verbose -dump-module %t/a.out | %FileCheck %s
11
+
12
+ // RUN: rm %t/objc-header.h
13
+ // RUN: %lldb-moduleimport-test -verbose -dump-module %t/a.out \
14
+ // RUN: | %FileCheck %s --check-prefix=FAIL
15
+
16
+ // RUN: %lldb-moduleimport-test -verbose -dump-module %t/a.out \
17
+ // RUN: -dummy-dwarfimporter | %FileCheck %s --check-prefix=SWIFTONLY
18
+
19
+ // CHECK: Importing basic... ok!
20
+ // FAIL: Importing basic... ok!
21
+ // SWIFTONLY: Importing basic... ok!
22
+ import ObjCModule
23
+
24
+ let pureSwift = Int32 ( 42 )
25
+ // FAIL-NOT: var_decl
26
+ // CHECK: var_decl "pureSwift" {{.*}} type='Int32'
27
+ // SWIFTONLY: var_decl "pureSwift" {{.*}} type='Int32'
28
+
29
+ let point = Point ( x: 1 , y: 2 )
30
+ // CHECK: var_decl "point" {{.*}} type='Point'
31
+ // SWIFTONLY-NOT: var_decl "point"
32
+
Original file line number Diff line number Diff line change @@ -220,6 +220,10 @@ int main(int argc, char **argv) {
220
220
desc (" The directory that holds the compiler resource files" ),
221
221
cat (Visible));
222
222
223
+ opt<bool > DummyDWARFImporter (
224
+ " dummy-dwarfimporter" ,
225
+ desc (" Install a dummy DWARFImporterDelegate" ), cat (Visible));
226
+
223
227
ParseCommandLineOptions (argc, argv);
224
228
225
229
// Unregister our options so they don't interfere with the command line
@@ -296,6 +300,13 @@ int main(int argc, char **argv) {
296
300
return 1 ;
297
301
}
298
302
303
+ swift::DWARFImporterDelegate dummyDWARFImporter;
304
+ if (DummyDWARFImporter) {
305
+ auto *ClangImporter = static_cast <swift::ClangImporter *>(
306
+ CI.getASTContext ().getClangModuleLoader ());
307
+ ClangImporter->setDWARFImporterDelegate (dummyDWARFImporter);
308
+ }
309
+
299
310
for (auto &Module : Modules)
300
311
if (!parseASTSection (*CI.getMemoryBufferSerializedModuleLoader (),
301
312
StringRef (Module.first , Module.second ), modules)) {
You can’t perform that action at this time.
0 commit comments