@@ -430,49 +430,54 @@ static void
430
430
getNormalInvocationArguments (std::vector<std::string> &invocationArgStrs,
431
431
ASTContext &ctx,
432
432
const ClangImporterOptions &importerOpts) {
433
- const llvm::Triple &triple = ctx.LangOpts .Target ;
433
+ const auto &LangOpts = ctx.LangOpts ;
434
+ const llvm::Triple &triple = LangOpts.Target ;
434
435
SearchPathOptions &searchPathOpts = ctx.SearchPathOpts ;
435
436
436
437
auto languageVersion = ctx.LangOpts .EffectiveLanguageVersion ;
437
438
438
- if (llvm::sys::path::extension (importerOpts.BridgingHeader ).endswith (
439
- PCH_EXTENSION)) {
440
- invocationArgStrs.insert (
441
- invocationArgStrs.end (),
442
- { " -include-pch" , importerOpts.BridgingHeader }
443
- );
439
+ if (llvm::sys::path::extension (importerOpts.BridgingHeader )
440
+ .endswith (PCH_EXTENSION)) {
441
+ invocationArgStrs.insert (invocationArgStrs.end (), {
442
+ " -include-pch" , importerOpts.BridgingHeader
443
+ });
444
444
}
445
445
446
446
// Construct the invocation arguments for the current target.
447
447
// Add target-independent options first.
448
- invocationArgStrs.insert (
449
- invocationArgStrs.end (),
450
- {
448
+ invocationArgStrs.insert (invocationArgStrs.end (), {
449
+ // Enable modules
450
+ " -fmodules" ,
451
+ " -Werror=non-modular-include-in-framework-module" ,
452
+ " -Xclang" , " -fmodule-feature" , " -Xclang" , " swift" ,
451
453
452
- // Enable modules
453
- " -fmodules" ,
454
- " -Werror=non-modular-include-in-framework-module" ,
455
- " -Xclang" , " -fmodule-feature" , " -Xclang" , " swift" ,
454
+ // Don't emit LLVM IR.
455
+ " -fsyntax-only" ,
456
456
457
- // Don't emit LLVM IR .
458
- " -fsyntax-only " ,
457
+ // Enable block support .
458
+ " -fblocks " ,
459
459
460
- // Enable block support.
461
- " -fblocks" ,
460
+ languageVersion.preprocessorDefinition (" __swift__" , {10000 , 100 , 1 }),
462
461
463
- languageVersion. preprocessorDefinition ( " __swift__ " , { 10000 , 100 , 1 }) ,
462
+ " -fretain-comments-from-system-headers " ,
464
463
465
- " -fretain-comments-from-system-headers" ,
464
+ SHIMS_INCLUDE_FLAG, searchPathOpts.RuntimeResourcePath ,
465
+ });
466
466
467
- SHIMS_INCLUDE_FLAG, searchPathOpts.RuntimeResourcePath ,
468
- });
467
+ if (LangOpts.EnableObjCInterop ) {
468
+ invocationArgStrs.insert (invocationArgStrs.end (),
469
+ {" -x" , " objective-c" , " -std=gnu11" , " -fobjc-arc" });
470
+ // TODO: Investigate whether 7.0 is a suitable default version.
471
+ if (!triple.isOSDarwin ())
472
+ invocationArgStrs.insert (invocationArgStrs.end (),
473
+ {" -fobjc-runtime=ios-7.0" });
474
+ } else {
475
+ invocationArgStrs.insert (invocationArgStrs.end (), {" -x" , " c" , " -std=gnu11" });
476
+ }
469
477
470
478
// Set C language options.
471
479
if (triple.isOSDarwin ()) {
472
480
invocationArgStrs.insert (invocationArgStrs.end (), {
473
- // Darwin uses Objective-C ARC.
474
- " -x" , " objective-c" , " -std=gnu11" , " -fobjc-arc" ,
475
-
476
481
// Define macros that Swift bridging headers use.
477
482
" -DSWIFT_CLASS_EXTRA=__attribute__((annotate(\" "
478
483
SWIFT_NATIVE_ANNOTATION_STRING " \" )))" ,
@@ -518,24 +523,16 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
518
523
" -DSWIFT_SDK_OVERLAY_UIKIT_EPOCH=2" ,
519
524
});
520
525
521
- // Get the version of this compiler and pass it to
522
- // C/Objective-C declarations.
526
+ // Get the version of this compiler and pass it to C/Objective-C
527
+ // declarations.
523
528
auto V = version::Version::getCurrentCompilerVersion ();
524
529
if (!V.empty ()) {
525
530
invocationArgStrs.insert (invocationArgStrs.end (), {
526
531
V.preprocessorDefinition (" __SWIFT_COMPILER_VERSION" ,
527
- {1000000000 , /* ignored*/ 0 , 1000000 , 1000 , 1 }),
532
+ {1000000000 , /* ignored*/ 0 , 1000000 , 1000 , 1 }),
528
533
});
529
534
}
530
535
} else {
531
- invocationArgStrs.insert (invocationArgStrs.end (), {
532
- // Non-Darwin platforms don't use the Objective-C runtime, so they can
533
- // not import Objective-C modules.
534
- //
535
- // Just use the most feature-rich C language mode.
536
- " -x" , " c" , " -std=gnu11" ,
537
- });
538
-
539
536
// The module map used for Glibc depends on the target we're compiling for,
540
537
// and is not included in the resource directory with the other implicit
541
538
// module maps. It's at {freebsd|linux}/{arch}/glibc.modulemap.
0 commit comments