[sdk-api-digester] Record whether a value decl is static.

Changing a static member to a non-static one, or the other way around,
can be source-breaking.
This commit is contained in:
Xi Ge
2016-10-21 14:08:33 -07:00
parent d068e94bbe
commit b8ee47c80b
4 changed files with 18 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
public struct S1 {
public func foo1() {}
public static func foo1() {}
mutating public func foo2() {}
internal func foo3() {}
private func foo4() {}
@@ -7,5 +7,5 @@ public struct S1 {
}
public class C1 {
open func foo1() {}
open class func foo1() {}
}

View File

@@ -17,9 +17,10 @@
"name": "foo1",
"printedName": "foo1()",
"declKind": "Func",
"usr": "s:FV4cake2S14foo1FT_T_",
"usr": "s:ZFV4cake2S14foo1FT_T_",
"location": "",
"moduleName": "cake",
"static": true,
"children": [
{
"kind": "TypeNominal",
@@ -77,9 +78,10 @@
"name": "foo1",
"printedName": "foo1()",
"declKind": "Func",
"usr": "s:FC4cake2C14foo1FT_T_",
"usr": "s:ZFC4cake2C14foo1FT_T_",
"location": "",
"moduleName": "cake",
"static": true,
"children": [
{
"kind": "TypeNominal",

View File

@@ -68,6 +68,7 @@ KEY(printedName)
KEY(moduleName)
KEY(throwing)
KEY(mutating)
KEY(static)
KEY(typeAttributes)
KEY(declAttributes)
KEY(declKind)

View File

@@ -265,6 +265,7 @@ struct SDKNodeInitInfo {
StringRef ModuleName;
bool IsThrowing = false;
bool IsMutating = false;
bool IsStatic = false;
Optional<uint8_t> SelfIndex;
std::vector<SDKDeclAttrKind> DeclAttrs;
std::vector<TypeAttrKind> TypeAttrs;
@@ -326,12 +327,14 @@ class SDKNodeDecl : public SDKNode {
StringRef Location;
StringRef ModuleName;
std::vector<SDKDeclAttrKind> DeclAttributes;
bool IsStatic;
bool hasDeclAttribute(SDKDeclAttrKind DAKind) const;
protected:
SDKNodeDecl(SDKNodeInitInfo Info, SDKNodeKind Kind) : SDKNode(Info, Kind),
DKind(Info.DKind), Usr(Info.USR), Location(Info.Location),
ModuleName(Info.ModuleName), DeclAttributes(Info.DeclAttrs) {}
ModuleName(Info.ModuleName), DeclAttributes(Info.DeclAttrs),
IsStatic(Info.IsStatic) {}
public:
StringRef getUsr() const { return Usr; }
@@ -346,6 +349,7 @@ public:
StringRef getFullyQualifiedName();
bool isSDKPrivate();
bool isDeprecated();
bool isStatic() const { return IsStatic; };
};
class SDKNodeType : public SDKNode {
@@ -774,6 +778,8 @@ NodeUniquePtr SDKNode::constructSDKNode(llvm::yaml::MappingNode *Node) {
Info.IsThrowing = true;
} else if (Key == Key_mutating) {
Info.IsMutating = true;
} else if (Key == Key_static) {
Info.IsStatic = true;
} else if (Key == Key_typeAttributes) {
auto *Seq = cast<llvm::yaml::SequenceNode>(Pair.getValue());
for (auto It = Seq->begin(); It != Seq->end(); ++ It) {
@@ -1009,7 +1015,7 @@ SDKNodeInitInfo::SDKNodeInitInfo(ValueDecl *VD) :
USR(calculateUsr(VD)), Location(calculateLocation(VD)),
ModuleName(VD->getModuleContext()->getName().str()),
IsThrowing(isFuncThrowing(VD)), IsMutating(isFuncMutating(VD)),
SelfIndex(getSelfIndex(VD)) {
IsStatic(VD->isStatic()), SelfIndex(getSelfIndex(VD)) {
if (VD->getAttrs().getDeprecated(VD->getASTContext()))
DeclAttrs.push_back(SDKDeclAttrKind::DAK_deprecated);
}
@@ -1345,6 +1351,8 @@ namespace swift {
out.mapRequired(Key_usr, Usr);
out.mapRequired(Key_location, Location);
out.mapRequired(Key_moduleName, ModuleName);
if (auto isStatic = D->isStatic())
out.mapRequired(Key_static, isStatic);
if (auto F = dyn_cast<SDKNodeAbstractFunc>(value.get())) {
if (bool isThrowing = F->isThrowing())