Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ Bug Fixes in This Version
- Fixed an assertion failure in serialization of constexpr structs containing unions. (#GH140130)
- Fixed duplicate entries in TableGen that caused the wrong attribute to be selected. (GH#140701)
- Fixed type mismatch error when 'builtin-elementwise-math' arguments have different qualifiers, this should be well-formed. (#GH141397)
- Constant evaluation now correctly runs the destructor of a variable declared in
- Constant evaluation now correctly runs the destructor of a variable declared in
the second clause of a C-style ``for`` loop. (#GH139818)

Bug Fixes to Compiler Builtins
Expand Down Expand Up @@ -843,6 +843,7 @@ Bug Fixes to AST Handling
- Fixed uninitialized use check in a lambda within CXXOperatorCallExpr. (#GH129198)
- Fixed a malformed printout of ``CXXParenListInitExpr`` in certain contexts.
- Fixed a malformed printout of certain calling convention function attributes. (#GH143160)
- Fixed dependency calculation for TypedefTypes (#GH89774)

Miscellaneous Bug Fixes
^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -5816,8 +5816,8 @@ class TypedefType final : public Type,
friend class ASTContext; // ASTContext creates these.
friend TrailingObjects;

TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType underlying,
QualType can);
TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType UnderlyingType,
bool HasTypeDifferentFromDecl);

public:
TypedefNameDecl *getDecl() const { return Decl; }
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5216,7 +5216,7 @@ QualType ASTContext::getTypedefType(const TypedefNameDecl *Decl,
if (Underlying.isNull())
Underlying = Decl->getUnderlyingType();
auto *NewType = new (*this, alignof(TypedefType)) TypedefType(
Type::Typedef, Decl, QualType(), getCanonicalType(Underlying));
Type::Typedef, Decl, Underlying, /*HasTypeDifferentFromDecl=*/false);
Decl->TypeForDecl = NewType;
Types.push_back(NewType);
return QualType(NewType, 0);
Expand All @@ -5238,7 +5238,7 @@ QualType ASTContext::getTypedefType(const TypedefNameDecl *Decl,
void *Mem = Allocate(TypedefType::totalSizeToAlloc<QualType>(true),
alignof(TypedefType));
auto *NewType = new (Mem) TypedefType(Type::Typedef, Decl, Underlying,
getCanonicalType(Underlying));
/*HasTypeDifferentFromDecl=*/true);
TypedefTypes.InsertNode(NewType, InsertPos);
Types.push_back(NewType);
return QualType(NewType, 0);
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4013,13 +4013,13 @@ StringRef CountAttributedType::getAttributeName(bool WithMacroPrefix) const {
}

TypedefType::TypedefType(TypeClass tc, const TypedefNameDecl *D,
QualType Underlying, QualType can)
: Type(tc, can, toSemanticDependence(can->getDependence())),
QualType UnderlyingType, bool HasTypeDifferentFromDecl)
: Type(tc, UnderlyingType.getCanonicalType(),
toSemanticDependence(UnderlyingType->getDependence())),
Decl(const_cast<TypedefNameDecl *>(D)) {
assert(!isa<TypedefType>(can) && "Invalid canonical type");
TypedefBits.hasTypeDifferentFromDecl = !Underlying.isNull();
TypedefBits.hasTypeDifferentFromDecl = HasTypeDifferentFromDecl;
if (!typeMatchesDecl())
*getTrailingObjects() = Underlying;
*getTrailingObjects() = UnderlyingType;
}

QualType TypedefType::desugar() const {
Expand Down
23 changes: 1 addition & 22 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,28 +1564,7 @@ llvm::DIType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty,

SourceLocation Loc = AliasDecl->getLocation();

if (CGM.getCodeGenOpts().DebugTemplateAlias &&
// FIXME: This is a workaround for the issue
// https://github.com/llvm/llvm-project/issues/89774
// The TemplateSpecializationType doesn't contain any instantiation
// information; dependent template arguments can't be resolved. For now,
// fall back to DW_TAG_typedefs for template aliases that are
// instantiation dependent, e.g.:
// ```
// template <int>
// using A = int;
//
// template<int I>
// struct S {
// using AA = A<I>; // Instantiation dependent.
// AA aa;
// };
//
// S<0> s;
// ```
// S::AA's underlying type A<I> is dependent on I so will be emitted as a
// DW_TAG_typedef.
!Ty->isInstantiationDependentType()) {
if (CGM.getCodeGenOpts().DebugTemplateAlias) {
auto ArgVector = ::GetTemplateArgs(TD, Ty);
TemplateArgs Args = {TD->getTemplateParameters(), ArgVector};

Expand Down
7 changes: 2 additions & 5 deletions clang/test/CodeGenCXX/dependent-template-alias.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -debug-info-kind=standalone -gtemplate-alias %s -gsimple-template-names=simple \
// RUN: | FileCheck %s

//// Check that -gtemplate-alias falls back to DW_TAG_typedef emission
//// for instantiation dependent type aliases.

template <int>
using A = int;

Expand All @@ -16,6 +13,6 @@ struct S {
S<0> s;

// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "aa", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[AA:[0-9]+]], size: 32)
// CHECK: [[AA]] = !DIDerivedType(tag: DW_TAG_typedef, name: "AA", file: ![[#]], line: [[#]], baseType: ![[A:[0-9]+]])
// CHECK: [[A]] = !DIDerivedType(tag: DW_TAG_typedef, name: "A<I>", file: ![[#]], line: [[#]], baseType: ![[int:[0-9]+]])
// CHECK: [[AA]] = !DIDerivedType(tag: DW_TAG_typedef, name: "AA", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[A:[0-9]+]])
// CHECK: [[A]] = !DIDerivedType(tag: DW_TAG_template_alias, name: "A", file: ![[#]], line: [[#]], baseType: ![[int:[0-9]+]], extraData: ![[#]])
// CHECK: [[int]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)