-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathTypeCheckAvailability.h
92 lines (76 loc) · 3.46 KB
/
TypeCheckAvailability.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//===--- TypeCheckAvailability.h - Availability Diagnostics -----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_SEMA_TYPE_CHECK_AVAILABILITY_H
#define SWIFT_SEMA_TYPE_CHECK_AVAILABILITY_H
#include "swift/AST/AttrKind.h"
#include "swift/AST/Identifier.h"
#include "swift/Basic/LLVM.h"
#include "swift/Basic/SourceLoc.h"
#include "swift/Basic/OptionSet.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
namespace swift {
class ApplyExpr;
class AvailableAttr;
class DeclContext;
class Expr;
class InFlightDiagnostic;
class TypeChecker;
class Decl;
class ValueDecl;
/// Diagnose uses of unavailable declarations.
void diagAvailability(TypeChecker &TC, const Expr *E,
DeclContext *DC);
enum class DeclAvailabilityFlag : uint8_t {
/// Do not diagnose uses of protocols in versions before they were introduced.
/// Used when type-checking protocol conformances, since conforming to a
/// protocol that doesn't exist yet is allowed.
AllowPotentiallyUnavailableProtocol = 1 << 0,
/// Diagnose uses of declarations in versions before they were introduced, but
/// do not return true to indicate that a diagnostic was emitted.
ContinueOnPotentialUnavailability = 1 << 1,
/// If a diagnostic must be emitted, use a variant indicating that the usage
/// is inout and both the getter and setter must be available.
ForInout = 1 << 2,
/// Do not diagnose uses of declarations in versions before they were
/// introduced. Used to work around availability-checker bugs.
AllowPotentiallyUnavailable = 1 << 3,
};
using DeclAvailabilityFlags = OptionSet<DeclAvailabilityFlag>;
/// Run the Availability-diagnostics algorithm otherwise used in an expr
/// context, but for non-expr contexts such as TypeDecls referenced from
/// TypeReprs.
bool diagnoseDeclAvailability(const ValueDecl *Decl,
TypeChecker &TC,
DeclContext *DC,
SourceRange R,
DeclAvailabilityFlags Options);
void diagnoseUnavailableOverride(ValueDecl *override,
const ValueDecl *base,
const AvailableAttr *attr);
/// Emit a diagnostic for references to declarations that have been
/// marked as unavailable, either through "unavailable" or "obsoleted:".
bool diagnoseExplicitUnavailability(const ValueDecl *D,
SourceRange R,
const DeclContext *DC,
const ApplyExpr *call);
/// Emit a diagnostic for references to declarations that have been
/// marked as unavailable, either through "unavailable" or "obsoleted:".
bool diagnoseExplicitUnavailability(
const ValueDecl *D,
SourceRange R,
const DeclContext *DC,
llvm::function_ref<void(InFlightDiagnostic &)> attachRenameFixIts);
/// Check if \p decl has a introduction version required by -require-explicit-availability
void checkExplicitAvailability(Decl *decl);
} // namespace swift
#endif // SWIFT_SEMA_TYPE_CHECK_AVAILABILITY_H