Skip to content

Commit 642e574

Browse files
authored
Merge branch 'main' into postra_sink_target_hook
2 parents 3813766 + 3a8894d commit 642e574

File tree

277 files changed

+1376
-1268
lines changed

Some content is hidden

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

277 files changed

+1376
-1268
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ jobs:
222222
python3 -m venv .venv
223223
source .venv/bin/activate
224224
python -m pip install psutil
225-
bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
225+
xcrun bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
226226
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
227227
if: always() # Upload artifacts even if the build or test suite fails
228228
with:

bolt/lib/Core/DebugNames.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ void DWARF5AcceleratorTable::populateAbbrevsMap() {
555555

556556
void DWARF5AcceleratorTable::writeEntry(BOLTDWARF5AccelTableData &Entry) {
557557
const uint64_t EntryID = getEntryID(Entry);
558-
if (EntryRelativeOffsets.find(EntryID) != EntryRelativeOffsets.end())
558+
if (EntryRelativeOffsets.contains(EntryID))
559559
EntryRelativeOffsets[EntryID] = EntriesBuffer->size();
560560

561561
const std::optional<DWARF5AccelTable::UnitIndexAndEncoding> EntryRet =

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ Error MustacheHTMLGenerator::generateDocs(
156156
SmallString<128> JSONPath;
157157
sys::path::native(RootDir.str() + "/json", JSONPath);
158158

159-
StringMap<json::Value> JSONFileMap;
160159
{
161160
llvm::TimeTraceScope TS("Iterate JSON files");
162161
std::error_code EC;

clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ static std::vector<std::pair<SourceLocation, StringRef>>
8181
getCommentsInRange(ASTContext *Ctx, CharSourceRange Range) {
8282
std::vector<std::pair<SourceLocation, StringRef>> Comments;
8383
auto &SM = Ctx->getSourceManager();
84-
std::pair<FileID, unsigned> BeginLoc = SM.getDecomposedLoc(Range.getBegin()),
85-
EndLoc = SM.getDecomposedLoc(Range.getEnd());
84+
const std::pair<FileID, unsigned> BeginLoc =
85+
SM.getDecomposedLoc(Range.getBegin()),
86+
EndLoc =
87+
SM.getDecomposedLoc(Range.getEnd());
8688

8789
if (BeginLoc.first != EndLoc.first)
8890
return Comments;
8991

9092
bool Invalid = false;
91-
StringRef Buffer = SM.getBufferData(BeginLoc.first, &Invalid);
93+
const StringRef Buffer = SM.getBufferData(BeginLoc.first, &Invalid);
9294
if (Invalid)
9395
return Comments;
9496

@@ -106,7 +108,7 @@ getCommentsInRange(ASTContext *Ctx, CharSourceRange Range) {
106108
break;
107109

108110
if (Tok.is(tok::comment)) {
109-
std::pair<FileID, unsigned> CommentLoc =
111+
const std::pair<FileID, unsigned> CommentLoc =
110112
SM.getDecomposedLoc(Tok.getLocation());
111113
assert(CommentLoc.first == BeginLoc.first);
112114
Comments.emplace_back(
@@ -125,7 +127,7 @@ static std::vector<std::pair<SourceLocation, StringRef>>
125127
getCommentsBeforeLoc(ASTContext *Ctx, SourceLocation Loc) {
126128
std::vector<std::pair<SourceLocation, StringRef>> Comments;
127129
while (Loc.isValid()) {
128-
clang::Token Tok = utils::lexer::getPreviousToken(
130+
const clang::Token Tok = utils::lexer::getPreviousToken(
129131
Loc, Ctx->getSourceManager(), Ctx->getLangOpts(),
130132
/*SkipComments=*/false);
131133
if (Tok.isNot(tok::comment))
@@ -142,11 +144,11 @@ getCommentsBeforeLoc(ASTContext *Ctx, SourceLocation Loc) {
142144

143145
static bool isLikelyTypo(llvm::ArrayRef<ParmVarDecl *> Params,
144146
StringRef ArgName, unsigned ArgIndex) {
145-
std::string ArgNameLowerStr = ArgName.lower();
146-
StringRef ArgNameLower = ArgNameLowerStr;
147+
const std::string ArgNameLowerStr = ArgName.lower();
148+
const StringRef ArgNameLower = ArgNameLowerStr;
147149
// The threshold is arbitrary.
148-
unsigned UpperBound = ((ArgName.size() + 2) / 3) + 1;
149-
unsigned ThisED = ArgNameLower.edit_distance(
150+
const unsigned UpperBound = ((ArgName.size() + 2) / 3) + 1;
151+
const unsigned ThisED = ArgNameLower.edit_distance(
150152
Params[ArgIndex]->getIdentifier()->getName().lower(),
151153
/*AllowReplacements=*/true, UpperBound);
152154
if (ThisED >= UpperBound)
@@ -155,17 +157,17 @@ static bool isLikelyTypo(llvm::ArrayRef<ParmVarDecl *> Params,
155157
for (unsigned I = 0, E = Params.size(); I != E; ++I) {
156158
if (I == ArgIndex)
157159
continue;
158-
IdentifierInfo *II = Params[I]->getIdentifier();
160+
const IdentifierInfo *II = Params[I]->getIdentifier();
159161
if (!II)
160162
continue;
161163

162164
const unsigned Threshold = 2;
163165
// Other parameters must be an edit distance at least Threshold more away
164166
// from this parameter. This gives us greater confidence that this is a
165167
// typo of this parameter and not one with a similar name.
166-
unsigned OtherED = ArgNameLower.edit_distance(II->getName().lower(),
167-
/*AllowReplacements=*/true,
168-
ThisED + Threshold);
168+
const unsigned OtherED = ArgNameLower.edit_distance(
169+
II->getName().lower(),
170+
/*AllowReplacements=*/true, ThisED + Threshold);
169171
if (OtherED < ThisED + Threshold)
170172
return false;
171173
}
@@ -267,7 +269,8 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
267269
return;
268270

269271
Callee = Callee->getFirstDecl();
270-
unsigned NumArgs = std::min<unsigned>(Args.size(), Callee->getNumParams());
272+
const unsigned NumArgs =
273+
std::min<unsigned>(Args.size(), Callee->getNumParams());
271274
if ((NumArgs == 0) || (IgnoreSingleArgument && NumArgs == 1))
272275
return;
273276

@@ -279,7 +282,7 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
279282

280283
for (unsigned I = 0; I < NumArgs; ++I) {
281284
const ParmVarDecl *PVD = Callee->getParamDecl(I);
282-
IdentifierInfo *II = PVD->getIdentifier();
285+
const IdentifierInfo *II = PVD->getIdentifier();
283286
if (!II)
284287
continue;
285288
if (FunctionDecl *Template = Callee->getTemplateInstantiationPattern()) {
@@ -293,7 +296,7 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
293296
}
294297
}
295298

296-
CharSourceRange BeforeArgument =
299+
const CharSourceRange BeforeArgument =
297300
MakeFileCharRange(ArgBeginLoc, Args[I]->getBeginLoc());
298301
ArgBeginLoc = Args[I]->getEndLoc();
299302

@@ -302,7 +305,7 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
302305
Comments = getCommentsInRange(Ctx, BeforeArgument);
303306
} else {
304307
// Fall back to parsing back from the start of the argument.
305-
CharSourceRange ArgsRange =
308+
const CharSourceRange ArgsRange =
306309
MakeFileCharRange(Args[I]->getBeginLoc(), Args[I]->getEndLoc());
307310
Comments = getCommentsBeforeLoc(Ctx, ArgsRange.getBegin());
308311
}
@@ -312,7 +315,7 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
312315
if (IdentRE.match(Comment.second, &Matches) &&
313316
!sameName(Matches[2], II->getName(), StrictMode)) {
314317
{
315-
DiagnosticBuilder Diag =
318+
const DiagnosticBuilder Diag =
316319
diag(Comment.first, "argument name '%0' in comment does not "
317320
"match parameter name %1")
318321
<< Matches[2] << II;
@@ -332,9 +335,9 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
332335

333336
// If the argument comments are missing for literals add them.
334337
if (Comments.empty() && shouldAddComment(Args[I])) {
335-
std::string ArgComment =
338+
const std::string ArgComment =
336339
(llvm::Twine("/*") + II->getName() + "=*/").str();
337-
DiagnosticBuilder Diag =
340+
const DiagnosticBuilder Diag =
338341
diag(Args[I]->getBeginLoc(),
339342
"argument comment missing for literal argument %0")
340343
<< II

clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ AST_MATCHER_P2(Expr, hasSideEffect, bool, CheckFunctionCalls,
2929
const Expr *E = &Node;
3030

3131
if (const auto *Op = dyn_cast<UnaryOperator>(E)) {
32-
UnaryOperator::Opcode OC = Op->getOpcode();
32+
const UnaryOperator::Opcode OC = Op->getOpcode();
3333
return OC == UO_PostInc || OC == UO_PostDec || OC == UO_PreInc ||
3434
OC == UO_PreDec;
3535
}
@@ -44,7 +44,7 @@ AST_MATCHER_P2(Expr, hasSideEffect, bool, CheckFunctionCalls,
4444
if (MethodDecl->isConst())
4545
return false;
4646

47-
OverloadedOperatorKind OpKind = OpCallExpr->getOperator();
47+
const OverloadedOperatorKind OpKind = OpCallExpr->getOperator();
4848
return OpKind == OO_Equal || OpKind == OO_PlusEqual ||
4949
OpKind == OO_MinusEqual || OpKind == OO_StarEqual ||
5050
OpKind == OO_SlashEqual || OpKind == OO_AmpEqual ||
@@ -130,7 +130,7 @@ void AssertSideEffectCheck::check(const MatchFinder::MatchResult &Result) {
130130

131131
StringRef AssertMacroName;
132132
while (Loc.isValid() && Loc.isMacroID()) {
133-
StringRef MacroName = Lexer::getImmediateMacroName(Loc, SM, LangOpts);
133+
const StringRef MacroName = Lexer::getImmediateMacroName(Loc, SM, LangOpts);
134134
Loc = SM.getImmediateMacroCallerLoc(Loc);
135135

136136
// Check if this macro is an assert.

clang-tools-extra/clang-tidy/bugprone/AssignmentInIfConditionCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void AssignmentInIfConditionCheck::check(
6666
}
6767

6868
void AssignmentInIfConditionCheck::report(const Expr *AssignmentExpr) {
69-
SourceLocation OpLoc =
69+
const SourceLocation OpLoc =
7070
isa<BinaryOperator>(AssignmentExpr)
7171
? cast<BinaryOperator>(AssignmentExpr)->getOperatorLoc()
7272
: cast<CXXOperatorCallExpr>(AssignmentExpr)->getOperatorLoc();

clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void BadSignalToKillThreadCheck::check(const MatchFinder::MatchResult &Result) {
4040
const Token &T = MI->tokens().back();
4141
if (!T.isLiteral() || !T.getLiteralData())
4242
return std::nullopt;
43-
StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
43+
const StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
4444

4545
llvm::APInt IntValue;
4646
constexpr unsigned AutoSenseRadix = 0;

clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ static bool isIdenticalStmt(const ASTContext &Ctx, const Stmt *Stmt1,
281281
const auto *IntLit1 = cast<IntegerLiteral>(Stmt1);
282282
const auto *IntLit2 = cast<IntegerLiteral>(Stmt2);
283283

284-
llvm::APInt I1 = IntLit1->getValue();
285-
llvm::APInt I2 = IntLit2->getValue();
284+
const llvm::APInt I1 = IntLit1->getValue();
285+
const llvm::APInt I2 = IntLit2->getValue();
286286
if (I1.getBitWidth() != I2.getBitWidth())
287287
return false;
288288
return I1 == I2;
@@ -352,7 +352,7 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult &Result) {
352352
}
353353
}
354354

355-
size_t N = Branches.size();
355+
const size_t N = Branches.size();
356356
llvm::BitVector KnownAsClone(N);
357357

358358
for (size_t I = 0; I + 1 < N; I++) {
@@ -375,7 +375,7 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult &Result) {
375375
// We report the first occurrence only when we find the second one.
376376
diag(Branches[I]->getBeginLoc(),
377377
"repeated branch body in conditional chain");
378-
SourceLocation End =
378+
const SourceLocation End =
379379
Lexer::getLocForEndOfToken(Branches[I]->getEndLoc(), 0,
380380
*Result.SourceManager, getLangOpts());
381381
if (End.isValid()) {

clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void CopyConstructorInitCheck::registerMatchers(MatchFinder *Finder) {
3131

3232
void CopyConstructorInitCheck::check(const MatchFinder::MatchResult &Result) {
3333
const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor");
34-
std::string ParamName = Ctor->getParamDecl(0)->getNameAsString();
34+
const std::string ParamName = Ctor->getParamDecl(0)->getNameAsString();
3535

3636
// We want only one warning (and FixIt) for each ctor.
3737
std::string FixItInitList;
@@ -40,7 +40,7 @@ void CopyConstructorInitCheck::check(const MatchFinder::MatchResult &Result) {
4040
bool HasWrittenInitializer = false;
4141
SmallVector<FixItHint, 2> SafeFixIts;
4242
for (const auto *Init : Ctor->inits()) {
43-
bool CtorInitIsWritten = Init->isWritten();
43+
const bool CtorInitIsWritten = Init->isWritten();
4444
HasWrittenInitializer = HasWrittenInitializer || CtorInitIsWritten;
4545
if (!Init->isBaseInitializer())
4646
continue;

clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ void CrtpConstructorAccessibilityCheck::check(
116116
assert(DerivedTemplateParameter &&
117117
"No template parameter corresponds to the derived class of the CRTP.");
118118

119-
bool NeedsFriend = !isDerivedParameterBefriended(CRTPDeclaration,
120-
DerivedTemplateParameter) &&
121-
!isDerivedClassBefriended(CRTPDeclaration, DerivedRecord);
119+
const bool NeedsFriend =
120+
!isDerivedParameterBefriended(CRTPDeclaration,
121+
DerivedTemplateParameter) &&
122+
!isDerivedClassBefriended(CRTPDeclaration, DerivedRecord);
122123

123124
const FixItHint HintFriend = FixItHint::CreateInsertion(
124125
CRTPDeclaration->getBraceRange().getEnd(),

0 commit comments

Comments
 (0)