Skip to content

Commit 52ef5ac

Browse files
authored
Merge branch 'main' into fix/add-freeze-for-combineVSelectWithAllOnesOrZeros
2 parents 8077f33 + 88c6448 commit 52ef5ac

File tree

56 files changed

+4373
-996
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4373
-996
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ Bug Fixes in This Version
144144

145145
Bug 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

148150
Bug Fixes to Attribute Support
149151
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/ASTContext.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

clang/include/clang/AST/DeclID.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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

clang/include/clang/Basic/Attr.td

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,22 +1059,13 @@ def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> {
10591059
def AsmLabel : InheritableAttr {
10601060
let Spellings = [CustomKeyword<"asm">, CustomKeyword<"__asm__">];
10611061
let Args = [
1062-
// Label specifies the mangled name for the decl.
1063-
StringArgument<"Label">,
1064-
1065-
// IsLiteralLabel specifies whether the label is literal (i.e. suppresses
1066-
// the global C symbol prefix) or not. If not, the mangle-suppression prefix
1067-
// ('\01') is omitted from the decl name at the LLVM IR level.
1068-
//
1069-
// Non-literal labels are used by some external AST sources like LLDB.
1070-
BoolArgument<"IsLiteralLabel", /*optional=*/0, /*fake=*/1>
1071-
];
1062+
// Label specifies the mangled name for the decl.
1063+
StringArgument<"Label">, ];
10721064
let SemaHandler = 0;
10731065
let Documentation = [AsmLabelDocs];
1074-
let AdditionalMembers =
1075-
[{
1066+
let AdditionalMembers = [{
10761067
bool isEquivalent(AsmLabelAttr *Other) const {
1077-
return getLabel() == Other->getLabel() && getIsLiteralLabel() == Other->getIsLiteralLabel();
1068+
return getLabel() == Other->getLabel();
10781069
}
10791070
}];
10801071
}

clang/lib/AST/Mangle.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) {
161161
if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
162162
// If we have an asm name, then we use it as the mangling.
163163

164-
// If the label isn't literal, or if this is an alias for an LLVM intrinsic,
164+
// If the label is an alias for an LLVM intrinsic,
165165
// do not add a "\01" prefix.
166-
if (!ALA->getIsLiteralLabel() || ALA->getLabel().starts_with("llvm.")) {
166+
if (ALA->getLabel().starts_with("llvm.")) {
167167
Out << ALA->getLabel();
168168
return;
169169
}

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2630,7 +2630,8 @@ StringRef CGDebugInfo::getVTableName(const CXXRecordDecl *RD) {
26302630
// existing information in the DWARF. The type is assumed to be 'void *'.
26312631
void CGDebugInfo::emitVTableSymbol(llvm::GlobalVariable *VTable,
26322632
const CXXRecordDecl *RD) {
2633-
if (!CGM.getTarget().getCXXABI().isItaniumFamily())
2633+
if (!CGM.getTarget().getCXXABI().isItaniumFamily() ||
2634+
CGM.getTarget().getTriple().isOSBinFormatCOFF())
26342635
return;
26352636
if (DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
26362637
return;

clang/lib/Sema/Sema.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff 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
}

clang/lib/Sema/SemaDecl.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8113,9 +8113,7 @@ NamedDecl *Sema::ActOnVariableDeclarator(
81138113
}
81148114
}
81158115

8116-
NewVD->addAttr(AsmLabelAttr::Create(Context, Label,
8117-
/*IsLiteralLabel=*/true,
8118-
SE->getStrTokenLoc(0)));
8116+
NewVD->addAttr(AsmLabelAttr::Create(Context, Label, SE->getStrTokenLoc(0)));
81198117
} else if (!ExtnameUndeclaredIdentifiers.empty()) {
81208118
llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
81218119
ExtnameUndeclaredIdentifiers.find(NewVD->getIdentifier());
@@ -10345,9 +10343,8 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
1034510343
if (Expr *E = D.getAsmLabel()) {
1034610344
// The parser guarantees this is a string.
1034710345
StringLiteral *SE = cast<StringLiteral>(E);
10348-
NewFD->addAttr(AsmLabelAttr::Create(Context, SE->getString(),
10349-
/*IsLiteralLabel=*/true,
10350-
SE->getStrTokenLoc(0)));
10346+
NewFD->addAttr(
10347+
AsmLabelAttr::Create(Context, SE->getString(), SE->getStrTokenLoc(0)));
1035110348
} else if (!ExtnameUndeclaredIdentifiers.empty()) {
1035210349
llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
1035310350
ExtnameUndeclaredIdentifiers.find(NewFD->getIdentifier());
@@ -20598,8 +20595,8 @@ void Sema::ActOnPragmaRedefineExtname(IdentifierInfo* Name,
2059820595
LookupOrdinaryName);
2059920596
AttributeCommonInfo Info(AliasName, SourceRange(AliasNameLoc),
2060020597
AttributeCommonInfo::Form::Pragma());
20601-
AsmLabelAttr *Attr = AsmLabelAttr::CreateImplicit(
20602-
Context, AliasName->getName(), /*IsLiteralLabel=*/true, Info);
20598+
AsmLabelAttr *Attr =
20599+
AsmLabelAttr::CreateImplicit(Context, AliasName->getName(), Info);
2060320600

2060420601
// If a declaration that:
2060520602
// 1) declares a function or a variable

clang/lib/Serialization/ASTReader.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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) \

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)