mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge remote-tracking branch 'origin/main' into rebranch
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "llvm/CAS/CASReference.h"
|
||||
|
||||
#include "swift/Basic/BridgedSwiftObject.h"
|
||||
#include "swift/Basic/Nullability.h"
|
||||
#include "swift/Basic/SourceLoc.h"
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#ifndef SWIFT_BASIC_BRIDGEDSWIFTOBJECT_H
|
||||
#define SWIFT_BASIC_BRIDGEDSWIFTOBJECT_H
|
||||
|
||||
#include "swift/Basic/Nullability.h"
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
#include <sys/stdint.h>
|
||||
#else
|
||||
@@ -28,28 +30,6 @@
|
||||
#define __has_feature(feature) 0
|
||||
#endif
|
||||
|
||||
// TODO: These macro definitions are duplicated in Visibility.h. Move
|
||||
// them to a single file if we find a location that both Visibility.h and
|
||||
// BridgedSwiftObject.h can import.
|
||||
#if __has_feature(nullability)
|
||||
// Provide macros to temporarily suppress warning about the use of
|
||||
// _Nullable and _Nonnull.
|
||||
#define SWIFT_BEGIN_NULLABILITY_ANNOTATIONS \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wnullability-extension\"")
|
||||
#define SWIFT_END_NULLABILITY_ANNOTATIONS \
|
||||
_Pragma("clang diagnostic pop")
|
||||
|
||||
#else
|
||||
// #define _Nullable and _Nonnull to nothing if we're not being built
|
||||
// with a compiler that supports them.
|
||||
#define _Nullable
|
||||
#define _Nonnull
|
||||
#define _Null_unspecified
|
||||
#define SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
|
||||
#define SWIFT_END_NULLABILITY_ANNOTATIONS
|
||||
#endif
|
||||
|
||||
SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
|
||||
|
||||
typedef const void * _Nonnull SwiftMetatype;
|
||||
|
||||
@@ -14,30 +14,15 @@
|
||||
#define SWIFT_C_BASIC_BASICBRIDGING_H
|
||||
|
||||
#include "swift/Basic/Compiler.h"
|
||||
#include "swift/Basic/Nullability.h"
|
||||
|
||||
// NOTE: DO NOT #include any stdlib headers here. e.g. <stdint.h>. Those are
|
||||
// part of "Darwin"/"Glibc" module, so when a Swift file imports this header,
|
||||
// it causes importing the "Darwin"/"Glibc" overlay module. That violates
|
||||
// layering. i.e. Darwin overlay is created by Swift compiler.
|
||||
|
||||
#if __clang__
|
||||
// Provide macros to temporarily suppress warning about the use of
|
||||
// _Nullable and _Nonnull.
|
||||
#define SWIFT_BEGIN_NULLABILITY_ANNOTATIONS \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wnullability-extension\"") \
|
||||
_Pragma("clang assume_nonnull begin")
|
||||
|
||||
#define SWIFT_END_NULLABILITY_ANNOTATIONS \
|
||||
_Pragma("clang diagnostic pop") _Pragma("clang assume_nonnull end")
|
||||
#else
|
||||
#define SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
|
||||
#define SWIFT_END_NULLABILITY_ANNOTATIONS
|
||||
#define _Nullable
|
||||
#define _Nonnull
|
||||
#endif
|
||||
|
||||
SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
|
||||
SWIFT_BEGIN_ASSUME_NONNULL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -119,9 +104,7 @@ void *JSON_array_pushNewValue(void *arrayPtr);
|
||||
}
|
||||
#endif
|
||||
|
||||
SWIFT_END_ASSUME_NONNULL
|
||||
SWIFT_END_NULLABILITY_ANNOTATIONS
|
||||
|
||||
#undef SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
|
||||
#undef SWIFT_END_NULLABILITY_ANNOTATIONS
|
||||
|
||||
#endif // SWIFT_C_BASIC_BASICBRIDGING_H
|
||||
|
||||
41
include/swift/Basic/Nullability.h
Normal file
41
include/swift/Basic/Nullability.h
Normal file
@@ -0,0 +1,41 @@
|
||||
//===--- Nullability.h ----------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2023 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_BASIC_NULLABILITY_H
|
||||
#define SWIFT_BASIC_NULLABILITY_H
|
||||
|
||||
// TODO: These macro definitions are duplicated in Visibility.h. Move
|
||||
// them to a single file if we find a location that both Visibility.h and
|
||||
// BridgedSwiftObject.h can import.
|
||||
#if __has_feature(nullability)
|
||||
// Provide macros to temporarily suppress warning about the use of
|
||||
// _Nullable and _Nonnull.
|
||||
#define SWIFT_BEGIN_NULLABILITY_ANNOTATIONS \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wnullability-extension\"")
|
||||
#define SWIFT_END_NULLABILITY_ANNOTATIONS _Pragma("clang diagnostic pop")
|
||||
|
||||
#define SWIFT_BEGIN_ASSUME_NONNULL _Pragma("clang assume_nonnull begin")
|
||||
#define SWIFT_END_ASSUME_NONNULL _Pragma("clang assume_nonnull end")
|
||||
#else
|
||||
// #define _Nullable and _Nonnull to nothing if we're not being built
|
||||
// with a compiler that supports them.
|
||||
#define _Nullable
|
||||
#define _Nonnull
|
||||
#define _Null_unspecified
|
||||
#define SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
|
||||
#define SWIFT_END_NULLABILITY_ANNOTATIONS
|
||||
#define SWIFT_BEGIN_ASSUME_NONNULL
|
||||
#define SWIFT_END_ASSUME_NONNULL
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user