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 92 93 94 95 96 97 98 99 100
|
//===--- TypeCheckConcurrency.h - Concurrency -------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 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
//
//===----------------------------------------------------------------------===//
//
// This file provides type checking support for macros.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_SEMA_TYPECHECKMACROS_H
#define SWIFT_SEMA_TYPECHECKMACROS_H
#include "swift/AST/Attr.h"
#include "swift/AST/ConcreteDeclRef.h"
#include "swift/AST/Type.h"
/// Prefix used for the names of macro expansion buffers, to replace the
/// leading "$s" used for Swift manglings.
#define MACRO_EXPANSION_BUFFER_MANGLING_PREFIX "@__swiftmacro_"
namespace swift {
class CustomAttr;
class Expr;
class MacroDecl;
class MacroExpansionExpr;
class MacroExpansionDecl;
class TypeRepr;
/// Expands the given macro expression and type-check the result with
/// the given expanded type.
///
/// \returns Expansion buffer ID if expansion succeeded, \p None if failed.
std::optional<unsigned> expandMacroExpr(MacroExpansionExpr *mee);
/// Expands the given macro expansion declaration.
///
/// \returns Expansion buffer ID if expansion succeeded, \p None if failed.
std::optional<unsigned> expandFreestandingMacro(MacroExpansionDecl *med);
/// Expand the accessors for the given storage declaration based on the
/// custom attribute that references the given macro.
std::optional<unsigned> expandAccessors(AbstractStorageDecl *storage,
CustomAttr *attr, MacroDecl *macro);
/// Expand the attributes for the given member declaration based
/// on the custom attribute that references the given macro.
///
/// If expansion occurred, returns the macro expansion buffer ID.
std::optional<unsigned> expandAttributes(CustomAttr *attr, MacroDecl *macro,
Decl *member);
/// Expand the synthesized members for the given declaration based on
/// the custom attribute that references the given macro.
///
/// If expansion occurred, returns the macro expansion buffer ID.
std::optional<unsigned> expandMembers(CustomAttr *attr, MacroDecl *macro,
Decl *decl);
/// Expand the peer declarations for the given declaration based on
/// the custom attribute that references the given macro.
///
/// If expansion occurred, returns the macro expansion buffer ID.
std::optional<unsigned> expandPeers(CustomAttr *attr, MacroDecl *macro,
Decl *decl);
/// Expand the extensions for the given declaration based on
/// the custom attribute that references the given macro. Extensions
/// can be produced by either conformance macros or extension macros.
///
/// If expansion occurred, returns the macro expansion buffer ID.
std::optional<unsigned> expandExtensions(CustomAttr *attr, MacroDecl *macro,
MacroRole role,
NominalTypeDecl *nominal);
/// Determine whether an accessor macro with the given attribute only
/// introduces observers like willSet and didSet.
bool accessorMacroOnlyIntroducesObservers(
MacroDecl *macro, const MacroRoleAttr *attr);
/// Determine whether an accessor macro (defined with the given role attribute)
/// introduces an init accessor.
bool accessorMacroIntroducesInitAccessor(
MacroDecl *macro, const MacroRoleAttr *attr);
/// Return true if the given macro role does not apply
/// to the declaration kind of \c attachedTo.
bool isInvalidAttachedMacro(MacroRole role,
Decl *attachedTo);
} // end namespace swift
#endif /* SWIFT_SEMA_TYPECHECKMACROS_H */
|