Skip to content

Commit 4c6d5fc

Browse files
committed
Merge from 'main' to 'sycl-web' (43 commits)
CONFLICT (content): Merge conflict in clang/include/clang/Driver/Options.td
2 parents b4d8973 + f679705 commit 4c6d5fc

File tree

949 files changed

+21370
-21161
lines changed

Some content is hidden

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

949 files changed

+21370
-21161
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
246246
TemplateSpecializationTypes;
247247
mutable llvm::FoldingSet<ParenType> ParenTypes{GeneralTypesLog2InitSize};
248248
mutable llvm::FoldingSet<UsingType> UsingTypes;
249+
mutable llvm::FoldingSet<TypedefType> TypedefTypes;
249250
mutable llvm::FoldingSet<ElaboratedType> ElaboratedTypes{
250251
GeneralTypesLog2InitSize};
251252
mutable llvm::FoldingSet<DependentNameType> DependentNameTypes;

clang/include/clang/AST/ASTDumper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ASTDumper : public ASTNodeTraverser<ASTDumper, TextNodeDumper> {
3232

3333
TextNodeDumper &doGetNodeDelegate() { return NodeDumper; }
3434

35+
void dumpInvalidDeclContext(const DeclContext *DC);
3536
void dumpLookups(const DeclContext *DC, bool DumpDecls);
3637

3738
template <typename SpecializationDecl>

clang/include/clang/AST/DeclBase.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,9 @@ class alignas(8) Decl {
474474

475475
bool isInStdNamespace() const;
476476

477+
// Return true if this is a FileContext Decl.
478+
bool isFileContextDecl() const;
479+
477480
ASTContext &getASTContext() const LLVM_READONLY;
478481

479482
/// Helper to get the language options from the ASTContext.
@@ -1906,6 +1909,10 @@ class DeclContext {
19061909
public:
19071910
~DeclContext();
19081911

1912+
// For use when debugging; hasValidDeclKind() will always return true for
1913+
// a correctly constructed object within its lifetime.
1914+
bool hasValidDeclKind() const;
1915+
19091916
Decl::Kind getDeclKind() const {
19101917
return static_cast<Decl::Kind>(DeclContextBits.DeclKind);
19111918
}
@@ -2527,6 +2534,8 @@ class DeclContext {
25272534
static bool classof(const Decl *D);
25282535
static bool classof(const DeclContext *D) { return true; }
25292536

2537+
void dumpAsDecl() const;
2538+
void dumpAsDecl(const ASTContext *Ctx) const;
25302539
void dumpDeclContext() const;
25312540
void dumpLookups() const;
25322541
void dumpLookups(llvm::raw_ostream &OS, bool DumpDecls = false,

clang/include/clang/AST/JSONNodeDumper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ class JSONNodeDumper
209209
void Visit(const APValue &Value, QualType Ty);
210210

211211
void VisitTypedefType(const TypedefType *TT);
212+
void VisitUsingType(const UsingType *TT);
212213
void VisitFunctionType(const FunctionType *T);
213214
void VisitFunctionProtoType(const FunctionProtoType *T);
214215
void VisitRValueReferenceType(const ReferenceType *RT);

clang/include/clang/AST/Type.h

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,6 +1807,24 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
18071807
unsigned IsUnqual : 1; // If true: typeof_unqual, else: typeof
18081808
};
18091809

1810+
class UsingBitfields {
1811+
friend class UsingType;
1812+
1813+
unsigned : NumTypeBits;
1814+
1815+
/// True if the underlying type is different from the declared one.
1816+
unsigned hasTypeDifferentFromDecl : 1;
1817+
};
1818+
1819+
class TypedefBitfields {
1820+
friend class TypedefType;
1821+
1822+
unsigned : NumTypeBits;
1823+
1824+
/// True if the underlying type is different from the declared one.
1825+
unsigned hasTypeDifferentFromDecl : 1;
1826+
};
1827+
18101828
class SubstTemplateTypeParmTypeBitfields {
18111829
friend class SubstTemplateTypeParmType;
18121830

@@ -1897,6 +1915,8 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
18971915
AttributedTypeBitfields AttributedTypeBits;
18981916
AutoTypeBitfields AutoTypeBits;
18991917
TypeOfBitfields TypeOfBits;
1918+
TypedefBitfields TypedefBits;
1919+
UsingBitfields UsingBits;
19001920
BuiltinTypeBitfields BuiltinTypeBits;
19011921
FunctionTypeBitfields FunctionTypeBits;
19021922
ObjCObjectTypeBitfields ObjCObjectTypeBits;
@@ -4486,9 +4506,12 @@ class UnresolvedUsingType : public Type {
44864506
}
44874507
};
44884508

4489-
class UsingType : public Type, public llvm::FoldingSetNode {
4509+
class UsingType final : public Type,
4510+
public llvm::FoldingSetNode,
4511+
private llvm::TrailingObjects<UsingType, QualType> {
44904512
UsingShadowDecl *Found;
44914513
friend class ASTContext; // ASTContext creates these.
4514+
friend TrailingObjects;
44924515

44934516
UsingType(const UsingShadowDecl *Found, QualType Underlying, QualType Canon);
44944517

@@ -4497,21 +4520,31 @@ class UsingType : public Type, public llvm::FoldingSetNode {
44974520
QualType getUnderlyingType() const;
44984521

44994522
bool isSugared() const { return true; }
4523+
4524+
// This always has the 'same' type as declared, but not necessarily identical.
45004525
QualType desugar() const { return getUnderlyingType(); }
45014526

4502-
void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, Found); }
4503-
static void Profile(llvm::FoldingSetNodeID &ID,
4504-
const UsingShadowDecl *Found) {
4527+
// Internal helper, for debugging purposes.
4528+
bool typeMatchesDecl() const { return !UsingBits.hasTypeDifferentFromDecl; }
4529+
4530+
void Profile(llvm::FoldingSetNodeID &ID) {
4531+
Profile(ID, Found, typeMatchesDecl() ? QualType() : getUnderlyingType());
4532+
}
4533+
static void Profile(llvm::FoldingSetNodeID &ID, const UsingShadowDecl *Found,
4534+
QualType Underlying) {
45054535
ID.AddPointer(Found);
4536+
if (!Underlying.isNull())
4537+
Underlying.Profile(ID);
45064538
}
45074539
static bool classof(const Type *T) { return T->getTypeClass() == Using; }
45084540
};
45094541

4510-
class TypedefType : public Type {
4542+
class TypedefType final : public Type,
4543+
public llvm::FoldingSetNode,
4544+
private llvm::TrailingObjects<TypedefType, QualType> {
45114545
TypedefNameDecl *Decl;
4512-
4513-
private:
45144546
friend class ASTContext; // ASTContext creates these.
4547+
friend TrailingObjects;
45154548

45164549
TypedefType(TypeClass tc, const TypedefNameDecl *D, QualType underlying,
45174550
QualType can);
@@ -4520,8 +4553,23 @@ class TypedefType : public Type {
45204553
TypedefNameDecl *getDecl() const { return Decl; }
45214554

45224555
bool isSugared() const { return true; }
4556+
4557+
// This always has the 'same' type as declared, but not necessarily identical.
45234558
QualType desugar() const;
45244559

4560+
// Internal helper, for debugging purposes.
4561+
bool typeMatchesDecl() const { return !TypedefBits.hasTypeDifferentFromDecl; }
4562+
4563+
void Profile(llvm::FoldingSetNodeID &ID) {
4564+
Profile(ID, Decl, typeMatchesDecl() ? QualType() : desugar());
4565+
}
4566+
static void Profile(llvm::FoldingSetNodeID &ID, const TypedefNameDecl *Decl,
4567+
QualType Underlying) {
4568+
ID.AddPointer(Decl);
4569+
if (!Underlying.isNull())
4570+
Underlying.Profile(ID);
4571+
}
4572+
45254573
static bool classof(const Type *T) { return T->getTypeClass() == Typedef; }
45264574
};
45274575

clang/include/clang/AST/TypeProperties.td

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,12 @@ let Class = TypedefType in {
379379
def : Property<"declaration", DeclRef> {
380380
let Read = [{ node->getDecl() }];
381381
}
382-
def : Property<"canonicalType", Optional<QualType>> {
383-
let Read = [{ makeOptionalFromNullable(node->getCanonicalTypeInternal()) }];
382+
def : Property<"underlyingType", QualType> {
383+
let Read = [{ node->desugar() }];
384384
}
385385

386386
def : Creator<[{
387-
QualType finalCanonicalType =
388-
canonicalType ? ctx.getCanonicalType(*canonicalType)
389-
: QualType();
390-
return ctx.getTypedefType(cast<TypedefNameDecl>(declaration),
391-
finalCanonicalType);
387+
return ctx.getTypedefType(cast<TypedefNameDecl>(declaration), underlyingType);
392388
}]>;
393389
}
394390

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,10 @@ CODEGENOPT(SYCLUseMainFileName, 1, 0)
500500
/// Whether to use opaque pointers.
501501
CODEGENOPT(OpaquePointers, 1, 0)
502502

503+
/// Modify C++ ABI to returning `this` pointer from constructors and
504+
/// non-deleting destructors. (No effect on Microsoft ABI.)
505+
CODEGENOPT(CtorDtorReturnThis, 1, 0)
506+
503507
#undef CODEGENOPT
504508
#undef ENUM_CODEGENOPT
505509
#undef VALUE_CODEGENOPT

clang/include/clang/Driver/Options.td

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ def Xs_separate : Separate<["-"], "Xs">, HelpText<"Pass <arg> to the offline com
859859
def z : Separate<["-"], "z">, Flags<[LinkerInput]>,
860860
HelpText<"Pass -z <arg> to the linker">, MetaVarName<"<arg>">,
861861
Group<Link_Group>;
862-
def offload_link : Flag<["--", "-"], "offload-link">, Group<Link_Group>,
862+
def offload_link : Flag<["--"], "offload-link">, Group<Link_Group>,
863863
HelpText<"Use the new offloading linker to perform the link job.">;
864864
def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>,
865865
HelpText<"Pass <arg> to the linker">, MetaVarName<"<arg>">,
@@ -965,7 +965,7 @@ def fno_bundle_offload_arch : Flag<["-"], "fno-bundle-offload-arch">,
965965
"uses the bundle tag `nvptx64-nvidia-cuda` when used. "
966966
"This allows .o files to contain .bc bundles that are unspecific "
967967
"to a particular arch version.">;
968-
def offload_arch_EQ : Joined<["--", "-"], "offload-arch=">, Flags<[NoXarchOption]>,
968+
def offload_arch_EQ : Joined<["--"], "offload-arch=">, Flags<[NoXarchOption]>,
969969
HelpText<"CUDA offloading device architecture (e.g. sm_35), or HIP offloading target ID in the form of a "
970970
"device architecture followed by target ID features delimited by a colon. Each target ID feature "
971971
"is a pre-defined string followed by a plus or minus sign (e.g. gfx908:xnack+:sramecc-). May be "
@@ -977,7 +977,7 @@ def hip_link : Flag<["--"], "hip-link">,
977977
HelpText<"Link clang-offload-bundler bundles for HIP">;
978978
def no_hip_rt: Flag<["-"], "no-hip-rt">,
979979
HelpText<"Do not link against HIP runtime libraries">;
980-
def no_offload_arch_EQ : Joined<["--", "-"], "no-offload-arch=">, Flags<[NoXarchOption]>,
980+
def no_offload_arch_EQ : Joined<["--"], "no-offload-arch=">, Flags<[NoXarchOption]>,
981981
HelpText<"Remove CUDA/HIP offloading device architecture (e.g. sm_35, gfx906) from the list of devices to compile for. "
982982
"'all' resets the list to its default value.">;
983983
def emit_static_lib : Flag<["--"], "emit-static-lib">,
@@ -1224,7 +1224,7 @@ defm autolink : BoolFOption<"autolink",
12241224
// In the future this option will be supported by other offloading
12251225
// languages and accept other values such as CPU/GPU architectures,
12261226
// offload kinds and target aliases.
1227-
def offload_EQ : CommaJoined<["--", "-"], "offload=">, Flags<[NoXarchOption]>,
1227+
def offload_EQ : CommaJoined<["--"], "offload=">, Flags<[NoXarchOption]>,
12281228
HelpText<"Specify comma-separated list of offloading target triples (CUDA and HIP only)">;
12291229

12301230
// C++ Coroutines TS
@@ -2665,15 +2665,15 @@ defm openmp_optimistic_collapse : BoolFOption<"openmp-optimistic-collapse",
26652665
PosFlag<SetTrue, [CC1Option]>, NegFlag<SetFalse>, BothFlags<[NoArgumentUnused, HelpHidden]>>;
26662666
def static_openmp: Flag<["-"], "static-openmp">,
26672667
HelpText<"Use the static host OpenMP runtime while linking.">;
2668-
def offload_new_driver : Flag<["--", "-"], "offload-new-driver">, Flags<[CC1Option]>, Group<f_Group>,
2668+
def offload_new_driver : Flag<["--"], "offload-new-driver">, Flags<[CC1Option]>, Group<f_Group>,
26692669
MarshallingInfoFlag<LangOpts<"OffloadingNewDriver">>, HelpText<"Use the new driver for offloading compilation.">;
2670-
def no_offload_new_driver : Flag<["--", "-"], "no-offload-new-driver">, Flags<[CC1Option]>, Group<f_Group>,
2670+
def no_offload_new_driver : Flag<["--"], "no-offload-new-driver">, Flags<[CC1Option]>, Group<f_Group>,
26712671
HelpText<"Don't Use the new driver for offloading compilation.">;
2672-
def offload_device_only : Flag<["--", "-"], "offload-device-only">,
2672+
def offload_device_only : Flag<["--"], "offload-device-only">,
26732673
HelpText<"Only compile for the offloading device.">;
2674-
def offload_host_only : Flag<["--", "-"], "offload-host-only">,
2674+
def offload_host_only : Flag<["--"], "offload-host-only">,
26752675
HelpText<"Only compile for the offloading host.">;
2676-
def offload_host_device : Flag<["--", "-"], "offload-host-device">,
2676+
def offload_host_device : Flag<["--"], "offload-host-device">,
26772677
HelpText<"Only compile for the offloading host.">;
26782678
def cuda_device_only : Flag<["--"], "cuda-device-only">, Alias<offload_device_only>,
26792679
HelpText<"Compile CUDA code for device only">;
@@ -5790,6 +5790,11 @@ def ehcontguard : Flag<["-"], "ehcontguard">,
57905790
def fdenormal_fp_math_f32_EQ : Joined<["-"], "fdenormal-fp-math-f32=">,
57915791
Group<f_Group>;
57925792

5793+
def fctor_dtor_return_this : Flag<["-"], "fctor-dtor-return-this">,
5794+
HelpText<"Change the C++ ABI to returning `this` pointer from constructors "
5795+
"and non-deleting destructors. (No effect on Microsoft ABI)">,
5796+
MarshallingInfoFlag<CodeGenOpts<"CtorDtorReturnThis">>;
5797+
57935798
} // let Flags = [CC1Option, NoDriverOption]
57945799

57955800
//===----------------------------------------------------------------------===//

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9325,7 +9325,7 @@ class Sema final {
93259325
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
93269326
const NamedDecl *D, const TemplateArgumentList *Innermost = nullptr,
93279327
bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
9328-
bool LookBeyondLambda = false, bool IncludeContainingStruct = false);
9328+
bool ForConstraintInstantiation = false);
93299329

93309330
/// A context in which code is being synthesized (where a source location
93319331
/// alone is not sufficient to identify the context). This covers template

clang/lib/AST/ASTContext.cpp

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,12 +2376,12 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
23762376
return getTypeInfo(cast<UsingType>(T)->desugar().getTypePtr());
23772377

23782378
case Type::Typedef: {
2379-
const TypedefNameDecl *Typedef = cast<TypedefType>(T)->getDecl();
2380-
TypeInfo Info = getTypeInfo(Typedef->getUnderlyingType().getTypePtr());
2379+
const auto *TT = cast<TypedefType>(T);
2380+
TypeInfo Info = getTypeInfo(TT->desugar().getTypePtr());
23812381
// If the typedef has an aligned attribute on it, it overrides any computed
23822382
// alignment we have. This violates the GCC documentation (which says that
23832383
// attribute(aligned) can only round up) but matches its implementation.
2384-
if (unsigned AttrAlign = Typedef->getMaxAlignment()) {
2384+
if (unsigned AttrAlign = TT->getDecl()->getMaxAlignment()) {
23852385
Align = AttrAlign;
23862386
AlignRequirement = AlignRequirementKind::RequiredByTypedef;
23872387
} else {
@@ -4650,34 +4650,60 @@ QualType ASTContext::getTypeDeclTypeSlow(const TypeDecl *Decl) const {
46504650
/// specified typedef name decl.
46514651
QualType ASTContext::getTypedefType(const TypedefNameDecl *Decl,
46524652
QualType Underlying) const {
4653-
if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
4653+
if (!Decl->TypeForDecl) {
4654+
if (Underlying.isNull())
4655+
Underlying = Decl->getUnderlyingType();
4656+
auto *NewType = new (*this, TypeAlignment) TypedefType(
4657+
Type::Typedef, Decl, QualType(), getCanonicalType(Underlying));
4658+
Decl->TypeForDecl = NewType;
4659+
Types.push_back(NewType);
4660+
return QualType(NewType, 0);
4661+
}
4662+
if (Underlying.isNull() || Decl->getUnderlyingType() == Underlying)
4663+
return QualType(Decl->TypeForDecl, 0);
4664+
assert(hasSameType(Decl->getUnderlyingType(), Underlying));
46544665

4655-
if (Underlying.isNull())
4656-
Underlying = Decl->getUnderlyingType();
4657-
QualType Canonical = getCanonicalType(Underlying);
4658-
auto *newType = new (*this, TypeAlignment)
4659-
TypedefType(Type::Typedef, Decl, Underlying, Canonical);
4660-
Decl->TypeForDecl = newType;
4661-
Types.push_back(newType);
4662-
return QualType(newType, 0);
4666+
llvm::FoldingSetNodeID ID;
4667+
TypedefType::Profile(ID, Decl, Underlying);
4668+
4669+
void *InsertPos = nullptr;
4670+
if (TypedefType *T = TypedefTypes.FindNodeOrInsertPos(ID, InsertPos)) {
4671+
assert(!T->typeMatchesDecl() &&
4672+
"non-divergent case should be handled with TypeDecl");
4673+
return QualType(T, 0);
4674+
}
4675+
4676+
void *Mem =
4677+
Allocate(TypedefType::totalSizeToAlloc<QualType>(true), TypeAlignment);
4678+
auto *NewType = new (Mem) TypedefType(Type::Typedef, Decl, Underlying,
4679+
getCanonicalType(Underlying));
4680+
TypedefTypes.InsertNode(NewType, InsertPos);
4681+
Types.push_back(NewType);
4682+
return QualType(NewType, 0);
46634683
}
46644684

46654685
QualType ASTContext::getUsingType(const UsingShadowDecl *Found,
46664686
QualType Underlying) const {
46674687
llvm::FoldingSetNodeID ID;
4668-
UsingType::Profile(ID, Found);
4688+
UsingType::Profile(ID, Found, Underlying);
46694689

46704690
void *InsertPos = nullptr;
4671-
UsingType *T = UsingTypes.FindNodeOrInsertPos(ID, InsertPos);
4672-
if (T)
4691+
if (UsingType *T = UsingTypes.FindNodeOrInsertPos(ID, InsertPos))
46734692
return QualType(T, 0);
46744693

4675-
assert(!Underlying.hasLocalQualifiers());
4676-
assert(Underlying == getTypeDeclType(cast<TypeDecl>(Found->getTargetDecl())));
4677-
QualType Canon = Underlying.getCanonicalType();
4694+
const Type *TypeForDecl =
4695+
cast<TypeDecl>(Found->getTargetDecl())->getTypeForDecl();
46784696

4679-
UsingType *NewType =
4680-
new (*this, TypeAlignment) UsingType(Found, Underlying, Canon);
4697+
assert(!Underlying.hasLocalQualifiers());
4698+
QualType Canon = Underlying->getCanonicalTypeInternal();
4699+
assert(TypeForDecl->getCanonicalTypeInternal() == Canon);
4700+
4701+
if (Underlying.getTypePtr() == TypeForDecl)
4702+
Underlying = QualType();
4703+
void *Mem =
4704+
Allocate(UsingType::totalSizeToAlloc<QualType>(!Underlying.isNull()),
4705+
TypeAlignment);
4706+
UsingType *NewType = new (Mem) UsingType(Found, Underlying, Canon);
46814707
Types.push_back(NewType);
46824708
UsingTypes.InsertNode(NewType, InsertPos);
46834709
return QualType(NewType, 0);

0 commit comments

Comments
 (0)