@@ -1303,29 +1303,30 @@ public static class Helpers
13031303 public static readonly string CreateInstanceIdentifier = Generator . GeneratedIdentifier ( "CreateInstance" ) ;
13041304 public static readonly string GetOrCreateInstanceIdentifier = Generator . GeneratedIdentifier ( "GetOrCreateInstance" ) ;
13051305
1306- public static string GetSuffixForInternal ( DeclarationContext @class )
1306+ public static string GetSuffixForInternal ( Class @class )
13071307 {
1308- if ( @class == null )
1309- return string . Empty ;
1310-
1311- Class template = null ;
13121308 var specialization = @class as ClassTemplateSpecialization ??
13131309 @class . Namespace as ClassTemplateSpecialization ;
1314- if ( specialization != null )
1315- {
1316- template = specialization . TemplatedDecl . TemplatedClass ;
1317- if ( @class != specialization )
1318- template = template . Classes . FirstOrDefault ( c => c . Name == @class . Name ) ;
1319- }
13201310
1321- if ( template == null || ! template . HasDependentValueFieldInLayout ( ) )
1311+ if ( specialization == null )
13221312 return string . Empty ;
13231313
1324- if ( specialization . Arguments . All (
1325- a => a . Type . Type ? . IsAddress ( ) == true ) )
1326- return "_Ptr" ;
1314+ Class template = specialization . TemplatedDecl . TemplatedClass ;
1315+ if ( @class != specialization )
1316+ template = template . Classes . FirstOrDefault ( c => c . Name == @class . Name ) ;
13271317
1328- return GetSuffixFor ( specialization ) ;
1318+ if ( template . HasDependentValueFieldInLayout ( ) )
1319+ {
1320+ if ( specialization . Arguments . All (
1321+ a => a . Type . Type ? . IsAddress ( ) == true ) )
1322+ return "_Ptr" ;
1323+ return GetSuffixFor ( specialization ) ;
1324+ }
1325+ // HACK: Clang can't always resolve complex templates such as the base of std::atomic in msvc
1326+ return ( from @base in @class . Bases
1327+ let suffix = GetSuffixForInternal ( @base . Class )
1328+ where suffix . Length > 0
1329+ select suffix ) . DefaultIfEmpty ( string . Empty ) . First ( ) ;
13291330 }
13301331
13311332 public static string GetSuffixFor ( Declaration decl )
0 commit comments