Skip to content

Commit ce820b8

Browse files
authored
LLVM and SPIRV-LLVM-Translator pulldown (WW25) #3934
LLVM: llvm/llvm-project@6c7be41 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@be24f4e
2 parents 5e8e5ea + 105a151 commit ce820b8

File tree

4,391 files changed

+153143
-114944
lines changed

Some content is hidden

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

4,391 files changed

+153143
-114944
lines changed

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,readability-identifier-naming'
1+
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,readability-identifier-naming'
22
CheckOptions:
33
- key: readability-identifier-naming.ClassCase
44
value: CamelCase

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ d8f0e6caa91e230a486c948ab643174e40bdf215
4040

4141
# Wiped out some non-ascii characters that snuck into the copyright.
4242
5b08a8a43254ed30bd953e869b0fd9fc1e8b82d0
43+
44+
# Use C++11 default member initializers in LLDB. NFC.
45+
9494c510af56d9c8593ab69017dcaa232210b235

.mailmap

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
#
2323
# Please keep this file sorted.
2424

25-
Martin Storsjö <[email protected]>
25+
26+
2627
2728
28-
29+
Jon Roelofs <[email protected]> Jon Roelofs <[email protected]>
30+
Jon Roelofs <[email protected]> Jonathan Roelofs <[email protected]>
31+
Jon Roelofs <[email protected]> Jonathan Roelofs <[email protected]>
32+
Martin Storsjö <[email protected]>

clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ stripFloatLiteralFraction(const MatchFinder::MatchResult &Result,
208208
if (const auto *LitFloat = llvm::dyn_cast<FloatingLiteral>(&Node))
209209
// Attempt to simplify a `Duration` factory call with a literal argument.
210210
if (llvm::Optional<llvm::APSInt> IntValue = truncateIfIntegral(*LitFloat))
211-
return IntValue->toString(/*radix=*/10);
211+
return toString(*IntValue, /*radix=*/10);
212212

213213
return llvm::None;
214214
}

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

Lines changed: 81 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ auto hasAnyListedName(const std::string &Names) {
3535
NarrowingConversionsCheck::NarrowingConversionsCheck(StringRef Name,
3636
ClangTidyContext *Context)
3737
: ClangTidyCheck(Name, Context),
38+
WarnOnIntegerNarrowingConversion(
39+
Options.get("WarnOnIntegerNarrowingConversion", true)),
3840
WarnOnFloatingPointNarrowingConversion(
3941
Options.get("WarnOnFloatingPointNarrowingConversion", true)),
4042
WarnWithinTemplateInstantiation(
@@ -45,6 +47,8 @@ NarrowingConversionsCheck::NarrowingConversionsCheck(StringRef Name,
4547

4648
void NarrowingConversionsCheck::storeOptions(
4749
ClangTidyOptions::OptionMap &Opts) {
50+
Options.store(Opts, "WarnOnIntegerNarrowingConversion",
51+
WarnOnIntegerNarrowingConversion);
4852
Options.store(Opts, "WarnOnFloatingPointNarrowingConversion",
4953
WarnOnFloatingPointNarrowingConversion);
5054
Options.store(Opts, "WarnWithinTemplateInstantiation",
@@ -67,8 +71,9 @@ void NarrowingConversionsCheck::registerMatchers(MatchFinder *Finder) {
6771
hasType(namedDecl(hasAnyListedName(IgnoreConversionFromTypes)));
6872

6973
// `IsConversionFromIgnoredType` will ignore narrowing calls from those types,
70-
// but not expressions that are promoted to `int64` due to a binary expression
71-
// with one of those types. For example, it will continue to reject:
74+
// but not expressions that are promoted to an ignored type as a result of a
75+
// binary expression with one of those types.
76+
// For example, it will continue to reject:
7277
// `int narrowed = int_value + container.size()`.
7378
// We attempt to address common incidents of compound expressions with
7479
// `IsIgnoredTypeTwoLevelsDeep`, allowing binary expressions that have one
@@ -217,6 +222,22 @@ static bool isWideEnoughToHold(const ASTContext &Context,
217222
return ToIntegerRange.contains(IntegerConstant);
218223
}
219224

225+
// Returns true iff the floating point constant can be losslessly represented
226+
// by an integer in the given destination type. eg. 2.0 can be accurately
227+
// represented by an int32_t, but neither 2^33 nor 2.001 can.
228+
static bool isFloatExactlyRepresentable(const ASTContext &Context,
229+
const llvm::APFloat &FloatConstant,
230+
const QualType &DestType) {
231+
unsigned DestWidth = Context.getIntWidth(DestType);
232+
bool DestSigned = DestType->isSignedIntegerOrEnumerationType();
233+
llvm::APSInt Result = llvm::APSInt(DestWidth, !DestSigned);
234+
bool IsExact = false;
235+
bool Overflows = FloatConstant.convertToInteger(
236+
Result, llvm::APFloat::rmTowardZero, &IsExact) &
237+
llvm::APFloat::opInvalidOp;
238+
return !Overflows && IsExact;
239+
}
240+
220241
static llvm::SmallString<64> getValueAsString(const llvm::APSInt &Value,
221242
uint64_t HexBits) {
222243
llvm::SmallString<64> Str;
@@ -233,6 +254,21 @@ static llvm::SmallString<64> getValueAsString(const llvm::APSInt &Value,
233254
return Str;
234255
}
235256

257+
bool NarrowingConversionsCheck::isWarningInhibitedByEquivalentSize(
258+
const ASTContext &Context, const BuiltinType &FromType,
259+
const BuiltinType &ToType) const {
260+
// With this option, we don't warn on conversions that have equivalent width
261+
// in bits. eg. uint32 <-> int32.
262+
if (!WarnOnEquivalentBitWidth) {
263+
uint64_t FromTypeSize = Context.getTypeSize(&FromType);
264+
uint64_t ToTypeSize = Context.getTypeSize(&ToType);
265+
if (FromTypeSize == ToTypeSize) {
266+
return true;
267+
}
268+
}
269+
return false;
270+
}
271+
236272
void NarrowingConversionsCheck::diagNarrowType(SourceLocation SourceLoc,
237273
const Expr &Lhs,
238274
const Expr &Rhs) {
@@ -294,34 +330,37 @@ void NarrowingConversionsCheck::handleIntegralCast(const ASTContext &Context,
294330
SourceLocation SourceLoc,
295331
const Expr &Lhs,
296332
const Expr &Rhs) {
297-
const BuiltinType *ToType = getBuiltinType(Lhs);
298-
// From [conv.integral]p7.3.8:
299-
// Conversions to unsigned integer is well defined so no warning is issued.
300-
// "The resulting value is the smallest unsigned value equal to the source
301-
// value modulo 2^n where n is the number of bits used to represent the
302-
// destination type."
303-
if (ToType->isUnsignedInteger())
304-
return;
305-
const BuiltinType *FromType = getBuiltinType(Rhs);
306-
307-
// With this option, we don't warn on conversions that have equivalent width
308-
// in bits. eg. uint32 <-> int32.
309-
if (!WarnOnEquivalentBitWidth) {
310-
uint64_t FromTypeSize = Context.getTypeSize(FromType);
311-
uint64_t ToTypeSize = Context.getTypeSize(ToType);
312-
if (FromTypeSize == ToTypeSize)
333+
if (WarnOnIntegerNarrowingConversion) {
334+
const BuiltinType *ToType = getBuiltinType(Lhs);
335+
// From [conv.integral]p7.3.8:
336+
// Conversions to unsigned integer is well defined so no warning is issued.
337+
// "The resulting value is the smallest unsigned value equal to the source
338+
// value modulo 2^n where n is the number of bits used to represent the
339+
// destination type."
340+
if (ToType->isUnsignedInteger())
313341
return;
314-
}
342+
const BuiltinType *FromType = getBuiltinType(Rhs);
315343

316-
llvm::APSInt IntegerConstant;
317-
if (getIntegerConstantExprValue(Context, Rhs, IntegerConstant)) {
318-
if (!isWideEnoughToHold(Context, IntegerConstant, *ToType))
319-
diagNarrowIntegerConstantToSignedInt(SourceLoc, Lhs, Rhs, IntegerConstant,
320-
Context.getTypeSize(FromType));
321-
return;
344+
// With this option, we don't warn on conversions that have equivalent width
345+
// in bits. eg. uint32 <-> int32.
346+
if (!WarnOnEquivalentBitWidth) {
347+
uint64_t FromTypeSize = Context.getTypeSize(FromType);
348+
uint64_t ToTypeSize = Context.getTypeSize(ToType);
349+
if (FromTypeSize == ToTypeSize)
350+
return;
351+
}
352+
353+
llvm::APSInt IntegerConstant;
354+
if (getIntegerConstantExprValue(Context, Rhs, IntegerConstant)) {
355+
if (!isWideEnoughToHold(Context, IntegerConstant, *ToType))
356+
diagNarrowIntegerConstantToSignedInt(SourceLoc, Lhs, Rhs,
357+
IntegerConstant,
358+
Context.getTypeSize(FromType));
359+
return;
360+
}
361+
if (!isWideEnoughToHold(Context, *FromType, *ToType))
362+
diagNarrowTypeToSignedInt(SourceLoc, Lhs, Rhs);
322363
}
323-
if (!isWideEnoughToHold(Context, *FromType, *ToType))
324-
diagNarrowTypeToSignedInt(SourceLoc, Lhs, Rhs);
325364
}
326365

327366
void NarrowingConversionsCheck::handleIntegralToBoolean(
@@ -344,7 +383,10 @@ void NarrowingConversionsCheck::handleIntegralToFloating(
344383
diagNarrowIntegerConstant(SourceLoc, Lhs, Rhs, IntegerConstant);
345384
return;
346385
}
386+
347387
const BuiltinType *FromType = getBuiltinType(Rhs);
388+
if (isWarningInhibitedByEquivalentSize(Context, *FromType, *ToType))
389+
return;
348390
if (!isWideEnoughToHold(Context, *FromType, *ToType))
349391
diagNarrowType(SourceLoc, Lhs, Rhs);
350392
}
@@ -353,25 +395,21 @@ void NarrowingConversionsCheck::handleFloatingToIntegral(
353395
const ASTContext &Context, SourceLocation SourceLoc, const Expr &Lhs,
354396
const Expr &Rhs) {
355397
llvm::APFloat FloatConstant(0.0);
398+
if (getFloatingConstantExprValue(Context, Rhs, FloatConstant)) {
399+
if (!isFloatExactlyRepresentable(Context, FloatConstant, Lhs.getType()))
400+
return diagNarrowConstant(SourceLoc, Lhs, Rhs);
356401

357-
// We always warn when Rhs is non-constexpr.
358-
if (!getFloatingConstantExprValue(Context, Rhs, FloatConstant))
359-
return diagNarrowType(SourceLoc, Lhs, Rhs);
402+
if (PedanticMode)
403+
return diagConstantCast(SourceLoc, Lhs, Rhs);
360404

361-
QualType DestType = Lhs.getType();
362-
unsigned DestWidth = Context.getIntWidth(DestType);
363-
bool DestSigned = DestType->isSignedIntegerOrEnumerationType();
364-
llvm::APSInt Result = llvm::APSInt(DestWidth, !DestSigned);
365-
bool IsExact = false;
366-
bool Overflows = FloatConstant.convertToInteger(
367-
Result, llvm::APFloat::rmTowardZero, &IsExact) &
368-
llvm::APFloat::opInvalidOp;
369-
// We warn iff the constant floating point value is not exactly representable.
370-
if (Overflows || !IsExact)
371-
return diagNarrowConstant(SourceLoc, Lhs, Rhs);
405+
return;
406+
}
372407

373-
if (PedanticMode)
374-
return diagConstantCast(SourceLoc, Lhs, Rhs);
408+
const BuiltinType *FromType = getBuiltinType(Rhs);
409+
const BuiltinType *ToType = getBuiltinType(Lhs);
410+
if (isWarningInhibitedByEquivalentSize(Context, *FromType, *ToType))
411+
return;
412+
diagNarrowType(SourceLoc, Lhs, Rhs); // Assumed always lossy.
375413
}
376414

377415
void NarrowingConversionsCheck::handleFloatingToBoolean(

clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ class NarrowingConversionsCheck : public ClangTidyCheck {
9393
void handleBinaryOperator(const ASTContext &Context,
9494
const BinaryOperator &Op);
9595

96+
bool isWarningInhibitedByEquivalentSize(const ASTContext &Context,
97+
const BuiltinType &FromType,
98+
const BuiltinType &ToType) const;
99+
100+
const bool WarnOnIntegerNarrowingConversion;
96101
const bool WarnOnFloatingPointNarrowingConversion;
97102
const bool WarnWithinTemplateInstantiation;
98103
const bool WarnOnEquivalentBitWidth;

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void ProBoundsConstantArrayIndexCheck::check(
9999

100100
if (Index->isSigned() && Index->isNegative()) {
101101
diag(Matched->getExprLoc(), "std::array<> index %0 is negative")
102-
<< Index->toString(10);
102+
<< toString(*Index, 10);
103103
return;
104104
}
105105

@@ -118,7 +118,7 @@ void ProBoundsConstantArrayIndexCheck::check(
118118
diag(Matched->getExprLoc(),
119119
"std::array<> index %0 is past the end of the array "
120120
"(which contains %1 elements)")
121-
<< Index->toString(10) << ArraySize.toString(10, false);
121+
<< toString(*Index, 10) << toString(ArraySize, 10, false);
122122
}
123123
}
124124

clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ void UniqueptrResetReleaseCheck::check(const MatchFinder::MatchResult &Result) {
124124
AssignmentText = " = std::move(*";
125125
TrailingText = ")";
126126
NeedsUtilityInclude = true;
127-
} else if (!Right->isRValue()) {
127+
} else if (!Right->isPRValue()) {
128128
AssignmentText = " = std::move(";
129129
TrailingText = ")";
130130
NeedsUtilityInclude = true;

clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ static bool usagesAreConst(ASTContext *Context, const UsageResult &Usages) {
429429
/// by reference.
430430
static bool usagesReturnRValues(const UsageResult &Usages) {
431431
for (const auto &U : Usages) {
432-
if (U.Expression && !U.Expression->isRValue())
432+
if (U.Expression && !U.Expression->isPRValue())
433433
return false;
434434
}
435435
return true;

0 commit comments

Comments
 (0)