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 @@ -144,6 +144,8 @@ Bug Fixes in This Version
144144
145145Bug Fixes to Compiler Builtins
146146^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
147+ - Fix an ambiguous reference to the builtin `type_info ` (available when using
148+ `-fms-compatibility `) with modules. (#GH38400)
147149
148150Bug Fixes to Attribute Support
149151^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
@@ -2388,6 +2391,15 @@ class ASTContext : public RefCountedBase<ASTContext> {
23882391 return getTagDeclType (MSGuidTagDecl);
23892392 }
23902393
2394+ // / Retrieve the implicitly-predeclared 'struct type_info' declaration.
2395+ TagDecl *getMSTypeInfoTagDecl () const {
2396+ // Lazily create this type on demand - it's only needed for MS builds.
2397+ if (!MSTypeInfoTagDecl) {
2398+ MSTypeInfoTagDecl = buildImplicitRecord (" type_info" );
2399+ }
2400+ return MSTypeInfoTagDecl;
2401+ }
2402+
23912403 // / Return whether a declaration to a builtin is allowed to be
23922404 // / overloaded/redeclared.
23932405 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 @@ -8317,6 +8317,9 @@ Decl *ASTReader::getPredefinedDecl(PredefinedDeclIDs ID) {
83178317 NewLoaded = Context.getCFConstantStringTagDecl ();
83188318 break ;
83198319
8320+ case PREDEF_DECL_BUILTIN_MS_TYPE_INFO_TAG_ID:
8321+ return Context.getMSTypeInfoTagDecl ();
8322+
83208323#define BuiltinTemplate (BTName ) \
83218324 case PREDEF_DECL##BTName##_ID: \
83228325 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