Skip to content

Commit 92fbedc

Browse files
committed
Factor the strict memory safety checking declarations into their own header
1 parent 4b3c18d commit 92fbedc

8 files changed

+42
-13
lines changed

lib/Sema/TypeCheckAvailability.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "TypeCheckConcurrency.h"
2020
#include "TypeCheckObjC.h"
2121
#include "TypeCheckType.h"
22+
#include "TypeCheckUnsafe.h"
2223
#include "TypeChecker.h"
2324
#include "swift/AST/ASTWalker.h"
2425
#include "swift/AST/AvailabilityDomain.h"

lib/Sema/TypeCheckAvailability.h

-11
Original file line numberDiff line numberDiff line change
@@ -273,17 +273,6 @@ void checkExplicitAvailability(Decl *decl);
273273
std::pair<const Decl *, bool /*inDefinition*/>
274274
enclosingContextForUnsafe(SourceLoc referenceLoc, const DeclContext *referenceDC);
275275

276-
/// Diagnose the given unsafe use right now.
277-
void diagnoseUnsafeUse(const UnsafeUse &use, bool asNote = false);
278-
279-
/// Diagnose any unsafe uses within the signature or definition of the given
280-
/// declaration, if there are any.
281-
void diagnoseUnsafeUsesIn(const Decl *decl);
282-
283-
/// Determine whether a reference to this declaration is considered unsafe,
284-
/// either explicitly (@unsafe) or because it references an unsafe type.
285-
bool isUnsafe(ConcreteDeclRef declRef);
286-
287276
} // namespace swift
288277

289278
#endif // SWIFT_SEMA_TYPE_CHECK_AVAILABILITY_H

lib/Sema/TypeCheckDeclOverride.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "TypeCheckEffects.h"
2121
#include "TypeCheckObjC.h"
2222
#include "TypeChecker.h"
23+
#include "TypeCheckUnsafe.h"
2324
#include "swift/AST/ASTVisitor.h"
2425
#include "swift/AST/Availability.h"
2526
#include "swift/AST/Decl.h"

lib/Sema/TypeCheckDeclPrimary.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "TypeCheckObjC.h"
2828
#include "TypeCheckType.h"
2929
#include "TypeChecker.h"
30+
#include "TypeCheckUnsafe.h"
3031
#include "swift/AST/ASTPrinter.h"
3132
#include "swift/AST/ASTVisitor.h"
3233
#include "swift/AST/ASTWalker.h"

lib/Sema/TypeCheckProtocol.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "TypeCheckEffects.h"
2828
#include "TypeCheckInvertible.h"
2929
#include "TypeCheckObjC.h"
30+
#include "TypeCheckUnsafe.h"
3031
#include "swift/AST/ASTContext.h"
3132
#include "swift/AST/ASTMangler.h"
3233
#include "swift/AST/ASTPrinter.h"

lib/Sema/TypeCheckStmt.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "TypeCheckDistributed.h"
2121
#include "TypeCheckType.h"
2222
#include "TypeChecker.h"
23+
#include "TypeCheckUnsafe.h"
2324
#include "swift/AST/ASTPrinter.h"
2425
#include "swift/AST/ASTScope.h"
2526
#include "swift/AST/ASTVisitor.h"

lib/Sema/TypeCheckUnsafe.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17+
#include "TypeCheckAvailability.h"
18+
#include "TypeCheckType.h"
19+
#include "TypeCheckUnsafe.h"
20+
1721
#include "swift/AST/ASTContext.h"
1822
#include "swift/AST/UnsafeUse.h"
1923
#include "swift/AST/DiagnosticsSema.h"
2024
#include "swift/AST/PackConformance.h"
2125
#include "swift/AST/SourceFile.h"
2226
#include "swift/AST/SourceFileExtras.h"
23-
#include "TypeCheckAvailability.h"
24-
#include "TypeCheckType.h"
2527

2628
using namespace swift;
2729

lib/Sema/TypeCheckUnsafe.h

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===--- TypeCheckUnasfe.h - Strict Safety Diagnostics ----------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef SWIFT_SEMA_TYPE_CHECK_UNSAFE_H
14+
#define SWIFT_SEMA_TYPE_CHECK_UNSAFE_H
15+
16+
#include "swift/AST/UnsafeUse.h"
17+
18+
namespace swift {
19+
20+
/// Diagnose the given unsafe use right now.
21+
void diagnoseUnsafeUse(const UnsafeUse &use, bool asNote = false);
22+
23+
/// Diagnose any unsafe uses within the signature or definition of the given
24+
/// declaration, if there are any.
25+
void diagnoseUnsafeUsesIn(const Decl *decl);
26+
27+
/// Determine whether a reference to this declaration is considered unsafe,
28+
/// either explicitly (@unsafe) or because it references an unsafe type.
29+
bool isUnsafe(ConcreteDeclRef declRef);
30+
31+
}
32+
33+
#endif // SWIFT_SEMA_TYPE_CHECK_UNSAFE_H

0 commit comments

Comments
 (0)