Skip to content

Commit 2c7c3a6

Browse files
authored
---
yaml --- r: 347487 b: refs/heads/master c: c79458a h: refs/heads/master i: 347485: 8ba00b8 347483: f108b5a 347479: 9540b73 347471: 233be31 347455: f8ffa08
1 parent 60bffeb commit 2c7c3a6

37 files changed

+764
-207
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: 36b9cac6a1c92f74c0ce61b600558b370569ebfc
2+
refs/heads/master: c79458ad8c33ae47ae163a518b0ca4dec467bf62
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/DebuggerClient.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ class DebuggerClient {
6161
SourceLoc Loc, bool IsTypeLookup,
6262
ResultVector &RV) = 0;
6363

64+
/// The following functions allow the debugger to modify the results of a
65+
/// qualfied lookup as needed. These methods may add, remove or modify the
66+
/// entries in `decls`. See the corresponding DeclContext::lookupInXYZ
67+
/// functions defined in NameLookup.cpp for more context.
68+
///
69+
70+
virtual void finishLookupInNominals(const DeclContext *dc,
71+
ArrayRef<NominalTypeDecl *> types,
72+
DeclName member, NLOptions options,
73+
SmallVectorImpl<ValueDecl *> &decls) {}
74+
75+
virtual void finishLookupInModule(const DeclContext *dc, ModuleDecl *module,
76+
DeclName member, NLOptions options,
77+
SmallVectorImpl<ValueDecl *> &decls) {}
78+
79+
virtual void finishLookupInAnyObject(const DeclContext *dc, DeclName member,
80+
NLOptions options,
81+
SmallVectorImpl<ValueDecl *> &decls) {}
82+
6483
/// When evaluating an expression in the context of an existing source file,
6584
/// we may want to prefer declarations from that source file.
6685
/// The DebuggerClient can return a private-discriminator to tell lookup to

trunk/include/swift/AST/NameLookup.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,10 @@ void forAllVisibleModules(const DeclContext *DC, const Fn &fn) {
367367
->forAllVisibleModules(ModuleDecl::AccessPathTy(), fn);
368368
}
369369

370-
/// Only name lookup has gathered a set of results, perform any necessary
370+
/// Once name lookup has gathered a set of results, perform any necessary
371371
/// steps to prune the result set before returning it to the caller.
372-
bool finishLookup(const DeclContext *dc, NLOptions options,
373-
SmallVectorImpl<ValueDecl *> &decls);
372+
void pruneLookupResultSet(const DeclContext *dc, NLOptions options,
373+
SmallVectorImpl<ValueDecl *> &decls);
374374

375375
/// Do nothing if debugClient is null.
376376
template <typename Result>

trunk/include/swift/AST/Pattern.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ class alignas(8) Pattern {
221221

222222
void print(llvm::raw_ostream &OS,
223223
const PrintOptions &Options = PrintOptions()) const;
224-
void dump() const;
224+
LLVM_ATTRIBUTE_DEPRECATED(
225+
void dump() const LLVM_ATTRIBUTE_USED,
226+
"only for use within the debugger");
225227

226228
/// walk - This recursively walks the AST rooted at this pattern.
227229
Pattern *walk(ASTWalker &walker);

trunk/include/swift/AST/TypeRepr.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ class alignas(8) TypeRepr {
160160

161161
void print(raw_ostream &OS, const PrintOptions &Opts = PrintOptions()) const;
162162
void print(ASTPrinter &Printer, const PrintOptions &Opts) const;
163-
void dump() const;
163+
LLVM_ATTRIBUTE_DEPRECATED(
164+
void dump() const LLVM_ATTRIBUTE_USED,
165+
"only for use within the debugger");
164166

165167
/// Clone the given type representation.
166168
TypeRepr *clone(const ASTContext &ctx) const;

trunk/include/swift/Reflection/ReflectionContext.h

Lines changed: 52 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class ReflectionContext
202202
RangeEnd - RangeStart);
203203

204204
auto findMachOSectionByName = [&](std::string Name)
205-
-> std::pair<std::pair<const char *, const char *>, uint64_t> {
205+
-> std::pair<const char *, const char *> {
206206
for (unsigned I = 0; I < NumSect; ++I) {
207207
auto S = reinterpret_cast<typename T::Section *>(
208208
SectionsBuf + (I * sizeof(typename T::Section)));
@@ -213,9 +213,9 @@ class ReflectionContext
213213
auto LocalSectStart =
214214
reinterpret_cast<const char *>(SectBufData + RemoteSecStart - RangeStart);
215215
auto LocalSectEnd = reinterpret_cast<const char *>(LocalSectStart + S->size);
216-
return {{LocalSectStart, LocalSectEnd}, 0};
216+
return {LocalSectStart, LocalSectEnd};
217217
}
218-
return {{nullptr, nullptr}, 0};
218+
return {nullptr, nullptr};
219219
};
220220

221221
auto FieldMdSec = findMachOSectionByName("__swift5_fieldmd");
@@ -225,24 +225,24 @@ class ReflectionContext
225225
auto TypeRefMdSec = findMachOSectionByName("__swift5_typeref");
226226
auto ReflStrMdSec = findMachOSectionByName("__swift5_reflstr");
227227

228-
if (FieldMdSec.first.first == nullptr &&
229-
AssocTySec.first.first == nullptr &&
230-
BuiltinTySec.first.first == nullptr &&
231-
CaptureSec.first.first == nullptr &&
232-
TypeRefMdSec.first.first == nullptr &&
233-
ReflStrMdSec.first.first == nullptr)
228+
if (FieldMdSec.first == nullptr &&
229+
AssocTySec.first == nullptr &&
230+
BuiltinTySec.first == nullptr &&
231+
CaptureSec.first == nullptr &&
232+
TypeRefMdSec.first == nullptr &&
233+
ReflStrMdSec.first == nullptr)
234234
return false;
235235

236236
auto LocalStartAddress = reinterpret_cast<uint64_t>(SectBuf.get());
237237
auto RemoteStartAddress = static_cast<uint64_t>(RangeStart);
238238

239239
ReflectionInfo info = {
240-
{{FieldMdSec.first.first, FieldMdSec.first.second}, 0},
241-
{{AssocTySec.first.first, AssocTySec.first.second}, 0},
242-
{{BuiltinTySec.first.first, BuiltinTySec.first.second}, 0},
243-
{{CaptureSec.first.first, CaptureSec.first.second}, 0},
244-
{{TypeRefMdSec.first.first, TypeRefMdSec.first.second}, 0},
245-
{{ReflStrMdSec.first.first, ReflStrMdSec.first.second}, 0},
240+
{{FieldMdSec.first, FieldMdSec.second}, 0},
241+
{{AssocTySec.first, AssocTySec.second}, 0},
242+
{{BuiltinTySec.first, BuiltinTySec.second}, 0},
243+
{{CaptureSec.first, CaptureSec.second}, 0},
244+
{{TypeRefMdSec.first, TypeRefMdSec.second}, 0},
245+
{{ReflStrMdSec.first, ReflStrMdSec.second}, 0},
246246
LocalStartAddress,
247247
RemoteStartAddress};
248248

@@ -310,7 +310,7 @@ class ReflectionContext
310310
sizeof(llvm::object::coff_section) * COFFFileHdr->NumberOfSections);
311311

312312
auto findCOFFSectionByName = [&](llvm::StringRef Name)
313-
-> std::pair<std::pair<const char *, const char *>, uint32_t> {
313+
-> std::pair<const char *, const char *> {
314314
for (size_t i = 0; i < COFFFileHdr->NumberOfSections; ++i) {
315315
const llvm::object::coff_section *COFFSec =
316316
reinterpret_cast<const llvm::object::coff_section *>(
@@ -336,45 +336,43 @@ class ReflectionContext
336336
End -= 8;
337337
}
338338

339-
return {{Begin, End}, 0};
339+
return {Begin, End};
340340
}
341-
return {{nullptr, nullptr}, 0};
341+
return {nullptr, nullptr};
342342
};
343343

344-
std::pair<std::pair<const char *, const char *>, uint32_t> CaptureSec =
344+
std::pair<const char *, const char *> CaptureSec =
345345
findCOFFSectionByName(".sw5cptr");
346-
std::pair<std::pair<const char *, const char *>, uint32_t> TypeRefMdSec =
346+
std::pair<const char *, const char *> TypeRefMdSec =
347347
findCOFFSectionByName(".sw5tyrf");
348-
std::pair<std::pair<const char *, const char *>, uint32_t> FieldMdSec =
348+
std::pair<const char *, const char *> FieldMdSec =
349349
findCOFFSectionByName(".sw5flmd");
350-
std::pair<std::pair<const char *, const char *>, uint32_t> AssocTySec =
350+
std::pair<const char *, const char *> AssocTySec =
351351
findCOFFSectionByName(".sw5asty");
352-
std::pair<std::pair<const char *, const char *>, uint32_t> BuiltinTySec =
352+
std::pair<const char *, const char *> BuiltinTySec =
353353
findCOFFSectionByName(".sw5bltn");
354-
std::pair<std::pair<const char *, const char *>, uint32_t> ReflStrMdSec =
354+
std::pair<const char *, const char *> ReflStrMdSec =
355355
findCOFFSectionByName(".sw5rfst");
356356

357-
if (FieldMdSec.first.first == nullptr &&
358-
AssocTySec.first.first == nullptr &&
359-
BuiltinTySec.first.first == nullptr &&
360-
CaptureSec.first.first == nullptr &&
361-
TypeRefMdSec.first.first == nullptr &&
362-
ReflStrMdSec.first.first == nullptr)
357+
if (FieldMdSec.first == nullptr &&
358+
AssocTySec.first == nullptr &&
359+
BuiltinTySec.first == nullptr &&
360+
CaptureSec.first == nullptr &&
361+
TypeRefMdSec.first == nullptr &&
362+
ReflStrMdSec.first == nullptr)
363363
return false;
364+
364365
auto LocalStartAddress = reinterpret_cast<uintptr_t>(DOSHdrBuf.get());
365366
auto RemoteStartAddress =
366367
static_cast<uintptr_t>(ImageStart.getAddressData());
367368

368369
ReflectionInfo Info = {
369-
{{FieldMdSec.first.first, FieldMdSec.first.second}, FieldMdSec.second},
370-
{{AssocTySec.first.first, AssocTySec.first.second}, AssocTySec.second},
371-
{{BuiltinTySec.first.first, BuiltinTySec.first.second},
372-
BuiltinTySec.second},
373-
{{CaptureSec.first.first, CaptureSec.first.second}, CaptureSec.second},
374-
{{TypeRefMdSec.first.first, TypeRefMdSec.first.second},
375-
TypeRefMdSec.second},
376-
{{ReflStrMdSec.first.first, ReflStrMdSec.first.second},
377-
ReflStrMdSec.second},
370+
{{FieldMdSec.first, FieldMdSec.second}, 0},
371+
{{AssocTySec.first, AssocTySec.second}, 0},
372+
{{BuiltinTySec.first, BuiltinTySec.second}, 0},
373+
{{CaptureSec.first, CaptureSec.second}, 0},
374+
{{TypeRefMdSec.first, TypeRefMdSec.second}, 0},
375+
{{ReflStrMdSec.first, ReflStrMdSec.second}, 0},
378376
LocalStartAddress,
379377
RemoteStartAddress};
380378
this->addReflectionInfo(Info);
@@ -450,7 +448,7 @@ class ReflectionContext
450448
auto StrTab = reinterpret_cast<const char *>(StrTabBuf.get());
451449

452450
auto findELFSectionByName = [&](std::string Name)
453-
-> std::pair<std::pair<const char *, const char *>, uint64_t> {
451+
-> std::pair<const char *, const char *> {
454452
// Now for all the sections, find their name.
455453
for (const typename T::Section *Hdr : SecHdrVec) {
456454
uint32_t Offset = Hdr->sh_name;
@@ -462,9 +460,9 @@ class ReflectionContext
462460
auto SecSize = Hdr->sh_size;
463461
auto SecBuf = this->getReader().readBytes(SecStart, SecSize);
464462
auto SecContents = reinterpret_cast<const char *>(SecBuf.get());
465-
return {{SecContents, SecContents + SecSize}, 0};
463+
return {SecContents, SecContents + SecSize};
466464
}
467-
return {{nullptr, nullptr}, 0};
465+
return {nullptr, nullptr};
468466
};
469467

470468
auto FieldMdSec = findELFSectionByName("swift5_fieldmd");
@@ -476,28 +474,25 @@ class ReflectionContext
476474

477475
// We succeed if at least one of the sections is present in the
478476
// ELF executable.
479-
if (FieldMdSec.first.first == nullptr &&
480-
AssocTySec.first.first == nullptr &&
481-
BuiltinTySec.first.first == nullptr &&
482-
CaptureSec.first.first == nullptr &&
483-
TypeRefMdSec.first.first == nullptr &&
484-
ReflStrMdSec.first.first == nullptr)
477+
if (FieldMdSec.first == nullptr &&
478+
AssocTySec.first == nullptr &&
479+
BuiltinTySec.first == nullptr &&
480+
CaptureSec.first == nullptr &&
481+
TypeRefMdSec.first == nullptr &&
482+
ReflStrMdSec.first == nullptr)
485483
return false;
486484

487485
auto LocalStartAddress = reinterpret_cast<uint64_t>(Buf.get());
488486
auto RemoteStartAddress =
489487
static_cast<uint64_t>(ImageStart.getAddressData());
490488

491489
ReflectionInfo info = {
492-
{{FieldMdSec.first.first, FieldMdSec.first.second}, FieldMdSec.second},
493-
{{AssocTySec.first.first, AssocTySec.first.second}, AssocTySec.second},
494-
{{BuiltinTySec.first.first, BuiltinTySec.first.second},
495-
BuiltinTySec.second},
496-
{{CaptureSec.first.first, CaptureSec.first.second}, CaptureSec.second},
497-
{{TypeRefMdSec.first.first, TypeRefMdSec.first.second},
498-
TypeRefMdSec.second},
499-
{{ReflStrMdSec.first.first, ReflStrMdSec.first.second},
500-
ReflStrMdSec.second},
490+
{{FieldMdSec.first, FieldMdSec.second}, 0},
491+
{{AssocTySec.first, AssocTySec.second}, 0},
492+
{{BuiltinTySec.first, BuiltinTySec.second}, 0},
493+
{{CaptureSec.first, CaptureSec.second}, 0},
494+
{{TypeRefMdSec.first, TypeRefMdSec.second}, 0},
495+
{{ReflStrMdSec.first, ReflStrMdSec.second}, 0},
501496
LocalStartAddress,
502497
RemoteStartAddress};
503498

trunk/include/swift/SIL/SILLocation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,8 @@ class MandatoryInlinedLocation : public SILLocation {
687687
: SILLocation(D, MandatoryInlinedKind, F) {}
688688
MandatoryInlinedLocation(SourceLoc L, unsigned F)
689689
: SILLocation(L, MandatoryInlinedKind, F) {}
690+
MandatoryInlinedLocation(DebugLoc L, unsigned F)
691+
: SILLocation(L, MandatoryInlinedKind, F) {}
690692
};
691693

692694
/// Used on the instruction performing auto-generated cleanup such as

trunk/include/swift/Serialization/SerializedModuleLoader.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ class SerializedModuleLoaderBase : public ModuleLoader {
5151
std::unique_ptr<llvm::MemoryBuffer> *moduleDocBuffer,
5252
bool &isFramework);
5353

54+
/// Attempts to search the provided directory for a loadable serialized
55+
/// .swiftmodule with the provided `ModuleFilename`. Subclasses must
56+
/// override this method to perform their custom module lookup behavior.
57+
///
58+
/// If such a module could not be loaded, the subclass must return a
59+
/// `std::error_code` indicating the failure. There are two specific error
60+
/// codes that will be treated specially:
61+
/// - `errc::no_such_file_or_directory`: The module loader will stop looking
62+
/// for loadable modules and will diagnose the lookup failure.
63+
/// - `errc::not_supported`: The module loader will stop looking for loadable
64+
/// modules and will defer to the remaining module loaders to look up this
65+
/// module.
5466
virtual std::error_code findModuleFilesInDirectory(
5567
AccessPathElem ModuleID, StringRef DirPath, StringRef ModuleFilename,
5668
StringRef ModuleDocFilename,

trunk/lib/AST/ASTPrinter.cpp

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,33 @@ void PrintAST::printTypedPattern(const TypedPattern *TP) {
985985
printTypeLoc(TP->getTypeLoc());
986986
}
987987

988+
/// Determines if we are required to print the name of a property declaration,
989+
/// or if we can elide it by printing a '_' instead.
990+
static bool mustPrintPropertyName(VarDecl *decl, PrintOptions opts) {
991+
// If we're not allowed to omit the name, we must print it.
992+
if (!opts.OmitNameOfInaccessibleProperties) return true;
993+
994+
// If it contributes to the parent's storage, we must print it because clients
995+
// need to be able to directly access the storage.
996+
// FIXME: We might be able to avoid printing names for some of these
997+
// if we serialized references to them using field indices.
998+
if (contributesToParentTypeStorage(decl)) return true;
999+
1000+
// If it's public or @usableFromInline, we must print the name because it's a
1001+
// visible entry-point.
1002+
if (isPublicOrUsableFromInline(decl)) return true;
1003+
1004+
// If it has an initial value, we must print the name because it's used in
1005+
// the mangled name of the initializer expression generator function.
1006+
// FIXME: We _could_ figure out a way to generate an entry point
1007+
// for the initializer expression without revealing the name. We just
1008+
// don't have a mangling for it.
1009+
if (decl->hasInitialValue()) return true;
1010+
1011+
// If none of those are true, we can elide the name of the variable.
1012+
return false;
1013+
}
1014+
9881015
void PrintAST::printPattern(const Pattern *pattern) {
9891016
switch (pattern->getKind()) {
9901017
case PatternKind::Any:
@@ -995,16 +1022,13 @@ void PrintAST::printPattern(const Pattern *pattern) {
9951022
auto named = cast<NamedPattern>(pattern);
9961023
auto decl = named->getDecl();
9971024
recordDeclLoc(decl, [&]{
998-
if (Options.OmitNameOfInaccessibleProperties &&
999-
contributesToParentTypeStorage(decl) &&
1000-
!isPublicOrUsableFromInline(decl) &&
1001-
// FIXME: We need to figure out a way to generate an entry point
1002-
// for the initializer expression without revealing the name.
1003-
!decl->hasInitialValue())
1004-
Printer << "_";
1005-
else
1025+
// FIXME: This always returns true now, because of the FIXMEs listed in
1026+
// mustPrintPropertyName.
1027+
if (mustPrintPropertyName(decl, Options))
10061028
Printer.printName(named->getBoundName());
1007-
});
1029+
else
1030+
Printer << "_";
1031+
});
10081032
break;
10091033
}
10101034

0 commit comments

Comments
 (0)