Skip to content

Commit 46f7de6

Browse files
author
MUSTAPHA BARKI
authored
Merge branch 'llvm:main' into Uncontrolled-data-used-in-path-expression
2 parents 5521b6f + a3d7c46 commit 46f7de6

File tree

221 files changed

+17680
-10757
lines changed

Some content is hidden

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

221 files changed

+17680
-10757
lines changed

.github/workflows/pr-code-lint.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ jobs:
4747
echo "Changed files:"
4848
echo "$CHANGED_FILES"
4949
50+
# The clang tidy version should always be upgraded to the first version
51+
# of a release cycle (x.1.0) or the last version of a release cycle, or
52+
# if there have been relevant clang-format backports.
5053
- name: Install clang-tidy
5154
uses: aminya/setup-cpp@17c11551771948abc5752bbf3183482567c7caf0 # v1.1.1
5255
with:
53-
clang-tidy: 20.1.8
56+
clang-tidy: 21.1.0
5457

5558
- name: Setup Python env
5659
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0

clang/docs/LanguageExtensions.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,8 @@ Each builtin accesses memory according to a provided boolean mask. These are
950950
provided as ``__builtin_masked_load`` and ``__builtin_masked_store``. The first
951951
argument is always boolean mask vector. The ``__builtin_masked_load`` builtin
952952
takes an optional third vector argument that will be used for the result of the
953-
masked-off lanes. These builtins assume the memory is always aligned.
953+
masked-off lanes. These builtins assume the memory is unaligned, use
954+
``__builtin_assume_aligned`` if alignment is desired.
954955

955956
The ``__builtin_masked_expand_load`` and ``__builtin_masked_compress_store``
956957
builtins have the same interface but store the result in consecutive indices.
@@ -969,17 +970,17 @@ Example:
969970
using v8b = bool [[clang::ext_vector_type(8)]];
970971
using v8i = int [[clang::ext_vector_type(8)]];
971972

972-
v8i load(v8b mask, v8i *ptr) { return __builtin_masked_load(mask, ptr); }
973+
v8i load(v8b mask, int *ptr) { return __builtin_masked_load(mask, ptr); }
973974
974-
v8i load_expand(v8b mask, v8i *ptr) {
975+
v8i load_expand(v8b mask, int *ptr) {
975976
return __builtin_masked_expand_load(mask, ptr);
976977
}
977978
978-
void store(v8b mask, v8i val, v8i *ptr) {
979+
void store(v8b mask, v8i val, int *ptr) {
979980
__builtin_masked_store(mask, val, ptr);
980981
}
981982
982-
void store_compress(v8b mask, v8i val, v8i *ptr) {
983+
void store_compress(v8b mask, v8i val, int *ptr) {
983984
__builtin_masked_compress_store(mask, val, ptr);
984985
}
985986

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ C++ Language Changes
150150
C++2c Feature Support
151151
^^^^^^^^^^^^^^^^^^^^^
152152

153+
- Started the implementation of `P2686R5 <https://wg21.link/P2686R5>`_ Constexpr structured bindings.
154+
At this timem, references to constexpr and decomposition of *tuple-like* types are not supported
155+
(only arrays and aggregates are).
156+
153157
C++23 Feature Support
154158
^^^^^^^^^^^^^^^^^^^^^
155159

@@ -422,6 +426,7 @@ Bug Fixes to C++ Support
422426
``__builtin_addressof``, and related issues with builtin arguments. (#GH154034)
423427
- Fix an assertion failure when taking the address on a non-type template parameter argument of
424428
object type. (#GH151531)
429+
- Suppress ``-Wdouble-promotion`` when explicitly asked for with C++ list initialization (#GH33409).
425430

426431
Bug Fixes to AST Handling
427432
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/OpenACCClause.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -842,9 +842,7 @@ struct OpenACCPrivateRecipe {
842842
VarDecl *AllocaDecl;
843843
Expr *InitExpr;
844844

845-
OpenACCPrivateRecipe(VarDecl *A, Expr *I) : AllocaDecl(A), InitExpr(I) {
846-
assert(!AllocaDecl || AllocaDecl->getInit() == nullptr);
847-
}
845+
OpenACCPrivateRecipe(VarDecl *A, Expr *I) : AllocaDecl(A), InitExpr(I) {}
848846

849847
bool isSet() const { return AllocaDecl; }
850848

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4945,6 +4945,12 @@ def HLSLResourceHandleFromImplicitBinding : LangBuiltin<"HLSL_LANG"> {
49454945
let Prototype = "void(...)";
49464946
}
49474947

4948+
def HLSLResourceNonUniformIndex : LangBuiltin<"HLSL_LANG"> {
4949+
let Spellings = ["__builtin_hlsl_resource_nonuniformindex"];
4950+
let Attributes = [NoThrow];
4951+
let Prototype = "uint32_t(uint32_t)";
4952+
}
4953+
49484954
def HLSLAll : LangBuiltin<"HLSL_LANG"> {
49494955
let Spellings = ["__builtin_hlsl_all"];
49504956
let Attributes = [NoThrow, Const];

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ defm decomp_decl : CXX17Compat<"decomposition declarations are">;
3535
defm inline_variable : CXX17Compat<"inline variables are">;
3636

3737
// C++20 compatibility with C++17 and earlier.
38-
defm decomp_decl_spec : CXX20Compat<
39-
"decomposition declaration declared "
40-
"%plural{1:'%1'|:with '%1' specifiers}0 is">;
38+
defm decomp_decl_spec
39+
: CXX20Compat<"decomposition declaration declared '%0' is">;
4140
defm constexpr_local_var_no_init : CXX20Compat<
4241
"uninitialized variable in a constexpr %select{function|constructor}0 is">;
4342
defm constexpr_function_try_block : CXX20Compat<
@@ -593,9 +592,8 @@ def warn_modifying_shadowing_decl :
593592
// C++ decomposition declarations
594593
def err_decomp_decl_context : Error<
595594
"decomposition declaration not permitted in this context">;
596-
def err_decomp_decl_spec : Error<
597-
"decomposition declaration cannot be declared "
598-
"%plural{1:'%1'|:with '%1' specifiers}0">;
595+
def err_decomp_decl_spec
596+
: Error<"decomposition declaration cannot be declared '%0'">;
599597
def err_decomp_decl_type : Error<
600598
"decomposition declaration cannot be declared with type %0; "
601599
"declared type must be 'auto' or reference to 'auto'">;

clang/lib/Analysis/FlowSensitive/Transfer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,12 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
657657
if (LocSrc == nullptr || LocDst == nullptr)
658658
return;
659659

660-
copyRecord(*LocSrc, *LocDst, Env);
660+
// If the destination object here is of a derived class, `Arg0` may be a
661+
// cast of that object to a base class, and the source object may be of a
662+
// sibling derived class. To handle these cases, ensure we are copying
663+
// only the fields for `Arg0`'s type, not the type of the underlying
664+
// `RecordStorageLocation`.
665+
copyRecord(*LocSrc, *LocDst, Env, Arg0->getType());
661666

662667
// The assignment operator can have an arbitrary return type. We model the
663668
// return value only if the return type is the same as or a base class of

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,11 +2140,23 @@ mlir::Value ScalarExprEmitter::VisitRealImag(const UnaryOperator *e,
21402140
: builder.createComplexImag(loc, complex);
21412141
}
21422142

2143-
// __real or __imag on a scalar returns zero. Emit the subexpr to ensure side
2143+
if (e->getOpcode() == UO_Real) {
2144+
return promotionTy.isNull() ? Visit(op)
2145+
: cgf.emitPromotedScalarExpr(op, promotionTy);
2146+
}
2147+
2148+
// __imag on a scalar returns zero. Emit the subexpr to ensure side
21442149
// effects are evaluated, but not the actual value.
2145-
cgf.cgm.errorNYI(e->getSourceRange(),
2146-
"VisitRealImag __real or __imag on a scalar");
2147-
return {};
2150+
if (op->isGLValue())
2151+
cgf.emitLValue(op);
2152+
else if (!promotionTy.isNull())
2153+
cgf.emitPromotedScalarExpr(op, promotionTy);
2154+
else
2155+
cgf.emitScalarExpr(op);
2156+
2157+
mlir::Type valueTy =
2158+
cgf.convertType(promotionTy.isNull() ? e->getType() : promotionTy);
2159+
return builder.getNullValue(valueTy, loc);
21482160
}
21492161

21502162
/// Return the size or alignment of the type of argument of the sizeof

clang/lib/CIR/CodeGen/CIRGenFunction.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,16 +1716,28 @@ class CIRGenFunction : public CIRGenTypeCache {
17161716
~ActiveOpenACCLoopRAII() { cgf.activeLoopOp = oldLoopOp; }
17171717
};
17181718

1719+
// Keep track of the last place we inserted a 'recipe' so that we can insert
1720+
// the next one in lexical order.
1721+
mlir::OpBuilder::InsertPoint lastRecipeLocation;
1722+
17191723
public:
17201724
// Helper type used to store the list of important information for a 'data'
17211725
// clause variable, or a 'cache' variable reference.
17221726
struct OpenACCDataOperandInfo {
17231727
mlir::Location beginLoc;
17241728
mlir::Value varValue;
17251729
std::string name;
1730+
// The type of the original variable reference: that is, after 'bounds' have
1731+
// removed pointers/array types/etc. So in the case of int arr[5], and a
1732+
// private(arr[1]), 'origType' is 'int', but 'baseType' is 'int[5]'.
1733+
QualType origType;
17261734
QualType baseType;
17271735
llvm::SmallVector<mlir::Value> bounds;
1736+
// The list of types that we found when going through the bounds, which we
1737+
// can use to properly set the alloca section.
1738+
llvm::SmallVector<QualType> boundTypes;
17281739
};
1740+
17291741
// Gets the collection of info required to lower and OpenACC clause or cache
17301742
// construct variable reference.
17311743
OpenACCDataOperandInfo getOpenACCDataOperandInfo(const Expr *e);

clang/lib/CIR/CodeGen/CIRGenOpenACC.cpp

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,33 @@ mlir::Value CIRGenFunction::createOpenACCConstantInt(mlir::Location loc,
6868
CIRGenFunction::OpenACCDataOperandInfo
6969
CIRGenFunction::getOpenACCDataOperandInfo(const Expr *e) {
7070
const Expr *curVarExpr = e->IgnoreParenImpCasts();
71+
QualType origType =
72+
curVarExpr->getType().getNonReferenceType().getUnqualifiedType();
73+
// Array sections are special, and we have to treat them that way.
74+
if (const auto *section =
75+
dyn_cast<ArraySectionExpr>(curVarExpr->IgnoreParenImpCasts()))
76+
origType = ArraySectionExpr::getBaseOriginalType(section);
7177

7278
mlir::Location exprLoc = cgm.getLoc(curVarExpr->getBeginLoc());
7379
llvm::SmallVector<mlir::Value> bounds;
80+
llvm::SmallVector<QualType> boundTypes;
7481

7582
std::string exprString;
7683
llvm::raw_string_ostream os(exprString);
7784
e->printPretty(os, nullptr, getContext().getPrintingPolicy());
7885

86+
auto addBoundType = [&](const Expr *e) {
87+
if (const auto *section = dyn_cast<ArraySectionExpr>(curVarExpr)) {
88+
QualType baseTy = ArraySectionExpr::getBaseOriginalType(
89+
section->getBase()->IgnoreParenImpCasts());
90+
boundTypes.push_back(QualType(baseTy->getPointeeOrArrayElementType(), 0));
91+
} else {
92+
boundTypes.push_back(curVarExpr->getType());
93+
}
94+
};
95+
96+
addBoundType(curVarExpr);
97+
7998
while (isa<ArraySectionExpr, ArraySubscriptExpr>(curVarExpr)) {
8099
mlir::Location boundLoc = cgm.getLoc(curVarExpr->getBeginLoc());
81100
mlir::Value lowerBound;
@@ -115,19 +134,28 @@ CIRGenFunction::getOpenACCDataOperandInfo(const Expr *e) {
115134

116135
bounds.push_back(createBound(*this, this->builder, boundLoc, lowerBound,
117136
upperBound, extent));
137+
addBoundType(curVarExpr);
118138
}
119139

120140
if (const auto *memExpr = dyn_cast<MemberExpr>(curVarExpr))
121-
return {exprLoc, emitMemberExpr(memExpr).getPointer(), exprString,
141+
return {exprLoc,
142+
emitMemberExpr(memExpr).getPointer(),
143+
exprString,
144+
origType,
122145
curVarExpr->getType().getNonReferenceType().getUnqualifiedType(),
123-
std::move(bounds)};
146+
std::move(bounds),
147+
std::move(boundTypes)};
124148

125149
// Sema has made sure that only 4 types of things can get here, array
126150
// subscript, array section, member expr, or DRE to a var decl (or the
127151
// former 3 wrapping a var-decl), so we should be able to assume this is
128152
// right.
129153
const auto *dre = cast<DeclRefExpr>(curVarExpr);
130-
return {exprLoc, emitDeclRefLValue(dre).getPointer(), exprString,
154+
return {exprLoc,
155+
emitDeclRefLValue(dre).getPointer(),
156+
exprString,
157+
origType,
131158
curVarExpr->getType().getNonReferenceType().getUnqualifiedType(),
132-
std::move(bounds)};
159+
std::move(bounds),
160+
std::move(boundTypes)};
133161
}

0 commit comments

Comments
 (0)