File tree Expand file tree Collapse file tree 7 files changed +38
-3
lines changed Expand file tree Collapse file tree 7 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,8 @@ Bug Fixes in This Version
137137
138138Bug Fixes to Compiler Builtins
139139^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
140+ - Fix an ambiguous reference to the builtin `type_info ` (available when using
141+ `-fms-compatibility `) with modules. (#GH38400)
140142
141143Bug Fixes to Attribute Support
142144^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change @@ -1290,6 +1290,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
12901290 // Implicitly-declared type 'struct _GUID'.
12911291 mutable TagDecl *MSGuidTagDecl = nullptr ;
12921292
1293+ // Implicitly-declared type 'struct type_info'.
1294+ mutable TagDecl *MSTypeInfoTagDecl = nullptr ;
1295+
12931296 // / Keep track of CUDA/HIP device-side variables ODR-used by host code.
12941297 // / This does not include extern shared variables used by device host
12951298 // / functions as addresses of shared variables are per warp, therefore
@@ -2381,6 +2384,15 @@ class ASTContext : public RefCountedBase<ASTContext> {
23812384 return getTagDeclType (MSGuidTagDecl);
23822385 }
23832386
2387+ // / Retrieve the implicitly-predeclared 'struct type_info' declaration.
2388+ TagDecl *getMSTypeInfoTagDecl () const {
2389+ // Lazily create this type on demand - it's only needed for MS builds.
2390+ if (!MSTypeInfoTagDecl) {
2391+ MSTypeInfoTagDecl = buildImplicitRecord (" type_info" );
2392+ }
2393+ return MSTypeInfoTagDecl;
2394+ }
2395+
23842396 // / Return whether a declaration to a builtin is allowed to be
23852397 // / overloaded/redeclared.
23862398 bool canBuiltinBeRedeclared (const FunctionDecl *) const ;
Original file line number Diff line number Diff line change @@ -77,6 +77,9 @@ enum PredefinedDeclIDs {
7777 // / The internal '__NSConstantString' tag type.
7878 PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID,
7979
80+ // / The predeclared 'type_info' struct.
81+ PREDEF_DECL_BUILTIN_MS_TYPE_INFO_TAG_ID,
82+
8083#define BuiltinTemplate (BTName ) PREDEF_DECL##BTName##_ID,
8184#include " clang/Basic/BuiltinTemplates.inc"
8285
Original file line number Diff line number Diff line change @@ -443,9 +443,7 @@ void Sema::Initialize() {
443443 if (getLangOpts ().MSVCCompat ) {
444444 if (getLangOpts ().CPlusPlus &&
445445 IdResolver.begin (&Context.Idents .get (" type_info" )) == IdResolver.end ())
446- PushOnScopeChains (
447- Context.buildImplicitRecord (" type_info" , TagTypeKind::Class),
448- TUScope);
446+ PushOnScopeChains (Context.getMSTypeInfoTagDecl (), TUScope);
449447
450448 addImplicitTypedef (" size_t" , Context.getSizeType ());
451449 }
Original file line number Diff line number Diff line change @@ -8318,6 +8318,9 @@ Decl *ASTReader::getPredefinedDecl(PredefinedDeclIDs ID) {
83188318 NewLoaded = Context.getCFConstantStringTagDecl ();
83198319 break ;
83208320
8321+ case PREDEF_DECL_BUILTIN_MS_TYPE_INFO_TAG_ID:
8322+ return Context.getMSTypeInfoTagDecl ();
8323+
83218324#define BuiltinTemplate (BTName ) \
83228325 case PREDEF_DECL##BTName##_ID: \
83238326 if (Context.Decl ##BTName) \
Original file line number Diff line number Diff line change @@ -5618,6 +5618,8 @@ void ASTWriter::PrepareWritingSpecialDecls(Sema &SemaRef) {
56185618 PREDEF_DECL_BUILTIN_MS_VA_LIST_ID);
56195619 RegisterPredefDecl (Context.MSGuidTagDecl ,
56205620 PREDEF_DECL_BUILTIN_MS_GUID_ID);
5621+ RegisterPredefDecl (Context.MSTypeInfoTagDecl ,
5622+ PREDEF_DECL_BUILTIN_MS_TYPE_INFO_TAG_ID);
56215623 RegisterPredefDecl (Context.ExternCContext , PREDEF_DECL_EXTERN_C_CONTEXT_ID);
56225624 RegisterPredefDecl (Context.CFConstantStringTypeDecl ,
56235625 PREDEF_DECL_CF_CONSTANT_STRING_ID);
Original file line number Diff line number Diff line change 1+ // RUN: split-file %s %t
2+
3+ // RUN: %clang_cc1 -I%t -emit-module -o %t/a.pcm -fmodules %t/module.modulemap -fno-implicit-modules -fmodule-name=a -x c++-header -fms-compatibility
4+ // RUN: %clang_cc1 -I%t -emit-module -o %t/b.pcm -fmodules %t/module.modulemap -fno-implicit-modules -fmodule-name=b -x c++-header -fms-compatibility -fmodule-file=%t/a.pcm
5+
6+ // --- module.modulemap
7+ module a { header " a.h" }
8+ module b { header " b.h" }
9+
10+ // --- a.h
11+ type_info* foo;
12+
13+ // --- b.h
14+ type_info* bar;
15+
You can’t perform that action at this time.
0 commit comments