Skip to content

Commit b2f9794

Browse files
authored
merge main into amd-staging (llvm#1710)
2 parents bb94c98 + 9e0db2d commit b2f9794

File tree

232 files changed

+8003
-1663
lines changed

Some content is hidden

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

232 files changed

+8003
-1663
lines changed

clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ static std::optional<TemplateSpecializationTypeLoc>
5454
matchEnableIfSpecializationImplTypename(TypeLoc TheType) {
5555
if (const auto Dep = TheType.getAs<DependentNameTypeLoc>()) {
5656
const IdentifierInfo *Identifier = Dep.getTypePtr()->getIdentifier();
57+
ElaboratedTypeKeyword Keyword = Dep.getTypePtr()->getKeyword();
5758
if (!Identifier || Identifier->getName() != "type" ||
58-
Dep.getTypePtr()->getKeyword() != ElaboratedTypeKeyword::Typename) {
59+
(Keyword != ElaboratedTypeKeyword::Typename &&
60+
Keyword != ElaboratedTypeKeyword::None)) {
5961
return std::nullopt;
6062
}
6163
TheType = Dep.getQualifierLoc().getTypeLoc();
@@ -108,8 +110,10 @@ matchEnableIfSpecializationImplTrait(TypeLoc TheType) {
108110

109111
if (const auto *AliasedType =
110112
dyn_cast<DependentNameType>(Specialization->getAliasedType())) {
113+
ElaboratedTypeKeyword Keyword = AliasedType->getKeyword();
111114
if (AliasedType->getIdentifier()->getName() != "type" ||
112-
AliasedType->getKeyword() != ElaboratedTypeKeyword::Typename) {
115+
(Keyword != ElaboratedTypeKeyword::Typename &&
116+
Keyword != ElaboratedTypeKeyword::None)) {
113117
return std::nullopt;
114118
}
115119
} else {

clang/docs/LanguageExtensions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,7 @@ to ``float``; see below for more information on this emulation.
10001000
* SPIR (natively)
10011001
* X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
10021002
* RISC-V (natively if Zfh or Zhinx is available)
1003+
* SystemZ (emulated)
10031004

10041005
* ``__bf16`` is supported on the following targets (currently never natively):
10051006

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,10 @@ Bug Fixes to C++ Support
502502
- Fixes matching of nested template template parameters. (#GH130362)
503503
- Correctly diagnoses template template paramters which have a pack parameter
504504
not in the last position.
505+
- Disallow overloading on struct vs class on dependent types, which is IFNDR, as
506+
this makes the problem diagnosable.
507+
- Improved preservation of the presence or abscence of typename specifier when
508+
printing types in diagnostics.
505509
- Clang now correctly parses ``if constexpr`` expressions in immediate function context. (#GH123524)
506510
- Fixed an assertion failure affecting code that uses C++23 "deducing this". (#GH130272)
507511
- Clang now properly instantiates destructors for initialized members within non-delegating constructors. (#GH93251)

clang/include/clang/AST/Type.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,6 +2838,20 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
28382838
/// immediately following this class.
28392839
template <typename T> const T *getAs() const;
28402840

2841+
/// Look through sugar for an instance of TemplateSpecializationType which
2842+
/// is not a type alias, or null if there is no such type.
2843+
/// This is used when you want as-written template arguments or the template
2844+
/// name for a class template specialization.
2845+
const TemplateSpecializationType *
2846+
getAsNonAliasTemplateSpecializationType() const;
2847+
2848+
const TemplateSpecializationType *
2849+
castAsNonAliasTemplateSpecializationType() const {
2850+
const auto *TST = getAsNonAliasTemplateSpecializationType();
2851+
assert(TST && "not a TemplateSpecializationType");
2852+
return TST;
2853+
}
2854+
28412855
/// Member-template getAsAdjusted<specific type>. Look through specific kinds
28422856
/// of sugar (parens, attributes, etc) for an instance of \<specific type>.
28432857
/// This is used when you need to walk over sugar nodes that represent some

clang/include/clang/Basic/TargetInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class TargetInfo : public TransferrableTargetInfo,
235235
bool NoAsmVariants; // True if {|} are normal characters.
236236
bool HasLegalHalfType; // True if the backend supports operations on the half
237237
// LLVM IR type.
238-
bool HalfArgsAndReturns;
238+
bool HalfArgsAndReturns; // OpenCL 6.1.1.1, NEON (IEEE 754-2008 half) type.
239239
bool HasFloat128;
240240
bool HasFloat16;
241241
bool HasBFloat16;

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
9595
return getZeroAttr(arrTy);
9696
if (auto ptrTy = mlir::dyn_cast<cir::PointerType>(ty))
9797
return getConstNullPtrAttr(ptrTy);
98+
if (auto recordTy = mlir::dyn_cast<cir::RecordType>(ty))
99+
return getZeroAttr(recordTy);
98100
if (mlir::isa<cir::BoolType>(ty)) {
99101
return getCIRBoolAttr(false);
100102
}

clang/include/clang/CIR/Dialect/IR/CIRTypes.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,9 @@ def CIR_RecordType : CIR_Type<"Record", "record",
499499
std::string getPrefixedName() {
500500
return getKindAsStr() + "." + getName().getValue().str();
501501
}
502+
503+
void complete(llvm::ArrayRef<mlir::Type> members, bool packed,
504+
bool isPadded);
502505
}];
503506

504507
let hasCustomAssemblyFormat = 1;

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ struct MissingFeatures {
103103

104104
// RecordType
105105
static bool recordTypeLayoutInfo() { return false; }
106+
static bool recursiveRecordLayout() { return false; }
107+
static bool skippedLayout() { return false; }
108+
static bool astRecordDeclAttr() { return false; }
109+
static bool cxxSupport() { return false; }
110+
static bool packedRecords() { return false; }
111+
static bool recordPadding() { return false; }
112+
static bool recordZeroInit() { return false; }
113+
static bool zeroSizeRecordMembers() { return false; }
106114

107115
// Misc
108116
static bool cxxABI() { return false; }

clang/lib/AST/ASTContext.cpp

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5747,6 +5747,30 @@ ASTContext::getMacroQualifiedType(QualType UnderlyingTy,
57475747
return QualType(newType, 0);
57485748
}
57495749

5750+
static ElaboratedTypeKeyword
5751+
getCanonicalElaboratedTypeKeyword(ElaboratedTypeKeyword Keyword) {
5752+
switch (Keyword) {
5753+
// These are just themselves.
5754+
case ElaboratedTypeKeyword::None:
5755+
case ElaboratedTypeKeyword::Struct:
5756+
case ElaboratedTypeKeyword::Union:
5757+
case ElaboratedTypeKeyword::Enum:
5758+
case ElaboratedTypeKeyword::Interface:
5759+
return Keyword;
5760+
5761+
// These are equivalent.
5762+
case ElaboratedTypeKeyword::Typename:
5763+
return ElaboratedTypeKeyword::None;
5764+
5765+
// These are functionally equivalent, so relying on their equivalence is
5766+
// IFNDR. By making them equivalent, we disallow overloading, which at least
5767+
// can produce a diagnostic.
5768+
case ElaboratedTypeKeyword::Class:
5769+
return ElaboratedTypeKeyword::Struct;
5770+
}
5771+
llvm_unreachable("unexpected keyword kind");
5772+
}
5773+
57505774
QualType ASTContext::getDependentNameType(ElaboratedTypeKeyword Keyword,
57515775
NestedNameSpecifier *NNS,
57525776
const IdentifierInfo *Name) const {
@@ -5758,10 +5782,13 @@ QualType ASTContext::getDependentNameType(ElaboratedTypeKeyword Keyword,
57585782
DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos))
57595783
return QualType(T, 0);
57605784

5785+
ElaboratedTypeKeyword CanonKeyword =
5786+
getCanonicalElaboratedTypeKeyword(Keyword);
5787+
NestedNameSpecifier *CanonNNS = getCanonicalNestedNameSpecifier(NNS);
5788+
57615789
QualType Canon;
5762-
if (NestedNameSpecifier *CanonNNS = getCanonicalNestedNameSpecifier(NNS);
5763-
CanonNNS != NNS) {
5764-
Canon = getDependentNameType(Keyword, CanonNNS, Name);
5790+
if (CanonKeyword != Keyword || CanonNNS != NNS) {
5791+
Canon = getDependentNameType(CanonKeyword, CanonNNS, Name);
57655792
[[maybe_unused]] DependentNameType *T =
57665793
DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos);
57675794
assert(!T && "broken canonicalization");
@@ -5800,27 +5827,27 @@ QualType ASTContext::getDependentTemplateSpecializationType(
58005827

58015828
QualType Canon;
58025829
if (!IsCanonical) {
5803-
ElaboratedTypeKeyword CanonKeyword = Keyword != ElaboratedTypeKeyword::None
5804-
? Keyword
5805-
: ElaboratedTypeKeyword::Typename;
5830+
ElaboratedTypeKeyword CanonKeyword =
5831+
getCanonicalElaboratedTypeKeyword(Keyword);
58065832
NestedNameSpecifier *CanonNNS = getCanonicalNestedNameSpecifier(NNS);
58075833
bool AnyNonCanonArgs = false;
58085834
auto CanonArgs =
58095835
::getCanonicalTemplateArguments(*this, Args, AnyNonCanonArgs);
58105836

5811-
if (AnyNonCanonArgs || CanonNNS != NNS || !Name.hasTemplateKeyword() ||
5812-
CanonKeyword != Keyword) {
5837+
if (CanonKeyword != Keyword || AnyNonCanonArgs || CanonNNS != NNS ||
5838+
!Name.hasTemplateKeyword()) {
58135839
Canon = getDependentTemplateSpecializationType(
58145840
CanonKeyword, {CanonNNS, Name.getName(), /*HasTemplateKeyword=*/true},
5815-
CanonArgs, /*IsCanonical=*/true);
5841+
CanonArgs,
5842+
/*IsCanonical=*/true);
58165843
// Find the insert position again.
58175844
[[maybe_unused]] auto *Nothing =
58185845
DependentTemplateSpecializationTypes.FindNodeOrInsertPos(ID,
58195846
InsertPos);
58205847
assert(!Nothing && "canonical type broken");
58215848
}
58225849
} else {
5823-
assert(Keyword != ElaboratedTypeKeyword::None);
5850+
assert(Keyword == getCanonicalElaboratedTypeKeyword(Keyword));
58245851
assert(Name.hasTemplateKeyword());
58255852
assert(NNS == getCanonicalNestedNameSpecifier(NNS));
58265853
#ifndef NDEBUG
@@ -7657,7 +7684,7 @@ ASTContext::getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const {
76577684
if (const auto *DTST = T->getAs<DependentTemplateSpecializationType>()) {
76587685
const DependentTemplateStorage &DTN = DTST->getDependentTemplateName();
76597686
QualType NewT = getDependentTemplateSpecializationType(
7660-
ElaboratedTypeKeyword::Typename,
7687+
ElaboratedTypeKeyword::None,
76617688
{/*NNS=*/nullptr, DTN.getName(), /*HasTemplateKeyword=*/true},
76627689
DTST->template_arguments(), /*IsCanonical=*/true);
76637690
assert(NewT.isCanonical());

clang/lib/AST/Type.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,6 +1938,14 @@ TagDecl *Type::getAsTagDecl() const {
19381938
return nullptr;
19391939
}
19401940

1941+
const TemplateSpecializationType *
1942+
Type::getAsNonAliasTemplateSpecializationType() const {
1943+
const auto *TST = getAs<TemplateSpecializationType>();
1944+
while (TST && TST->isTypeAlias())
1945+
TST = TST->desugar()->getAs<TemplateSpecializationType>();
1946+
return TST;
1947+
}
1948+
19411949
bool Type::hasAttr(attr::Kind AK) const {
19421950
const Type *Cur = this;
19431951
while (const auto *AT = Cur->getAs<AttributedType>()) {

0 commit comments

Comments
 (0)