Skip to content

Commit c6ef802

Browse files
Merge pull request #9195 from adrian-prantl/17260802
Debug info: Represent clang-imported submodules.
2 parents 2048bd5 + 0cb4a28 commit c6ef802

File tree

9 files changed

+1720
-1662
lines changed

9 files changed

+1720
-1662
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 1671 additions & 1387 deletions
Large diffs are not rendered by default.

lib/IRGen/IRGenDebugInfo.h

Lines changed: 24 additions & 258 deletions
Large diffs are not rendered by default.

lib/IRGen/IRGenModule.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ static clang::CodeGenerator *createClangCodeGenerator(ASTContext &Context,
9797
CGO.setDebugInfo(clang::codegenoptions::DebugInfoKind::DebugLineTablesOnly);
9898
break;
9999
case IRGenDebugInfoKind::ASTTypes:
100-
// TODO: Enable -gmodules for the clang code generator.
101100
case IRGenDebugInfoKind::DwarfTypes:
101+
CGO.DebugTypeExtRefs = true;
102102
CGO.setDebugInfo(clang::codegenoptions::DebugInfoKind::FullDebugInfo);
103103
break;
104104
}
@@ -380,7 +380,8 @@ IRGenModule::IRGenModule(IRGenerator &irgen,
380380
UseSwiftCC = (SwiftCC == llvm::CallingConv::Swift);
381381

382382
if (IRGen.Opts.DebugInfoKind > IRGenDebugInfoKind::None)
383-
DebugInfo = new IRGenDebugInfo(IRGen.Opts, *CI, *this, Module, SF);
383+
DebugInfo = IRGenDebugInfo::createIRGenDebugInfo(IRGen.Opts, *CI, *this,
384+
Module, SF);
384385

385386
initClangTypeConverter();
386387

lib/IRGen/IRGenSIL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//===----------------------------------------------------------------------===//
1717

1818
#define DEBUG_TYPE "irgensil"
19+
#include "llvm/IR/DIBuilder.h"
1920
#include "llvm/IR/Function.h"
2021
#include "llvm/IR/Module.h"
2122
#include "llvm/IR/Instructions.h"
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
// RUN: rm -rf %t && mkdir -p %t
2-
// REQUIRES: OS=macosx
1+
// RUN: %target-swift-frontend -emit-ir %s -g -I %S/Inputs -o - | %FileCheck %s
32

4-
// RUN: %target-swift-frontend -emit-ir %s -g -o - | %FileCheck %s
3+
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Bar",
4+
// CHECK-SAME: scope: ![[SUBMODULE:[0-9]+]]
55

6-
// CHECK: !DIImportedEntity(
7-
// CHECK: tag: DW_TAG_imported_module{{.*}}entity: ![[C:.*]], line: [[@LINE+1]])
8-
import Darwin.C
6+
// CHECK: ![[SUBMODULE]] = !DIModule(scope: ![[CLANGMODULE:[0-9]+]],
7+
// CHECK-SAME: name: "SubModule",
8+
// CHECK: ![[CLANGMODULE]] = !DIModule(scope: null, name: "ClangModule",
9+
// CHECK: !DIImportedEntity({{.*}}, entity: ![[SUBMODULE]], line: [[@LINE+1]])
10+
import ClangModule.SubModule
911

10-
let irrational = sqrt(2 as Double)
11-
12-
// CHECK: ![[C]] = !DIModule(scope: ![[Darwin:.*]], name: "C",
13-
// CHECK: ![[Darwin]] = !DIModule(scope: null, name: "Darwin",
12+
let bar = Bar()

test/DebugInfo/Inputs/SubModule.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
struct Bar {};

test/DebugInfo/Inputs/module.map

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module ClangModule {
2+
header "ClangModule.h"
3+
export *
4+
module SubModule {
5+
header "SubModule.h"
6+
export *
7+
}
8+
}

test/DebugInfo/test-foundation.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ class MyObject : NSObject {
1818
var MyArr = NSArray()
1919
// IMPORT-CHECK: filename: "test-foundation.swift"
2020
// IMPORT-CHECK-DAG: [[FOUNDATION:[0-9]+]] = !DIModule({{.*}} name: "Foundation",{{.*}} includePath:
21-
// IMPORT-CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "NSArray", scope: ![[FOUNDATION]]
22-
// IMPORT-CHECK-DAG: !DIImportedEntity(tag: DW_TAG_imported_module, {{.*}}entity: ![[FOUNDATION]]
21+
// IMPORT-CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "NSArray", scope: ![[NSARRAY:[0-9]+]]
22+
// IMPORT-CHECK-DAG: ![[NSARRAY]] = !DIModule(scope: ![[FOUNDATION:[0-9]+]], name: "NSArray"
23+
// IMPORT-CHECK-DAG: !DIImportedEntity(tag: DW_TAG_imported_module, {{.*}}entity: ![[FOUNDATION]]
2324

2425
func foo(_ obj: MyObject) {
2526
return obj.foo(obj)

0 commit comments

Comments
 (0)