Skip to content

Commit e107182

Browse files
committed
Merge remote-tracking branch 'apple/master' into master-rebranch
2 parents ac6dffd + ed5edb8 commit e107182

File tree

74 files changed

+1040
-674
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1040
-674
lines changed

include/swift/AST/ASTContext.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ class ASTContext final {
214214
void operator=(const ASTContext&) = delete;
215215

216216
ASTContext(LangOptions &langOpts, TypeCheckerOptions &typeckOpts,
217-
SearchPathOptions &SearchPathOpts, SourceManager &SourceMgr,
217+
SearchPathOptions &SearchPathOpts,
218+
ClangImporterOptions &ClangImporterOpts,
219+
SourceManager &SourceMgr,
218220
DiagnosticEngine &Diags);
219221

220222
public:
@@ -228,6 +230,7 @@ class ASTContext final {
228230

229231
static ASTContext *get(LangOptions &langOpts, TypeCheckerOptions &typeckOpts,
230232
SearchPathOptions &SearchPathOpts,
233+
ClangImporterOptions &ClangImporterOpts,
231234
SourceManager &SourceMgr, DiagnosticEngine &Diags);
232235
~ASTContext();
233236

@@ -246,6 +249,9 @@ class ASTContext final {
246249
/// The search path options used by this AST context.
247250
SearchPathOptions &SearchPathOpts;
248251

252+
/// The clang importer options used by this AST context.
253+
ClangImporterOptions &ClangImporterOpts;
254+
249255
/// The source manager object.
250256
SourceManager &SourceMgr;
251257

include/swift/AST/Decl.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -3886,7 +3886,7 @@ class ClassDecl final : public NominalTypeDecl {
38863886

38873887
friend class SuperclassDeclRequest;
38883888
friend class SuperclassTypeRequest;
3889-
friend class EmittedMembersRequest;
3889+
friend class SemanticMembersRequest;
38903890
friend class HasMissingDesignatedInitializersRequest;
38913891
friend class InheritsSuperclassInitializersRequest;
38923892

@@ -4074,10 +4074,6 @@ class ClassDecl final : public NominalTypeDecl {
40744074
/// Record the presence of an @objc method with the given selector.
40754075
void recordObjCMethod(AbstractFunctionDecl *method, ObjCSelector selector);
40764076

4077-
/// Get all the members of this class, synthesizing any implicit members
4078-
/// that appear in the vtable if needed.
4079-
ArrayRef<Decl *> getEmittedMembers() const;
4080-
40814077
// Implement isa/cast/dyncast/etc.
40824078
static bool classof(const Decl *D) {
40834079
return D->getKind() == DeclKind::Class;

include/swift/AST/DeclContext.h

+10
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,16 @@ class IterableDeclContext {
783783
/// Retrieve the set of members in this context.
784784
DeclRange getMembers() const;
785785

786+
/// Get the members that were syntactically present in the source code,
787+
/// and will not contain any members that are implicitly synthesized by
788+
/// the implementation.
789+
ArrayRef<Decl *> getParsedMembers() const;
790+
791+
/// Get all the members that are semantically within this context,
792+
/// including any implicitly-synthesized members.
793+
/// The resulting list of members will be stable across translation units.
794+
ArrayRef<Decl *> getSemanticMembers() const;
795+
786796
/// Retrieve the set of members in this context without loading any from the
787797
/// associated lazy loader; this should only be used as part of implementing
788798
/// abstractions on top of member loading, such as a name lookup table.

include/swift/AST/DiagnosticsFrontend.def

+4-4
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,11 @@ ERROR(error_optimization_remark_pattern, none, "%0 in '%1'",
328328
(StringRef, StringRef))
329329

330330
ERROR(error_invalid_debug_prefix_map, none,
331-
"invalid argument '%0' to -debug-prefix-map; it must be of the form "
332-
"'original=remapped'", (StringRef))
331+
"values for '-debug-prefix-map' must be in the format 'original=remapped'"
332+
", but '%0' was provided", (StringRef))
333333
ERROR(error_invalid_coverage_prefix_map, none,
334-
"invalid argument '%0' to -coverage-prefix-map; it must be of the form "
335-
"'original=remapped'", (StringRef))
334+
"values for '-coverage-prefix-map' must be in the format "
335+
"'original=remapped', but '%0' was provided", (StringRef))
336336

337337

338338
ERROR(error_unable_to_write_swift_ranges_file, none,

include/swift/AST/SILOptions.h

+5
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ class SILOptions {
128128
/// Assume that code will be executed in a single-threaded environment.
129129
bool AssumeSingleThreaded = false;
130130

131+
/// Turn @inline(__always) attributes into no-ops.
132+
///
133+
/// For experimentation around code size reduction.
134+
bool IgnoreAlwaysInline = false;
135+
131136
/// Indicates which sanitizer is turned on.
132137
OptionSet<SanitizerKind> Sanitizers;
133138

include/swift/AST/TypeCheckRequests.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1080,9 +1080,9 @@ class SynthesizeAccessorRequest :
10801080
void cacheResult(AccessorDecl *value) const;
10811081
};
10821082

1083-
class EmittedMembersRequest :
1084-
public SimpleRequest<EmittedMembersRequest,
1085-
ArrayRef<Decl *>(ClassDecl *),
1083+
class SemanticMembersRequest :
1084+
public SimpleRequest<SemanticMembersRequest,
1085+
ArrayRef<Decl *>(IterableDeclContext *),
10861086
RequestFlags::Cached> {
10871087
public:
10881088
using SimpleRequest::SimpleRequest;
@@ -1092,7 +1092,7 @@ class EmittedMembersRequest :
10921092

10931093
// Evaluation.
10941094
ArrayRef<Decl *>
1095-
evaluate(Evaluator &evaluator, ClassDecl *classDecl) const;
1095+
evaluate(Evaluator &evaluator, IterableDeclContext *idc) const;
10961096

10971097
public:
10981098
bool isCached() const { return true; }

include/swift/AST/TypeCheckerTypeIDZone.def

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ SWIFT_REQUEST(TypeChecker, TypeEraserHasViableInitRequest,
6565
SWIFT_REQUEST(TypeChecker, DynamicallyReplacedDeclRequest,
6666
ValueDecl *(ValueDecl *),
6767
Cached, NoLocationInfo)
68-
SWIFT_REQUEST(TypeChecker, EmittedMembersRequest, ArrayRef<Decl *>(ClassDecl *),
69-
Cached, NoLocationInfo)
68+
SWIFT_REQUEST(TypeChecker, SemanticMembersRequest,
69+
ArrayRef<Decl *>(IterableDeclContext *), Cached, NoLocationInfo)
7070
SWIFT_REQUEST(TypeChecker, EnumRawValuesRequest,
7171
evaluator::SideEffect (EnumDecl *, TypeResolutionStage),
7272
SeparatelyCached, NoLocationInfo)

include/swift/Basic/LangOptions.h

+109
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,115 @@ namespace swift {
577577
/// parameters of closures.
578578
bool EnableOneWayClosureParameters = false;
579579
};
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+
580689
} // end namespace swift
581690

582691
#endif // SWIFT_BASIC_LANGOPTIONS_H

include/swift/ClangImporter/ClangImporter.h

+3-6
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class ClangImporter final : public ClangModuleLoader {
115115
private:
116116
Implementation &Impl;
117117

118-
ClangImporter(ASTContext &ctx, const ClangImporterOptions &clangImporterOpts,
118+
ClangImporter(ASTContext &ctx,
119119
DependencyTracker *tracker,
120120
DWARFImporterDelegate *dwarfImporterDelegate);
121121

@@ -137,8 +137,6 @@ class ClangImporter final : public ClangModuleLoader {
137137
/// \param ctx The ASTContext into which the module will be imported.
138138
/// The ASTContext's SearchPathOptions will be used for the Clang importer.
139139
///
140-
/// \param importerOpts The options to use for the Clang importer.
141-
///
142140
/// \param swiftPCHHash A hash of Swift's various options in a compiler
143141
/// invocation, used to create a unique Bridging PCH if requested.
144142
///
@@ -150,12 +148,12 @@ class ClangImporter final : public ClangModuleLoader {
150148
/// \returns a new Clang module importer, or null (with a diagnostic) if
151149
/// an error occurred.
152150
static std::unique_ptr<ClangImporter>
153-
create(ASTContext &ctx, const ClangImporterOptions &importerOpts,
151+
create(ASTContext &ctx,
154152
std::string swiftPCHHash = "", DependencyTracker *tracker = nullptr,
155153
DWARFImporterDelegate *dwarfImporterDelegate = nullptr);
156154

157155
static std::vector<std::string>
158-
getClangArguments(ASTContext &ctx, const ClangImporterOptions &importerOpts);
156+
getClangArguments(ASTContext &ctx);
159157

160158
static std::unique_ptr<clang::CompilerInvocation>
161159
createClangInvocation(ClangImporter *importer,
@@ -474,7 +472,6 @@ class ClangImporter final : public ClangModuleLoader {
474472

475473
bool isSerializable(const clang::Type *type,
476474
bool checkCanonical) const override;
477-
ArrayRef<std::string> getExtraClangArgs() const;
478475
};
479476

480477
ImportDecl *createImportDecl(ASTContext &Ctx, DeclContext *DC, ClangNode ClangN,

0 commit comments

Comments
 (0)