Skip to content

Commit feda78b

Browse files
authored
Merge branch 'main' into store-to-immutable-checker
2 parents 89389a5 + eefc3d2 commit feda78b

File tree

418 files changed

+18348
-4619
lines changed

Some content is hidden

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

418 files changed

+18348
-4619
lines changed

bolt/lib/Core/Exceptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ bool CFIReaderWriter::fillCFIInfoFor(BinaryFunction &Function) const {
500500

501501
const FDE &CurFDE = *I->second;
502502
std::optional<uint64_t> LSDA = CurFDE.getLSDAAddress();
503-
Function.setLSDAAddress(LSDA ? *LSDA : 0);
503+
Function.setLSDAAddress(LSDA.value_or(0));
504504

505505
uint64_t Offset = Function.getFirstInstructionOffset();
506506
uint64_t CodeAlignment = CurFDE.getLinkedCIE()->getCodeAlignmentFactor();

clang-tools-extra/clang-include-fixer/IncludeFixer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Action : public clang::ASTFrontendAction {
5353

5454
Compiler->createSema(getTranslationUnitKind(), CompletionConsumer);
5555
SemaSource->setCompilerInstance(Compiler);
56-
Compiler->getSema().addExternalSource(SemaSource.get());
56+
Compiler->getSema().addExternalSource(SemaSource);
5757

5858
clang::ParseAST(Compiler->getSema(), Compiler->getFrontendOpts().ShowStats,
5959
Compiler->getFrontendOpts().SkipFunctionBodies);

clang-tools-extra/clang-tidy/.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Checks: >
2222
-performance-unnecessary-value-param,
2323
readability-*,
2424
-readability-avoid-nested-conditional-operator,
25-
-readability-avoid-return-with-void-value,
2625
-readability-braces-around-statements,
2726
-readability-container-contains,
2827
-readability-convert-member-functions-to-static,

clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,11 @@ void NarrowingConversionsCheck::diagNarrowTypeOrConstant(
381381
const Expr &Rhs) {
382382
APValue Constant = getConstantExprValue(Context, Rhs);
383383
if (Constant.isInt())
384-
return diagNarrowIntegerConstant(SourceLoc, Lhs, Rhs, Constant.getInt());
385-
if (Constant.isFloat())
386-
return diagNarrowConstant(SourceLoc, Lhs, Rhs);
387-
return diagNarrowType(SourceLoc, Lhs, Rhs);
384+
diagNarrowIntegerConstant(SourceLoc, Lhs, Rhs, Constant.getInt());
385+
else if (Constant.isFloat())
386+
diagNarrowConstant(SourceLoc, Lhs, Rhs);
387+
else
388+
diagNarrowType(SourceLoc, Lhs, Rhs);
388389
}
389390

390391
void NarrowingConversionsCheck::handleIntegralCast(const ASTContext &Context,
@@ -460,10 +461,10 @@ void NarrowingConversionsCheck::handleFloatingToIntegral(
460461
llvm::APFloat FloatConstant(0.0);
461462
if (getFloatingConstantExprValue(Context, Rhs, FloatConstant)) {
462463
if (!isFloatExactlyRepresentable(Context, FloatConstant, Lhs.getType()))
463-
return diagNarrowConstant(SourceLoc, Lhs, Rhs);
464+
diagNarrowConstant(SourceLoc, Lhs, Rhs);
464465

465-
if (PedanticMode)
466-
return diagConstantCast(SourceLoc, Lhs, Rhs);
466+
else if (PedanticMode)
467+
diagConstantCast(SourceLoc, Lhs, Rhs);
467468

468469
return;
469470
}
@@ -478,7 +479,7 @@ void NarrowingConversionsCheck::handleFloatingToIntegral(
478479
void NarrowingConversionsCheck::handleFloatingToBoolean(
479480
const ASTContext &Context, SourceLocation SourceLoc, const Expr &Lhs,
480481
const Expr &Rhs) {
481-
return diagNarrowTypeOrConstant(Context, SourceLoc, Lhs, Rhs);
482+
diagNarrowTypeOrConstant(Context, SourceLoc, Lhs, Rhs);
482483
}
483484

484485
void NarrowingConversionsCheck::handleBooleanToSignedIntegral(
@@ -532,19 +533,20 @@ void NarrowingConversionsCheck::handleBinaryOperator(const ASTContext &Context,
532533
if (LhsType == RhsType)
533534
return;
534535
if (RhsType->getKind() == BuiltinType::Bool && LhsType->isSignedInteger())
535-
return handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
536-
if (RhsType->isInteger() && LhsType->getKind() == BuiltinType::Bool)
537-
return handleIntegralToBoolean(Context, SourceLoc, Lhs, Rhs);
538-
if (RhsType->isInteger() && LhsType->isFloatingPoint())
539-
return handleIntegralToFloating(Context, SourceLoc, Lhs, Rhs);
540-
if (RhsType->isInteger() && LhsType->isInteger())
541-
return handleIntegralCast(Context, SourceLoc, Lhs, Rhs);
542-
if (RhsType->isFloatingPoint() && LhsType->getKind() == BuiltinType::Bool)
543-
return handleFloatingToBoolean(Context, SourceLoc, Lhs, Rhs);
544-
if (RhsType->isFloatingPoint() && LhsType->isInteger())
545-
return handleFloatingToIntegral(Context, SourceLoc, Lhs, Rhs);
546-
if (RhsType->isFloatingPoint() && LhsType->isFloatingPoint())
547-
return handleFloatingCast(Context, SourceLoc, Lhs, Rhs);
536+
handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
537+
else if (RhsType->isInteger() && LhsType->getKind() == BuiltinType::Bool)
538+
handleIntegralToBoolean(Context, SourceLoc, Lhs, Rhs);
539+
else if (RhsType->isInteger() && LhsType->isFloatingPoint())
540+
handleIntegralToFloating(Context, SourceLoc, Lhs, Rhs);
541+
else if (RhsType->isInteger() && LhsType->isInteger())
542+
handleIntegralCast(Context, SourceLoc, Lhs, Rhs);
543+
else if (RhsType->isFloatingPoint() &&
544+
LhsType->getKind() == BuiltinType::Bool)
545+
handleFloatingToBoolean(Context, SourceLoc, Lhs, Rhs);
546+
else if (RhsType->isFloatingPoint() && LhsType->isInteger())
547+
handleFloatingToIntegral(Context, SourceLoc, Lhs, Rhs);
548+
else if (RhsType->isFloatingPoint() && LhsType->isFloatingPoint())
549+
handleFloatingCast(Context, SourceLoc, Lhs, Rhs);
548550
}
549551

550552
bool NarrowingConversionsCheck::handleConditionalOperator(
@@ -577,21 +579,28 @@ void NarrowingConversionsCheck::handleImplicitCast(
577579
SourceLocation SourceLoc = Lhs.getExprLoc();
578580
switch (Cast.getCastKind()) {
579581
case CK_BooleanToSignedIntegral:
580-
return handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
582+
handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
583+
return;
581584
case CK_IntegralToBoolean:
582-
return handleIntegralToBoolean(Context, SourceLoc, Lhs, Rhs);
585+
handleIntegralToBoolean(Context, SourceLoc, Lhs, Rhs);
586+
return;
583587
case CK_IntegralToFloating:
584-
return handleIntegralToFloating(Context, SourceLoc, Lhs, Rhs);
588+
handleIntegralToFloating(Context, SourceLoc, Lhs, Rhs);
589+
return;
585590
case CK_IntegralCast:
586-
return handleIntegralCast(Context, SourceLoc, Lhs, Rhs);
591+
handleIntegralCast(Context, SourceLoc, Lhs, Rhs);
592+
return;
587593
case CK_FloatingToBoolean:
588-
return handleFloatingToBoolean(Context, SourceLoc, Lhs, Rhs);
594+
handleFloatingToBoolean(Context, SourceLoc, Lhs, Rhs);
595+
return;
589596
case CK_FloatingToIntegral:
590-
return handleFloatingToIntegral(Context, SourceLoc, Lhs, Rhs);
597+
handleFloatingToIntegral(Context, SourceLoc, Lhs, Rhs);
598+
return;
591599
case CK_FloatingCast:
592-
return handleFloatingCast(Context, SourceLoc, Lhs, Rhs);
600+
handleFloatingCast(Context, SourceLoc, Lhs, Rhs);
601+
return;
593602
default:
594-
break;
603+
return;
595604
}
596605
}
597606

@@ -610,9 +619,10 @@ void NarrowingConversionsCheck::handleBinaryOperator(const ASTContext &Context,
610619

611620
void NarrowingConversionsCheck::check(const MatchFinder::MatchResult &Result) {
612621
if (const auto *Op = Result.Nodes.getNodeAs<BinaryOperator>("binary_op"))
613-
return handleBinaryOperator(*Result.Context, *Op);
614-
if (const auto *Cast = Result.Nodes.getNodeAs<ImplicitCastExpr>("cast"))
615-
return handleImplicitCast(*Result.Context, *Cast);
616-
llvm_unreachable("must be binary operator or cast expression");
622+
handleBinaryOperator(*Result.Context, *Op);
623+
else if (const auto *Cast = Result.Nodes.getNodeAs<ImplicitCastExpr>("cast"))
624+
handleImplicitCast(*Result.Context, *Cast);
625+
else
626+
llvm_unreachable("must be binary operator or cast expression");
617627
}
618628
} // namespace clang::tidy::bugprone

clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,15 @@ void ImplicitBoolConversionCheck::check(
361361
if (const auto *CastToBool =
362362
Result.Nodes.getNodeAs<ImplicitCastExpr>("implicitCastToBool")) {
363363
const auto *Parent = Result.Nodes.getNodeAs<Stmt>("parentStmt");
364-
return handleCastToBool(CastToBool, Parent, *Result.Context);
364+
handleCastToBool(CastToBool, Parent, *Result.Context);
365+
return;
365366
}
366367

367368
if (const auto *CastFromBool =
368369
Result.Nodes.getNodeAs<ImplicitCastExpr>("implicitCastFromBool")) {
369370
const auto *NextImplicitCast =
370371
Result.Nodes.getNodeAs<ImplicitCastExpr>("furtherImplicitCast");
371-
return handleCastFromBool(CastFromBool, NextImplicitCast, *Result.Context);
372+
handleCastFromBool(CastFromBool, NextImplicitCast, *Result.Context);
372373
}
373374
}
374375

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ Improvements to Clang's diagnostics
123123
Moved the warning for a missing (though implied) attribute on a redeclaration into this group.
124124
Added a new warning in this group for the case where the attribute is missing/implicit on
125125
an override of a virtual method.
126+
- Fixed fix-it hint for fold expressions. Clang now correctly places the suggested right
127+
parenthesis when diagnosing malformed fold expressions. (#GH151787)
126128

127129
Improvements to Clang's time-trace
128130
----------------------------------
@@ -241,12 +243,16 @@ Static Analyzer
241243
---------------
242244
- The Clang Static Analyzer now handles parenthesized initialization.
243245
(#GH148875)
246+
- ``__datasizeof`` (C++) and ``_Countof`` (C) no longer cause a failed assertion
247+
when given an operand of VLA type. (#GH151711)
244248

245249
New features
246250
^^^^^^^^^^^^
247251

248252
Crash and bug fixes
249253
^^^^^^^^^^^^^^^^^^^
254+
- Fixed a crash in the static analyzer that when the expression in an
255+
``[[assume(expr)]]`` attribute was enclosed in parentheses. (#GH151529)
250256

251257
Improvements
252258
^^^^^^^^^^^^

clang/include/clang/AST/ASTContext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,12 @@ class ASTContext : public RefCountedBase<ASTContext> {
13351335
return ExternalSource.get();
13361336
}
13371337

1338+
/// Retrieve a pointer to the external AST source associated
1339+
/// with this AST context, if any. Returns as an IntrusiveRefCntPtr.
1340+
IntrusiveRefCntPtr<ExternalASTSource> getExternalSourcePtr() const {
1341+
return ExternalSource;
1342+
}
1343+
13381344
/// Attach an AST mutation listener to the AST context.
13391345
///
13401346
/// The AST mutation listener provides the ability to track modifications to

clang/include/clang/AST/Expr.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -553,17 +553,13 @@ class Expr : public ValueStmt {
553553
bool IgnoreTemplateOrMacroSubstitution = false) const;
554554

555555
/// isIntegerConstantExpr - Return the value if this expression is a valid
556-
/// integer constant expression. If not a valid i-c-e, return std::nullopt
557-
/// and fill in Loc (if specified) with the location of the invalid
558-
/// expression.
556+
/// integer constant expression. If not a valid i-c-e, return std::nullopt.
559557
///
560558
/// Note: This does not perform the implicit conversions required by C++11
561559
/// [expr.const]p5.
562560
std::optional<llvm::APSInt>
563-
getIntegerConstantExpr(const ASTContext &Ctx,
564-
SourceLocation *Loc = nullptr) const;
565-
bool isIntegerConstantExpr(const ASTContext &Ctx,
566-
SourceLocation *Loc = nullptr) const;
561+
getIntegerConstantExpr(const ASTContext &Ctx) const;
562+
bool isIntegerConstantExpr(const ASTContext &Ctx) const;
567563

568564
/// isCXX98IntegralConstantExpr - Return true if this expression is an
569565
/// integral constant expression in C++98. Can only be used in C++.
@@ -574,8 +570,8 @@ class Expr : public ValueStmt {
574570
///
575571
/// Note: This does not perform the implicit conversions required by C++11
576572
/// [expr.const]p5.
577-
bool isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result = nullptr,
578-
SourceLocation *Loc = nullptr) const;
573+
bool isCXX11ConstantExpr(const ASTContext &Ctx,
574+
APValue *Result = nullptr) const;
579575

580576
/// isPotentialConstantExpr - Return true if this function's definition
581577
/// might be usable in a constant expression in C++11, if it were marked

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,11 +716,39 @@ TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_bf16_fp4, "V8yUiUiIUi", "nc", "gfx
716716
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f32_fp8, "V8fV2UiUiIUi", "nc", "gfx1250-insts")
717717
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f32_bf8, "V8fV2UiUiIUi", "nc", "gfx1250-insts")
718718
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f32_fp4, "V8fUiUiIUi", "nc", "gfx1250-insts")
719+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_fp8_bf16, "V2UiV8yf", "nc", "gfx1250-insts")
720+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_bf8_bf16, "V2UiV8yf", "nc", "gfx1250-insts")
721+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_fp8_f16, "V2UiV8hf", "nc", "gfx1250-insts")
722+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_bf8_f16, "V2UiV8hf", "nc", "gfx1250-insts")
723+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_fp8_f32, "V2UiV8ff", "nc", "gfx1250-insts")
724+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_bf8_f32, "V2UiV8ff", "nc", "gfx1250-insts")
725+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_fp4_f32, "UiV8ff", "nc", "gfx1250-insts")
726+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_fp4_f16, "UiV8hf", "nc", "gfx1250-insts")
727+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_fp4_bf16, "UiV8yf", "nc", "gfx1250-insts")
728+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_bf16, "V2UiV8yUif", "nc", "gfx1250-insts")
729+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_sr_pk8_bf8_bf16, "V2UiV8yUif", "nc", "gfx1250-insts")
730+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_f16, "V2UiV8hUif", "nc", "gfx1250-insts")
731+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_sr_pk8_bf8_f16, "V2UiV8hUif", "nc", "gfx1250-insts")
732+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_f32, "V2UiV8fUif", "nc", "gfx1250-insts")
733+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_sr_pk8_bf8_f32, "V2UiV8fUif", "nc", "gfx1250-insts")
734+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_sr_pk8_fp4_f32, "UiV8fUif", "nc", "gfx1250-insts")
735+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_sr_pk8_fp4_f16, "UiV8hUif", "nc", "gfx1250-insts")
736+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_sr_pk8_fp4_bf16, "UiV8yUif", "nc", "gfx1250-insts")
719737
TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_fp8_f32_e5m3, "iffiIb", "nc", "fp8e5m3-insts")
720738
TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_fp8_f32_e5m3, "ifiiIi", "nc", "fp8e5m3-insts")
721739
TARGET_BUILTIN(__builtin_amdgcn_sat_pk4_i4_i8, "UsUi", "nc", "gfx1250-insts")
722740
TARGET_BUILTIN(__builtin_amdgcn_sat_pk4_u4_u8, "UsUi", "nc", "gfx1250-insts")
723741

742+
TARGET_BUILTIN(__builtin_amdgcn_permlane_bcast, "iiii", "nc", "gfx1250-insts,wavefrontsize32")
743+
TARGET_BUILTIN(__builtin_amdgcn_permlane_up, "iiii", "nc", "gfx1250-insts,wavefrontsize32")
744+
TARGET_BUILTIN(__builtin_amdgcn_permlane_down, "iiii", "nc", "gfx1250-insts,wavefrontsize32")
745+
TARGET_BUILTIN(__builtin_amdgcn_permlane_xor, "iiii", "nc", "gfx1250-insts,wavefrontsize32")
746+
TARGET_BUILTIN(__builtin_amdgcn_permlane_idx_gen, "iii", "nc", "gfx1250-insts,wavefrontsize32")
747+
748+
TARGET_BUILTIN(__builtin_amdgcn_perm_pk16_b4_u4, "V2UiUiUiV2Ui", "nc", "tensor-cvt-lut-insts")
749+
TARGET_BUILTIN(__builtin_amdgcn_perm_pk16_b6_u4, "V3UiUiULiV2Ui", "nc", "tensor-cvt-lut-insts")
750+
TARGET_BUILTIN(__builtin_amdgcn_perm_pk16_b8_u4, "V4UiULiULiV2Ui", "nc", "tensor-cvt-lut-insts")
751+
724752
// GFX1250 WMMA builtins
725753
TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x4_f32, "V8fIbV2fIbV2fIsV8fIbIb", "nc", "gfx1250-insts,wavefrontsize32")
726754
TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x32_bf16, "V8fIbV16yIbV16yIsV8fIbIb", "nc", "gfx1250-insts,wavefrontsize32")

0 commit comments

Comments
 (0)