Skip to content

Commit

Permalink
Merge branch 'llvm:main' into complex-deinterleaving/single-reductions
Browse files Browse the repository at this point in the history
  • Loading branch information
NickGuy-Arm authored Oct 22, 2024
2 parents effea38 + b81d8e9 commit aac0ea6
Show file tree
Hide file tree
Showing 1,863 changed files with 68,278 additions and 41,823 deletions.
7 changes: 0 additions & 7 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# Checkout as native, commit as LF except in specific circumstances
* text=auto
*.bat text eol=crlf
*.rc text eol=crlf
*.sln text eol=crlf
*.natvis text eol=crlf

libcxx/src/**/*.cpp merge=libcxx-reformat
libcxx/include/**/*.h merge=libcxx-reformat

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM docker.io/library/ubuntu:22.04 as base
ENV LLVM_SYSROOT=/opt/llvm

FROM base as stage1-toolchain
ENV LLVM_VERSION=18.1.8
ENV LLVM_VERSION=19.1.2

RUN apt-get update && \
apt-get install -y \
Expand Down
2 changes: 1 addition & 1 deletion bolt/include/bolt/Core/DIEBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class DIEBuilder {

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

Expand Down
4 changes: 2 additions & 2 deletions bolt/lib/Core/BinaryContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,8 +1294,8 @@ bool BinaryContext::handleAArch64Veneer(uint64_t Address, bool MatchOnly) {
Veneer->getOrCreateLocalLabel(Address);
Veneer->setMaxSize(TotalSize);
Veneer->updateState(BinaryFunction::State::Disassembled);
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: handling veneer function at 0x" << Address
<< "\n");
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: handling veneer function at 0x"
<< Twine::utohexstr(Address) << "\n");
return true;
};

Expand Down
6 changes: 3 additions & 3 deletions bolt/lib/Passes/VeneerElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ Error VeneerElimination::runOnFunctions(BinaryContext &BC) {
continue;

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

VeneerCallers++;
BC.MIB->replaceBranchTarget(Instr, VeneerDestinations[TargetSymbol],
BC.Ctx.get());
BC.MIB->replaceBranchTarget(Instr, It->second, BC.Ctx.get());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Rewrite/DWARFRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ void DWARFRewriter::updateDWARFObjectAddressRanges(
Die.getTag() == dwarf::DW_TAG_compile_unit)) {
if (opts::Verbosity >= 1)
errs() << "BOLT-WARNING: cannot update ranges for DIE in Unit offset 0x"
<< Unit.getOffset() << '\n';
<< Twine::utohexstr(Unit.getOffset()) << '\n';
}
}

Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/clang-doc/Generators.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ std::string getTagType(TagTypeKind AS);
} // namespace doc
} // namespace clang

namespace llvm {
extern template class Registry<clang::doc::Generator>;
} // namespace llvm

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H
4 changes: 4 additions & 0 deletions clang-tools-extra/clang-tidy/ClangTidyModuleRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ using ClangTidyModuleRegistry = llvm::Registry<ClangTidyModule>;

} // namespace clang::tidy

namespace llvm {
extern template class Registry<clang::tidy::ClangTidyModule>;
} // namespace llvm

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYMODULEREGISTRY_H
7 changes: 5 additions & 2 deletions clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@

#include "UseInternalLinkageCheck.h"
#include "../utils/FileExtensionsUtils.h"
#include "../utils/LexerUtils.h"
#include "clang/AST/Decl.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/ASTMatchers/ASTMatchersMacros.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/Specifiers.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Lex/Token.h"
#include "llvm/ADT/STLExtras.h"

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

DiagnosticBuilder DB = diag(VD->getLocation(), Message) << "variable" << VD;
SourceLocation FixLoc = VD->getTypeSpecStartLoc();
const SourceLocation FixLoc = VD->getInnerLocStart();
if (FixLoc.isInvalid() || FixLoc.isMacroID())
return;
if (FixMode == FixModeKind::UseStatic)
Expand Down
82 changes: 38 additions & 44 deletions clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#include "UseStartsEndsWithCheck.h"

#include "../utils/ASTUtils.h"
#include "../utils/OptionsUtils.h"
#include "../utils/Matchers.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Lex/Lexer.h"

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

const auto HasStartsWithMethodWithName = [](const std::string &Name) {
return hasMethod(
cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
.bind("starts_with_fun"));
const auto ClassTypeWithMethod = [](const StringRef MethodBoundName,
const auto... Methods) {
return cxxRecordDecl(anyOf(
hasMethod(cxxMethodDecl(isConst(), parameterCountIs(1),
returns(booleanType()), hasAnyName(Methods))
.bind(MethodBoundName))...));
};
const auto HasStartsWithMethod =
anyOf(HasStartsWithMethodWithName("starts_with"),
HasStartsWithMethodWithName("startsWith"),
HasStartsWithMethodWithName("startswith"));

const auto OnClassWithStartsWithFunction =
on(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
anyOf(HasStartsWithMethod,
hasAnyBase(hasType(hasCanonicalType(
hasDeclaration(cxxRecordDecl(HasStartsWithMethod)))))))))));

const auto HasEndsWithMethodWithName = [](const std::string &Name) {
return hasMethod(
cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
.bind("ends_with_fun"));
};
const auto HasEndsWithMethod = anyOf(HasEndsWithMethodWithName("ends_with"),
HasEndsWithMethodWithName("endsWith"),
HasEndsWithMethodWithName("endswith"));
const auto OnClassWithEndsWithFunction =
on(expr(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl(
anyOf(HasEndsWithMethod,
hasAnyBase(hasType(hasCanonicalType(hasDeclaration(
cxxRecordDecl(HasEndsWithMethod)))))))))))
.bind("haystack"));
ClassTypeWithMethod("starts_with_fun", "starts_with", "startsWith",
"startswith", "StartsWith");

const auto OnClassWithEndsWithFunction = ClassTypeWithMethod(
"ends_with_fun", "ends_with", "endsWith", "endswith", "EndsWith");

// Case 1: X.find(Y) [!=]= 0 -> starts_with.
const auto FindExpr = cxxMemberCallExpr(
anyOf(argumentCountIs(1), hasArgument(1, ZeroLiteral)),
callee(cxxMethodDecl(hasName("find")).bind("find_fun")),
OnClassWithStartsWithFunction, hasArgument(0, expr().bind("needle")));
callee(
cxxMethodDecl(hasName("find"), ofClass(OnClassWithStartsWithFunction))
.bind("find_fun")),
hasArgument(0, expr().bind("needle")));

// Case 2: X.rfind(Y, 0) [!=]= 0 -> starts_with.
const auto RFindExpr = cxxMemberCallExpr(
hasArgument(1, ZeroLiteral),
callee(cxxMethodDecl(hasName("rfind")).bind("find_fun")),
OnClassWithStartsWithFunction, hasArgument(0, expr().bind("needle")));
callee(cxxMethodDecl(hasName("rfind"),
ofClass(OnClassWithStartsWithFunction))
.bind("find_fun")),
hasArgument(0, expr().bind("needle")));

// Case 3: X.compare(0, LEN(Y), Y) [!=]= 0 -> starts_with.
const auto CompareExpr = cxxMemberCallExpr(
argumentCountIs(3), hasArgument(0, ZeroLiteral),
callee(cxxMethodDecl(hasName("compare")).bind("find_fun")),
OnClassWithStartsWithFunction, hasArgument(2, expr().bind("needle")),
callee(cxxMethodDecl(hasName("compare"),
ofClass(OnClassWithStartsWithFunction))
.bind("find_fun")),
hasArgument(2, expr().bind("needle")),
hasArgument(1, lengthExprForStringNode("needle")));

// Case 4: X.compare(LEN(X) - LEN(Y), LEN(Y), Y) [!=]= 0 -> ends_with.
const auto CompareEndsWithExpr = cxxMemberCallExpr(
argumentCountIs(3),
callee(cxxMethodDecl(hasName("compare")).bind("find_fun")),
OnClassWithEndsWithFunction, hasArgument(2, expr().bind("needle")),
callee(cxxMethodDecl(hasName("compare"),
ofClass(OnClassWithEndsWithFunction))
.bind("find_fun")),
on(expr().bind("haystack")), hasArgument(2, expr().bind("needle")),
hasArgument(1, lengthExprForStringNode("needle")),
hasArgument(0,
binaryOperator(hasOperatorName("-"),
Expand All @@ -145,7 +139,7 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
// All cases comparing to 0.
Finder->addMatcher(
binaryOperator(
hasAnyOperatorName("==", "!="),
matchers::isEqualityOperator(),
hasOperands(cxxMemberCallExpr(anyOf(FindExpr, RFindExpr, CompareExpr,
CompareEndsWithExpr))
.bind("find_expr"),
Expand All @@ -156,7 +150,7 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
// Case 5: X.rfind(Y) [!=]= LEN(X) - LEN(Y) -> ends_with.
Finder->addMatcher(
binaryOperator(
hasAnyOperatorName("==", "!="),
matchers::isEqualityOperator(),
hasOperands(
cxxMemberCallExpr(
anyOf(
Expand All @@ -166,8 +160,10 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
1,
anyOf(declRefExpr(to(varDecl(hasName("npos")))),
memberExpr(member(hasName("npos"))))))),
callee(cxxMethodDecl(hasName("rfind")).bind("find_fun")),
OnClassWithEndsWithFunction,
callee(cxxMethodDecl(hasName("rfind"),
ofClass(OnClassWithEndsWithFunction))
.bind("find_fun")),
on(expr().bind("haystack")),
hasArgument(0, expr().bind("needle")))
.bind("find_expr"),
binaryOperator(hasOperatorName("-"),
Expand All @@ -190,9 +186,8 @@ void UseStartsEndsWithCheck::check(const MatchFinder::MatchResult &Result) {
const CXXMethodDecl *ReplacementFunction =
StartsWithFunction ? StartsWithFunction : EndsWithFunction;

if (ComparisonExpr->getBeginLoc().isMacroID()) {
if (ComparisonExpr->getBeginLoc().isMacroID())
return;
}

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

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

// Add possible negation '!'.
if (Neg) {
if (Neg)
Diagnostic << FixItHint::CreateInsertion(FindExpr->getBeginLoc(), "!");
}
}

} // namespace clang::tidy::modernize
4 changes: 3 additions & 1 deletion clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ getPreviousTokenAndStart(SourceLocation Location, const SourceManager &SM,
if (Location.isInvalid())
return {Token, Location};

auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location));
const auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location));
while (Location != StartOfFile) {
Location = Lexer::GetBeginningOfToken(Location, SM, LangOpts);
if (!Lexer::getRawToken(Location, Token, SM, LangOpts) &&
(!SkipComments || !Token.is(tok::comment))) {
break;
}
if (Location == StartOfFile)
return {Token, Location};
Location = Location.getLocWithOffset(-1);
}
return {Token, Location};
Expand Down
1 change: 1 addition & 0 deletions clang-tools-extra/clangd/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ struct Config {
bool DeducedTypes = true;
bool Designators = true;
bool BlockEnd = false;
bool DefaultArguments = false;
// Limit the length of type names in inlay hints. (0 means no limit)
uint32_t TypeNameLimit = 32;
} InlayHints;
Expand Down
6 changes: 5 additions & 1 deletion clang-tools-extra/clangd/ConfigCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "llvm/Support/Regex.h"
#include "llvm/Support/SMLoc.h"
#include "llvm/Support/SourceMgr.h"
#include <algorithm>
#include <memory>
#include <optional>
#include <string>
Expand Down Expand Up @@ -669,6 +668,11 @@ struct FragmentCompiler {
Out.Apply.push_back([Value(**F.BlockEnd)](const Params &, Config &C) {
C.InlayHints.BlockEnd = Value;
});
if (F.DefaultArguments)
Out.Apply.push_back(
[Value(**F.DefaultArguments)](const Params &, Config &C) {
C.InlayHints.DefaultArguments = Value;
});
if (F.TypeNameLimit)
Out.Apply.push_back(
[Value(**F.TypeNameLimit)](const Params &, Config &C) {
Expand Down
3 changes: 3 additions & 0 deletions clang-tools-extra/clangd/ConfigFragment.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ struct Fragment {
std::optional<Located<bool>> Designators;
/// Show defined symbol names at the end of a definition block.
std::optional<Located<bool>> BlockEnd;
/// Show parameter names and default values of default arguments after all
/// of the explicit arguments.
std::optional<Located<bool>> DefaultArguments;
/// Limit the length of type name hints. (0 means no limit)
std::optional<Located<uint32_t>> TypeNameLimit;
};
Expand Down
5 changes: 4 additions & 1 deletion clang-tools-extra/clangd/ConfigYAML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "llvm/Support/YAMLParser.h"
#include <optional>
#include <string>
#include <system_error>

namespace clang {
namespace clangd {
Expand Down Expand Up @@ -268,6 +267,10 @@ class Parser {
if (auto Value = boolValue(N, "BlockEnd"))
F.BlockEnd = *Value;
});
Dict.handle("DefaultArguments", [&](Node &N) {
if (auto Value = boolValue(N, "DefaultArguments"))
F.DefaultArguments = *Value;
});
Dict.handle("TypeNameLimit", [&](Node &N) {
if (auto Value = uint32Value(N, "TypeNameLimit"))
F.TypeNameLimit = *Value;
Expand Down
Loading

0 comments on commit aac0ea6

Please sign in to comment.