@@ -2321,8 +2321,16 @@ class ModuleWriter {
2321
2321
M.getASTContext ().LangOpts .EffectiveLanguageVersion ) << " \n "
2322
2322
" #pragma clang diagnostic push\n "
2323
2323
" \n "
2324
- " #if defined(__has_include) && "
2325
- " __has_include(<swift/objc-prologue.h>)\n "
2324
+ " #if !defined(__has_include)\n "
2325
+ " # define __has_include(x) 0\n "
2326
+ " #endif\n "
2327
+ " #if !defined(__has_attribute)\n "
2328
+ " # define __has_attribute(x) 0\n "
2329
+ " #endif\n "
2330
+ " #if !defined(__has_feature)\n "
2331
+ " # define __has_feature(x) 0\n "
2332
+ " #endif\n "
2333
+ " #if __has_include(<swift/objc-prologue.h>)\n "
2326
2334
" # include <swift/objc-prologue.h>\n "
2327
2335
" #endif\n "
2328
2336
" \n "
@@ -2334,7 +2342,7 @@ class ModuleWriter {
2334
2342
" \n "
2335
2343
" #if !defined(SWIFT_TYPEDEFS)\n "
2336
2344
" # define SWIFT_TYPEDEFS 1\n "
2337
- " # if defined(__has_include) && __has_include(<uchar.h>)\n "
2345
+ " # if __has_include(<uchar.h>)\n "
2338
2346
" # include <uchar.h>\n "
2339
2347
" # elif !defined(__cplusplus) || __cplusplus < 201103L\n "
2340
2348
" typedef uint_least16_t char16_t;\n "
@@ -2366,38 +2374,35 @@ class ModuleWriter {
2366
2374
" # endif\n "
2367
2375
" #endif\n "
2368
2376
" \n "
2369
- " #if defined(__has_attribute) && "
2370
- " __has_attribute(objc_runtime_name)\n "
2377
+ " #if __has_attribute(objc_runtime_name)\n "
2371
2378
" # define SWIFT_RUNTIME_NAME(X) "
2372
2379
" __attribute__((objc_runtime_name(X)))\n "
2373
2380
" #else\n "
2374
2381
" # define SWIFT_RUNTIME_NAME(X)\n "
2375
2382
" #endif\n "
2376
- " #if defined(__has_attribute) && "
2377
- " __has_attribute(swift_name)\n "
2383
+ " #if __has_attribute(swift_name)\n "
2378
2384
" # define SWIFT_COMPILE_NAME(X) "
2379
2385
" __attribute__((swift_name(X)))\n "
2380
2386
" #else\n "
2381
2387
" # define SWIFT_COMPILE_NAME(X)\n "
2382
2388
" #endif\n "
2383
- " #if defined(__has_attribute) && "
2384
- " __has_attribute(objc_method_family)\n "
2389
+ " #if __has_attribute(objc_method_family)\n "
2385
2390
" # define SWIFT_METHOD_FAMILY(X) "
2386
2391
" __attribute__((objc_method_family(X)))\n "
2387
2392
" #else\n "
2388
2393
" # define SWIFT_METHOD_FAMILY(X)\n "
2389
2394
" #endif\n "
2390
- " #if defined(__has_attribute) && __has_attribute(noescape)\n "
2395
+ " #if __has_attribute(noescape)\n "
2391
2396
" # define SWIFT_NOESCAPE __attribute__((noescape))\n "
2392
2397
" #else\n "
2393
2398
" # define SWIFT_NOESCAPE\n "
2394
2399
" #endif\n "
2395
- " #if defined(__has_attribute) && __has_attribute(warn_unused_result)\n "
2400
+ " #if __has_attribute(warn_unused_result)\n "
2396
2401
" # define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))\n "
2397
2402
" #else\n "
2398
2403
" # define SWIFT_WARN_UNUSED_RESULT\n "
2399
2404
" #endif\n "
2400
- " #if defined(__has_attribute) && __has_attribute(noreturn)\n "
2405
+ " #if __has_attribute(noreturn)\n "
2401
2406
" # define SWIFT_NORETURN __attribute__((noreturn))\n "
2402
2407
" #else\n "
2403
2408
" # define SWIFT_NORETURN\n "
@@ -2412,8 +2417,7 @@ class ModuleWriter {
2412
2417
" # define SWIFT_ENUM_EXTRA\n "
2413
2418
" #endif\n "
2414
2419
" #if !defined(SWIFT_CLASS)\n "
2415
- " # if defined(__has_attribute) && "
2416
- " __has_attribute(objc_subclassing_restricted)\n "
2420
+ " # if __has_attribute(objc_subclassing_restricted)\n "
2417
2421
" # define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) "
2418
2422
" __attribute__((objc_subclassing_restricted)) "
2419
2423
" SWIFT_CLASS_EXTRA\n "
@@ -2443,8 +2447,7 @@ class ModuleWriter {
2443
2447
" #endif\n "
2444
2448
" \n "
2445
2449
" #if !defined(OBJC_DESIGNATED_INITIALIZER)\n "
2446
- " # if defined(__has_attribute) && "
2447
- " __has_attribute(objc_designated_initializer)\n "
2450
+ " # if __has_attribute(objc_designated_initializer)\n "
2448
2451
" # define OBJC_DESIGNATED_INITIALIZER "
2449
2452
" __attribute__((objc_designated_initializer))\n "
2450
2453
" # else\n "
@@ -2464,8 +2467,7 @@ class ModuleWriter {
2464
2467
" # define SWIFT_ENUM(_type, _name) "
2465
2468
" enum _name : _type _name; "
2466
2469
" enum SWIFT_ENUM_ATTR SWIFT_ENUM_EXTRA _name : _type\n "
2467
- " # if defined(__has_feature) && "
2468
- " __has_feature(generalized_swift_name)\n "
2470
+ " # if __has_feature(generalized_swift_name)\n "
2469
2471
" # define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME) "
2470
2472
" enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); "
2471
2473
" enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR "
@@ -2506,7 +2508,7 @@ class ModuleWriter {
2506
2508
}
2507
2509
2508
2510
void writeImports (raw_ostream &out) {
2509
- out << " #if defined(__has_feature) && __has_feature(modules)\n " ;
2511
+ out << " #if __has_feature(modules)\n " ;
2510
2512
2511
2513
// Track printed names to handle overlay modules.
2512
2514
llvm::SmallPtrSet<Identifier, 8 > seenImports;
0 commit comments