Skip to content

Commit

Permalink
Merge "merge main into amd-staging" into amd-staging
Browse files Browse the repository at this point in the history
  • Loading branch information
ronlieb committed Aug 30, 2024
2 parents 0e4399c + 6cf7959 commit 28f9f84
Show file tree
Hide file tree
Showing 351 changed files with 14,156 additions and 5,578 deletions.
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ Bug Fixes to C++ Support
- Fix evaluation of the index of dependent pack indexing expressions/types specifiers (#GH105900)
- Correctly handle subexpressions of an immediate invocation in the presence of implicit casts. (#GH105558)
- Clang now correctly handles direct-list-initialization of a structured bindings from an array. (#GH31813)
- Mangle placeholders for deduced types as a template-prefix, such that mangling
of template template parameters uses the correct production. (#GH106182)
- Fixed an assertion failure when converting vectors to int/float with invalid expressions. (#GH105486)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
31 changes: 18 additions & 13 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,24 @@ class SemaPPCallbacks;
class TemplateDeductionInfo;
} // namespace sema

// AssignmentAction - This is used by all the assignment diagnostic functions
// to represent what is actually causing the operation
enum class AssignmentAction {
Assigning,
Passing,
Returning,
Converting,
Initializing,
Sending,
Casting,
Passing_CFAudited
};
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
const AssignmentAction &AA) {
DB << llvm::to_underlying(AA);
return DB;
}

namespace threadSafety {
class BeforeSet;
void threadSafetyCleanup(BeforeSet *Cache);
Expand Down Expand Up @@ -6497,19 +6515,6 @@ class Sema final : public SemaBase {
/// cleanup that are created by the current full expression.
SmallVector<ExprWithCleanups::CleanupObject, 8> ExprCleanupObjects;

// AssignmentAction - This is used by all the assignment diagnostic functions
// to represent what is actually causing the operation
enum AssignmentAction {
AA_Assigning,
AA_Passing,
AA_Returning,
AA_Converting,
AA_Initializing,
AA_Sending,
AA_Casting,
AA_Passing_CFAudited
};

/// Determine whether the use of this declaration is valid, without
/// emitting diagnostics.
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
Expand Down
12 changes: 4 additions & 8 deletions clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4442,14 +4442,10 @@ void CXXNameMangler::mangleType(const DeducedTemplateSpecializationType *T) {
if (!Deduced.isNull())
return mangleType(Deduced);

TemplateDecl *TD = T->getTemplateName().getAsTemplateDecl();
assert(TD && "shouldn't form deduced TST unless we know we have a template");

if (mangleSubstitution(TD))
return;

mangleName(GlobalDecl(TD));
addSubstitution(TD);
TemplateName TN = T->getTemplateName();
assert(TN.getAsTemplateDecl() &&
"shouldn't form deduced TST unless we know we have a template");
mangleType(TN);
}

void CXXNameMangler::mangleType(const AtomicType *T) {
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
TheModule->addModuleFlag(llvm::Module::Error, "UnifiedLTO", uint32_t(1));
}

// FIXME: This should eventually be replaced by a first-class driver option.
// This should be done for both clang and flang simultaneously.
// Print a textual, '-passes=' compatible, representation of pipeline if
// requested.
if (PrintPipelinePasses) {
Expand Down
10 changes: 7 additions & 3 deletions clang/lib/CodeGen/CodeGenFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,13 +1064,17 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
// OpenCL C 2.0 v2.2-11 s6.9.i:
// Recursion is not supported.
//
// HLSL
// Recursion is not supported.
//
// SYCL v1.2.1 s3.10:
// kernels cannot include RTTI information, exception classes,
// recursive code, virtual functions or make use of C++ libraries that
// are not compiled for the device.
if (FD && ((getLangOpts().CPlusPlus && FD->isMain()) ||
getLangOpts().OpenCL || getLangOpts().SYCLIsDevice ||
(getLangOpts().CUDA && FD->hasAttr<CUDAGlobalAttr>())))
if (FD &&
((getLangOpts().CPlusPlus && FD->isMain()) || getLangOpts().OpenCL ||
getLangOpts().HLSL || getLangOpts().SYCLIsDevice ||
(getLangOpts().CUDA && FD->hasAttr<CUDAGlobalAttr>())))
Fn->addFnAttr(llvm::Attribute::NoRecurse);

llvm::RoundingMode RM = getLangOpts().getDefaultRoundingMode();
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Format/UnwrappedLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4029,6 +4029,7 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
}
break;
case tok::coloncolon:
case tok::hashhash:
break;
default:
if (!JSPastExtendsOrImplements && !ClassName &&
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Sema/SemaARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,8 @@ bool SemaARM::CheckNeonBuiltinFunctionCall(const TargetInfo &TI,
if (RHS.isInvalid())
return true;
if (SemaRef.DiagnoseAssignmentResult(ConvTy, Arg->getBeginLoc(), LHSTy,
RHSTy, RHS.get(), Sema::AA_Assigning))
RHSTy, RHS.get(),
AssignmentAction::Assigning))
return true;
}

Expand Down Expand Up @@ -921,7 +922,7 @@ bool SemaARM::CheckARMBuiltinExclusiveCall(unsigned BuiltinID,
CastNeeded = CK_BitCast;
Diag(DRE->getBeginLoc(), diag::ext_typecheck_convert_discards_qualifiers)
<< PointerArg->getType() << Context.getPointerType(AddrType)
<< Sema::AA_Passing << PointerArg->getSourceRange();
<< AssignmentAction::Passing << PointerArg->getSourceRange();
}

// Finally, do the cast and replace the argument with the corrected version.
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaCast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2673,7 +2673,7 @@ void CastOperation::checkAddressSpaceCast(QualType SrcType, QualType DestType) {
? DestPPointee.getAddressSpace() != SrcPPointee.getAddressSpace()
: !DestPPointee.isAddressSpaceOverlapping(SrcPPointee)) {
Self.Diag(OpRange.getBegin(), DiagID)
<< SrcType << DestType << Sema::AA_Casting
<< SrcType << DestType << AssignmentAction::Casting
<< SrcExpr.get()->getSourceRange();
if (!Nested)
SrcExpr = ExprError();
Expand Down Expand Up @@ -3213,7 +3213,7 @@ void CastOperation::CheckCStyleCast() {
!CastQuals.compatiblyIncludesObjCLifetime(ExprQuals)) {
Self.Diag(SrcExpr.get()->getBeginLoc(),
diag::err_typecheck_incompatible_ownership)
<< SrcType << DestType << Sema::AA_Casting
<< SrcType << DestType << AssignmentAction::Casting
<< SrcExpr.get()->getSourceRange();
return;
}
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4880,7 +4880,8 @@ bool Sema::BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
if (Arg->isTypeDependent())
return false;

ExprResult Res = PerformImplicitConversion(Arg, Context.IntTy, AA_Passing);
ExprResult Res = PerformImplicitConversion(Arg, Context.IntTy,
AssignmentAction::Passing);

if (Res.isInvalid())
return true;
Expand Down
15 changes: 7 additions & 8 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13299,8 +13299,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
}

// WebAssembly tables can't be used to initialise a variable.
if (Init && !Init->getType().isNull() &&
Init->getType()->isWebAssemblyTableType()) {
if (!Init->getType().isNull() && Init->getType()->isWebAssemblyTableType()) {
Diag(Init->getExprLoc(), diag::err_wasm_table_art) << 0;
VDecl->setInvalidDecl();
return;
Expand Down Expand Up @@ -13443,7 +13442,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
if (getLangOpts().DebuggerCastResultToId && DclT->isObjCObjectPointerType() &&
Init->getType() == Context.UnknownAnyTy) {
ExprResult Result = forceUnknownAnyToType(Init, Context.getObjCIdType());
if (Result.isInvalid()) {
if (!Result.isUsable()) {
VDecl->setInvalidDecl();
return;
}
Expand Down Expand Up @@ -13471,7 +13470,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
InitializationSequence Init(*this, Entity, Kind, MultiExprArg(E));
return Init.Failed() ? ExprError() : E;
});
if (Res.isInvalid()) {
if (!Res.isUsable()) {
VDecl->setInvalidDecl();
} else if (Res.get() != Args[Idx]) {
Args[Idx] = Res.get();
Expand All @@ -13484,7 +13483,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
/*TopLevelOfInitList=*/false,
/*TreatUnavailableAsInvalid=*/false);
ExprResult Result = InitSeq.Perform(*this, Entity, Kind, Args, &DclT);
if (Result.isInvalid()) {
if (!Result.isUsable()) {
// If the provided initializer fails to initialize the var decl,
// we attach a recovery expr for better recovery.
auto RecoveryExpr =
Expand All @@ -13508,8 +13507,8 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
InitSeq.step_begin()->Kind ==
InitializationSequence::SK_ParenthesizedListInit;
QualType VDeclType = VDecl->getType();
if (Init && !Init->getType().isNull() &&
!Init->getType()->isDependentType() && !VDeclType->isDependentType() &&
if (!Init->getType().isNull() && !Init->getType()->isDependentType() &&
!VDeclType->isDependentType() &&
Context.getAsIncompleteArrayType(VDeclType) &&
Context.getAsIncompleteArrayType(Init->getType())) {
// Bail out if it is not possible to deduce array size from the
Expand Down Expand Up @@ -13572,7 +13571,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
ExprResult Result =
ActOnFinishFullExpr(Init, VDecl->getLocation(),
/*DiscardedValue*/ false, VDecl->isConstexpr());
if (Result.isInvalid()) {
if (!Result.isUsable()) {
VDecl->setInvalidDecl();
return;
}
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10897,7 +10897,8 @@ bool Sema::CheckDestructor(CXXDestructorDecl *Destructor) {
ExprResult This =
ActOnCXXThis(OperatorDelete->getParamDecl(0)->getLocation());
assert(!This.isInvalid() && "couldn't form 'this' expr in dtor?");
This = PerformImplicitConversion(This.get(), ParamType, AA_Passing);
This = PerformImplicitConversion(This.get(), ParamType,
AssignmentAction::Passing);
if (This.isInvalid()) {
// FIXME: Register this as a context note so that it comes out
// in the right order.
Expand Down
38 changes: 22 additions & 16 deletions clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9615,7 +9615,7 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &CallerRHS,
QualType RHSType = RHS.get()->getType();
if (Diagnose) {
RHS = PerformImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(),
AA_Assigning);
AssignmentAction::Assigning);
} else {
ImplicitConversionSequence ICS =
TryImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(),
Expand All @@ -9627,7 +9627,7 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &CallerRHS,
if (ICS.isFailure())
return Incompatible;
RHS = PerformImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(),
ICS, AA_Assigning);
ICS, AssignmentAction::Assigning);
}
if (RHS.isInvalid())
return Incompatible;
Expand Down Expand Up @@ -9917,6 +9917,9 @@ static ExprResult convertVector(Expr *E, QualType ElementType, Sema &S) {
/// IntTy without losing precision.
static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int,
QualType OtherIntTy) {
if (Int->get()->containsErrors())
return false;

QualType IntTy = Int->get()->getType().getUnqualifiedType();

// Reject cases where the value of the Int is unknown as that would
Expand Down Expand Up @@ -9955,6 +9958,9 @@ static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int,
/// FloatTy without losing precision.
static bool canConvertIntTyToFloatTy(Sema &S, ExprResult *Int,
QualType FloatTy) {
if (Int->get()->containsErrors())
return false;

QualType IntTy = Int->get()->getType().getUnqualifiedType();

// Determine if the integer constant can be expressed as a floating point
Expand Down Expand Up @@ -13683,8 +13689,8 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
ConvTy = CheckAssignmentConstraints(Loc, LHSType, RHSType);
}

if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType,
RHS.get(), AA_Assigning))
if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType, RHS.get(),
AssignmentAction::Assigning))
return QualType();

CheckForNullPointerDereference(*this, LHSExpr);
Expand Down Expand Up @@ -16692,7 +16698,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
MayHaveConvFixit = true;
break;
case IncompatiblePointer:
if (Action == AA_Passing_CFAudited) {
if (Action == AssignmentAction::Passing_CFAudited) {
DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
} else if (getLangOpts().CPlusPlus) {
DiagKind = diag::err_typecheck_convert_incompatible_pointer;
Expand Down Expand Up @@ -16846,19 +16852,19 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,

QualType FirstType, SecondType;
switch (Action) {
case AA_Assigning:
case AA_Initializing:
case AssignmentAction::Assigning:
case AssignmentAction::Initializing:
// The destination type comes first.
FirstType = DstType;
SecondType = SrcType;
break;

case AA_Returning:
case AA_Passing:
case AA_Passing_CFAudited:
case AA_Converting:
case AA_Sending:
case AA_Casting:
case AssignmentAction::Returning:
case AssignmentAction::Passing:
case AssignmentAction::Passing_CFAudited:
case AssignmentAction::Converting:
case AssignmentAction::Sending:
case AssignmentAction::Casting:
// The source type comes first.
FirstType = SrcType;
SecondType = DstType;
Expand All @@ -16867,8 +16873,8 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,

PartialDiagnostic FDiag = PDiag(DiagKind);
AssignmentAction ActionForDiag = Action;
if (Action == AA_Passing_CFAudited)
ActionForDiag = AA_Passing;
if (Action == AssignmentAction::Passing_CFAudited)
ActionForDiag = AssignmentAction::Passing;

FDiag << FirstType << SecondType << ActionForDiag
<< SrcExpr->getSourceRange();
Expand Down Expand Up @@ -16908,7 +16914,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
if (CheckInferredResultType)
ObjC().EmitRelatedResultTypeNote(SrcExpr);

if (Action == AA_Returning && ConvTy == IncompatiblePointer)
if (Action == AssignmentAction::Returning && ConvTy == IncompatiblePointer)
ObjC().EmitRelatedResultTypeNoteForReturn(DstType);

if (Complained)
Expand Down
Loading

0 comments on commit 28f9f84

Please sign in to comment.