Merge remote-tracking branch 'origin/master' into master-next

This commit is contained in:
swift-ci
2019-02-14 10:09:06 -08:00
4 changed files with 132 additions and 0 deletions

View File

@@ -28,6 +28,7 @@
#include "clang/Basic/Module.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Lex/HeaderSearch.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringSet.h"
@@ -169,6 +170,16 @@ createInvocationForBuildingFromInterface(ASTContext &Ctx, StringRef ModuleName,
SubInvocation.setClangModuleCachePath(CacheDir);
SubInvocation.getFrontendOptions().PrebuiltModuleCachePath = PrebuiltCacheDir;
// Respect the detailed-record preprocessor setting of the parent context.
// This, and the "raw" clang module format it implicitly enables, are required
// by sourcekitd.
if (auto *ClangLoader = Ctx.getClangModuleLoader()) {
auto &Opts = ClangLoader->getClangInstance().getPreprocessorOpts();
if (Opts.DetailedRecord) {
SubInvocation.getClangImporterOptions().DetailedPreprocessingRecord = true;
}
}
// Inhibit warnings from the SubInvocation since we are assuming the user
// is not in a position to fix them.
SubInvocation.getDiagnosticOptions().SuppressWarnings = true;

View File

@@ -24,3 +24,11 @@ func f(s : inout [Int]) {
// RUN: %sourcekitd-test -req=interface-gen-open -module Swift \
// RUN: == -req=find-usr -usr "s:SMsSkRzSL7ElementSTRpzrlE4sortyyF::SYNTHESIZED::s:Sa::SYNTHESIZED::USRDOESNOTEXIST" | %FileCheck -check-prefix=SYNTHESIZED-USR3 %s
// SYNTHESIZED-USR3-NOT: USR NOT FOUND
// Test we can generate the interface of a module loaded via a .swiftinterface file correctly
// RUN: %empty-directory(%t.mod)
// RUN: %swift -emit-module -o /dev/null -emit-parseable-module-interface-path %t.mod/swift_mod.swiftinterface %S/Inputs/swift_mod.swift -parse-as-library
// RUN: %sourcekitd-test -req=interface-gen -module swift_mod -- -I %t.mod -enable-parseable-module-interface -module-cache-path %t/mcp > %t.response
// RUN: diff -u %s.from_swiftinterface.response %t.response

View File

@@ -0,0 +1,112 @@
public class MyClass {
public func pub_method()
}
public func pub_function()
[
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
key.offset: 1,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 8,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 14,
key.length: 7
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
key.offset: 29,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 36,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 41,
key.length: 10
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
key.offset: 57,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 64,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 69,
key.length: 12
}
]
<<NULL>>
[
{
key.kind: source.lang.swift.decl.class,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "MyClass",
key.offset: 8,
key.length: 47,
key.runtime_name: "_TtC4main7MyClass",
key.nameoffset: 14,
key.namelength: 7,
key.bodyoffset: 23,
key.bodylength: 31,
key.attributes: [
{
key.offset: 1,
key.length: 6,
key.attribute: source.decl.attribute.public
}
],
key.substructure: [
{
key.kind: source.lang.swift.decl.function.method.instance,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "pub_method()",
key.offset: 36,
key.length: 17,
key.nameoffset: 41,
key.namelength: 12,
key.attributes: [
{
key.offset: 29,
key.length: 6,
key.attribute: source.decl.attribute.public
}
]
}
]
},
{
key.kind: source.lang.swift.decl.function.free,
key.accessibility: source.lang.swift.accessibility.public,
key.name: "pub_function()",
key.offset: 64,
key.length: 19,
key.nameoffset: 69,
key.namelength: 14,
key.attributes: [
{
key.offset: 57,
key.length: 6,
key.attribute: source.decl.attribute.public
}
]
}
]

View File

@@ -708,6 +708,7 @@ void SwiftLangSupport::editorOpenInterface(EditorConsumer &Consumer,
}
Invocation.getClangImporterOptions().ImportForwardDeclarations = true;
Invocation.getFrontendOptions().EnableParseableModuleInterface = true;
std::string ErrMsg;
auto IFaceGenRef = SwiftInterfaceGenContext::create(Name,