@@ -278,18 +278,18 @@ typedef std::shared_ptr<SwiftEnumDescriptor> SwiftEnumDescriptorSP;
278
278
typedef llvm::DenseMap<opaque_compiler_type_t , SwiftEnumDescriptorSP>
279
279
EnumInfoCache;
280
280
typedef std::shared_ptr<EnumInfoCache> EnumInfoCacheSP;
281
- typedef llvm::DenseMap<const swift::ASTContext *, EnumInfoCacheSP>
281
+ typedef llvm::DenseMap<const SwiftASTContext *, EnumInfoCacheSP>
282
282
ASTEnumInfoCacheMap;
283
283
284
- static EnumInfoCache *GetEnumInfoCache (const swift::ASTContext *a ) {
284
+ static EnumInfoCache *GetEnumInfoCache (const SwiftASTContext *swift_ast_ctx ) {
285
285
static ASTEnumInfoCacheMap g_cache;
286
286
static std::mutex g_mutex;
287
287
std::lock_guard<std::mutex> locker (g_mutex);
288
- ASTEnumInfoCacheMap::iterator pos = g_cache.find (a );
288
+ ASTEnumInfoCacheMap::iterator pos = g_cache.find (swift_ast_ctx );
289
289
if (pos == g_cache.end ()) {
290
- g_cache.insert (
291
- std::make_pair (a , std::shared_ptr<EnumInfoCache>(new EnumInfoCache ())));
292
- return g_cache.find (a )->second .get ();
290
+ g_cache.insert (std::make_pair (
291
+ swift_ast_ctx , std::shared_ptr<EnumInfoCache>(new EnumInfoCache ())));
292
+ return g_cache.find (swift_ast_ctx )->second .get ();
293
293
}
294
294
return pos->second .get ();
295
295
}
@@ -357,12 +357,12 @@ class SwiftEnumDescriptor {
357
357
358
358
virtual ~SwiftEnumDescriptor () = default ;
359
359
360
- static SwiftEnumDescriptor *CreateDescriptor (swift::ASTContext *ast ,
360
+ static SwiftEnumDescriptor *CreateDescriptor (SwiftASTContext *swift_ast_ctx ,
361
361
swift::CanType swift_can_type,
362
362
swift::EnumDecl *enum_decl);
363
363
364
364
protected:
365
- SwiftEnumDescriptor (swift::ASTContext *ast, swift:: CanType swift_can_type,
365
+ SwiftEnumDescriptor (swift::CanType swift_can_type,
366
366
swift::EnumDecl *enum_decl, SwiftEnumDescriptor::Kind k)
367
367
: m_kind(k), m_type_name() {
368
368
if (swift_can_type.getPointer ()) {
@@ -381,10 +381,9 @@ class SwiftEnumDescriptor {
381
381
382
382
class SwiftEmptyEnumDescriptor : public SwiftEnumDescriptor {
383
383
public:
384
- SwiftEmptyEnumDescriptor (swift::ASTContext *ast,
385
- swift::CanType swift_can_type,
384
+ SwiftEmptyEnumDescriptor (swift::CanType swift_can_type,
386
385
swift::EnumDecl *enum_decl)
387
- : SwiftEnumDescriptor(ast, swift_can_type, enum_decl,
386
+ : SwiftEnumDescriptor(swift_can_type, enum_decl,
388
387
SwiftEnumDescriptor::Kind::Empty) {}
389
388
390
389
ElementInfo *GetElementFromData (const lldb_private::DataExtractor &data,
@@ -445,18 +444,15 @@ class SwiftCStyleEnumDescriptor : public SwiftEnumDescriptor {
445
444
llvm::SmallString<32 > m_description = {" SwiftCStyleEnumDescriptor" };
446
445
447
446
public:
448
- SwiftCStyleEnumDescriptor (swift::ASTContext *ast ,
447
+ SwiftCStyleEnumDescriptor (SwiftASTContext *swift_ast_ctx ,
449
448
swift::CanType swift_can_type,
450
449
swift::EnumDecl *enum_decl)
451
- : SwiftEnumDescriptor(ast, swift_can_type, enum_decl,
450
+ : SwiftEnumDescriptor(swift_can_type, enum_decl,
452
451
SwiftEnumDescriptor::Kind::CStyle),
453
452
m_nopayload_elems_bitmask (), m_elements(), m_element_indexes() {
454
453
LOG_PRINTF (GetLog (LLDBLog::Types), " doing C-style enum layout for %s" ,
455
454
GetTypeName ().AsCString ());
456
455
457
- SwiftASTContext *swift_ast_ctx = SwiftASTContext::GetSwiftASTContext (ast);
458
- if (!swift_ast_ctx)
459
- return ;
460
456
swift::irgen::IRGenModule &irgen_module = swift_ast_ctx->GetIRGenModule ();
461
457
const swift::irgen::EnumImplStrategy &enum_impl_strategy =
462
458
swift::irgen::getEnumImplStrategy (irgen_module, swift_can_type);
@@ -587,15 +583,14 @@ class SwiftAllPayloadEnumDescriptor : public SwiftEnumDescriptor {
587
583
llvm::SmallString<32 > m_description = {" SwiftAllPayloadEnumDescriptor" };
588
584
589
585
public:
590
- SwiftAllPayloadEnumDescriptor (swift::ASTContext *ast ,
586
+ SwiftAllPayloadEnumDescriptor (SwiftASTContext *swift_ast_ctx ,
591
587
swift::CanType swift_can_type,
592
588
swift::EnumDecl *enum_decl)
593
- : SwiftEnumDescriptor(ast, swift_can_type, enum_decl,
589
+ : SwiftEnumDescriptor(swift_can_type, enum_decl,
594
590
SwiftEnumDescriptor::Kind::AllPayload) {
595
591
LOG_PRINTF (GetLog (LLDBLog::Types), " doing ADT-style enum layout for %s" ,
596
592
GetTypeName ().AsCString ());
597
593
598
- SwiftASTContext *swift_ast_ctx = SwiftASTContext::GetSwiftASTContext (ast);
599
594
swift::irgen::IRGenModule &irgen_module = swift_ast_ctx->GetIRGenModule ();
600
595
const swift::irgen::EnumImplStrategy &enum_impl_strategy =
601
596
swift::irgen::getEnumImplStrategy (irgen_module, swift_can_type);
@@ -730,13 +725,13 @@ class SwiftAllPayloadEnumDescriptor : public SwiftEnumDescriptor {
730
725
731
726
class SwiftMixedEnumDescriptor : public SwiftEnumDescriptor {
732
727
public:
733
- SwiftMixedEnumDescriptor (swift::ASTContext *ast ,
728
+ SwiftMixedEnumDescriptor (SwiftASTContext *swift_ast_ctx ,
734
729
swift::CanType swift_can_type,
735
730
swift::EnumDecl *enum_decl)
736
- : SwiftEnumDescriptor(ast, swift_can_type, enum_decl,
731
+ : SwiftEnumDescriptor(swift_can_type, enum_decl,
737
732
SwiftEnumDescriptor::Kind::Mixed),
738
- m_non_payload_cases (ast , swift_can_type, enum_decl),
739
- m_payload_cases(ast , swift_can_type, enum_decl) {}
733
+ m_non_payload_cases (swift_ast_ctx , swift_can_type, enum_decl),
734
+ m_payload_cases(swift_ast_ctx , swift_can_type, enum_decl) {}
740
735
741
736
ElementInfo *GetElementFromData (const lldb_private::DataExtractor &data,
742
737
bool no_payload) override {
@@ -775,10 +770,9 @@ class SwiftResilientEnumDescriptor : public SwiftEnumDescriptor {
775
770
llvm::SmallString<32 > m_description = {" SwiftResilientEnumDescriptor" };
776
771
777
772
public:
778
- SwiftResilientEnumDescriptor (swift::ASTContext *ast,
779
- swift::CanType swift_can_type,
773
+ SwiftResilientEnumDescriptor (swift::CanType swift_can_type,
780
774
swift::EnumDecl *enum_decl)
781
- : SwiftEnumDescriptor(ast, swift_can_type, enum_decl,
775
+ : SwiftEnumDescriptor(swift_can_type, enum_decl,
782
776
SwiftEnumDescriptor::Kind::Resilient) {
783
777
LOG_PRINTF (GetLog (LLDBLog::Types), " doing resilient enum layout for %s" ,
784
778
GetTypeName ().AsCString ());
@@ -803,13 +797,12 @@ class SwiftResilientEnumDescriptor : public SwiftEnumDescriptor {
803
797
};
804
798
805
799
SwiftEnumDescriptor *
806
- SwiftEnumDescriptor::CreateDescriptor (swift::ASTContext *ast ,
800
+ SwiftEnumDescriptor::CreateDescriptor (SwiftASTContext *swift_ast_ctx ,
807
801
swift::CanType swift_can_type,
808
802
swift::EnumDecl *enum_decl) {
809
- assert (ast );
803
+ assert (swift_ast_ctx );
810
804
assert (enum_decl);
811
805
assert (swift_can_type.getPointer ());
812
- SwiftASTContext *swift_ast_ctx = SwiftASTContext::GetSwiftASTContext (ast);
813
806
assert (swift_ast_ctx);
814
807
swift::irgen::IRGenModule &irgen_module = swift_ast_ctx->GetIRGenModule ();
815
808
const swift::irgen::EnumImplStrategy &enum_impl_strategy =
@@ -820,32 +813,35 @@ SwiftEnumDescriptor::CreateDescriptor(swift::ASTContext *ast,
820
813
elements_with_no_payload = enum_impl_strategy.getElementsWithNoPayload ();
821
814
swift::SILType swift_sil_type = irgen_module.getLoweredType (swift_can_type);
822
815
if (!irgen_module.getTypeInfo (swift_sil_type).isFixedSize ())
823
- return new SwiftResilientEnumDescriptor (ast, swift_can_type, enum_decl);
816
+ return new SwiftResilientEnumDescriptor (swift_can_type, enum_decl);
824
817
if (elements_with_no_payload.size () == 0 ) {
825
818
// Nothing with no payload.. empty or all payloads?
826
819
if (elements_with_payload.size () == 0 )
827
- return new SwiftEmptyEnumDescriptor (ast, swift_can_type, enum_decl);
828
- return new SwiftAllPayloadEnumDescriptor (ast, swift_can_type, enum_decl);
820
+ return new SwiftEmptyEnumDescriptor (swift_can_type, enum_decl);
821
+ return new SwiftAllPayloadEnumDescriptor (swift_ast_ctx, swift_can_type,
822
+ enum_decl);
829
823
}
830
824
831
825
// Something with no payload.. mixed or C-style?
832
826
if (elements_with_payload.size () == 0 )
833
- return new SwiftCStyleEnumDescriptor (ast, swift_can_type, enum_decl);
834
- return new SwiftMixedEnumDescriptor (ast, swift_can_type, enum_decl);
827
+ return new SwiftCStyleEnumDescriptor (swift_ast_ctx, swift_can_type,
828
+ enum_decl);
829
+ return new SwiftMixedEnumDescriptor (swift_ast_ctx, swift_can_type, enum_decl);
835
830
}
836
831
837
832
static SwiftEnumDescriptor *
838
- GetEnumInfoFromEnumDecl (swift::ASTContext *ast, swift::CanType swift_can_type,
833
+ GetEnumInfoFromEnumDecl (SwiftASTContext *swift_ast_ctx,
834
+ swift::CanType swift_can_type,
839
835
swift::EnumDecl *enum_decl) {
840
- return SwiftEnumDescriptor::CreateDescriptor (ast, swift_can_type, enum_decl);
836
+ return SwiftEnumDescriptor::CreateDescriptor (swift_ast_ctx, swift_can_type,
837
+ enum_decl);
841
838
}
842
839
843
840
SwiftEnumDescriptor *
844
841
SwiftASTContext::GetCachedEnumInfo (opaque_compiler_type_t type) {
845
842
VALID_OR_RETURN_CHECK_TYPE (type, nullptr );
846
843
847
- ThreadSafeASTContext ast_ctx = GetASTContext ();
848
- EnumInfoCache *enum_info_cache = GetEnumInfoCache (*ast_ctx);
844
+ EnumInfoCache *enum_info_cache = GetEnumInfoCache (this );
849
845
EnumInfoCache::const_iterator pos = enum_info_cache->find (type);
850
846
if (pos != enum_info_cache->end ())
851
847
return pos->second .get ();
@@ -856,11 +852,11 @@ SwiftASTContext::GetCachedEnumInfo(opaque_compiler_type_t type) {
856
852
SwiftEnumDescriptorSP enum_info_sp;
857
853
swift::CanType swift_can_type (GetCanonicalSwiftType (type));
858
854
if (auto *enum_type = swift_can_type->getAs <swift::EnumType>()) {
859
- enum_info_sp.reset (GetEnumInfoFromEnumDecl (*ast_ctx , swift_can_type,
855
+ enum_info_sp.reset (GetEnumInfoFromEnumDecl (this , swift_can_type,
860
856
enum_type->getDecl ()));
861
857
} else if (auto *bound_enum_type =
862
858
swift_can_type->getAs <swift::BoundGenericEnumType>()) {
863
- enum_info_sp.reset (GetEnumInfoFromEnumDecl (*ast_ctx , swift_can_type,
859
+ enum_info_sp.reset (GetEnumInfoFromEnumDecl (this , swift_can_type,
864
860
bound_enum_type->getDecl ()));
865
861
}
866
862
0 commit comments