Skip to content

[cxx-interop][SwiftCompilerSources] Do not use SWIFT_IMPORT_UNSAFE with BridgedOwnedString #76408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/Basic/BasicBridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class BridgedOwnedString {
#endif

void destroy() const;
};
} SWIFT_SELF_CONTAINED;

SWIFT_NAME("getter:BridgedOwnedString.data(self:)")
BRIDGED_INLINE
Expand Down
7 changes: 7 additions & 0 deletions include/swift/Basic/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@
#define SWIFT_IMPORT_UNSAFE
#endif

/// Same as `SWIFT_SELF_CONTAINED` in <swift/bridging>.
#if __has_attribute(swift_attr)
#define SWIFT_SELF_CONTAINED __attribute__((swift_attr("import_owned")))
#else
#define SWIFT_SELF_CONTAINED
#endif

#ifdef __GNUC__
#define SWIFT_ATTRIBUTE_NORETURN __attribute__((noreturn))
#elif defined(_MSC_VER)
Expand Down
28 changes: 14 additions & 14 deletions include/swift/SIL/SILBridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ struct BridgedLifetimeDependenceInfo {
BRIDGED_INLINE bool checkScope(SwiftInt index) const;
BRIDGED_INLINE SwiftInt getTargetIndex() const;

SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedOwnedString getDebugDescription() const;
BRIDGED_INLINE BridgedOwnedString getDebugDescription() const;
};

struct BridgedLifetimeDependenceInfoArray {
Expand Down Expand Up @@ -313,7 +313,7 @@ struct BridgedASTType {
}
#endif

SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedOwnedString getDebugDescription() const;
BRIDGED_INLINE BridgedOwnedString getDebugDescription() const;

BRIDGED_INLINE bool hasTypeParameter() const;

Expand Down Expand Up @@ -394,7 +394,7 @@ struct BridgedType {
}
#endif

SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedOwnedString getDebugDescription() const;
BRIDGED_INLINE BridgedOwnedString getDebugDescription() const;
BRIDGED_INLINE bool isNull() const;
BRIDGED_INLINE bool isAddress() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getAddressType() const;
Expand Down Expand Up @@ -486,7 +486,7 @@ struct BridgedValue {

Kind getKind() const;
BRIDGED_INLINE swift::ValueBase * _Nonnull getSILValue() const;
SWIFT_IMPORT_UNSAFE BridgedOwnedString getDebugDescription() const;
BridgedOwnedString getDebugDescription() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedOperand getFirstUse() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getType() const;
BRIDGED_INLINE Ownership getOwnership() const;
Expand Down Expand Up @@ -582,7 +582,7 @@ struct BridgedLocation {
}
#endif

SWIFT_IMPORT_UNSAFE BridgedOwnedString getDebugDescription() const;
BridgedOwnedString getDebugDescription() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedLocation getAutogeneratedLocation() const;
BRIDGED_INLINE bool hasValidLineNumber() const;
BRIDGED_INLINE bool isAutoGenerated() const;
Expand Down Expand Up @@ -638,7 +638,7 @@ struct BridgedFunction {
SWIFT_IMPORT_UNSAFE BridgedFunction() {}
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE swift::SILFunction * _Nonnull getFunction() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef getName() const;
SWIFT_IMPORT_UNSAFE BridgedOwnedString getDebugDescription() const;
BridgedOwnedString getDebugDescription() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedLocation getLocation() const;
BRIDGED_INLINE bool hasOwnership() const;
BRIDGED_INLINE bool hasLoweredAddresses() const;
Expand Down Expand Up @@ -732,7 +732,7 @@ struct BridgedGlobalVar {
BridgedGlobalVar(SwiftObject obj) : obj(obj) {}
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE swift::SILGlobalVariable * _Nonnull getGlobal() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedNullableVarDecl getDecl() const;
SWIFT_IMPORT_UNSAFE BridgedOwnedString getDebugDescription() const;
BridgedOwnedString getDebugDescription() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef getName() const;
BRIDGED_INLINE bool isLet() const;
BRIDGED_INLINE void setLet(bool value) const;
Expand Down Expand Up @@ -849,7 +849,7 @@ struct BridgedInstruction {
#endif

BridgedInstruction(SwiftObject obj) : obj(obj) {}
SWIFT_IMPORT_UNSAFE BridgedOwnedString getDebugDescription() const;
BridgedOwnedString getDebugDescription() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedInstruction getNext() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedInstruction getPrevious() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedBasicBlock getParent() const;
Expand Down Expand Up @@ -1111,7 +1111,7 @@ struct BridgedBasicBlock {
}
#endif

SWIFT_IMPORT_UNSAFE BridgedOwnedString getDebugDescription() const;
BridgedOwnedString getDebugDescription() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedBasicBlock getNext() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedBasicBlock getPrevious() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedFunction getFunction() const;
Expand Down Expand Up @@ -1151,7 +1151,7 @@ struct BridgedSuccessorArray {
struct BridgedVTableEntry {
const swift::SILVTableEntry * _Nonnull entry;

SWIFT_IMPORT_UNSAFE BridgedOwnedString getDebugDescription() const;
BridgedOwnedString getDebugDescription() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedFunction getImplementation() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedVTableEntry advanceBy(SwiftInt index) const;
};
Expand All @@ -1164,7 +1164,7 @@ struct BridgedVTableEntryArray {
struct BridgedVTable {
const swift::SILVTable * _Nonnull vTable;

SWIFT_IMPORT_UNSAFE BridgedOwnedString getDebugDescription() const;
BridgedOwnedString getDebugDescription() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedVTableEntryArray getEntries() const;
};

Expand All @@ -1185,7 +1185,7 @@ struct BridgedWitnessTableEntry {
}
#endif

SWIFT_IMPORT_UNSAFE BridgedOwnedString getDebugDescription() const;
BridgedOwnedString getDebugDescription() const;
BRIDGED_INLINE Kind getKind() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedFunction getMethodFunction() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedWitnessTableEntry advanceBy(SwiftInt index) const;
Expand All @@ -1199,7 +1199,7 @@ struct BridgedWitnessTableEntryArray {
struct BridgedWitnessTable {
const swift::SILWitnessTable * _Nonnull table;

SWIFT_IMPORT_UNSAFE BridgedOwnedString getDebugDescription() const;
BridgedOwnedString getDebugDescription() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedWitnessTableEntryArray getEntries() const;
};

Expand All @@ -1210,7 +1210,7 @@ struct OptionalBridgedWitnessTable {
struct BridgedDefaultWitnessTable {
const swift::SILDefaultWitnessTable * _Nonnull table;

SWIFT_IMPORT_UNSAFE BridgedOwnedString getDebugDescription() const;
BridgedOwnedString getDebugDescription() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedWitnessTableEntryArray getEntries() const;
};

Expand Down
10 changes: 5 additions & 5 deletions include/swift/SILOptimizer/OptimizerBridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ struct BridgedPassContext {
Lowered
};

SWIFT_IMPORT_UNSAFE BridgedOwnedString getModuleDescription() const;
BridgedOwnedString getModuleDescription() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedChangeNotificationHandler asNotificationHandler() const;
BRIDGED_INLINE void notifyDependencyOnBodyOf(BridgedFunction otherFunction) const;
BRIDGED_INLINE SILStage getSILStage() const;
Expand Down Expand Up @@ -251,12 +251,12 @@ struct BridgedPassContext {
BridgedFunction function) const;
bool specializeClassMethodInst(BridgedInstruction cm) const;
bool specializeAppliesInFunction(BridgedFunction function, bool isMandatory) const;
SWIFT_IMPORT_UNSAFE BridgedOwnedString mangleOutlinedVariable(BridgedFunction function) const;
SWIFT_IMPORT_UNSAFE BridgedOwnedString mangleAsyncRemoved(BridgedFunction function) const;
SWIFT_IMPORT_UNSAFE BridgedOwnedString mangleWithDeadArgs(const SwiftInt * _Nullable deadArgs,
BridgedOwnedString mangleOutlinedVariable(BridgedFunction function) const;
BridgedOwnedString mangleAsyncRemoved(BridgedFunction function) const;
BridgedOwnedString mangleWithDeadArgs(const SwiftInt * _Nullable deadArgs,
SwiftInt numDeadArgs,
BridgedFunction function) const;
SWIFT_IMPORT_UNSAFE BridgedOwnedString mangleWithClosureArgs(BridgedValueArray closureArgs,
BridgedOwnedString mangleWithClosureArgs(BridgedValueArray closureArgs,
BridgedArrayRef closureArgIndices,
BridgedFunction applySiteCallee) const;

Expand Down