Skip to content

Commit

Permalink
[AutoBump] Merge with 76b827b (Sep 20)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorickert committed Dec 13, 2024
2 parents d1726f4 + 76b827b commit a00dc5b
Show file tree
Hide file tree
Showing 1,486 changed files with 92,627 additions and 37,693 deletions.
5 changes: 5 additions & 0 deletions .github/new-prs-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1008,3 +1008,8 @@ bazel:

offload:
- offload/**

tablegen:
- llvm/include/TableGen/**
- llvm/lib/TableGen/**
- llvm/utils/TableGen/**
1 change: 0 additions & 1 deletion clang-tools-extra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ add_subdirectory(clang-move)
add_subdirectory(clang-query)
add_subdirectory(include-cleaner)
add_subdirectory(pp-trace)
add_subdirectory(pseudo)
add_subdirectory(tool-template)

option(CLANG_TOOLS_EXTRA_INCLUDE_DOCS "Generate build targets for the Clang Extra Tools docs."
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/CODE_OWNERS.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ D: clang-tidy

N: Manuel Klimek
E: klimek@google.com
D: clang-rename, all parts of clang-tools-extra not covered by someone else
D: all parts of clang-tools-extra not covered by someone else

N: Sam McCall
E: sammccall@google.com
Expand Down
2 changes: 0 additions & 2 deletions clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
++Context.Stats.ErrorsIgnoredNOLINT;
// Ignored a warning, should ignore related notes as well
LastErrorWasIgnored = true;
Context.DiagEngine->Clear();
for (const auto &Error : SuppressionErrors)
Context.diag(Error);
return;
Expand Down Expand Up @@ -457,7 +456,6 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
if (Info.hasSourceManager())
checkFilters(Info.getLocation(), Info.getSourceManager());

Context.DiagEngine->Clear();
for (const auto &Error : SuppressionErrors)
Context.diag(Error);
}
Expand Down
10 changes: 5 additions & 5 deletions clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ void AvoidCArraysCheck::check(const MatchFinder::MatchResult &Result) {
enum class RecommendType { Array, Vector, Span };
llvm::SmallVector<const char *> RecommendTypes{};
if (IsVLA) {
RecommendTypes.push_back("std::vector<>");
RecommendTypes.push_back("'std::vector'");
} else if (ArrayType->getTypePtr()->isIncompleteArrayType() && IsInParam) {
// in function parameter, we also don't know the size of
// IncompleteArrayType.
if (Result.Context->getLangOpts().CPlusPlus20)
RecommendTypes.push_back("std::span<>");
RecommendTypes.push_back("'std::span'");
else {
RecommendTypes.push_back("std::array<>");
RecommendTypes.push_back("std::vector<>");
RecommendTypes.push_back("'std::array'");
RecommendTypes.push_back("'std::vector'");
}
} else {
RecommendTypes.push_back("std::array<>");
RecommendTypes.push_back("'std::array'");
}
diag(ArrayType->getBeginLoc(),
"do not declare %select{C-style|C VLA}0 arrays, use %1 instead")
Expand Down
6 changes: 3 additions & 3 deletions clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ StatementMatcher makeIteratorLoopMatcher(bool IsReverse) {
/// EndVarName: 'j' (as a VarDecl)
/// In the second example only:
/// EndCallName: 'container.size()' (as a CXXMemberCallExpr) or
/// 'size(contaner)' (as a CallExpr)
/// 'size(container)' (as a CallExpr)
///
/// Client code will need to make sure that:
/// - The containers on which 'size()' is called is the container indexed.
Expand Down Expand Up @@ -491,7 +491,7 @@ static bool isDirectMemberExpr(const Expr *E) {
}

/// Given an expression that represents an usage of an element from the
/// containter that we are iterating over, returns false when it can be
/// container that we are iterating over, returns false when it can be
/// guaranteed this element cannot be modified as a result of this usage.
static bool canBeModified(ASTContext *Context, const Expr *E) {
if (E->getType().isConstQualified())
Expand Down Expand Up @@ -922,7 +922,7 @@ bool LoopConvertCheck::isConvertible(ASTContext *Context,
const ast_matchers::BoundNodes &Nodes,
const ForStmt *Loop,
LoopFixerKind FixerKind) {
// In self contained diagnosics mode we don't want dependancies on other
// In self contained diagnostic mode we don't want dependencies on other
// loops, otherwise, If we already modified the range of this for loop, don't
// do any further updates on this iteration.
if (areDiagsSelfContained())
Expand Down
56 changes: 30 additions & 26 deletions clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,40 @@
using namespace clang::ast_matchers;

namespace clang::tidy::readability {

void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {
const auto SupportedContainers = hasType(
hasUnqualifiedDesugaredType(recordType(hasDeclaration(cxxRecordDecl(
hasAnyName("::std::set", "::std::unordered_set", "::std::map",
"::std::unordered_map", "::std::multiset",
"::std::unordered_multiset", "::std::multimap",
"::std::unordered_multimap"))))));
const auto HasContainsMatchingParamType = hasMethod(
cxxMethodDecl(isConst(), parameterCountIs(1), returns(booleanType()),
hasName("contains"), unless(isDeleted()), isPublic(),
hasParameter(0, hasType(hasUnqualifiedDesugaredType(
equalsBoundNode("parameterType"))))));

const auto CountCall =
cxxMemberCallExpr(on(SupportedContainers),
callee(cxxMethodDecl(hasName("count"))),
argumentCountIs(1))
cxxMemberCallExpr(
argumentCountIs(1),
callee(cxxMethodDecl(
hasName("count"),
hasParameter(0, hasType(hasUnqualifiedDesugaredType(
type().bind("parameterType")))),
ofClass(cxxRecordDecl(HasContainsMatchingParamType)))))
.bind("call");

const auto FindCall =
cxxMemberCallExpr(on(SupportedContainers),
callee(cxxMethodDecl(hasName("find"))),
argumentCountIs(1))
cxxMemberCallExpr(
argumentCountIs(1),
callee(cxxMethodDecl(
hasName("find"),
hasParameter(0, hasType(hasUnqualifiedDesugaredType(
type().bind("parameterType")))),
ofClass(cxxRecordDecl(HasContainsMatchingParamType)))))
.bind("call");

const auto EndCall = cxxMemberCallExpr(on(SupportedContainers),
callee(cxxMethodDecl(hasName("end"))),
argumentCountIs(0));
const auto EndCall = cxxMemberCallExpr(
argumentCountIs(0),
callee(
cxxMethodDecl(hasName("end"),
// In the matchers below, FindCall should always appear
// before EndCall so 'parameterType' is properly bound.
ofClass(cxxRecordDecl(HasContainsMatchingParamType)))));

const auto Literal0 = integerLiteral(equals(0));
const auto Literal1 = integerLiteral(equals(1));
Expand All @@ -52,10 +62,7 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {
.bind("positiveComparison"),
this);
AddSimpleMatcher(
binaryOperator(hasLHS(CountCall), hasOperatorName("!="), hasRHS(Literal0))
.bind("positiveComparison"));
AddSimpleMatcher(
binaryOperator(hasLHS(Literal0), hasOperatorName("!="), hasRHS(CountCall))
binaryOperator(hasOperatorName("!="), hasOperands(CountCall, Literal0))
.bind("positiveComparison"));
AddSimpleMatcher(
binaryOperator(hasLHS(CountCall), hasOperatorName(">"), hasRHS(Literal0))
Expand All @@ -72,10 +79,7 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {

// Find inverted membership tests which use `count()`.
AddSimpleMatcher(
binaryOperator(hasLHS(CountCall), hasOperatorName("=="), hasRHS(Literal0))
.bind("negativeComparison"));
AddSimpleMatcher(
binaryOperator(hasLHS(Literal0), hasOperatorName("=="), hasRHS(CountCall))
binaryOperator(hasOperatorName("=="), hasOperands(CountCall, Literal0))
.bind("negativeComparison"));
AddSimpleMatcher(
binaryOperator(hasLHS(CountCall), hasOperatorName("<="), hasRHS(Literal0))
Expand All @@ -92,10 +96,10 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {

// Find membership tests based on `find() == end()`.
AddSimpleMatcher(
binaryOperator(hasLHS(FindCall), hasOperatorName("!="), hasRHS(EndCall))
binaryOperator(hasOperatorName("!="), hasOperands(FindCall, EndCall))
.bind("positiveComparison"));
AddSimpleMatcher(
binaryOperator(hasLHS(FindCall), hasOperatorName("=="), hasRHS(EndCall))
binaryOperator(hasOperatorName("=="), hasOperands(FindCall, EndCall))
.bind("negativeComparison"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@

namespace clang::tidy::readability {

/// Finds usages of `container.count()` and `find() == end()` which should be
/// replaced by a call to the `container.contains()` method introduced in C++20.
/// Finds usages of `container.count()` and
/// `container.find() == container.end()` which should be replaced by a call
/// to the `container.contains()` method.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/readability/container-contains.html
Expand All @@ -24,10 +25,11 @@ class ContainerContainsCheck : public ClangTidyCheck {
: ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) final;
void check(const ast_matchers::MatchFinder::MatchResult &Result) final;

protected:
bool isLanguageVersionSupported(const LangOptions &LO) const final {
return LO.CPlusPlus20;
return LO.CPlusPlus;
}
std::optional<TraversalKind> getCheckTraversalKind() const override {
return TK_AsIs;
}
};

Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clangd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ target_link_libraries(clangDaemon
${LLVM_PTHREAD_LIB}

clangIncludeCleaner
clangPseudo
clangTidy
clangTidyUtils

Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ PreambleFileStatusCache::getProducingFS(
: ProxyFileSystem(std::move(FS)), StatCache(StatCache) {}

llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
openFileForRead(const llvm::Twine &Path) override {
auto File = getUnderlyingFS().openFileForRead(Path);
openFileForRead(const llvm::Twine &Path, bool IsText = true) override {
auto File = getUnderlyingFS().openFileForRead(Path, IsText);
if (!File || !*File)
return File;
// Eagerly stat opened file, as the followup `status` call on the file
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/Preamble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@ class TimerFS : public llvm::vfs::ProxyFileSystem {
: ProxyFileSystem(std::move(FS)) {}

llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
openFileForRead(const llvm::Twine &Path) override {
openFileForRead(const llvm::Twine &Path, bool IsText = true) override {
WallTimerRegion T(Timer);
auto FileOr = getUnderlyingFS().openFileForRead(Path);
auto FileOr = getUnderlyingFS().openFileForRead(Path, IsText);
if (!FileOr)
return FileOr;
return std::make_unique<TimerFile>(Timer, std::move(FileOr.get()));
Expand Down
32 changes: 16 additions & 16 deletions clang-tools-extra/clangd/SemanticSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#include "Protocol.h"
#include "Selection.h"
#include "SourceCode.h"
#include "clang-pseudo/Bracket.h"
#include "clang-pseudo/DirectiveTree.h"
#include "clang-pseudo/Token.h"
#include "clang/AST/DeclBase.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
Expand All @@ -25,6 +22,9 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Error.h"
#include "support/Bracket.h"
#include "support/DirectiveTree.h"
#include "support/Token.h"
#include <optional>
#include <queue>
#include <vector>
Expand Down Expand Up @@ -181,16 +181,16 @@ llvm::Expected<std::vector<FoldingRange>> getFoldingRanges(ParsedAST &AST) {
// Related issue: https://github.com/clangd/clangd/issues/310
llvm::Expected<std::vector<FoldingRange>>
getFoldingRanges(const std::string &Code, bool LineFoldingOnly) {
auto OrigStream = pseudo::lex(Code, clang::pseudo::genericLangOpts());
auto OrigStream = lex(Code, genericLangOpts());

auto DirectiveStructure = pseudo::DirectiveTree::parse(OrigStream);
pseudo::chooseConditionalBranches(DirectiveStructure, OrigStream);
auto DirectiveStructure = DirectiveTree::parse(OrigStream);
chooseConditionalBranches(DirectiveStructure, OrigStream);

// FIXME: Provide ranges in the disabled-PP regions as well.
auto Preprocessed = DirectiveStructure.stripDirectives(OrigStream);

auto ParseableStream = cook(Preprocessed, clang::pseudo::genericLangOpts());
pseudo::pairBrackets(ParseableStream);
auto ParseableStream = cook(Preprocessed, genericLangOpts());
pairBrackets(ParseableStream);

std::vector<FoldingRange> Result;
auto AddFoldingRange = [&](Position Start, Position End,
Expand All @@ -205,19 +205,19 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) {
FR.kind = Kind.str();
Result.push_back(FR);
};
auto OriginalToken = [&](const pseudo::Token &T) {
auto OriginalToken = [&](const Token &T) {
return OrigStream.tokens()[T.OriginalIndex];
};
auto StartOffset = [&](const pseudo::Token &T) {
auto StartOffset = [&](const Token &T) {
return OriginalToken(T).text().data() - Code.data();
};
auto StartPosition = [&](const pseudo::Token &T) {
auto StartPosition = [&](const Token &T) {
return offsetToPosition(Code, StartOffset(T));
};
auto EndOffset = [&](const pseudo::Token &T) {
auto EndOffset = [&](const Token &T) {
return StartOffset(T) + OriginalToken(T).Length;
};
auto EndPosition = [&](const pseudo::Token &T) {
auto EndPosition = [&](const Token &T) {
return offsetToPosition(Code, EndOffset(T));
};
auto Tokens = ParseableStream.tokens();
Expand All @@ -235,7 +235,7 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) {
}
}
}
auto IsBlockComment = [&](const pseudo::Token &T) {
auto IsBlockComment = [&](const Token &T) {
assert(T.Kind == tok::comment);
return OriginalToken(T).Length >= 2 &&
Code.substr(StartOffset(T), 2) == "/*";
Expand All @@ -246,10 +246,10 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) {
T++;
continue;
}
pseudo::Token *FirstComment = T;
Token *FirstComment = T;
// Show starting sentinals (// and /*) of the comment.
Position Start = offsetToPosition(Code, 2 + StartOffset(*FirstComment));
pseudo::Token *LastComment = T;
Token *LastComment = T;
Position End = EndPosition(*T);
while (T != Tokens.end() && T->Kind == tok::comment &&
StartPosition(*T).line <= End.line + 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@
//
//===----------------------------------------------------------------------===//

#include "clang-pseudo/Bracket.h"
#include "Bracket.h"

namespace clang {
namespace pseudo {
namespace clangd {
namespace {

struct Bracket {
Expand All @@ -83,7 +83,7 @@ struct Bracket {
// Find brackets in the stream and convert to Bracket struct.
std::vector<Bracket> findBrackets(const TokenStream &Stream) {
std::vector<Bracket> Brackets;
auto Add = [&](const pseudo::Token &Tok, Bracket::BracketKind K,
auto Add = [&](const Token &Tok, Bracket::BracketKind K,
Bracket::Direction D) {
Brackets.push_back(
{K, D, Tok.Line, Tok.Indent, Stream.index(Tok), Bracket::None});
Expand Down Expand Up @@ -151,5 +151,5 @@ void pairBrackets(TokenStream &Stream) {
applyPairings(Brackets, Stream);
}

} // namespace pseudo
} // namespace clangd
} // namespace clang
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
//
//===----------------------------------------------------------------------===//

#ifndef CLANG_PSEUDO_BRACKET_H
#define CLANG_PSEUDO_BRACKET_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_BRACKET_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_BRACKET_H

#include "clang-pseudo/Token.h"
#include "Token.h"

namespace clang {
namespace pseudo {
namespace clangd {

/// Identifies bracket token in the stream which should be paired.
/// Sets Token::Pair accordingly.
void pairBrackets(TokenStream &);

} // namespace pseudo
} // namespace clangd
} // namespace clang

#endif
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_BRACKET_H
Loading

0 comments on commit a00dc5b

Please sign in to comment.