Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
ffb5831
[libc] add various macros relate to *ADDR* (#164830)
c8ef Nov 8, 2025
a0e222f
[SimplifyCFG] Simplify uncond br with icmp & select (#165580)
Camsyn Nov 8, 2025
21c1b78
fix: C++ empty record with align lead to va_list out of sync (#72197)
hstk30-hw Nov 8, 2025
b9ea93c
[InstCombine] Fold operation into select, when one operand is zext of…
andjo403 Nov 8, 2025
fa98c8d
Fix bazel build for #166719
googlewalt Nov 8, 2025
6deb50d
[clang-tidy][NFC] Fix misc-const-correctness warnings (11/N) (#167128)
vbvictor Nov 8, 2025
c6ffc93
[clang-tidy][NFC] Fix misc-const-correctness warnings (14/N) (#167131)
vbvictor Nov 8, 2025
6313830
Fix missing include from #166664
googlewalt Nov 8, 2025
d838ca2
[clang-doc] Remove an unused local variable (NFC) (#167104)
kazutakahirata Nov 8, 2025
ee0652b
[flang] Remove unused local variables (NFC) (#167105)
kazutakahirata Nov 8, 2025
0028ef6
[llvm] Remove unused local variables (NFC) (#167106)
kazutakahirata Nov 8, 2025
2844d86
[mlir] Remove unused local variables (NFC) (#167107)
kazutakahirata Nov 8, 2025
ce7f9f9
[llvm] Proofread *.rst (#167108)
kazutakahirata Nov 8, 2025
01bea27
[clang-tidy][NFC] Fix misc-const-correctness warnings (10/N) (#167127)
vbvictor Nov 8, 2025
545c302
[clang-tidy][NFC] Fix misc-const-correctness warnings (8/N) (#167123)
vbvictor Nov 8, 2025
385dbc1
[clang-tidy][NFC] Fix misc-const-correctness warnings (12/N) (#167129)
vbvictor Nov 8, 2025
5896a25
[clang-tidy][NFC] Fix misc-const-correctness warnings (13/N) (#167130)
vbvictor Nov 8, 2025
ace77c2
[clang-tidy][NFC] Fix misc-const-correctness warnings (9/N) (#167124)
vbvictor Nov 8, 2025
cbfc053
merge main into amd-staging
z1-cciauto Nov 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ Error MustacheHTMLGenerator::generateDocs(
SmallString<128> JSONPath;
sys::path::native(RootDir.str() + "/json", JSONPath);

StringMap<json::Value> JSONFileMap;
{
llvm::TimeTraceScope TS("Iterate JSON files");
std::error_code EC;
Expand Down
43 changes: 23 additions & 20 deletions clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,16 @@ static std::vector<std::pair<SourceLocation, StringRef>>
getCommentsInRange(ASTContext *Ctx, CharSourceRange Range) {
std::vector<std::pair<SourceLocation, StringRef>> Comments;
auto &SM = Ctx->getSourceManager();
std::pair<FileID, unsigned> BeginLoc = SM.getDecomposedLoc(Range.getBegin()),
EndLoc = SM.getDecomposedLoc(Range.getEnd());
const std::pair<FileID, unsigned> BeginLoc =
SM.getDecomposedLoc(Range.getBegin()),
EndLoc =
SM.getDecomposedLoc(Range.getEnd());

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

bool Invalid = false;
StringRef Buffer = SM.getBufferData(BeginLoc.first, &Invalid);
const StringRef Buffer = SM.getBufferData(BeginLoc.first, &Invalid);
if (Invalid)
return Comments;

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

if (Tok.is(tok::comment)) {
std::pair<FileID, unsigned> CommentLoc =
const std::pair<FileID, unsigned> CommentLoc =
SM.getDecomposedLoc(Tok.getLocation());
assert(CommentLoc.first == BeginLoc.first);
Comments.emplace_back(
Expand All @@ -125,7 +127,7 @@ static std::vector<std::pair<SourceLocation, StringRef>>
getCommentsBeforeLoc(ASTContext *Ctx, SourceLocation Loc) {
std::vector<std::pair<SourceLocation, StringRef>> Comments;
while (Loc.isValid()) {
clang::Token Tok = utils::lexer::getPreviousToken(
const clang::Token Tok = utils::lexer::getPreviousToken(
Loc, Ctx->getSourceManager(), Ctx->getLangOpts(),
/*SkipComments=*/false);
if (Tok.isNot(tok::comment))
Expand All @@ -142,11 +144,11 @@ getCommentsBeforeLoc(ASTContext *Ctx, SourceLocation Loc) {

static bool isLikelyTypo(llvm::ArrayRef<ParmVarDecl *> Params,
StringRef ArgName, unsigned ArgIndex) {
std::string ArgNameLowerStr = ArgName.lower();
StringRef ArgNameLower = ArgNameLowerStr;
const std::string ArgNameLowerStr = ArgName.lower();
const StringRef ArgNameLower = ArgNameLowerStr;
// The threshold is arbitrary.
unsigned UpperBound = ((ArgName.size() + 2) / 3) + 1;
unsigned ThisED = ArgNameLower.edit_distance(
const unsigned UpperBound = ((ArgName.size() + 2) / 3) + 1;
const unsigned ThisED = ArgNameLower.edit_distance(
Params[ArgIndex]->getIdentifier()->getName().lower(),
/*AllowReplacements=*/true, UpperBound);
if (ThisED >= UpperBound)
Expand All @@ -155,17 +157,17 @@ static bool isLikelyTypo(llvm::ArrayRef<ParmVarDecl *> Params,
for (unsigned I = 0, E = Params.size(); I != E; ++I) {
if (I == ArgIndex)
continue;
IdentifierInfo *II = Params[I]->getIdentifier();
const IdentifierInfo *II = Params[I]->getIdentifier();
if (!II)
continue;

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

Callee = Callee->getFirstDecl();
unsigned NumArgs = std::min<unsigned>(Args.size(), Callee->getNumParams());
const unsigned NumArgs =
std::min<unsigned>(Args.size(), Callee->getNumParams());
if ((NumArgs == 0) || (IgnoreSingleArgument && NumArgs == 1))
return;

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

for (unsigned I = 0; I < NumArgs; ++I) {
const ParmVarDecl *PVD = Callee->getParamDecl(I);
IdentifierInfo *II = PVD->getIdentifier();
const IdentifierInfo *II = PVD->getIdentifier();
if (!II)
continue;
if (FunctionDecl *Template = Callee->getTemplateInstantiationPattern()) {
Expand All @@ -293,7 +296,7 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
}
}

CharSourceRange BeforeArgument =
const CharSourceRange BeforeArgument =
MakeFileCharRange(ArgBeginLoc, Args[I]->getBeginLoc());
ArgBeginLoc = Args[I]->getEndLoc();

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

// If the argument comments are missing for literals add them.
if (Comments.empty() && shouldAddComment(Args[I])) {
std::string ArgComment =
const std::string ArgComment =
(llvm::Twine("/*") + II->getName() + "=*/").str();
DiagnosticBuilder Diag =
const DiagnosticBuilder Diag =
diag(Args[I]->getBeginLoc(),
"argument comment missing for literal argument %0")
<< II
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ AST_MATCHER_P2(Expr, hasSideEffect, bool, CheckFunctionCalls,
const Expr *E = &Node;

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

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

StringRef AssertMacroName;
while (Loc.isValid() && Loc.isMacroID()) {
StringRef MacroName = Lexer::getImmediateMacroName(Loc, SM, LangOpts);
const StringRef MacroName = Lexer::getImmediateMacroName(Loc, SM, LangOpts);
Loc = SM.getImmediateMacroCallerLoc(Loc);

// Check if this macro is an assert.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void AssignmentInIfConditionCheck::check(
}

void AssignmentInIfConditionCheck::report(const Expr *AssignmentExpr) {
SourceLocation OpLoc =
const SourceLocation OpLoc =
isa<BinaryOperator>(AssignmentExpr)
? cast<BinaryOperator>(AssignmentExpr)->getOperatorLoc()
: cast<CXXOperatorCallExpr>(AssignmentExpr)->getOperatorLoc();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void BadSignalToKillThreadCheck::check(const MatchFinder::MatchResult &Result) {
const Token &T = MI->tokens().back();
if (!T.isLiteral() || !T.getLiteralData())
return std::nullopt;
StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
const StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());

llvm::APInt IntValue;
constexpr unsigned AutoSenseRadix = 0;
Expand Down
8 changes: 4 additions & 4 deletions clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ static bool isIdenticalStmt(const ASTContext &Ctx, const Stmt *Stmt1,
const auto *IntLit1 = cast<IntegerLiteral>(Stmt1);
const auto *IntLit2 = cast<IntegerLiteral>(Stmt2);

llvm::APInt I1 = IntLit1->getValue();
llvm::APInt I2 = IntLit2->getValue();
const llvm::APInt I1 = IntLit1->getValue();
const llvm::APInt I2 = IntLit2->getValue();
if (I1.getBitWidth() != I2.getBitWidth())
return false;
return I1 == I2;
Expand Down Expand Up @@ -352,7 +352,7 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult &Result) {
}
}

size_t N = Branches.size();
const size_t N = Branches.size();
llvm::BitVector KnownAsClone(N);

for (size_t I = 0; I + 1 < N; I++) {
Expand All @@ -375,7 +375,7 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult &Result) {
// We report the first occurrence only when we find the second one.
diag(Branches[I]->getBeginLoc(),
"repeated branch body in conditional chain");
SourceLocation End =
const SourceLocation End =
Lexer::getLocForEndOfToken(Branches[I]->getEndLoc(), 0,
*Result.SourceManager, getLangOpts());
if (End.isValid()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void CopyConstructorInitCheck::registerMatchers(MatchFinder *Finder) {

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

// We want only one warning (and FixIt) for each ctor.
std::string FixItInitList;
Expand All @@ -40,7 +40,7 @@ void CopyConstructorInitCheck::check(const MatchFinder::MatchResult &Result) {
bool HasWrittenInitializer = false;
SmallVector<FixItHint, 2> SafeFixIts;
for (const auto *Init : Ctor->inits()) {
bool CtorInitIsWritten = Init->isWritten();
const bool CtorInitIsWritten = Init->isWritten();
HasWrittenInitializer = HasWrittenInitializer || CtorInitIsWritten;
if (!Init->isBaseInitializer())
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ void CrtpConstructorAccessibilityCheck::check(
assert(DerivedTemplateParameter &&
"No template parameter corresponds to the derived class of the CRTP.");

bool NeedsFriend = !isDerivedParameterBefriended(CRTPDeclaration,
DerivedTemplateParameter) &&
!isDerivedClassBefriended(CRTPDeclaration, DerivedRecord);
const bool NeedsFriend =
!isDerivedParameterBefriended(CRTPDeclaration,
DerivedTemplateParameter) &&
!isDerivedClassBefriended(CRTPDeclaration, DerivedRecord);

const FixItHint HintFriend = FixItHint::CreateInsertion(
CRTPDeclaration->getBraceRange().getEnd(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void DefaultOperatorNewOnOveralignedTypeCheck::check(
// Get the found 'new' expression.
const auto *NewExpr = Result.Nodes.getNodeAs<CXXNewExpr>("new");

QualType T = NewExpr->getAllocatedType();
const QualType T = NewExpr->getAllocatedType();
// Dependent types do not have fixed alignment.
if (T->isDependentType())
return;
Expand All @@ -35,25 +35,25 @@ void DefaultOperatorNewOnOveralignedTypeCheck::check(
if (!D || !D->isCompleteDefinition())
return;

ASTContext &Context = D->getASTContext();
const ASTContext &Context = D->getASTContext();

// Check if no alignment was specified for the type.
if (!Context.isAlignmentRequired(T))
return;

// The user-specified alignment (in bits).
unsigned SpecifiedAlignment = D->getMaxAlignment();
const unsigned SpecifiedAlignment = D->getMaxAlignment();
// Double-check if no alignment was specified.
if (!SpecifiedAlignment)
return;
// The alignment used by default 'operator new' (in bits).
unsigned DefaultNewAlignment = Context.getTargetInfo().getNewAlign();
const unsigned DefaultNewAlignment = Context.getTargetInfo().getNewAlign();

bool OverAligned = SpecifiedAlignment > DefaultNewAlignment;
bool HasDefaultOperatorNew =
const bool OverAligned = SpecifiedAlignment > DefaultNewAlignment;
const bool HasDefaultOperatorNew =
!NewExpr->getOperatorNew() || NewExpr->getOperatorNew()->isImplicit();

unsigned CharWidth = Context.getTargetInfo().getCharWidth();
const unsigned CharWidth = Context.getTargetInfo().getCharWidth();
if (HasDefaultOperatorNew && OverAligned)
diag(NewExpr->getBeginLoc(),
"allocation function returns a pointer with alignment %0 but the "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ AST_MATCHER(CXXMethodDecl, nameCollidesWithMethodInBase) {

for (const auto &BaseMethod : CurrentRecord->methods()) {
if (namesCollide(*BaseMethod, Node)) {
ast_matchers::internal::BoundNodesTreeBuilder Result(*Builder);
const ast_matchers::internal::BoundNodesTreeBuilder Result(*Builder);
Builder->setBinding("base_method",
clang::DynTypedNode::create(*BaseMethod));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void DynamicStaticInitializersCheck::registerMatchers(MatchFinder *Finder) {
void DynamicStaticInitializersCheck::check(
const MatchFinder::MatchResult &Result) {
const auto *Var = Result.Nodes.getNodeAs<VarDecl>("var");
SourceLocation Loc = Var->getLocation();
const SourceLocation Loc = Var->getLocation();
if (!Loc.isValid() || !utils::isPresumedLocInHeaderFile(
Loc, *Result.SourceManager, HeaderFileExtensions))
return;
Expand Down
Loading