Skip to content

Commit c09ab51

Browse files
Merge branch 'main' into cmpbr
2 parents 1e4a21a + f1ba894 commit c09ab51

File tree

1,247 files changed

+33746
-15330
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,247 files changed

+33746
-15330
lines changed

.github/workflows/containers/github-action-ci/stage1.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM docker.io/library/ubuntu:22.04 as base
22
ENV LLVM_SYSROOT=/opt/llvm
33

44
FROM base as stage1-toolchain
5-
ENV LLVM_VERSION=18.1.8
5+
ENV LLVM_VERSION=19.1.2
66

77
RUN apt-get update && \
88
apt-get install -y \

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/misc/UseInternalLinkageCheck.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88

99
#include "UseInternalLinkageCheck.h"
1010
#include "../utils/FileExtensionsUtils.h"
11+
#include "../utils/LexerUtils.h"
1112
#include "clang/AST/Decl.h"
1213
#include "clang/ASTMatchers/ASTMatchFinder.h"
1314
#include "clang/ASTMatchers/ASTMatchers.h"
1415
#include "clang/ASTMatchers/ASTMatchersMacros.h"
1516
#include "clang/Basic/SourceLocation.h"
1617
#include "clang/Basic/Specifiers.h"
18+
#include "clang/Basic/TokenKinds.h"
19+
#include "clang/Lex/Token.h"
1720
#include "llvm/ADT/STLExtras.h"
1821

1922
using namespace clang::ast_matchers;
@@ -113,7 +116,7 @@ static constexpr StringRef Message =
113116
void UseInternalLinkageCheck::check(const MatchFinder::MatchResult &Result) {
114117
if (const auto *FD = Result.Nodes.getNodeAs<FunctionDecl>("fn")) {
115118
DiagnosticBuilder DB = diag(FD->getLocation(), Message) << "function" << FD;
116-
SourceLocation FixLoc = FD->getTypeSpecStartLoc();
119+
const SourceLocation FixLoc = FD->getInnerLocStart();
117120
if (FixLoc.isInvalid() || FixLoc.isMacroID())
118121
return;
119122
if (FixMode == FixModeKind::UseStatic)
@@ -128,7 +131,7 @@ void UseInternalLinkageCheck::check(const MatchFinder::MatchResult &Result) {
128131
return;
129132

130133
DiagnosticBuilder DB = diag(VD->getLocation(), Message) << "variable" << VD;
131-
SourceLocation FixLoc = VD->getTypeSpecStartLoc();
134+
const SourceLocation FixLoc = VD->getInnerLocStart();
132135
if (FixLoc.isInvalid() || FixLoc.isMacroID())
133136
return;
134137
if (FixMode == FixModeKind::UseStatic)

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/clang-tidy/utils/LexerUtils.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ getPreviousTokenAndStart(SourceLocation Location, const SourceManager &SM,
2424
if (Location.isInvalid())
2525
return {Token, Location};
2626

27-
auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location));
27+
const auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location));
2828
while (Location != StartOfFile) {
2929
Location = Lexer::GetBeginningOfToken(Location, SM, LangOpts);
3030
if (!Lexer::getRawToken(Location, Token, SM, LangOpts) &&
3131
(!SkipComments || !Token.is(tok::comment))) {
3232
break;
3333
}
34+
if (Location == StartOfFile)
35+
return {Token, Location};
3436
Location = Location.getLocWithOffset(-1);
3537
}
3638
return {Token, Location};

clang-tools-extra/clangd/Config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ struct Config {
162162
bool DeducedTypes = true;
163163
bool Designators = true;
164164
bool BlockEnd = false;
165+
bool DefaultArguments = false;
165166
// Limit the length of type names in inlay hints. (0 means no limit)
166167
uint32_t TypeNameLimit = 32;
167168
} InlayHints;

clang-tools-extra/clangd/ConfigCompile.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include "llvm/Support/Regex.h"
4444
#include "llvm/Support/SMLoc.h"
4545
#include "llvm/Support/SourceMgr.h"
46-
#include <algorithm>
4746
#include <memory>
4847
#include <optional>
4948
#include <string>
@@ -669,6 +668,11 @@ struct FragmentCompiler {
669668
Out.Apply.push_back([Value(**F.BlockEnd)](const Params &, Config &C) {
670669
C.InlayHints.BlockEnd = Value;
671670
});
671+
if (F.DefaultArguments)
672+
Out.Apply.push_back(
673+
[Value(**F.DefaultArguments)](const Params &, Config &C) {
674+
C.InlayHints.DefaultArguments = Value;
675+
});
672676
if (F.TypeNameLimit)
673677
Out.Apply.push_back(
674678
[Value(**F.TypeNameLimit)](const Params &, Config &C) {

0 commit comments

Comments
 (0)