Skip to content

Commit 3c50c62

Browse files
committed
---
yaml --- r: 347603 b: refs/heads/master c: fa64e92 h: refs/heads/master i: 347601: 55a926f 347599: 7e7bc85
1 parent 4128918 commit 3c50c62

File tree

15 files changed

+85
-11
lines changed

15 files changed

+85
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 0721847584bca9a91275a79b2ac7b77ce2c84ac4
2+
refs/heads/master: fa64e920720990b20dabd8125081e4f989f190ba
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/AST/Module.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,10 @@ class FileUnit : public DeclContext {
843843
return getParentModule()->getName().str();
844844
}
845845

846+
/// If this is a module imported from a parseable interface, return the path
847+
/// to the interface file, otherwise an empty StringRef.
848+
virtual StringRef getParseableInterface() const { return {}; }
849+
846850
/// Traverse the decls within this file.
847851
///
848852
/// \returns true if traversal was aborted, false if it completed

trunk/include/swift/Serialization/ModuleFormat.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,8 @@ namespace input_block {
643643
IMPORTED_HEADER_CONTENTS,
644644
MODULE_FLAGS, // [unused]
645645
SEARCH_PATH,
646-
FILE_DEPENDENCY
646+
FILE_DEPENDENCY,
647+
PARSEABLE_INTERFACE_PATH
647648
};
648649

649650
using ImportedModuleLayout = BCRecordLayout<
@@ -690,6 +691,12 @@ namespace input_block {
690691
BCFixed<1>, // SDK-relative?
691692
BCBlob // path
692693
>;
694+
695+
using ParseableInterfaceLayout = BCRecordLayout<
696+
PARSEABLE_INTERFACE_PATH,
697+
BCBlob // file path
698+
>;
699+
693700
}
694701

695702
/// The record types within the "decls-and-types" block.

trunk/include/swift/Serialization/SerializationOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace swift {
3333
StringRef GroupInfoPath;
3434
StringRef ImportedHeader;
3535
StringRef ModuleLinkName;
36+
StringRef ParseableInterface;
3637
ArrayRef<std::string> ExtraClangOptions;
3738

3839
/// Describes a single-file dependency for this module, along with the

trunk/include/swift/Serialization/SerializedModuleLoader.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ class SerializedASTFile final : public LoadedFile {
198198
friend class ModuleFile;
199199

200200
ModuleFile &File;
201+
202+
/// The parseable interface this module was generated from if any.
203+
/// Used for debug info.
204+
std::string ParseableInterface;
205+
201206
bool IsSIB;
202207

203208
~SerializedASTFile() = default;
@@ -294,6 +299,13 @@ class SerializedASTFile final : public LoadedFile {
294299

295300
virtual const clang::Module *getUnderlyingClangModule() const override;
296301

302+
/// If this is a module imported from a parseable interface, return the path
303+
/// to the interface file, otherwise an empty StringRef.
304+
virtual StringRef getParseableInterface() const override {
305+
return ParseableInterface;
306+
}
307+
void setParseableInterface(StringRef PI) { ParseableInterface = PI; }
308+
297309
virtual bool getAllGenericSignatures(
298310
SmallVectorImpl<GenericSignature*> &genericSignatures)
299311
override;

trunk/include/swift/Serialization/Validation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ struct ValidationInfo {
9292
class ExtendedValidationInfo {
9393
SmallVector<StringRef, 4> ExtraClangImporterOpts;
9494
StringRef SDKPath;
95+
StringRef ParseableInterface;
9596
struct {
9697
unsigned ArePrivateImportsEnabled : 1;
9798
unsigned IsSIB : 1;
@@ -113,6 +114,8 @@ class ExtendedValidationInfo {
113114
void addExtraClangImporterOption(StringRef option) {
114115
ExtraClangImporterOpts.push_back(option);
115116
}
117+
StringRef getParseableInterface() const { return ParseableInterface; }
118+
void setParseableInterface(StringRef PI) { ParseableInterface = PI; }
116119

117120
bool isSIB() const { return Bits.IsSIB; }
118121
void setIsSIB(bool val) {

trunk/lib/AST/Module.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,10 @@ StringRef ModuleDecl::getModuleFilename() const {
11571157
// per-file names. Modules can consist of more than one file.
11581158
StringRef Result;
11591159
for (auto F : getFiles()) {
1160+
Result = F->getParseableInterface();
1161+
if (!Result.empty())
1162+
return Result;
1163+
11601164
if (auto SF = dyn_cast<SourceFile>(F)) {
11611165
if (!Result.empty())
11621166
return StringRef();

trunk/lib/Frontend/Frontend.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ CompilerInvocation::getParseableInterfaceOutputPathForWholeModule() const {
124124
.SupplementaryOutputs.ParseableInterfaceOutputPath;
125125
}
126126

127-
SerializationOptions
128-
CompilerInvocation::computeSerializationOptions(const SupplementaryOutputPaths &outs,
129-
bool moduleIsPublic) {
127+
SerializationOptions CompilerInvocation::computeSerializationOptions(
128+
const SupplementaryOutputPaths &outs, bool moduleIsPublic) {
130129
const FrontendOptions &opts = getFrontendOptions();
131130

132131
SerializationOptions serializationOpts;

trunk/lib/Frontend/ParseableInterfaceModuleLoader.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,12 @@ class swift::ParseableInterfaceBuilder {
582582
std::string OutPathStr = OutPath;
583583
SerializationOpts.OutputPath = OutPathStr.c_str();
584584
SerializationOpts.ModuleLinkName = FEOpts.ModuleLinkName;
585+
586+
// Record any non-SDK parseable interface files for the debug info.
587+
StringRef SDKPath = SubInstance.getASTContext().SearchPathOpts.SDKPath;
588+
if (!getRelativeDepPath(InPath, SDKPath))
589+
SerializationOpts.ParseableInterface = InPath;
590+
585591
SmallVector<FileDependency, 16> Deps;
586592
if (collectDepsForSerialization(SubInstance, Deps,
587593
FEOpts.SerializeModuleInterfaceDependencyHashes)) {

trunk/lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,13 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
191191

192192
private:
193193
static StringRef getFilenameFromDC(const DeclContext *DC) {
194-
if (auto LF = dyn_cast<LoadedFile>(DC))
194+
if (auto *LF = dyn_cast<LoadedFile>(DC))
195195
return LF->getFilename();
196-
if (auto SF = dyn_cast<SourceFile>(DC))
196+
if (auto *SF = dyn_cast<SourceFile>(DC))
197197
return SF->getFilename();
198-
else if (auto M = dyn_cast<ModuleDecl>(DC))
198+
if (auto *M = dyn_cast<ModuleDecl>(DC))
199199
return M->getModuleFilename();
200-
else
201-
return StringRef();
200+
return {};
202201
}
203202

204203
using DebugLoc = SILLocation::DebugLoc;
@@ -717,7 +716,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
717716
ModuleDecl *M = IM.second;
718717
if (Optional<ASTSourceDescriptor> ModuleDesc = getClangModule(*M))
719718
return getOrCreateModule(*ModuleDesc, ModuleDesc->getModuleOrNull());
720-
721719
StringRef Path = getFilenameFromDC(M);
722720
StringRef Name = M->getName().str();
723721
return getOrCreateModule(M, TheCU, Name, Path);

trunk/lib/Serialization/ModuleFile.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,11 @@ ModuleFile::ModuleFile(
13351335
SearchPaths.push_back({blobData, isFramework, isSystem});
13361336
break;
13371337
}
1338+
case input_block::PARSEABLE_INTERFACE_PATH: {
1339+
if (extInfo)
1340+
extInfo->setParseableInterface(blobData);
1341+
break;
1342+
}
13381343
default:
13391344
// Unknown input kind, possibly for use by a future version of the
13401345
// module format.

trunk/lib/Serialization/Serialization.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ void Serializer::writeBlockInfoBlock() {
834834
BLOCK_RECORD(input_block, MODULE_FLAGS);
835835
BLOCK_RECORD(input_block, SEARCH_PATH);
836836
BLOCK_RECORD(input_block, FILE_DEPENDENCY);
837+
BLOCK_RECORD(input_block, PARSEABLE_INTERFACE_PATH);
837838

838839
BLOCK(DECLS_AND_TYPES_BLOCK);
839840
#define RECORD(X) BLOCK_RECORD(decls_block, X);
@@ -1060,6 +1061,7 @@ void Serializer::writeInputBlock(const SerializationOptions &options) {
10601061
input_block::ImportedHeaderContentsLayout ImportedHeaderContents(Out);
10611062
input_block::SearchPathLayout SearchPath(Out);
10621063
input_block::FileDependencyLayout FileDependency(Out);
1064+
input_block::ParseableInterfaceLayout ParseableInterface(Out);
10631065

10641066
if (options.SerializeOptionsForDebugging) {
10651067
const SearchPathOptions &searchPathOpts = M->getASTContext().SearchPathOpts;
@@ -1081,6 +1083,9 @@ void Serializer::writeInputBlock(const SerializationOptions &options) {
10811083
dep.getPath());
10821084
}
10831085

1086+
if (!options.ParseableInterface.empty())
1087+
ParseableInterface.emit(ScratchRecord, options.ParseableInterface);
1088+
10841089
ModuleDecl::ImportFilter allImportFilter;
10851090
allImportFilter |= ModuleDecl::ImportFilterKind::Public;
10861091
allImportFilter |= ModuleDecl::ImportFilterKind::Private;

trunk/lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ FileUnit *SerializedModuleLoaderBase::loadAST(
400400
// We've loaded the file. Now try to bring it into the AST.
401401
auto fileUnit = new (Ctx) SerializedASTFile(M, *loadedModuleFile,
402402
extendedInfo.isSIB());
403+
fileUnit->setParseableInterface(extendedInfo.getParseableInterface());
403404
M.addFile(*fileUnit);
404405
if (extendedInfo.isTestable())
405406
M.setTestingEnabled();
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend-typecheck %S/basic.swift \
3+
// RUN: -emit-parseable-module-interface-path %t/basic.swiftinterface
4+
// RUN: %target-swift-frontend -emit-ir -module-name Foo %s -I %t -g -o - \
5+
// RUN: | %FileCheck %s
6+
// RUN: %target-swift-frontend -emit-ir -module-name Foo %s -I %t -g -o - \
7+
// RUN: -sdk %t | %FileCheck %s --check-prefix=SDK
8+
9+
import basic
10+
11+
// CHECK: !DIModule(scope: null, name: "basic", includePath: "
12+
// CHECK-SAME: basic.swiftinterface"
13+
14+
// We don;t record any parseable interfaces from the SDK.
15+
// They're in the SDK after all.
16+
// SDK: !DIModule(scope: null, name: "basic", includePath: "
17+
// SDK-SAME: basic{{.*}}.swiftmodule"
18+
19+
20+
func markUsed<T>(_ t: T) {}
21+
markUsed(basic.foo(1, 2))
22+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Note that this test should still "pass" when Swift.swiftinterface has not
2+
// been generated.
3+
4+
// RUN: %empty-directory(%t)
5+
// RUN: not ls %platform-module-dir/Swift.swiftmodule/%target-cpu.swiftinterface || %target-swift-frontend -build-module-from-parseable-interface %platform-module-dir/Swift.swiftmodule/%target-cpu.swiftinterface -parse-stdlib -o %t/Swift.swiftmodule
6+
7+
// REQUIRES: nonexecutable_test

0 commit comments

Comments
 (0)