Skip to content

Commit 304346f

Browse files
committed
merge main into amd-staging
2 parents 253c189 + 04bddda commit 304346f

File tree

1,140 files changed

+3213
-124907
lines changed

Some content is hidden

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

1,140 files changed

+3213
-124907
lines changed

clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeAnnotations.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ bool isAssignmentOperatorLifetimeBound(const CXXMethodDecl *CMD);
3838
/// method or because it's a normal assignment operator.
3939
bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD);
4040

41+
// Tells whether the type is annotated with [[gsl::Pointer]].
42+
bool isGslPointerType(QualType QT);
43+
// Tells whether the type is annotated with [[gsl::Owner]].
44+
bool isGslOwnerType(QualType QT);
45+
4146
} // namespace clang::lifetimes
4247

4348
#endif // LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMEANNOTATIONS_H

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8657,6 +8657,8 @@ def err_conditional_vector_size : Error<
86578657
def err_conditional_vector_element_size : Error<
86588658
"vector condition type %0 and result type %1 do not have elements of the "
86598659
"same size">;
8660+
def err_conditional_vector_scalar_type_unsupported : Error<
8661+
"scalar type %0 not supported with vector condition type %1">;
86608662
def err_conditional_vector_has_void : Error<
86618663
"GNU vector conditional operand cannot be %select{void|a throw expression}0">;
86628664
def err_conditional_vector_operand_type

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8721,10 +8721,6 @@ class Sema final : public SemaBase {
87218721
ExprResult &RHS,
87228722
SourceLocation QuestionLoc);
87238723

8724-
QualType CheckSizelessVectorConditionalTypes(ExprResult &Cond,
8725-
ExprResult &LHS, ExprResult &RHS,
8726-
SourceLocation QuestionLoc);
8727-
87288724
//// Determines if a type is trivially relocatable
87298725
/// according to the C++26 rules.
87308726
// FIXME: This is in Sema because it requires

clang/lib/AST/ByteCode/BitcastBuffer.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ struct BitcastBuffer {
8989
Data = std::make_unique<std::byte[]>(ByteSize);
9090
}
9191

92+
/// Returns the byte at the given offset.
93+
std::byte *atByte(unsigned Offset) {
94+
assert(Offset < FinalBitSize.roundToBytes());
95+
return Data.get() + Offset;
96+
}
97+
9298
/// Returns the buffer size in bits.
9399
Bits size() const { return FinalBitSize; }
94100
Bytes byteSize() const { return FinalBitSize.toBytes(); }
@@ -113,6 +119,13 @@ struct BitcastBuffer {
113119
std::unique_ptr<std::byte[]> copyBits(Bits BitOffset, Bits BitWidth,
114120
Bits FullBitWidth,
115121
Endian TargetEndianness) const;
122+
123+
/// Dereferences the value at the given offset.
124+
template <typename T> T deref(Bytes Offset) const {
125+
assert(Offset.getQuantity() < FinalBitSize.roundToBytes());
126+
assert((Offset.getQuantity() + sizeof(T)) <= FinalBitSize.roundToBytes());
127+
return *reinterpret_cast<T *>(Data.get() + Offset.getQuantity());
128+
}
116129
};
117130

118131
} // namespace interp

clang/lib/AST/ByteCode/Integral.h

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -202,30 +202,21 @@ template <unsigned Bits, bool Signed> class Integral final {
202202

203203
static Integral min(unsigned NumBits) { return Integral(Min); }
204204
static Integral max(unsigned NumBits) { return Integral(Max); }
205+
static Integral zero(unsigned BitWidth = 0) { return from(0); }
205206

206-
template <typename ValT> static Integral from(ValT Value) {
207-
if constexpr (std::is_integral<ValT>::value)
207+
template <typename ValT>
208+
static Integral from(ValT Value, unsigned NumBits = 0) {
209+
if constexpr (std::is_integral_v<ValT>)
208210
return Integral(Value);
209211
else
210-
return Integral::from(static_cast<Integral::ReprT>(Value));
212+
return Integral(static_cast<Integral::ReprT>(Value));
211213
}
212214

213215
template <unsigned SrcBits, bool SrcSign>
214-
static std::enable_if_t<SrcBits != 0, Integral>
215-
from(Integral<SrcBits, SrcSign> Value) {
216+
static Integral from(Integral<SrcBits, SrcSign> Value) {
216217
return Integral(Value.V);
217218
}
218219

219-
static Integral zero(unsigned BitWidth = 0) { return from(0); }
220-
221-
template <typename T> static Integral from(T Value, unsigned NumBits) {
222-
return Integral(Value);
223-
}
224-
225-
static bool inRange(int64_t Value, unsigned NumBits) {
226-
return CheckRange<ReprT, Min, Max>(Value);
227-
}
228-
229220
static bool increment(Integral A, Integral *R) {
230221
return add(A, Integral(ReprT(1)), A.bitWidth(), R);
231222
}
@@ -328,13 +319,6 @@ template <unsigned Bits, bool Signed> class Integral final {
328319
return false;
329320
}
330321
}
331-
template <typename T, T Min, T Max> static bool CheckRange(int64_t V) {
332-
if constexpr (std::is_signed_v<T>) {
333-
return Min <= V && V <= Max;
334-
} else {
335-
return V >= 0 && static_cast<uint64_t>(V) <= Max;
336-
}
337-
}
338322
};
339323

340324
template <unsigned Bits, bool Signed>

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,8 +1997,8 @@ static bool interp__builtin_memcmp(InterpState &S, CodePtr OpPC,
19971997
for (size_t I = 0; I != CmpSize; I += ElemSize) {
19981998
if (IsWide) {
19991999
INT_TYPE_SWITCH(*S.getContext().classify(ASTCtx.getWCharType()), {
2000-
T A = *reinterpret_cast<T *>(BufferA.Data.get() + I);
2001-
T B = *reinterpret_cast<T *>(BufferB.Data.get() + I);
2000+
T A = *reinterpret_cast<T *>(BufferA.atByte(I));
2001+
T B = *reinterpret_cast<T *>(BufferB.atByte(I));
20022002
if (A < B) {
20032003
pushInteger(S, -1, Call->getType());
20042004
return true;
@@ -2009,8 +2009,8 @@ static bool interp__builtin_memcmp(InterpState &S, CodePtr OpPC,
20092009
}
20102010
});
20112011
} else {
2012-
std::byte A = BufferA.Data[I];
2013-
std::byte B = BufferB.Data[I];
2012+
std::byte A = BufferA.deref<std::byte>(Bytes(I));
2013+
std::byte B = BufferB.deref<std::byte>(Bytes(I));
20142014

20152015
if (A < B) {
20162016
pushInteger(S, -1, Call->getType());

clang/lib/AST/ByteCode/Program.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ unsigned Program::getOrCreateNativePointer(const void *Ptr) {
2727
return It->second;
2828
}
2929

30-
const void *Program::getNativePointer(unsigned Idx) {
30+
const void *Program::getNativePointer(unsigned Idx) const {
3131
return NativePointers[Idx];
3232
}
3333

clang/lib/AST/ByteCode/Program.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Program final {
5858
unsigned getOrCreateNativePointer(const void *Ptr);
5959

6060
/// Returns the value of a marshalled native pointer.
61-
const void *getNativePointer(unsigned Idx);
61+
const void *getNativePointer(unsigned Idx) const;
6262

6363
/// Emits a string literal among global data.
6464
unsigned createGlobalString(const StringLiteral *S,

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,10 @@ void TextNodeDumper::Visit(const APValue &Value, QualType Ty) {
850850
return;
851851
}
852852
case APValue::AddrLabelDiff:
853-
OS << "AddrLabelDiff <todo>";
853+
OS << "AddrLabelDiff ";
854+
OS << "&&" << Value.getAddrLabelDiffLHS()->getLabel()->getName();
855+
OS << " - ";
856+
OS << "&&" << Value.getAddrLabelDiffRHS()->getLabel()->getName();
854857
return;
855858
}
856859
llvm_unreachable("Unknown APValue kind!");

clang/lib/Analysis/LifetimeSafety/FactsGenerator.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@
1515
namespace clang::lifetimes::internal {
1616
using llvm::isa_and_present;
1717

18-
static bool isGslPointerType(QualType QT) {
19-
if (const auto *RD = QT->getAsCXXRecordDecl()) {
20-
// We need to check the template definition for specializations.
21-
if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
22-
return CTSD->getSpecializedTemplate()
23-
->getTemplatedDecl()
24-
->hasAttr<PointerAttr>();
25-
return RD->hasAttr<PointerAttr>();
26-
}
27-
return false;
28-
}
29-
3018
static bool isPointerType(QualType QT) {
3119
return QT->isPointerOrReferenceType() || isGslPointerType(QT);
3220
}

0 commit comments

Comments
 (0)