@@ -31,7 +31,7 @@ using namespace irgen;
31
31
32
32
class ReflectionMetadataBuilder : public ConstantBuilder <> {
33
33
protected:
34
- SmallPtrSetImpl <CanType> &BuiltinTypes;
34
+ llvm::SetVector <CanType> &BuiltinTypes;
35
35
36
36
// Collect any builtin types referenced from this type.
37
37
void addBuiltinTypeRefs (CanType type) {
@@ -54,7 +54,7 @@ class ReflectionMetadataBuilder : public ConstantBuilder<> {
54
54
55
55
public:
56
56
ReflectionMetadataBuilder (IRGenModule &IGM,
57
- SmallPtrSetImpl <CanType> &BuiltinTypes)
57
+ llvm::SetVector <CanType> &BuiltinTypes)
58
58
: ConstantBuilder(IGM), BuiltinTypes(BuiltinTypes) {}
59
59
};
60
60
@@ -127,7 +127,7 @@ class AssociatedTypeMetadataBuilder : public ReflectionMetadataBuilder {
127
127
AssociatedTypeMetadataBuilder (IRGenModule &IGM,
128
128
ArrayRef<const NominalTypeDecl *> NominalTypeDecls,
129
129
ArrayRef<const ExtensionDecl *> ExtensionDecls,
130
- SmallPtrSetImpl <CanType> &BuiltinTypes)
130
+ llvm::SetVector <CanType> &BuiltinTypes)
131
131
: ReflectionMetadataBuilder(IGM, BuiltinTypes),
132
132
NominalTypeDecls (NominalTypeDecls),
133
133
ExtensionDecls(ExtensionDecls) {}
@@ -237,7 +237,7 @@ class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder {
237
237
public:
238
238
FieldTypeMetadataBuilder (IRGenModule &IGM,
239
239
ArrayRef<const NominalTypeDecl *> NominalTypeDecls,
240
- SmallPtrSetImpl <CanType> &BuiltinTypes)
240
+ llvm::SetVector <CanType> &BuiltinTypes)
241
241
: ReflectionMetadataBuilder(IGM, BuiltinTypes),
242
242
NominalTypeDecls (NominalTypeDecls) {}
243
243
@@ -273,7 +273,7 @@ class BuiltinTypeMetadataBuilder : public ReflectionMetadataBuilder {
273
273
void addBuiltinType (CanType builtinType) {
274
274
addTypeRef (builtinType->getASTContext ().TheBuiltinModule , builtinType);
275
275
276
- auto &ti = cast<LoadableTypeInfo >(IGM.getTypeInfoForUnlowered (builtinType));
276
+ auto &ti = cast<FixedTypeInfo >(IGM.getTypeInfoForUnlowered (builtinType));
277
277
addConstantInt32 (ti.getFixedSize ().getValue ());
278
278
addConstantInt32 (ti.getFixedAlignment ().getValue ());
279
279
addConstantInt32 (ti.getFixedStride ().getValue ());
@@ -288,7 +288,7 @@ class BuiltinTypeMetadataBuilder : public ReflectionMetadataBuilder {
288
288
289
289
public:
290
290
BuiltinTypeMetadataBuilder (IRGenModule &IGM,
291
- SmallPtrSetImpl <CanType> &BuiltinTypes)
291
+ llvm::SetVector <CanType> &BuiltinTypes)
292
292
: ReflectionMetadataBuilder(IGM, BuiltinTypes) {}
293
293
294
294
llvm::GlobalVariable *emit () {
@@ -381,15 +381,16 @@ llvm::Constant *IRGenModule::getAddrOfStringForTypeRef(StringRef Str) {
381
381
382
382
void IRGenModule::emitReflectionMetadataRecords () {
383
383
auto DoNotHaveDecls = NominalTypeDecls.empty () && ExtensionDecls.empty ();
384
- if (!Opts.EnableReflectionMetadata || DoNotHaveDecls)
384
+ if (!Opts.EnableReflectionMetadata ||
385
+ (!Opts.EnableReflectionBuiltins && DoNotHaveDecls))
385
386
return ;
386
387
387
388
// We collect all referenced builtin types and emit records for them.
388
389
// In practice only the standard library should directly reference
389
390
// builtin types.
390
391
//
391
392
// FIXME: This metadata should be in the runtime instead.
392
- SmallPtrSet <CanType, 4 > BuiltinTypes;
393
+ llvm::SetVector <CanType> BuiltinTypes;
393
394
394
395
{
395
396
FieldTypeMetadataBuilder builder (*this , NominalTypeDecls, BuiltinTypes);
@@ -408,7 +409,13 @@ void IRGenModule::emitReflectionMetadataRecords() {
408
409
addUsedGlobal (var);
409
410
}
410
411
411
- {
412
+ if (Opts.EnableReflectionBuiltins ) {
413
+ BuiltinTypes.insert (Context.TheNativeObjectType );
414
+ BuiltinTypes.insert (Context.TheUnknownObjectType );
415
+ BuiltinTypes.insert (Context.TheBridgeObjectType );
416
+ BuiltinTypes.insert (Context.TheRawPointerType );
417
+ BuiltinTypes.insert (Context.TheUnsafeValueBufferType );
418
+
412
419
BuiltinTypeMetadataBuilder builder (*this , BuiltinTypes);
413
420
auto var = builder.emit ();
414
421
if (var)
0 commit comments