Skip to content

Commit cf20f7c

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-for-hoist
2 parents ef52b83 + 629a182 commit cf20f7c

File tree

543 files changed

+12818
-5822
lines changed

Some content is hidden

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

543 files changed

+12818
-5822
lines changed

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class DIEBuilder {
314314

315315
BC.errs()
316316
<< "BOLT-ERROR: unable to find TypeUnit for Type Unit at offset 0x"
317-
<< DU.getOffset() << "\n";
317+
<< Twine::utohexstr(DU.getOffset()) << "\n";
318318
return nullptr;
319319
}
320320

bolt/lib/Core/BinaryContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,8 +1294,8 @@ bool BinaryContext::handleAArch64Veneer(uint64_t Address, bool MatchOnly) {
12941294
Veneer->getOrCreateLocalLabel(Address);
12951295
Veneer->setMaxSize(TotalSize);
12961296
Veneer->updateState(BinaryFunction::State::Disassembled);
1297-
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: handling veneer function at 0x" << Address
1298-
<< "\n");
1297+
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: handling veneer function at 0x"
1298+
<< Twine::utohexstr(Address) << "\n");
12991299
return true;
13001300
};
13011301

bolt/lib/Passes/VeneerElimination.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ Error VeneerElimination::runOnFunctions(BinaryContext &BC) {
7373
continue;
7474

7575
const MCSymbol *TargetSymbol = BC.MIB->getTargetSymbol(Instr, 0);
76-
if (VeneerDestinations.find(TargetSymbol) == VeneerDestinations.end())
76+
auto It = VeneerDestinations.find(TargetSymbol);
77+
if (It == VeneerDestinations.end())
7778
continue;
7879

7980
VeneerCallers++;
80-
BC.MIB->replaceBranchTarget(Instr, VeneerDestinations[TargetSymbol],
81-
BC.Ctx.get());
81+
BC.MIB->replaceBranchTarget(Instr, It->second, BC.Ctx.get());
8282
}
8383
}
8484
}

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,7 @@ void DWARFRewriter::updateDWARFObjectAddressRanges(
13621362
Die.getTag() == dwarf::DW_TAG_compile_unit)) {
13631363
if (opts::Verbosity >= 1)
13641364
errs() << "BOLT-WARNING: cannot update ranges for DIE in Unit offset 0x"
1365-
<< Unit.getOffset() << '\n';
1365+
<< Twine::utohexstr(Unit.getOffset()) << '\n';
13661366
}
13671367
}
13681368

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

Lines changed: 38 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
#include "UseStartsEndsWithCheck.h"
1010

1111
#include "../utils/ASTUtils.h"
12-
#include "../utils/OptionsUtils.h"
12+
#include "../utils/Matchers.h"
13+
#include "clang/ASTMatchers/ASTMatchers.h"
1314
#include "clang/Lex/Lexer.h"
1415

1516
#include <string>
@@ -82,60 +83,53 @@ UseStartsEndsWithCheck::UseStartsEndsWithCheck(StringRef Name,
8283
void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
8384
const auto ZeroLiteral = integerLiteral(equals(0));
8485

85-
const auto HasStartsWithMethodWithName = [](const std::string &Name) {
86-
return hasMethod(
87-
cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
88-
.bind("starts_with_fun"));
86+
const auto ClassTypeWithMethod = [](const StringRef MethodBoundName,
87+
const auto... Methods) {
88+
return cxxRecordDecl(anyOf(
89+
hasMethod(cxxMethodDecl(isConst(), parameterCountIs(1),
90+
returns(booleanType()), hasAnyName(Methods))
91+
.bind(MethodBoundName))...));
8992
};
90-
const auto HasStartsWithMethod =
91-
anyOf(HasStartsWithMethodWithName("starts_with"),
92-
HasStartsWithMethodWithName("startsWith"),
93-
HasStartsWithMethodWithName("startswith"));
93+
9494
const auto OnClassWithStartsWithFunction =
95-
on(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
96-
anyOf(HasStartsWithMethod,
97-
hasAnyBase(hasType(hasCanonicalType(
98-
hasDeclaration(cxxRecordDecl(HasStartsWithMethod)))))))))));
99-
100-
const auto HasEndsWithMethodWithName = [](const std::string &Name) {
101-
return hasMethod(
102-
cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
103-
.bind("ends_with_fun"));
104-
};
105-
const auto HasEndsWithMethod = anyOf(HasEndsWithMethodWithName("ends_with"),
106-
HasEndsWithMethodWithName("endsWith"),
107-
HasEndsWithMethodWithName("endswith"));
108-
const auto OnClassWithEndsWithFunction =
109-
on(expr(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
110-
anyOf(HasEndsWithMethod,
111-
hasAnyBase(hasType(hasCanonicalType(hasDeclaration(
112-
cxxRecordDecl(HasEndsWithMethod)))))))))))
113-
.bind("haystack"));
95+
ClassTypeWithMethod("starts_with_fun", "starts_with", "startsWith",
96+
"startswith", "StartsWith");
97+
98+
const auto OnClassWithEndsWithFunction = ClassTypeWithMethod(
99+
"ends_with_fun", "ends_with", "endsWith", "endswith", "EndsWith");
114100

115101
// Case 1: X.find(Y) [!=]= 0 -> starts_with.
116102
const auto FindExpr = cxxMemberCallExpr(
117103
anyOf(argumentCountIs(1), hasArgument(1, ZeroLiteral)),
118-
callee(cxxMethodDecl(hasName("find")).bind("find_fun")),
119-
OnClassWithStartsWithFunction, hasArgument(0, expr().bind("needle")));
104+
callee(
105+
cxxMethodDecl(hasName("find"), ofClass(OnClassWithStartsWithFunction))
106+
.bind("find_fun")),
107+
hasArgument(0, expr().bind("needle")));
120108

121109
// Case 2: X.rfind(Y, 0) [!=]= 0 -> starts_with.
122110
const auto RFindExpr = cxxMemberCallExpr(
123111
hasArgument(1, ZeroLiteral),
124-
callee(cxxMethodDecl(hasName("rfind")).bind("find_fun")),
125-
OnClassWithStartsWithFunction, hasArgument(0, expr().bind("needle")));
112+
callee(cxxMethodDecl(hasName("rfind"),
113+
ofClass(OnClassWithStartsWithFunction))
114+
.bind("find_fun")),
115+
hasArgument(0, expr().bind("needle")));
126116

127117
// Case 3: X.compare(0, LEN(Y), Y) [!=]= 0 -> starts_with.
128118
const auto CompareExpr = cxxMemberCallExpr(
129119
argumentCountIs(3), hasArgument(0, ZeroLiteral),
130-
callee(cxxMethodDecl(hasName("compare")).bind("find_fun")),
131-
OnClassWithStartsWithFunction, hasArgument(2, expr().bind("needle")),
120+
callee(cxxMethodDecl(hasName("compare"),
121+
ofClass(OnClassWithStartsWithFunction))
122+
.bind("find_fun")),
123+
hasArgument(2, expr().bind("needle")),
132124
hasArgument(1, lengthExprForStringNode("needle")));
133125

134126
// Case 4: X.compare(LEN(X) - LEN(Y), LEN(Y), Y) [!=]= 0 -> ends_with.
135127
const auto CompareEndsWithExpr = cxxMemberCallExpr(
136128
argumentCountIs(3),
137-
callee(cxxMethodDecl(hasName("compare")).bind("find_fun")),
138-
OnClassWithEndsWithFunction, hasArgument(2, expr().bind("needle")),
129+
callee(cxxMethodDecl(hasName("compare"),
130+
ofClass(OnClassWithEndsWithFunction))
131+
.bind("find_fun")),
132+
on(expr().bind("haystack")), hasArgument(2, expr().bind("needle")),
139133
hasArgument(1, lengthExprForStringNode("needle")),
140134
hasArgument(0,
141135
binaryOperator(hasOperatorName("-"),
@@ -145,7 +139,7 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
145139
// All cases comparing to 0.
146140
Finder->addMatcher(
147141
binaryOperator(
148-
hasAnyOperatorName("==", "!="),
142+
matchers::isEqualityOperator(),
149143
hasOperands(cxxMemberCallExpr(anyOf(FindExpr, RFindExpr, CompareExpr,
150144
CompareEndsWithExpr))
151145
.bind("find_expr"),
@@ -156,7 +150,7 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
156150
// Case 5: X.rfind(Y) [!=]= LEN(X) - LEN(Y) -> ends_with.
157151
Finder->addMatcher(
158152
binaryOperator(
159-
hasAnyOperatorName("==", "!="),
153+
matchers::isEqualityOperator(),
160154
hasOperands(
161155
cxxMemberCallExpr(
162156
anyOf(
@@ -166,8 +160,10 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
166160
1,
167161
anyOf(declRefExpr(to(varDecl(hasName("npos")))),
168162
memberExpr(member(hasName("npos"))))))),
169-
callee(cxxMethodDecl(hasName("rfind")).bind("find_fun")),
170-
OnClassWithEndsWithFunction,
163+
callee(cxxMethodDecl(hasName("rfind"),
164+
ofClass(OnClassWithEndsWithFunction))
165+
.bind("find_fun")),
166+
on(expr().bind("haystack")),
171167
hasArgument(0, expr().bind("needle")))
172168
.bind("find_expr"),
173169
binaryOperator(hasOperatorName("-"),
@@ -190,9 +186,8 @@ void UseStartsEndsWithCheck::check(const MatchFinder::MatchResult &Result) {
190186
const CXXMethodDecl *ReplacementFunction =
191187
StartsWithFunction ? StartsWithFunction : EndsWithFunction;
192188

193-
if (ComparisonExpr->getBeginLoc().isMacroID()) {
189+
if (ComparisonExpr->getBeginLoc().isMacroID())
194190
return;
195-
}
196191

197192
const bool Neg = ComparisonExpr->getOpcode() == BO_NE;
198193

@@ -220,9 +215,8 @@ void UseStartsEndsWithCheck::check(const MatchFinder::MatchResult &Result) {
220215
(ReplacementFunction->getName() + "(").str());
221216

222217
// Add possible negation '!'.
223-
if (Neg) {
218+
if (Neg)
224219
Diagnostic << FixItHint::CreateInsertion(FindExpr->getBeginLoc(), "!");
225-
}
226220
}
227221

228222
} // namespace clang::tidy::modernize

clang-tools-extra/clangd/test/log.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RUN: env CLANGD_FLAGS=-compile-commands-dir=no-such-dir not clangd -lit-test </dev/null 2>&1 >/dev/null | FileCheck %s
22
CHECK: I[{{.*}}]{{.*}} clangd version {{.*}}
33
CHECK: Working directory: {{.*}}
4-
CHECK: argv[0]: clangd
4+
CHECK: argv[0]: {{.*}}clangd
55
CHECK: argv[1]: -lit-test
66
CHECK: CLANGD_FLAGS: -compile-commands-dir=no-such-dir
77
CHECK: E[{{.*}}] Path specified by --compile-commands-dir does not exist.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// RUN: not clang-query --invalid-arg 2>&1 | FileCheck %s
22

3-
// CHECK: error: clang-query{{(\.exe)?}}: Unknown command line argument '--invalid-arg'. Try: 'clang-query{{(\.exe)?}} --help'
3+
// CHECK: error: clang-query{{(\.exe)?}}: Unknown command line argument '--invalid-arg'. Try: '{{.*}}clang-query{{(\.exe)?}} --help'
44
// CHECK-NEXT: clang-query{{(\.exe)?}}: Did you mean '--extra-arg'?

clang-tools-extra/test/clang-tidy/checkers/modernize/use-starts-ends-with.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,9 @@ struct prefer_underscore_version_flip {
3232
size_t find(const char *s, size_t pos = 0) const;
3333
};
3434

35-
struct prefer_underscore_version_inherit : public string_like {
36-
bool startsWith(const char *s) const;
37-
};
38-
3935
void test(std::string s, std::string_view sv, sub_string ss, sub_sub_string sss,
4036
string_like sl, string_like_camel slc, prefer_underscore_version puv,
41-
prefer_underscore_version_flip puvf,
42-
prefer_underscore_version_inherit puvi) {
37+
prefer_underscore_version_flip puvf) {
4338
s.find("a") == 0;
4439
// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with instead of find() == 0
4540
// CHECK-FIXES: s.starts_with("a");
@@ -153,12 +148,6 @@ void test(std::string s, std::string_view sv, sub_string ss, sub_sub_string sss,
153148
// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with
154149
// CHECK-FIXES: puvf.starts_with("a");
155150

156-
// Here, the subclass has startsWith, the superclass has starts_with.
157-
// We prefer the version from the subclass.
158-
puvi.find("a") == 0;
159-
// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use startsWith
160-
// CHECK-FIXES: puvi.startsWith("a");
161-
162151
s.compare(0, 1, "a") == 0;
163152
// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with instead of compare() == 0
164153
// CHECK-FIXES: s.starts_with("a");
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// RUN: not clang-tidy --invalid-arg 2>&1 | FileCheck %s
22

3-
// CHECK: error: clang-tidy{{(\.exe)?}}: Unknown command line argument '--invalid-arg'. Try: 'clang-tidy{{(\.exe)?}} --help'
3+
// CHECK: error: clang-tidy{{(\.exe)?}}: Unknown command line argument '--invalid-arg'. Try: '{{.*}}clang-tidy{{(\.exe)?}} --help'
44
// CHECK-NEXT: clang-tidy{{(\.exe)?}}: Did you mean '--extra-arg'?

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5505,6 +5505,31 @@ the configuration (without a prefix: ``Auto``).
55055505
}
55065506
}
55075507

5508+
.. _RemoveEmptyLinesInUnwrappedLines:
5509+
5510+
**RemoveEmptyLinesInUnwrappedLines** (``Boolean``) :versionbadge:`clang-format 20` :ref:`<RemoveEmptyLinesInUnwrappedLines>`
5511+
Remove empty lines within unwrapped lines.
5512+
5513+
.. code-block:: c++
5514+
5515+
false: true:
5516+
5517+
int c vs. int c = a + b;
5518+
5519+
= a + b;
5520+
5521+
enum : unsigned vs. enum : unsigned {
5522+
AA = 0,
5523+
{ BB
5524+
AA = 0, } myEnum;
5525+
BB
5526+
} myEnum;
5527+
5528+
while ( vs. while (true) {
5529+
}
5530+
true) {
5531+
}
5532+
55085533
.. _RemoveParentheses:
55095534

55105535
**RemoveParentheses** (``RemoveParenthesesStyle``) :versionbadge:`clang-format 17` :ref:`<RemoveParentheses>`

0 commit comments

Comments
 (0)