Merge remote-tracking branch 'origin/main' into next

This commit is contained in:
swift_jenkins
2022-02-25 14:00:23 -08:00
12 changed files with 431 additions and 0 deletions

View File

@@ -43,6 +43,19 @@ void OStream_write(BridgedOStream os, BridgedStringRef str);
void freeBridgedStringRef(BridgedStringRef str);
//===----------------------------------------------------------------------===//
// Source location
//===----------------------------------------------------------------------===//
typedef struct {
const unsigned char * _Nullable pointer;
} BridgedSourceLoc;
typedef struct {
BridgedSourceLoc start;
SwiftInt byteLength;
} BridgedCharSourceRange;
SWIFT_END_NULLABILITY_ANNOTATIONS
#ifdef __cplusplus

View File

@@ -36,6 +36,27 @@ inline llvm::ArrayRef<T> getArrayRef(BridgedArrayRef bridged) {
return {static_cast<const T *>(bridged.data), bridged.numElements};
}
inline SourceLoc getSourceLoc(const BridgedSourceLoc &bridged) {
return SourceLoc(
llvm::SMLoc::getFromPointer((const char *)bridged.pointer));
}
inline BridgedSourceLoc getBridgedSourceLoc(const SourceLoc &loc) {
return {static_cast<const unsigned char *>(loc.getOpaquePointerValue())};
}
inline CharSourceRange
getCharSourceRange(const BridgedCharSourceRange &bridged) {
auto start = getSourceLoc(bridged.start);
return CharSourceRange(start, bridged.byteLength);
}
inline BridgedCharSourceRange
getBridgedCharSourceRange(const CharSourceRange &range) {
auto start = getBridgedSourceLoc(range.getStart());
return {start, range.getByteLength()};
}
/// Copies the string in an malloc'ed memory and the caller is responsible for
/// freeing it. 'freeBridgedStringRef()' is available in 'BasicBridging.h'
inline BridgedStringRef