Skip to content

Commit 52fcadf

Browse files
authored
Merge pull request #10011 from CodaFi/code-covfeferage
[4.0] Add a size heuristic to the Space Engine
2 parents 900e8be + b5a69c7 commit 52fcadf

File tree

12 files changed

+592
-63
lines changed

12 files changed

+592
-63
lines changed

include/swift/AST/Attr.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ SIMPLE_DECL_ATTR(NSKeyedArchiverEncodeNonGenericSubclassesOnly,
286286
OnClass | NotSerialized | LongAttribute,
287287
/*Not serialized */ 70)
288288

289+
// HACK: Attribute needed to preserve source compatibility by downgrading errors
290+
// due to an SDK change in Dispatch
291+
SIMPLE_DECL_ATTR(_downgrade_exhaustivity_check, DowngradeExhaustivityCheck,
292+
OnEnumElement | LongAttribute | UserInaccessible, 71)
293+
289294
#undef TYPE_ATTR
290295
#undef DECL_ATTR_ALIAS
291296
#undef SIMPLE_DECL_ATTR

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3701,6 +3701,10 @@ NOTE(missing_particular_case,none,
37013701
WARNING(redundant_particular_case,none,
37023702
"case is already handled by previous patterns; consider removing it",())
37033703

3704+
// HACK: Downgrades the above to warnings if any of the cases is marked
3705+
// @_downgrade_exhaustivity_check.
3706+
WARNING(non_exhaustive_switch_warn_swift3,none, "switch must be exhaustive", ())
3707+
37043708
#ifndef DIAG_NO_UNDEF
37053709
# if defined(DIAG)
37063710
# undef DIAG

lib/AST/ASTDumper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,8 @@ namespace {
840840

841841
void visitEnumElementDecl(EnumElementDecl *EED) {
842842
printCommon(EED, "enum_element_decl");
843+
if (EED->getAttrs().hasAttribute<DowngradeExhaustivityCheckAttr>())
844+
OS << "@_downgrade_exhaustivity_check";
843845
PrintWithColorRAII(OS, ParenthesisColor) << ')';
844846
}
845847

lib/AST/Attr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,10 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
506506
Printer.printAttrName("@_staticInitializeObjCMetadata");
507507
break;
508508

509+
case DAK_DowngradeExhaustivityCheck:
510+
Printer.printAttrName("@_downgrade_exhaustivity_check");
511+
break;
512+
509513
case DAK_Count:
510514
llvm_unreachable("exceed declaration attribute kinds");
511515

lib/Sema/TypeCheckAttr.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class AttributeEarlyChecker : public AttributeVisitor<AttributeEarlyChecker> {
107107
IGNORED_ATTR(NSKeyedArchiverClassName)
108108
IGNORED_ATTR(StaticInitializeObjCMetadata)
109109
IGNORED_ATTR(NSKeyedArchiverEncodeNonGenericSubclassesOnly)
110+
IGNORED_ATTR(DowngradeExhaustivityCheck)
110111
#undef IGNORED_ATTR
111112

112113
// @noreturn has been replaced with a 'Never' return type.
@@ -784,6 +785,7 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
784785
IGNORED_ATTR(ObjCMembers)
785786
IGNORED_ATTR(StaticInitializeObjCMetadata)
786787
IGNORED_ATTR(NSKeyedArchiverEncodeNonGenericSubclassesOnly)
788+
IGNORED_ATTR(DowngradeExhaustivityCheck)
787789
#undef IGNORED_ATTR
788790

789791
void visitAvailableAttr(AvailableAttr *attr);

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6103,6 +6103,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
61036103
UNINTERESTING_ATTR(NSKeyedArchiverClassName)
61046104
UNINTERESTING_ATTR(StaticInitializeObjCMetadata)
61056105
UNINTERESTING_ATTR(NSKeyedArchiverEncodeNonGenericSubclassesOnly)
6106+
UNINTERESTING_ATTR(DowngradeExhaustivityCheck)
61066107
#undef UNINTERESTING_ATTR
61076108

61086109
void visitAvailableAttr(AvailableAttr *attr) {

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5915,7 +5915,7 @@ static bool hasGenericAncestry(ClassDecl *classDecl) {
59155915
/// Infer the attribute tostatic-initialize the Objective-C metadata for the
59165916
/// given class, if needed.
59175917
static void inferStaticInitializeObjCMetadata(ClassDecl *classDecl,
5918-
bool requiresNSCodingAttr) {
5918+
bool requiresNSCodingAttr) {
59195919
// If we already have the attribute, there's nothing to do.
59205920
if (classDecl->getAttrs().hasAttribute<StaticInitializeObjCMetadataAttr>())
59215921
return;

0 commit comments

Comments
 (0)