@@ -577,6 +577,115 @@ namespace swift {
577
577
// / parameters of closures.
578
578
bool EnableOneWayClosureParameters = false ;
579
579
};
580
+
581
+ // / Options for controlling the behavior of the Clang importer.
582
+ class ClangImporterOptions final {
583
+ public:
584
+ // / The module cache path which the Clang importer should use.
585
+ std::string ModuleCachePath;
586
+
587
+ // / Extra arguments which should be passed to the Clang importer.
588
+ std::vector<std::string> ExtraArgs;
589
+
590
+ // / A directory for overriding Clang's resource directory.
591
+ std::string OverrideResourceDir;
592
+
593
+ // / The target CPU to compile for.
594
+ // /
595
+ // / Equivalent to Clang's -mcpu=.
596
+ std::string TargetCPU;
597
+
598
+ // / The path to which we should store indexing data, if any.
599
+ std::string IndexStorePath;
600
+
601
+ // / The bridging header or PCH that will be imported.
602
+ std::string BridgingHeader;
603
+
604
+ // / When automatically generating a precompiled header from the bridging
605
+ // / header, place it in this directory.
606
+ std::string PrecompiledHeaderOutputDir;
607
+
608
+ // / The optimizaton setting. This doesn't typically matter for
609
+ // / import, but it can affect Clang's IR generation of static functions.
610
+ std::string Optimization;
611
+
612
+ // / Disable validating the persistent PCH.
613
+ bool PCHDisableValidation = false ;
614
+
615
+ // / \see Mode
616
+ enum class Modes : uint8_t {
617
+ // / Set up Clang for importing modules into Swift and generating IR from
618
+ // / Swift code.
619
+ Normal,
620
+ // / Set up Clang for backend compilation only.
621
+ EmbedBitcode,
622
+ // / Set up Clang to emit a precompiled module from a C/Objective-C module
623
+ // / map or dump debugging info about a precompiled module.
624
+ PrecompiledModule
625
+ };
626
+
627
+ // / Controls how Clang is initially set up.
628
+ Modes Mode = Modes::Normal;
629
+
630
+ // / When set, preserves more information during import.
631
+ // /
632
+ // / Also \em disables some information that is only needed for object file
633
+ // / generation.
634
+ bool DetailedPreprocessingRecord = false ;
635
+
636
+ // / If true, Clang diagnostics will be dumped to stderr using Clang's
637
+ // / diagnostic printer as well as being passed to Swift's diagnostic engine.
638
+ bool DumpClangDiagnostics = false ;
639
+
640
+ // / If true, forward declarations will be imported using unavailable types
641
+ // / instead of dropped altogether when possible.
642
+ bool ImportForwardDeclarations = false ;
643
+
644
+ // / Whether to use the import as member inference system
645
+ // /
646
+ // / When importing a global, try to infer whether we can import it as a
647
+ // / member of some type instead. This includes inits, computed properties,
648
+ // / and methods.
649
+ bool InferImportAsMember = false ;
650
+
651
+ // / If true ignore the swift bridged attribute.
652
+ bool DisableSwiftBridgeAttr = false ;
653
+
654
+ // / When set, don't look for or load overlays.
655
+ bool DisableOverlayModules = false ;
656
+
657
+ // / When set, don't enforce warnings with -Werror.
658
+ bool DebuggerSupport = false ;
659
+
660
+ // / When set, ClangImporter is disabled, and all requests go to the
661
+ // / DWARFImporter delegate.
662
+ bool DisableSourceImport = false ;
663
+
664
+ // / When set, use ExtraArgs alone to configure clang instance because ExtraArgs
665
+ // / contains the full option set.
666
+ bool ExtraArgsOnly = false ;
667
+
668
+ // / Return a hash code of any components from these options that should
669
+ // / contribute to a Swift Bridging PCH hash.
670
+ llvm::hash_code getPCHHashComponents () const {
671
+ using llvm::hash_combine;
672
+ using llvm::hash_combine_range;
673
+
674
+ return hash_combine (ModuleCachePath,
675
+ hash_combine_range (ExtraArgs.begin (), ExtraArgs.end ()),
676
+ OverrideResourceDir,
677
+ TargetCPU,
678
+ BridgingHeader,
679
+ PrecompiledHeaderOutputDir,
680
+ static_cast <uint8_t >(Mode),
681
+ DetailedPreprocessingRecord,
682
+ ImportForwardDeclarations,
683
+ InferImportAsMember,
684
+ DisableSwiftBridgeAttr,
685
+ DisableOverlayModules);
686
+ }
687
+ };
688
+
580
689
} // end namespace swift
581
690
582
691
#endif // SWIFT_BASIC_LANGOPTIONS_H
0 commit comments