Skip to content

Commit fc7d919

Browse files
author
Jenkins
committed
merge main into amd-staging
Change-Id: Iecb1b14fcbee9f74590efbd8c542c0955490a3a5
2 parents 47b6a30 + a1eaed7 commit fc7d919

File tree

27 files changed

+303
-40
lines changed

27 files changed

+303
-40
lines changed

clang-tools-extra/clang-doc/HTMLGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ writeFileDefinition(const Location &L,
457457
Node->Children.emplace_back(std::make_unique<TextNode>(" of file "));
458458
auto LocFileNode = std::make_unique<TagNode>(
459459
HTMLTag::TAG_A, llvm::sys::path::filename(FileURL));
460-
LocFileNode->Attributes.emplace_back("href", std::string(FileURL.str()));
460+
LocFileNode->Attributes.emplace_back("href", std::string(FileURL));
461461
Node->Children.emplace_back(std::move(LocFileNode));
462462
return Node;
463463
}

clang-tools-extra/clang-tidy/GlobList.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ namespace clang::tidy {
1616
// from the GlobList.
1717
static bool consumeNegativeIndicator(StringRef &GlobList) {
1818
GlobList = GlobList.trim();
19-
if (GlobList.starts_with("-")) {
20-
GlobList = GlobList.substr(1);
21-
return true;
22-
}
23-
return false;
19+
return GlobList.consume_front("-");
2420
}
2521

2622
// Converts first glob from the comma-separated list of globs to Regex and

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,7 @@ void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
274274
allOf(anyOf(hasCastKind(CK_NullToPointer),
275275
hasCastKind(CK_NullToMemberPointer)),
276276
hasSourceExpression(cxxBoolLiteral()))),
277-
hasSourceExpression(expr(hasType(booleanType()))),
278-
unless(ExceptionCases));
277+
hasSourceExpression(expr(hasType(booleanType()))));
279278
auto BoolXor =
280279
binaryOperator(hasOperatorName("^"), hasLHS(ImplicitCastFromBool),
281280
hasRHS(ImplicitCastFromBool));
@@ -315,7 +314,7 @@ void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
315314
traverse(
316315
TK_AsIs,
317316
implicitCastExpr(
318-
ImplicitCastFromBool,
317+
ImplicitCastFromBool, unless(ExceptionCases),
319318
// Exclude comparisons of bools, as they are always cast to
320319
// integers in such context:
321320
// bool_expr_a == bool_expr_b

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ Changes in existing checks
493493
<clang-tidy/checks/readability/implicit-bool-conversion>` check to take
494494
do-while loops into account for the `AllowIntegerConditions` and
495495
`AllowPointerConditions` options. It also now provides more consistent
496-
suggestions when parentheses are added to the return value.
496+
suggestions when parentheses are added to the return value. It also ignores
497+
false-positives for comparison containing bool bitfield.
497498

498499
- Improved :doc:`readability-misleading-indentation
499500
<clang-tidy/checks/readability/misleading-indentation>` check to ignore

clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ int* functionReturningPointer();
1212
struct Struct {
1313
int member;
1414
unsigned bitfield : 1;
15+
bool boolfield : 1;
1516
};
1617

1718

@@ -28,6 +29,8 @@ void implicitConversionIntegerToBoolInConditionalsIsAllowed() {
2829
if (!s.member) {}
2930
if (s.bitfield) {}
3031
if (!s.bitfield) {}
32+
if (s.boolfield == true) {}
33+
if (s.boolfield != true) {}
3134
if (functionReturningInt()) {}
3235
if (!functionReturningInt()) {}
3336
if (functionReturningInt() && functionReturningPointer()) {}

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4432,6 +4432,11 @@ the configuration (without a prefix: ``Auto``).
44324432
**PenaltyBreakOpenParenthesis** (``Unsigned``) :versionbadge:`clang-format 14` :ref:`<PenaltyBreakOpenParenthesis>`
44334433
The penalty for breaking after ``(``.
44344434

4435+
.. _PenaltyBreakScopeResolution:
4436+
4437+
**PenaltyBreakScopeResolution** (``Unsigned``) :versionbadge:`clang-format 18` :ref:`<PenaltyBreakScopeResolution>`
4438+
The penalty for breaking after ``::``.
4439+
44354440
.. _PenaltyBreakString:
44364441

44374442
**PenaltyBreakString** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`<PenaltyBreakString>`

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,7 @@ clang-format
11891189
- Add ``BreakAdjacentStringLiterals`` option.
11901190
- Add ``ObjCPropertyAttributeOrder`` which can be used to sort ObjC property
11911191
attributes (like ``nonatomic, strong, nullable``).
1192+
- Add ``PenaltyBreakScopeResolution`` option.
11921193
- Add ``.clang-format-ignore`` files.
11931194
- Add ``AlignFunctionPointers`` sub-option for ``AlignConsecutiveDeclarations``.
11941195

clang/include/clang/Format/Format.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3398,6 +3398,10 @@ struct FormatStyle {
33983398
/// \version 14
33993399
unsigned PenaltyBreakOpenParenthesis;
34003400

3401+
/// The penalty for breaking after ``::``.
3402+
/// \version 18
3403+
unsigned PenaltyBreakScopeResolution;
3404+
34013405
/// The penalty for each line break introduced inside a string literal.
34023406
/// \version 3.7
34033407
unsigned PenaltyBreakString;
@@ -4873,6 +4877,7 @@ struct FormatStyle {
48734877
PenaltyBreakComment == R.PenaltyBreakComment &&
48744878
PenaltyBreakFirstLessLess == R.PenaltyBreakFirstLessLess &&
48754879
PenaltyBreakOpenParenthesis == R.PenaltyBreakOpenParenthesis &&
4880+
PenaltyBreakScopeResolution == R.PenaltyBreakScopeResolution &&
48764881
PenaltyBreakString == R.PenaltyBreakString &&
48774882
PenaltyBreakTemplateDeclaration ==
48784883
R.PenaltyBreakTemplateDeclaration &&

clang/lib/Format/Format.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,8 @@ template <> struct MappingTraits<FormatStyle> {
10541054
Style.PenaltyBreakFirstLessLess);
10551055
IO.mapOptional("PenaltyBreakOpenParenthesis",
10561056
Style.PenaltyBreakOpenParenthesis);
1057+
IO.mapOptional("PenaltyBreakScopeResolution",
1058+
Style.PenaltyBreakScopeResolution);
10571059
IO.mapOptional("PenaltyBreakString", Style.PenaltyBreakString);
10581060
IO.mapOptional("PenaltyBreakTemplateDeclaration",
10591061
Style.PenaltyBreakTemplateDeclaration);
@@ -1602,6 +1604,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
16021604
LLVMStyle.PenaltyReturnTypeOnItsOwnLine = 60;
16031605
LLVMStyle.PenaltyBreakBeforeFirstCallParameter = 19;
16041606
LLVMStyle.PenaltyBreakOpenParenthesis = 0;
1607+
LLVMStyle.PenaltyBreakScopeResolution = 500;
16051608
LLVMStyle.PenaltyBreakTemplateDeclaration = prec::Relational;
16061609
LLVMStyle.PenaltyIndentedWhitespace = 0;
16071610

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3765,7 +3765,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
37653765
}
37663766

37673767
if (Left.is(tok::coloncolon))
3768-
return 500;
3768+
return Style.PenaltyBreakScopeResolution;
37693769
if (Right.isOneOf(TT_StartOfName, TT_FunctionDeclarationName) ||
37703770
Right.is(tok::kw_operator)) {
37713771
if (Line.startsWith(tok::kw_for) && Right.PartOfMultiVariableDeclStmt)

clang/unittests/Format/ConfigParseTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ TEST(ConfigParseTest, ParsesConfiguration) {
255255
PenaltyBreakTemplateDeclaration, 1234u);
256256
CHECK_PARSE("PenaltyBreakOpenParenthesis: 1234", PenaltyBreakOpenParenthesis,
257257
1234u);
258+
CHECK_PARSE("PenaltyBreakScopeResolution: 1234", PenaltyBreakScopeResolution,
259+
1234u);
258260
CHECK_PARSE("PenaltyExcessCharacter: 1234", PenaltyExcessCharacter, 1234u);
259261
CHECK_PARSE("PenaltyReturnTypeOnItsOwnLine: 1234",
260262
PenaltyReturnTypeOnItsOwnLine, 1234u);

clang/unittests/Format/FormatTest.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21567,6 +21567,19 @@ TEST_F(FormatTest, BreakPenaltyAfterForLoopLParen) {
2156721567
Style);
2156821568
}
2156921569

21570+
TEST_F(FormatTest, BreakPenaltyScopeResolution) {
21571+
FormatStyle Style = getLLVMStyle();
21572+
Style.ColumnLimit = 20;
21573+
Style.PenaltyExcessCharacter = 100;
21574+
verifyFormat("unsigned long\n"
21575+
"foo::bar();",
21576+
Style);
21577+
Style.PenaltyBreakScopeResolution = 10;
21578+
verifyFormat("unsigned long foo::\n"
21579+
" bar();",
21580+
Style);
21581+
}
21582+
2157021583
TEST_F(FormatTest, WorksFor8bitEncodings) {
2157121584
// FIXME: unstable test case
2157221585
EXPECT_EQ("\"\xce\xe4\xed\xe0\xe6\xe4\xfb \xe2 \"\n"

libcxx/include/__concepts/arithmetic.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ concept floating_point = is_floating_point_v<_Tp>;
4242

4343
template <class _Tp>
4444
concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value;
45+
4546
template <class _Tp>
4647
concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value;
4748

49+
template <class _Tp>
50+
concept __libcpp_integer = __libcpp_unsigned_integer<_Tp> || __libcpp_signed_integer<_Tp>;
51+
4852
#endif // _LIBCPP_STD_VER >= 20
4953

5054
_LIBCPP_END_NAMESPACE_STD
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// UNSUPPORTED: c++03, c++11, c++14, c++17
10+
11+
// Concept helpers for the internal type traits for the fundamental types.
12+
13+
// template <class _Tp>
14+
// concept __libcpp_integer;
15+
16+
#include <concepts>
17+
18+
#include "test_macros.h"
19+
20+
struct SomeObject {};
21+
22+
enum SomeEnum {};
23+
24+
enum class SomeScopedEnum {};
25+
26+
// Unsigned
27+
static_assert(std::__libcpp_integer<unsigned char>);
28+
static_assert(std::__libcpp_integer<unsigned short int>);
29+
static_assert(std::__libcpp_integer<unsigned int>);
30+
static_assert(std::__libcpp_integer<unsigned long int>);
31+
static_assert(std::__libcpp_integer<unsigned long long int>);
32+
static_assert(std::__libcpp_integer<unsigned short int>);
33+
#ifndef _LIBCPP_HAS_NO_INT128
34+
static_assert(std::__libcpp_integer<__uint128_t>);
35+
#endif
36+
// Signed
37+
static_assert(std::__libcpp_integer<signed char>);
38+
static_assert(std::__libcpp_integer<short int>);
39+
static_assert(std::__libcpp_integer<int>);
40+
static_assert(std::__libcpp_integer<long int>);
41+
static_assert(std::__libcpp_integer<long long int>);
42+
static_assert(std::__libcpp_integer<short int>);
43+
#ifndef _LIBCPP_HAS_NO_INT128
44+
static_assert(std::__libcpp_integer<__int128_t>);
45+
#endif
46+
// Non-integer
47+
static_assert(!std::__libcpp_integer<bool>);
48+
static_assert(!std::__libcpp_integer<char>);
49+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
50+
static_assert(!std::__libcpp_integer<wchar_t>);
51+
#endif
52+
static_assert(!std::__libcpp_integer<char8_t>);
53+
static_assert(!std::__libcpp_integer<char16_t>);
54+
static_assert(!std::__libcpp_integer<char32_t>);
55+
static_assert(!std::__libcpp_integer<float>);
56+
static_assert(!std::__libcpp_integer<double>);
57+
static_assert(!std::__libcpp_integer<long double>);
58+
static_assert(!std::__libcpp_integer<void>);
59+
static_assert(!std::__libcpp_integer<int*>);
60+
static_assert(!std::__libcpp_integer<unsigned int*>);
61+
static_assert(!std::__libcpp_integer<SomeObject>);
62+
static_assert(!std::__libcpp_integer<SomeEnum>);
63+
static_assert(!std::__libcpp_integer<SomeScopedEnum>);
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// UNSUPPORTED: c++03, c++11, c++14, c++17
10+
11+
// Concept helpers for the internal type traits for the fundamental types.
12+
13+
// template <class _Tp>
14+
// concept __libcpp_signed_integer;
15+
16+
#include <concepts>
17+
18+
#include "test_macros.h"
19+
20+
struct SomeObject {};
21+
22+
enum SomeEnum {};
23+
24+
enum class SomeScopedEnum {};
25+
26+
// Unsigned
27+
static_assert(!std::__libcpp_signed_integer<unsigned char>);
28+
static_assert(!std::__libcpp_signed_integer<unsigned short int>);
29+
static_assert(!std::__libcpp_signed_integer<unsigned int>);
30+
static_assert(!std::__libcpp_signed_integer<unsigned long int>);
31+
static_assert(!std::__libcpp_signed_integer<unsigned long long int>);
32+
static_assert(!std::__libcpp_signed_integer<unsigned short int>);
33+
#ifndef _LIBCPP_HAS_NO_INT128
34+
static_assert(!std::__libcpp_signed_integer<__uint128_t>);
35+
#endif
36+
// Signed
37+
static_assert(std::__libcpp_signed_integer<signed char>);
38+
static_assert(std::__libcpp_signed_integer<short int>);
39+
static_assert(std::__libcpp_signed_integer<int>);
40+
static_assert(std::__libcpp_signed_integer<long int>);
41+
static_assert(std::__libcpp_signed_integer<long long int>);
42+
static_assert(std::__libcpp_signed_integer<short int>);
43+
#ifndef _LIBCPP_HAS_NO_INT128
44+
static_assert(std::__libcpp_signed_integer<__int128_t>);
45+
#endif
46+
// Non-integer
47+
static_assert(!std::__libcpp_signed_integer<bool>);
48+
static_assert(!std::__libcpp_signed_integer<char>);
49+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
50+
static_assert(!std::__libcpp_signed_integer<wchar_t>);
51+
#endif
52+
static_assert(!std::__libcpp_signed_integer<char8_t>);
53+
static_assert(!std::__libcpp_signed_integer<char16_t>);
54+
static_assert(!std::__libcpp_signed_integer<char32_t>);
55+
static_assert(!std::__libcpp_signed_integer<float>);
56+
static_assert(!std::__libcpp_signed_integer<double>);
57+
static_assert(!std::__libcpp_signed_integer<long double>);
58+
static_assert(!std::__libcpp_signed_integer<void>);
59+
static_assert(!std::__libcpp_signed_integer<int*>);
60+
static_assert(!std::__libcpp_signed_integer<unsigned int*>);
61+
static_assert(!std::__libcpp_signed_integer<SomeObject>);
62+
static_assert(!std::__libcpp_signed_integer<SomeEnum>);
63+
static_assert(!std::__libcpp_signed_integer<SomeScopedEnum>);
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// UNSUPPORTED: c++03, c++11, c++14, c++17
10+
11+
// Concept helpers for the internal type traits for the fundamental types.
12+
13+
// template <class _Tp>
14+
// concept __libcpp_unsigned_integer;
15+
16+
#include <concepts>
17+
18+
#include "test_macros.h"
19+
20+
struct SomeObject {};
21+
22+
enum SomeEnum {};
23+
24+
enum class SomeScopedEnum {};
25+
26+
// Unsigned
27+
static_assert(std::__libcpp_unsigned_integer<unsigned char>);
28+
static_assert(std::__libcpp_unsigned_integer<unsigned short int>);
29+
static_assert(std::__libcpp_unsigned_integer<unsigned int>);
30+
static_assert(std::__libcpp_unsigned_integer<unsigned long int>);
31+
static_assert(std::__libcpp_unsigned_integer<unsigned long long int>);
32+
static_assert(std::__libcpp_unsigned_integer<unsigned short int>);
33+
#ifndef _LIBCPP_HAS_NO_INT128
34+
static_assert(std::__libcpp_unsigned_integer<__uint128_t>);
35+
#endif
36+
// Signed
37+
static_assert(!std::__libcpp_unsigned_integer<signed char>);
38+
static_assert(!std::__libcpp_unsigned_integer<short int>);
39+
static_assert(!std::__libcpp_unsigned_integer<int>);
40+
static_assert(!std::__libcpp_unsigned_integer<long int>);
41+
static_assert(!std::__libcpp_unsigned_integer<long long int>);
42+
static_assert(!std::__libcpp_unsigned_integer<short int>);
43+
#ifndef _LIBCPP_HAS_NO_INT128
44+
static_assert(!std::__libcpp_unsigned_integer<__int128_t>);
45+
#endif
46+
// Non-integer
47+
static_assert(!std::__libcpp_unsigned_integer<bool>);
48+
static_assert(!std::__libcpp_unsigned_integer<char>);
49+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
50+
static_assert(!std::__libcpp_unsigned_integer<wchar_t>);
51+
#endif
52+
static_assert(!std::__libcpp_unsigned_integer<char8_t>);
53+
static_assert(!std::__libcpp_unsigned_integer<char16_t>);
54+
static_assert(!std::__libcpp_unsigned_integer<char32_t>);
55+
static_assert(!std::__libcpp_unsigned_integer<float>);
56+
static_assert(!std::__libcpp_unsigned_integer<double>);
57+
static_assert(!std::__libcpp_unsigned_integer<long double>);
58+
static_assert(!std::__libcpp_unsigned_integer<void>);
59+
static_assert(!std::__libcpp_unsigned_integer<int*>);
60+
static_assert(!std::__libcpp_unsigned_integer<unsigned int*>);
61+
static_assert(!std::__libcpp_unsigned_integer<SomeObject>);
62+
static_assert(!std::__libcpp_unsigned_integer<SomeEnum>);
63+
static_assert(!std::__libcpp_unsigned_integer<SomeScopedEnum>);

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,15 +2265,12 @@ Register FastISel::fastEmitZExtFromI1(MVT VT, unsigned Op0) {
22652265
/// might result in multiple MBB's for one BB. As such, the start of the
22662266
/// BB might correspond to a different MBB than the end.
22672267
bool FastISel::handlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB) {
2268-
const Instruction *TI = LLVMBB->getTerminator();
2269-
22702268
SmallPtrSet<MachineBasicBlock *, 4> SuccsHandled;
22712269
FuncInfo.OrigNumPHINodesToUpdate = FuncInfo.PHINodesToUpdate.size();
22722270

22732271
// Check successor nodes' PHI nodes that expect a constant to be available
22742272
// from this block.
2275-
for (unsigned succ = 0, e = TI->getNumSuccessors(); succ != e; ++succ) {
2276-
const BasicBlock *SuccBB = TI->getSuccessor(succ);
2273+
for (const BasicBlock *SuccBB : successors(LLVMBB)) {
22772274
if (!isa<PHINode>(SuccBB->begin()))
22782275
continue;
22792276
MachineBasicBlock *SuccMBB = FuncInfo.MBBMap[SuccBB];

0 commit comments

Comments
 (0)