Skip to content

Commit fa4aa26

Browse files
authored
---
yaml --- r: 348776 b: refs/heads/master c: 0746d1e h: refs/heads/master
1 parent b4a8335 commit fa4aa26

File tree

158 files changed

+5649
-4894
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+5649
-4894
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: 262f6864c2d319d668d6243d17595d1bd5a61881
2+
refs/heads/master: 0746d1e896ee6a05b1c80c287a24d201f0a4555f
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/docs/WindowsBuild.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,11 @@ cmake -G "Visual Studio 2017" -A x64 -T "host=x64"^ ...
186186
md "S:\b\lldb"
187187
cd "S:\b\lldb"
188188
cmake -G Ninja^
189+
-DLLVM_DIR="S:/b/llvm/lib/cmake/llvm"^
190+
-DClang_DIR="S:/b/llvm/lib/cmake/clang"^
191+
-DSwift_DIR="S:/b/swift/lib/cmake/swift"^
189192
-DCMAKE_BUILD_TYPE=RelWithDebInfo^
190193
-DLLDB_ALLOW_STATIC_BINDINGS=YES^
191-
-DLLDB_PATH_TO_CLANG_SOURCE="S:\clang"^
192-
-DLLDB_PATH_TO_SWIFT_SOURCE="S:\swift"^
193-
-DLLDB_PATH_TO_CLANG_BUILD="S:\b\llvm"^
194-
-DLLDB_PATH_TO_LLVM_BUILD="S:\b\llvm"^
195-
-DLLDB_PATH_TO_SWIFT_BUILD="S:\b\swift"^
196194
-DLLVM_ENABLE_ASSERTIONS=ON^
197195
-DPYTHON_HOME="%ProgramFiles(x86)%\Microsoft Visual Studio\Shared\Python37_64"^
198196
S:\lldb

trunk/include/swift/AST/DiagnosticConsumer.h

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,17 @@ enum class DiagnosticKind : uint8_t {
3838
Note
3939
};
4040

41-
/// Extra information carried along with a diagnostic, which may or
42-
/// may not be of interest to a given diagnostic consumer.
41+
/// Information about a diagnostic passed to DiagnosticConsumers.
4342
struct DiagnosticInfo {
4443
DiagID ID = DiagID(0);
44+
SourceLoc Loc;
45+
DiagnosticKind Kind;
46+
StringRef FormatString;
47+
ArrayRef<DiagnosticArgument> FormatArgs;
48+
SourceLoc BufferIndirectlyCausingDiagnostic;
49+
50+
/// DiagnosticInfo of notes which are children of this diagnostic, if any
51+
ArrayRef<DiagnosticInfo *> ChildDiagnosticInfo;
4552

4653
/// Represents a fix-it, a replacement of one range of text with another.
4754
class FixIt {
@@ -60,6 +67,24 @@ struct DiagnosticInfo {
6067

6168
/// Extra source ranges that are attached to the diagnostic.
6269
ArrayRef<FixIt> FixIts;
70+
71+
/// This is a note which has a parent error or warning
72+
bool IsChildNote = false;
73+
74+
DiagnosticInfo() {}
75+
76+
DiagnosticInfo(DiagID ID, SourceLoc Loc, DiagnosticKind Kind,
77+
StringRef FormatString,
78+
ArrayRef<DiagnosticArgument> FormatArgs,
79+
SourceLoc BufferIndirectlyCausingDiagnostic,
80+
ArrayRef<DiagnosticInfo *> ChildDiagnosticInfo,
81+
ArrayRef<CharSourceRange> Ranges, ArrayRef<FixIt> FixIts,
82+
bool IsChildNote)
83+
: ID(ID), Loc(Loc), Kind(Kind), FormatString(FormatString),
84+
FormatArgs(FormatArgs),
85+
BufferIndirectlyCausingDiagnostic(BufferIndirectlyCausingDiagnostic),
86+
ChildDiagnosticInfo(ChildDiagnosticInfo), Ranges(Ranges),
87+
FixIts(FixIts), IsChildNote(IsChildNote) {}
6388
};
6489

6590
/// Abstract interface for classes that present diagnostics to the user.

trunk/include/swift/AST/DiagnosticEngine.h

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,9 @@ namespace swift {
337337
SmallVector<DiagnosticArgument, 3> Args;
338338
SmallVector<CharSourceRange, 2> Ranges;
339339
SmallVector<FixIt, 2> FixIts;
340+
std::vector<Diagnostic> ChildNotes;
340341
SourceLoc Loc;
342+
bool IsChildNote = false;
341343
const Decl *Decl = nullptr;
342344

343345
friend DiagnosticEngine;
@@ -362,10 +364,13 @@ namespace swift {
362364
ArrayRef<DiagnosticArgument> getArgs() const { return Args; }
363365
ArrayRef<CharSourceRange> getRanges() const { return Ranges; }
364366
ArrayRef<FixIt> getFixIts() const { return FixIts; }
367+
ArrayRef<Diagnostic> getChildNotes() const { return ChildNotes; }
368+
bool isChildNote() const { return IsChildNote; }
365369
SourceLoc getLoc() const { return Loc; }
366370
const class Decl *getDecl() const { return Decl; }
367371

368372
void setLoc(SourceLoc loc) { Loc = loc; }
373+
void setIsChildNote(bool isChildNote) { IsChildNote = isChildNote; }
369374
void setDecl(const class Decl *decl) { Decl = decl; }
370375

371376
/// Returns true if this object represents a particular diagnostic.
@@ -386,6 +391,8 @@ namespace swift {
386391
void addFixIt(FixIt &&F) {
387392
FixIts.push_back(std::move(F));
388393
}
394+
395+
void addChildNote(Diagnostic &&D);
389396
};
390397

391398
/// Describes an in-flight diagnostic, which is currently active
@@ -665,7 +672,8 @@ namespace swift {
665672

666673
friend class InFlightDiagnostic;
667674
friend class DiagnosticTransaction;
668-
675+
friend class CompoundDiagnosticTransaction;
676+
669677
public:
670678
explicit DiagnosticEngine(SourceManager &SourceMgr)
671679
: SourceMgr(SourceMgr), ActiveDiagnostic(),
@@ -878,6 +886,15 @@ namespace swift {
878886
return diagnose(decl, Diagnostic(id, std::move(args)...));
879887
}
880888

889+
/// Emit a parent diagnostic and attached notes.
890+
///
891+
/// \param parentDiag An InFlightDiagnostic representing the parent diag.
892+
///
893+
/// \param builder A closure which builds and emits notes to be attached to
894+
/// the parent diag.
895+
void diagnoseWithNotes(InFlightDiagnostic parentDiag,
896+
llvm::function_ref<void(void)> builder);
897+
881898
/// \returns true if diagnostic is marked with PointsToFirstBadToken
882899
/// option.
883900
bool isDiagnosticPointsToFirstBadToken(DiagID id) const;
@@ -905,6 +922,10 @@ namespace swift {
905922
/// Retrieve the active diagnostic.
906923
Diagnostic &getActiveDiagnostic() { return *ActiveDiagnostic; }
907924

925+
/// Generate DiagnosticInfo for a Diagnostic to be passed to consumers.
926+
Optional<DiagnosticInfo>
927+
diagnosticInfoForDiagnostic(const Diagnostic &diagnostic);
928+
908929
/// Send \c diag to all diagnostic consumers.
909930
void emitDiagnostic(const Diagnostic &diag);
910931

@@ -945,6 +966,7 @@ namespace swift {
945966
/// in LIFO order. An open transaction is implicitly committed upon
946967
/// destruction.
947968
class DiagnosticTransaction {
969+
protected:
948970
DiagnosticEngine &Engine;
949971

950972
/// How many tentative diagnostics there were when the transaction
@@ -968,7 +990,6 @@ namespace swift {
968990
Depth(Engine.TransactionCount),
969991
IsOpen(true)
970992
{
971-
assert(!Engine.ActiveDiagnostic);
972993
Engine.TransactionCount++;
973994
}
974995

@@ -1011,6 +1032,61 @@ namespace swift {
10111032
"transactions must be closed LIFO");
10121033
}
10131034
};
1035+
1036+
/// Represents a diagnostic transaction which constructs a compound diagnostic
1037+
/// from any diagnostics emitted inside. A compound diagnostic consists of a
1038+
/// parent error, warning, or remark followed by a variable number of child
1039+
/// notes. The semantics are otherwise the same as a regular
1040+
/// DiagnosticTransaction.
1041+
class CompoundDiagnosticTransaction : public DiagnosticTransaction {
1042+
public:
1043+
explicit CompoundDiagnosticTransaction(DiagnosticEngine &engine)
1044+
: DiagnosticTransaction(engine) {}
1045+
1046+
~CompoundDiagnosticTransaction() {
1047+
if (IsOpen) {
1048+
commit();
1049+
}
1050+
1051+
if (Depth == 0) {
1052+
Engine.TransactionStrings.clear();
1053+
Engine.TransactionAllocator.Reset();
1054+
}
1055+
}
1056+
1057+
void commit() {
1058+
assert(PrevDiagnostics < Engine.TentativeDiagnostics.size() &&
1059+
"CompoundDiagnosticTransaction must contain at least one diag");
1060+
1061+
// The first diagnostic is assumed to be the parent. If this is not an
1062+
// error or warning, we'll assert later when trying to add children.
1063+
Diagnostic &parent = Engine.TentativeDiagnostics[PrevDiagnostics];
1064+
1065+
// Associate the children with the parent.
1066+
for (auto diag =
1067+
Engine.TentativeDiagnostics.begin() + PrevDiagnostics + 1;
1068+
diag != Engine.TentativeDiagnostics.end(); ++diag) {
1069+
diag->setIsChildNote(true);
1070+
parent.addChildNote(std::move(*diag));
1071+
}
1072+
1073+
// Erase the children, they'll be emitted alongside their parent.
1074+
Engine.TentativeDiagnostics.erase(Engine.TentativeDiagnostics.begin() +
1075+
PrevDiagnostics + 1,
1076+
Engine.TentativeDiagnostics.end());
1077+
1078+
DiagnosticTransaction::commit();
1079+
}
1080+
};
1081+
1082+
inline void
1083+
DiagnosticEngine::diagnoseWithNotes(InFlightDiagnostic parentDiag,
1084+
llvm::function_ref<void(void)> builder) {
1085+
CompoundDiagnosticTransaction transaction(*this);
1086+
parentDiag.flush();
1087+
builder();
1088+
}
1089+
10141090
} // end namespace swift
10151091

10161092
#endif

trunk/include/swift/AST/Identifier.h

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,26 @@ class Identifier {
5656

5757
const char *Pointer;
5858

59+
public:
60+
enum : size_t {
61+
NumLowBitsAvailable = 2,
62+
RequiredAlignment = 1 << NumLowBitsAvailable,
63+
SpareBitMask = ((intptr_t)1 << NumLowBitsAvailable) - 1
64+
};
65+
66+
private:
5967
/// Constructor, only accessible by ASTContext, which handles the uniquing.
60-
explicit Identifier(const char *Ptr) : Pointer(Ptr) {}
68+
explicit Identifier(const char *Ptr) : Pointer(Ptr) {
69+
assert(((uintptr_t)Ptr & SpareBitMask) == 0
70+
&& "Identifier pointer does not use any spare bits");
71+
}
72+
73+
/// A type with the alignment expected of a valid \c Identifier::Pointer .
74+
struct alignas(uint32_t) Aligner {};
75+
76+
static_assert(alignof(Aligner) >= RequiredAlignment,
77+
"Identifier table will provide enough spare bits");
78+
6179
public:
6280
explicit Identifier() : Pointer(nullptr) {}
6381

@@ -153,12 +171,15 @@ class Identifier {
153171
bool operator<(Identifier RHS) const { return Pointer < RHS.Pointer; }
154172

155173
static Identifier getEmptyKey() {
156-
return Identifier((const char*)
157-
llvm::DenseMapInfo<const void*>::getEmptyKey());
174+
uintptr_t Val = static_cast<uintptr_t>(-1);
175+
Val <<= NumLowBitsAvailable;
176+
return Identifier((const char*)Val);
158177
}
178+
159179
static Identifier getTombstoneKey() {
160-
return Identifier((const char*)
161-
llvm::DenseMapInfo<const void*>::getTombstoneKey());
180+
uintptr_t Val = static_cast<uintptr_t>(-2);
181+
Val <<= NumLowBitsAvailable;
182+
return Identifier((const char*)Val);
162183
}
163184

164185
private:
@@ -202,7 +223,7 @@ namespace llvm {
202223
static inline swift::Identifier getFromVoidPointer(void *P) {
203224
return swift::Identifier::getFromOpaquePointer(P);
204225
}
205-
enum { NumLowBitsAvailable = 2 };
226+
enum { NumLowBitsAvailable = swift::Identifier::NumLowBitsAvailable };
206227
};
207228

208229
} // end namespace llvm
@@ -221,15 +242,15 @@ class DeclBaseName {
221242
};
222243

223244
private:
224-
/// In a special DeclName represenenting a subscript, this opaque pointer
245+
/// In a special DeclName representing a subscript, this opaque pointer
225246
/// is used as the data of the base name identifier.
226247
/// This is an implementation detail that should never leak outside of
227248
/// DeclName.
228-
static void *SubscriptIdentifierData;
249+
static const Identifier::Aligner SubscriptIdentifierData;
229250
/// As above, for special constructor DeclNames.
230-
static void *ConstructorIdentifierData;
251+
static const Identifier::Aligner ConstructorIdentifierData;
231252
/// As above, for special destructor DeclNames.
232-
static void *DestructorIdentifierData;
253+
static const Identifier::Aligner DestructorIdentifierData;
233254

234255
Identifier Ident;
235256

@@ -239,23 +260,23 @@ class DeclBaseName {
239260
DeclBaseName(Identifier I) : Ident(I) {}
240261

241262
static DeclBaseName createSubscript() {
242-
return DeclBaseName(Identifier((const char *)SubscriptIdentifierData));
263+
return DeclBaseName(Identifier((const char *)&SubscriptIdentifierData));
243264
}
244265

245266
static DeclBaseName createConstructor() {
246-
return DeclBaseName(Identifier((const char *)ConstructorIdentifierData));
267+
return DeclBaseName(Identifier((const char *)&ConstructorIdentifierData));
247268
}
248269

249270
static DeclBaseName createDestructor() {
250-
return DeclBaseName(Identifier((const char *)DestructorIdentifierData));
271+
return DeclBaseName(Identifier((const char *)&DestructorIdentifierData));
251272
}
252273

253274
Kind getKind() const {
254-
if (Ident.get() == SubscriptIdentifierData) {
275+
if (Ident.get() == (const char *)&SubscriptIdentifierData) {
255276
return Kind::Subscript;
256-
} else if (Ident.get() == ConstructorIdentifierData) {
277+
} else if (Ident.get() == (const char *)&ConstructorIdentifierData) {
257278
return Kind::Constructor;
258-
} else if (Ident.get() == DestructorIdentifierData) {
279+
} else if (Ident.get() == (const char *)&DestructorIdentifierData) {
259280
return Kind::Destructor;
260281
} else {
261282
return Kind::Normal;
@@ -720,7 +741,7 @@ namespace llvm {
720741
static inline swift::DeclName getFromVoidPointer(void *ptr) {
721742
return swift::DeclName::getFromOpaqueValue(ptr);
722743
}
723-
enum { NumLowBitsAvailable = 0 };
744+
enum { NumLowBitsAvailable = PointerLikeTypeTraits<swift::DeclBaseName>::NumLowBitsAvailable - 2 };
724745
};
725746

726747
// DeclNames hash just like pointers.

trunk/include/swift/ClangImporter/ClangImporterOptions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ class ClangImporterOptions {
103103
using llvm::hash_combine;
104104

105105
auto Code = hash_value(ModuleCachePath);
106-
// ExtraArgs ignored - already considered in Clang's module hashing.
106+
Code = hash_combine(Code, llvm::hash_combine_range(ExtraArgs.begin(),
107+
ExtraArgs.end()));
107108
Code = hash_combine(Code, OverrideResourceDir);
108109
Code = hash_combine(Code, TargetCPU);
109110
Code = hash_combine(Code, BridgingHeader);

trunk/include/swift/Frontend/PrintingDiagnosticConsumer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ class PrintingDiagnosticConsumer : public DiagnosticConsumer {
5050
bool didErrorOccur() {
5151
return DidErrorOccur;
5252
}
53+
54+
private:
55+
void printDiagnostic(SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
56+
StringRef FormatString,
57+
ArrayRef<DiagnosticArgument> FormatArgs,
58+
const DiagnosticInfo &Info,
59+
SourceLoc bufferIndirectlyCausingDiagnostic);
5360
};
5461

5562
}

trunk/include/swift/Reflection/ReflectionContext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ class ReflectionContext
393393
auto SecBuf = this->getReader().readBytes(
394394
RemoteAddress(SectionHdrAddress + (I * SectionEntrySize)),
395395
SectionEntrySize);
396+
if (!SecBuf)
397+
return false;
396398
auto SecHdr =
397399
reinterpret_cast<const typename T::Section *>(SecBuf.get());
398400
SecHdrVec.push_back(SecHdr);

trunk/include/swift/Reflection/TypeRefBuilder.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,8 @@ class TypeRefBuilder {
376376
// Try to resolve to the underlying type, if we can.
377377
if (opaqueDescriptor->getKind() ==
378378
Node::Kind::OpaqueTypeDescriptorSymbolicReference) {
379-
if (!OpaqueUnderlyingTypeReader)
380-
return nullptr;
381-
382379
auto underlyingTy = OpaqueUnderlyingTypeReader(
383-
(const void *)opaqueDescriptor->getIndex(), ordinal);
380+
opaqueDescriptor->getIndex(), ordinal);
384381

385382
if (!underlyingTy)
386383
return nullptr;
@@ -598,7 +595,7 @@ class TypeRefBuilder {
598595
unsigned PointerSize;
599596
std::function<Demangle::Node * (RemoteRef<char>)>
600597
TypeRefDemangler;
601-
std::function<const TypeRef* (const void*, unsigned)>
598+
std::function<const TypeRef* (uint64_t, unsigned)>
602599
OpaqueUnderlyingTypeReader;
603600

604601
public:
@@ -613,9 +610,8 @@ class TypeRefBuilder {
613610
Dem, /*useOpaqueTypeSymbolicReferences*/ true);
614611
}),
615612
OpaqueUnderlyingTypeReader(
616-
[&reader](const void *descriptor, unsigned ordinal) -> const TypeRef* {
617-
auto context = (typename Runtime::StoredPointer)descriptor;
618-
return reader.readUnderlyingTypeForOpaqueTypeDescriptor(context,
613+
[&reader](uint64_t descriptorAddr, unsigned ordinal) -> const TypeRef* {
614+
return reader.readUnderlyingTypeForOpaqueTypeDescriptor(descriptorAddr,
619615
ordinal);
620616
})
621617
{}

0 commit comments

Comments
 (0)