diff --git a/lib/ClangImporter/ClangDiagnosticConsumer.cpp b/lib/ClangImporter/ClangDiagnosticConsumer.cpp index 5e0627b7650..e5f088fe176 100644 --- a/lib/ClangImporter/ClangDiagnosticConsumer.cpp +++ b/lib/ClangImporter/ClangDiagnosticConsumer.cpp @@ -165,8 +165,10 @@ SourceLoc ClangDiagnosticConsumer::resolveSourceLocation( const clang::SourceManager *toInsert) { return std::less()(inArray.get(), toInsert); }); - if (iter->get() != &clangSrcMgr) + if (iter == sourceManagersWithDiagnostics.end() || + iter->get() != &clangSrcMgr) { sourceManagersWithDiagnostics.insert(iter, &clangSrcMgr); + } return loc; } diff --git a/test/ClangImporter/Inputs/custom-modules/Warnings1.h b/test/ClangImporter/Inputs/custom-modules/Warnings1.h new file mode 100644 index 00000000000..fea1abfb8f5 --- /dev/null +++ b/test/ClangImporter/Inputs/custom-modules/Warnings1.h @@ -0,0 +1,4 @@ +extern void old() __attribute__((deprecated)); +static void warnings1() { + old(); +} diff --git a/test/ClangImporter/Inputs/custom-modules/Warnings2.h b/test/ClangImporter/Inputs/custom-modules/Warnings2.h new file mode 100644 index 00000000000..5de1f76526e --- /dev/null +++ b/test/ClangImporter/Inputs/custom-modules/Warnings2.h @@ -0,0 +1,4 @@ +extern void old() __attribute__((deprecated)); +static void warnings2() { + old(); +} diff --git a/test/ClangImporter/Inputs/custom-modules/Warnings3.h b/test/ClangImporter/Inputs/custom-modules/Warnings3.h new file mode 100644 index 00000000000..377cbc739c2 --- /dev/null +++ b/test/ClangImporter/Inputs/custom-modules/Warnings3.h @@ -0,0 +1,4 @@ +extern void old() __attribute__((deprecated)); +static void warnings3() { + old(); +} diff --git a/test/ClangImporter/Inputs/custom-modules/Warnings4.h b/test/ClangImporter/Inputs/custom-modules/Warnings4.h new file mode 100644 index 00000000000..d3966033200 --- /dev/null +++ b/test/ClangImporter/Inputs/custom-modules/Warnings4.h @@ -0,0 +1,4 @@ +extern void old() __attribute__((deprecated)); +static void warnings4() { + old(); +} diff --git a/test/ClangImporter/Inputs/custom-modules/Warnings5.h b/test/ClangImporter/Inputs/custom-modules/Warnings5.h new file mode 100644 index 00000000000..d2c4a65c7a0 --- /dev/null +++ b/test/ClangImporter/Inputs/custom-modules/Warnings5.h @@ -0,0 +1,4 @@ +extern void old() __attribute__((deprecated)); +static void warnings5() { + old(); +} diff --git a/test/ClangImporter/Inputs/custom-modules/Warnings6.h b/test/ClangImporter/Inputs/custom-modules/Warnings6.h new file mode 100644 index 00000000000..878ca17f9a7 --- /dev/null +++ b/test/ClangImporter/Inputs/custom-modules/Warnings6.h @@ -0,0 +1,4 @@ +extern void old() __attribute__((deprecated)); +static void warnings6() { + old(); +} diff --git a/test/ClangImporter/Inputs/custom-modules/Warnings7.h b/test/ClangImporter/Inputs/custom-modules/Warnings7.h new file mode 100644 index 00000000000..44886264c78 --- /dev/null +++ b/test/ClangImporter/Inputs/custom-modules/Warnings7.h @@ -0,0 +1,4 @@ +extern void old() __attribute__((deprecated)); +static void warnings7() { + old(); +} diff --git a/test/ClangImporter/Inputs/custom-modules/Warnings8.h b/test/ClangImporter/Inputs/custom-modules/Warnings8.h new file mode 100644 index 00000000000..ad91d6627df --- /dev/null +++ b/test/ClangImporter/Inputs/custom-modules/Warnings8.h @@ -0,0 +1,4 @@ +extern void old() __attribute__((deprecated)); +static void warnings8() { + old(); +} diff --git a/test/ClangImporter/Inputs/custom-modules/Warnings9.h b/test/ClangImporter/Inputs/custom-modules/Warnings9.h new file mode 100644 index 00000000000..50a19385945 --- /dev/null +++ b/test/ClangImporter/Inputs/custom-modules/Warnings9.h @@ -0,0 +1,4 @@ +extern void old() __attribute__((deprecated)); +static void warnings9() { + old(); +} diff --git a/test/ClangImporter/Inputs/custom-modules/module.map b/test/ClangImporter/Inputs/custom-modules/module.map index 9b5c8c4220a..2b6d8c41d55 100644 --- a/test/ClangImporter/Inputs/custom-modules/module.map +++ b/test/ClangImporter/Inputs/custom-modules/module.map @@ -189,3 +189,13 @@ module IndirectFields { module ObjCBridgeNonconforming { header "ObjCBridgeNonconforming.h" } + +module Warnings1 { header "Warnings1.h" } +module Warnings2 { header "Warnings2.h" } +module Warnings3 { header "Warnings3.h" } +module Warnings4 { header "Warnings4.h" } +module Warnings5 { header "Warnings5.h" } +module Warnings6 { header "Warnings6.h" } +module Warnings7 { header "Warnings7.h" } +module Warnings8 { header "Warnings8.h" } +module Warnings9 { header "Warnings9.h" } diff --git a/test/ClangImporter/diags-from-many-modules.swift b/test/ClangImporter/diags-from-many-modules.swift new file mode 100644 index 00000000000..db23d0afd4e --- /dev/null +++ b/test/ClangImporter/diags-from-many-modules.swift @@ -0,0 +1,23 @@ +// RUN: %empty-directory(%t) +// RUN: %target-swift-frontend -typecheck %s -I %S/Inputs/custom-modules -module-cache-path %t 2> %t.err.txt +// RUN: %FileCheck -input-file=%t.err.txt %s + +import Warnings1 +import Warnings2 +import Warnings3 +import Warnings4 +import Warnings5 +import Warnings6 +import Warnings7 +import Warnings8 +import Warnings9 + +// CHECK: Warnings1.h:{{.+}}: warning: 'old' is deprecated +// CHECK: Warnings2.h:{{.+}}: warning: 'old' is deprecated +// CHECK: Warnings3.h:{{.+}}: warning: 'old' is deprecated +// CHECK: Warnings4.h:{{.+}}: warning: 'old' is deprecated +// CHECK: Warnings5.h:{{.+}}: warning: 'old' is deprecated +// CHECK: Warnings6.h:{{.+}}: warning: 'old' is deprecated +// CHECK: Warnings7.h:{{.+}}: warning: 'old' is deprecated +// CHECK: Warnings8.h:{{.+}}: warning: 'old' is deprecated +// CHECK: Warnings9.h:{{.+}}: warning: 'old' is deprecated