mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #85608 from kavon/opaque-values/fixes-5
OpaqueValues: fixes for distributed actors + introduce AccessControls
This commit is contained in:
81
include/swift/Basic/AccessControls.h
Normal file
81
include/swift/Basic/AccessControls.h
Normal file
@@ -0,0 +1,81 @@
|
||||
//===--- AccessControls.h ---------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2014 - 2025 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 defines macros that help control access to APIs.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SWIFT_ACCESSCONTROLS_H
|
||||
#define SWIFT_ACCESSCONTROLS_H
|
||||
|
||||
/// Deprecation warnings
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
#if !defined(SWIFT_DEPRECATED)
|
||||
#define SWIFT_DEPRECATED __attribute__((deprecated))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED_MSG)
|
||||
#define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))
|
||||
#endif
|
||||
#else
|
||||
#if !defined(SWIFT_DEPRECATED)
|
||||
#define SWIFT_DEPRECATED
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED_MSG)
|
||||
#define SWIFT_DEPRECATED_MSG(...)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/// Unavailable errors
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
#if !defined(SWIFT_UNAVAILABLE)
|
||||
#define SWIFT_UNAVAILABLE __attribute__((unavailable))
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE_MSG)
|
||||
#define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg)))
|
||||
#endif
|
||||
#else
|
||||
#if !defined(SWIFT_UNAVAILABLE)
|
||||
#define SWIFT_UNAVAILABLE
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE_MSG)
|
||||
#define SWIFT_UNAVAILABLE_MSG(msg)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// Access controls that are only active when included in SILGen sources.
|
||||
#if defined(SWIFT_INCLUDED_IN_SILGEN_SOURCES)
|
||||
|
||||
// Override any prior definitions with these.
|
||||
#define SWIFT_DEPRECATED_IN_SILGEN SWIFT_DEPRECATED
|
||||
#define SWIFT_DEPRECATED_IN_SILGEN_MSG(...) SWIFT_DEPRECATED_MSG(__VA_ARGS__)
|
||||
#define SWIFT_UNAVAILABLE_IN_SILGEN SWIFT_UNAVAILABLE
|
||||
#define SWIFT_UNAVAILABLE_IN_SILGEN_MSG(MSG) SWIFT_UNAVAILABLE_MSG(MSG)
|
||||
|
||||
#else
|
||||
|
||||
#if !defined(SWIFT_DEPRECATED_IN_SILGEN)
|
||||
#define SWIFT_DEPRECATED_IN_SILGEN
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED_IN_SILGEN_MSG)
|
||||
#define SWIFT_DEPRECATED_IN_SILGEN_MSG(...)
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE_IN_SILGEN)
|
||||
#define SWIFT_UNAVAILABLE_IN_SILGEN
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE_IN_SILGEN_MSG)
|
||||
#define SWIFT_UNAVAILABLE_IN_SILGEN_MSG(MSG)
|
||||
#endif
|
||||
#endif // SWIFT_INCLUDED_IN_SILGEN_SOURCES
|
||||
|
||||
#endif // SWIFT_ACCESSCONTROLS_H
|
||||
@@ -31,6 +31,7 @@
|
||||
#define SWIFT_SIL_FUNCTIONCONVENTIONS_H
|
||||
|
||||
#include "swift/AST/Types.h"
|
||||
#include "swift/Basic/AccessControls.h"
|
||||
#include "swift/SIL/SILArgumentConvention.h"
|
||||
#include "swift/SIL/SILType.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
@@ -526,11 +527,9 @@ public:
|
||||
- getNumIndirectSILErrorResults()];
|
||||
}
|
||||
|
||||
/// WARNING: Do not use this from SILGen!
|
||||
/// Use methods such as `isSILIndirect` or query the ParameterInfo instead.
|
||||
///
|
||||
/// Return the SIL argument convention of apply/entry argument at
|
||||
/// the given argument index.
|
||||
SWIFT_UNAVAILABLE_IN_SILGEN_MSG("Use methods such as `isSILIndirect` or query the ParameterInfo instead.")
|
||||
SILArgumentConvention getSILArgumentConvention(unsigned index) const;
|
||||
|
||||
/// Return the SIL type of the apply/entry argument at the given index.
|
||||
|
||||
17
include/swift/SIL/SILGenUtils.h
Normal file
17
include/swift/SIL/SILGenUtils.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Created by Kavon Farvardin on 11/19/25.
|
||||
//
|
||||
|
||||
#ifndef SWIFT_SILGENUTILS_H
|
||||
#define SWIFT_SILGENUTILS_H
|
||||
|
||||
#include "swift/SIL/SILValue.h"
|
||||
|
||||
namespace swift {
|
||||
|
||||
// Unsafe access may have invalid storage (e.g. a RawPointer).
|
||||
bool isPossibleUnsafeAccessInvalidStorage(SILValue access, SILFunction *F);
|
||||
|
||||
} // namespace swift
|
||||
|
||||
#endif // SWIFT_SILGENUTILS_H
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "swift/AST/Decl.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "swift/SIL/SILValue.h"
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
@@ -30,7 +31,6 @@ class SILArgument;
|
||||
class SILFunction;
|
||||
class SILLocation;
|
||||
class SILType;
|
||||
class SILValue;
|
||||
|
||||
/// Creates a reference to the distributed actor's \p actorSystem
|
||||
/// stored property.
|
||||
@@ -46,11 +46,16 @@ SILValue refDistributedActorSystem(SILBuilder &B,
|
||||
/// \param actorType If non-empty, the type of the distributed actor that is
|
||||
/// provided as one of the arguments.
|
||||
/// \param args The arguments provided to the call, not including the base.
|
||||
/// \param indirectResult If the result is known to be returned indirect,
|
||||
/// this is the temporary storage for it.
|
||||
/// \param tryTargets For a call that can throw, the normal and error basic
|
||||
/// blocks that the call will branch to.
|
||||
void emitDistributedActorSystemWitnessCall(
|
||||
/// \returns If the apply result is known to be returned directly,
|
||||
/// and there are no tryTargets, then the result is returned.
|
||||
std::optional<SILValue> emitDistributedActorSystemWitnessCall(
|
||||
SILBuilder &B, SILLocation loc, DeclName methodName, SILValue base,
|
||||
SILType actorType, llvm::ArrayRef<SILValue> args,
|
||||
std::optional<SILValue> indirectResult = std::nullopt,
|
||||
std::optional<std::pair<SILBasicBlock *, SILBasicBlock *>> tryTargets =
|
||||
std::nullopt);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user