Skip to content

Commit 6d73dff

Browse files
committed
---
yaml --- r: 345214 b: refs/heads/master c: 015f4ba h: refs/heads/master
1 parent fb13b49 commit 6d73dff

24 files changed

+1333
-205
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: d99d086b1e09cb668aec12736c9f4c3f18f1fc5a
2+
refs/heads/master: 015f4ba8cfaf9f5170b6a1d34025887d1d96b25f
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/Decl.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4977,7 +4977,10 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
49774977
TypeChecked,
49784978

49794979
/// This is a memberwise initializer that will be synthesized by SILGen.
4980-
MemberwiseInitializer
4980+
MemberwiseInitializer,
4981+
4982+
/// Function body text was deserialized from a .swiftmodule.
4983+
Deserialized
49814984

49824985
// This enum currently needs to fit in a 3-bit bitfield.
49834986
};
@@ -4999,6 +5002,9 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
49995002
/// BodyKind::TypeChecked.
50005003
BraceStmt *Body;
50015004

5005+
/// This enum member is active if getBodyKind() is BodyKind::Deserialized.
5006+
StringRef BodyStringRepresentation;
5007+
50025008
/// This enum member is active if getBodyKind() == BodyKind::Synthesize.
50035009
BodySynthesizer Synthesizer;
50045010

@@ -5093,6 +5099,11 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
50935099
return getBodyKind() != BodyKind::None;
50945100
}
50955101

5102+
/// Returns true if the text of this function's body can be retrieved either
5103+
/// by extracting the text from the source buffer or reading the inlinable
5104+
/// body from a deserialized swiftmodule.
5105+
bool hasInlinableBodyText() const;
5106+
50965107
/// Returns the function body, if it was parsed, or nullptr otherwise.
50975108
///
50985109
/// Note that a null return value does not imply that the source code did not
@@ -5156,6 +5167,18 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
51565167
setBodyKind(BodyKind::TypeChecked);
51575168
}
51585169

5170+
/// Gets the body of this function, stripping the unused portions of #if
5171+
/// configs inside the body. If this function was not deserialized from a
5172+
/// .swiftmodule, this body is reconstructed from the original
5173+
/// source buffer.
5174+
StringRef getInlinableBodyText(SmallVectorImpl<char> &scratch) const;
5175+
5176+
void setBodyStringRepresentation(StringRef body) {
5177+
assert(getBodyKind() == BodyKind::None);
5178+
setBodyKind(BodyKind::Deserialized);
5179+
BodyStringRepresentation = body;
5180+
}
5181+
51595182
bool isBodyTypeChecked() const {
51605183
return getBodyKind() == BodyKind::TypeChecked;
51615184
}

trunk/include/swift/AST/PrintOptions.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <vector>
2424

2525
namespace swift {
26+
class ASTPrinter;
2627
class GenericEnvironment;
2728
class CanType;
2829
class Decl;
@@ -356,10 +357,9 @@ struct PrintOptions {
356357
QualifyNestedDeclarations ShouldQualifyNestedDeclarations =
357358
QualifyNestedDeclarations::Never;
358359

359-
/// \brief If this is not \c nullptr then functions (including accessors and
360-
/// constructors) will be printed with a body that is determined by this
361-
/// function.
362-
std::function<std::string(const ValueDecl *)> FunctionBody;
360+
/// \brief If this is not \c nullptr then function bodies (including accessors
361+
/// and constructors) will be printed by this function.
362+
std::function<void(const ValueDecl *, ASTPrinter &)> FunctionBody;
363363

364364
BracketOptions BracketOptions;
365365

trunk/include/swift/SILOptimizer/Utils/Existential.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ struct ConcreteExistentialInfo {
9696
ConcreteExistentialInfo(Operand &ArgOperand, CanType ConcreteType,
9797
ProtocolDecl *Protocol);
9898

99-
ConcreteExistentialInfo(ConcreteExistentialInfo &) = delete;
100-
10199
/// For scenerios where ConcreteExistentialInfo is created using a known
102100
/// ConcreteType and ProtocolDecl, both of InitExistential
103101
/// and ConcreteValue can be null. So there is no need for explicit check for

trunk/include/swift/Serialization/DeclTypeRecordNodes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ OTHER(NORMAL_PROTOCOL_CONFORMANCE_ID, 246)
180180
OTHER(PROTOCOL_CONFORMANCE_XREF, 247)
181181
OTHER(MEMBERS, 248)
182182
OTHER(XREF, 249)
183+
OTHER(INLINABLE_BODY_TEXT, 250)
183184

184185
#undef RECORD
185186
#undef DECLTYPERECORDNODES_HAS_RECORD_VAL

trunk/include/swift/Serialization/ModuleFile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,9 @@ class ModuleFile
884884

885885
/// Reads a foreign error conformance from \c DeclTypeCursor, if present.
886886
Optional<ForeignErrorConvention> maybeReadForeignErrorConvention();
887+
888+
/// Reads inlinable body text from \c DeclTypeCursor, if present.
889+
Optional<StringRef> maybeReadInlinableBodyText();
887890
};
888891

889892
template <typename T, typename RawData>

trunk/include/swift/Serialization/ModuleFormat.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const uint16_t VERSION_MAJOR = 0;
5555
/// describe what change you made. The content of this comment isn't important;
5656
/// it just ensures a conflict if two people change the module format.
5757
/// Don't worry about adhering to the 80-column limit for this line.
58-
const uint16_t VERSION_MINOR = 443; // Last change: serialize unsubstituted type alias type
58+
const uint16_t VERSION_MINOR = 444; // Last change: inlinable body text
5959

6060
using DeclIDField = BCFixed<31>;
6161

@@ -979,8 +979,11 @@ namespace decls_block {
979979
BCVBR<5>, // number of parameter name components
980980
BCArray<IdentifierIDField> // name components,
981981
// followed by TypeID dependencies
982-
// Trailed by its generic parameters, if any, followed by the parameter
983-
// patterns.
982+
// This record is trailed by:
983+
// - its generic parameters, if any
984+
// - its parameter patterns,
985+
// - the foreign error convention, if any
986+
// - inlinable body text, if any
984987
>;
985988

986989
using VarLayout = BCRecordLayout<
@@ -1044,6 +1047,8 @@ namespace decls_block {
10441047
// - its _silgen_name, if any
10451048
// - its generic parameters, if any
10461049
// - body parameter patterns
1050+
// - the foreign error convention, if any
1051+
// - inlinable body text, if any
10471052
>;
10481053

10491054
// TODO: remove the unnecessary FuncDecl components here
@@ -1073,6 +1078,8 @@ namespace decls_block {
10731078
// - its _silgen_name, if any
10741079
// - its generic parameters, if any
10751080
// - body parameter patterns
1081+
// - the foreign error convention, if any
1082+
// - inlinable body text, if any
10761083
>;
10771084

10781085
using PatternBindingLayout = BCRecordLayout<
@@ -1176,6 +1183,12 @@ namespace decls_block {
11761183
BCFixed<1>, // implicit?
11771184
BCFixed<1>, // objc?
11781185
GenericEnvironmentIDField // generic environment
1186+
// This record is trailed by its inlinable body text
1187+
>;
1188+
1189+
using InlinableBodyTextLayout = BCRecordLayout<
1190+
INLINABLE_BODY_TEXT,
1191+
BCBlob // body text
11791192
>;
11801193

11811194
using ParameterListLayout = BCRecordLayout<

0 commit comments

Comments
 (0)