Skip to content

Commit e4942c6

Browse files
committed
Merge from 'main' to 'sycl-web' (292 commits)
CONFLICT (content): Merge conflict in llvm/include/llvm/Demangle/ItaniumDemangle.h
2 parents 7608b60 + dd8b266 commit e4942c6

File tree

1,160 files changed

+76324
-36314
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,160 files changed

+76324
-36314
lines changed

bolt/test/perf2bolt/lit.local.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import shutil
2+
import subprocess
23

3-
if shutil.which("perf") is not None:
4-
config.available_features.add("perf")
4+
if shutil.which("perf") is not None and subprocess.run(["perf", "record", "-e", "cycles:u", "-o", "/dev/null", "--", "perf", "--version"], capture_output=True).returncode == 0:
5+
config.available_features.add("perf")

clang-tools-extra/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ add_subdirectory(clang-move)
2727
add_subdirectory(clang-query)
2828
add_subdirectory(include-cleaner)
2929
add_subdirectory(pp-trace)
30-
add_subdirectory(pseudo)
3130
add_subdirectory(tool-template)
3231

3332
option(CLANG_TOOLS_EXTRA_INCLUDE_DOCS "Generate build targets for the Clang Extra Tools docs."

clang-tools-extra/CODE_OWNERS.TXT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ D: clang-tidy
2323

2424
N: Manuel Klimek
2525
26-
D: clang-rename, all parts of clang-tools-extra not covered by someone else
26+
D: all parts of clang-tools-extra not covered by someone else
2727

2828
N: Sam McCall
2929

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
380380
++Context.Stats.ErrorsIgnoredNOLINT;
381381
// Ignored a warning, should ignore related notes as well
382382
LastErrorWasIgnored = true;
383-
Context.DiagEngine->Clear();
384383
for (const auto &Error : SuppressionErrors)
385384
Context.diag(Error);
386385
return;
@@ -457,7 +456,6 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
457456
if (Info.hasSourceManager())
458457
checkFilters(Info.getLocation(), Info.getSourceManager());
459458

460-
Context.DiagEngine->Clear();
461459
for (const auto &Error : SuppressionErrors)
462460
Context.diag(Error);
463461
}

clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "AvoidCArraysCheck.h"
1010
#include "clang/AST/ASTContext.h"
1111
#include "clang/ASTMatchers/ASTMatchFinder.h"
12+
#include "clang/ASTMatchers/ASTMatchers.h"
1213

1314
using namespace clang::ast_matchers;
1415

@@ -60,6 +61,7 @@ void AvoidCArraysCheck::registerMatchers(MatchFinder *Finder) {
6061

6162
Finder->addMatcher(
6263
typeLoc(hasValidBeginLoc(), hasType(arrayType()),
64+
optionally(hasParent(parmVarDecl().bind("param_decl"))),
6365
unless(anyOf(hasParent(parmVarDecl(isArgvOfMain())),
6466
hasParent(varDecl(isExternC())),
6567
hasParent(fieldDecl(
@@ -72,11 +74,28 @@ void AvoidCArraysCheck::registerMatchers(MatchFinder *Finder) {
7274

7375
void AvoidCArraysCheck::check(const MatchFinder::MatchResult &Result) {
7476
const auto *ArrayType = Result.Nodes.getNodeAs<TypeLoc>("typeloc");
75-
77+
const bool IsInParam =
78+
Result.Nodes.getNodeAs<ParmVarDecl>("param_decl") != nullptr;
79+
const bool IsVLA = ArrayType->getTypePtr()->isVariableArrayType();
80+
enum class RecommendType { Array, Vector, Span };
81+
llvm::SmallVector<const char *> RecommendTypes{};
82+
if (IsVLA) {
83+
RecommendTypes.push_back("'std::vector'");
84+
} else if (ArrayType->getTypePtr()->isIncompleteArrayType() && IsInParam) {
85+
// in function parameter, we also don't know the size of
86+
// IncompleteArrayType.
87+
if (Result.Context->getLangOpts().CPlusPlus20)
88+
RecommendTypes.push_back("'std::span'");
89+
else {
90+
RecommendTypes.push_back("'std::array'");
91+
RecommendTypes.push_back("'std::vector'");
92+
}
93+
} else {
94+
RecommendTypes.push_back("'std::array'");
95+
}
7696
diag(ArrayType->getBeginLoc(),
77-
"do not declare %select{C-style|C VLA}0 arrays, use "
78-
"%select{std::array<>|std::vector<>}0 instead")
79-
<< ArrayType->getTypePtr()->isVariableArrayType();
97+
"do not declare %select{C-style|C VLA}0 arrays, use %1 instead")
98+
<< IsVLA << llvm::join(RecommendTypes, " or ");
8099
}
81100

82101
} // namespace clang::tidy::modernize

clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ StatementMatcher makeIteratorLoopMatcher(bool IsReverse) {
262262
/// EndVarName: 'j' (as a VarDecl)
263263
/// In the second example only:
264264
/// EndCallName: 'container.size()' (as a CXXMemberCallExpr) or
265-
/// 'size(contaner)' (as a CallExpr)
265+
/// 'size(container)' (as a CallExpr)
266266
///
267267
/// Client code will need to make sure that:
268268
/// - The containers on which 'size()' is called is the container indexed.
@@ -491,7 +491,7 @@ static bool isDirectMemberExpr(const Expr *E) {
491491
}
492492

493493
/// Given an expression that represents an usage of an element from the
494-
/// containter that we are iterating over, returns false when it can be
494+
/// container that we are iterating over, returns false when it can be
495495
/// guaranteed this element cannot be modified as a result of this usage.
496496
static bool canBeModified(ASTContext *Context, const Expr *E) {
497497
if (E->getType().isConstQualified())
@@ -922,7 +922,7 @@ bool LoopConvertCheck::isConvertible(ASTContext *Context,
922922
const ast_matchers::BoundNodes &Nodes,
923923
const ForStmt *Loop,
924924
LoopFixerKind FixerKind) {
925-
// In self contained diagnosics mode we don't want dependancies on other
925+
// In self contained diagnostic mode we don't want dependencies on other
926926
// loops, otherwise, If we already modified the range of this for loop, don't
927927
// do any further updates on this iteration.
928928
if (areDiagsSelfContained())

clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,40 @@
1313
using namespace clang::ast_matchers;
1414

1515
namespace clang::tidy::readability {
16-
1716
void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {
18-
const auto SupportedContainers = hasType(
19-
hasUnqualifiedDesugaredType(recordType(hasDeclaration(cxxRecordDecl(
20-
hasAnyName("::std::set", "::std::unordered_set", "::std::map",
21-
"::std::unordered_map", "::std::multiset",
22-
"::std::unordered_multiset", "::std::multimap",
23-
"::std::unordered_multimap"))))));
17+
const auto HasContainsMatchingParamType = hasMethod(
18+
cxxMethodDecl(isConst(), parameterCountIs(1), returns(booleanType()),
19+
hasName("contains"), unless(isDeleted()), isPublic(),
20+
hasParameter(0, hasType(hasUnqualifiedDesugaredType(
21+
equalsBoundNode("parameterType"))))));
2422

2523
const auto CountCall =
26-
cxxMemberCallExpr(on(SupportedContainers),
27-
callee(cxxMethodDecl(hasName("count"))),
28-
argumentCountIs(1))
24+
cxxMemberCallExpr(
25+
argumentCountIs(1),
26+
callee(cxxMethodDecl(
27+
hasName("count"),
28+
hasParameter(0, hasType(hasUnqualifiedDesugaredType(
29+
type().bind("parameterType")))),
30+
ofClass(cxxRecordDecl(HasContainsMatchingParamType)))))
2931
.bind("call");
3032

3133
const auto FindCall =
32-
cxxMemberCallExpr(on(SupportedContainers),
33-
callee(cxxMethodDecl(hasName("find"))),
34-
argumentCountIs(1))
34+
cxxMemberCallExpr(
35+
argumentCountIs(1),
36+
callee(cxxMethodDecl(
37+
hasName("find"),
38+
hasParameter(0, hasType(hasUnqualifiedDesugaredType(
39+
type().bind("parameterType")))),
40+
ofClass(cxxRecordDecl(HasContainsMatchingParamType)))))
3541
.bind("call");
3642

37-
const auto EndCall = cxxMemberCallExpr(on(SupportedContainers),
38-
callee(cxxMethodDecl(hasName("end"))),
39-
argumentCountIs(0));
43+
const auto EndCall = cxxMemberCallExpr(
44+
argumentCountIs(0),
45+
callee(
46+
cxxMethodDecl(hasName("end"),
47+
// In the matchers below, FindCall should always appear
48+
// before EndCall so 'parameterType' is properly bound.
49+
ofClass(cxxRecordDecl(HasContainsMatchingParamType)))));
4050

4151
const auto Literal0 = integerLiteral(equals(0));
4252
const auto Literal1 = integerLiteral(equals(1));
@@ -52,10 +62,7 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {
5262
.bind("positiveComparison"),
5363
this);
5464
AddSimpleMatcher(
55-
binaryOperator(hasLHS(CountCall), hasOperatorName("!="), hasRHS(Literal0))
56-
.bind("positiveComparison"));
57-
AddSimpleMatcher(
58-
binaryOperator(hasLHS(Literal0), hasOperatorName("!="), hasRHS(CountCall))
65+
binaryOperator(hasOperatorName("!="), hasOperands(CountCall, Literal0))
5966
.bind("positiveComparison"));
6067
AddSimpleMatcher(
6168
binaryOperator(hasLHS(CountCall), hasOperatorName(">"), hasRHS(Literal0))
@@ -72,10 +79,7 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {
7279

7380
// Find inverted membership tests which use `count()`.
7481
AddSimpleMatcher(
75-
binaryOperator(hasLHS(CountCall), hasOperatorName("=="), hasRHS(Literal0))
76-
.bind("negativeComparison"));
77-
AddSimpleMatcher(
78-
binaryOperator(hasLHS(Literal0), hasOperatorName("=="), hasRHS(CountCall))
82+
binaryOperator(hasOperatorName("=="), hasOperands(CountCall, Literal0))
7983
.bind("negativeComparison"));
8084
AddSimpleMatcher(
8185
binaryOperator(hasLHS(CountCall), hasOperatorName("<="), hasRHS(Literal0))
@@ -92,10 +96,10 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {
9296

9397
// Find membership tests based on `find() == end()`.
9498
AddSimpleMatcher(
95-
binaryOperator(hasLHS(FindCall), hasOperatorName("!="), hasRHS(EndCall))
99+
binaryOperator(hasOperatorName("!="), hasOperands(FindCall, EndCall))
96100
.bind("positiveComparison"));
97101
AddSimpleMatcher(
98-
binaryOperator(hasLHS(FindCall), hasOperatorName("=="), hasRHS(EndCall))
102+
binaryOperator(hasOperatorName("=="), hasOperands(FindCall, EndCall))
99103
.bind("negativeComparison"));
100104
}
101105

clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313

1414
namespace clang::tidy::readability {
1515

16-
/// Finds usages of `container.count()` and `find() == end()` which should be
17-
/// replaced by a call to the `container.contains()` method introduced in C++20.
16+
/// Finds usages of `container.count()` and
17+
/// `container.find() == container.end()` which should be replaced by a call
18+
/// to the `container.contains()` method.
1819
///
1920
/// For the user-facing documentation see:
2021
/// http://clang.llvm.org/extra/clang-tidy/checks/readability/container-contains.html
@@ -24,10 +25,11 @@ class ContainerContainsCheck : public ClangTidyCheck {
2425
: ClangTidyCheck(Name, Context) {}
2526
void registerMatchers(ast_matchers::MatchFinder *Finder) final;
2627
void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
27-
28-
protected:
2928
bool isLanguageVersionSupported(const LangOptions &LO) const final {
30-
return LO.CPlusPlus20;
29+
return LO.CPlusPlus;
30+
}
31+
std::optional<TraversalKind> getCheckTraversalKind() const override {
32+
return TK_AsIs;
3133
}
3234
};
3335

clang-tools-extra/clangd/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ target_link_libraries(clangDaemon
183183
${LLVM_PTHREAD_LIB}
184184

185185
clangIncludeCleaner
186-
clangPseudo
187186
clangTidy
188187
clangTidyUtils
189188

clang-tools-extra/clangd/FS.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ PreambleFileStatusCache::getProducingFS(
6464
: ProxyFileSystem(std::move(FS)), StatCache(StatCache) {}
6565

6666
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
67-
openFileForRead(const llvm::Twine &Path) override {
68-
auto File = getUnderlyingFS().openFileForRead(Path);
67+
openFileForRead(const llvm::Twine &Path, bool IsText = true) override {
68+
auto File = getUnderlyingFS().openFileForRead(Path, IsText);
6969
if (!File || !*File)
7070
return File;
7171
// Eagerly stat opened file, as the followup `status` call on the file

clang-tools-extra/clangd/Preamble.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,9 @@ class TimerFS : public llvm::vfs::ProxyFileSystem {
479479
: ProxyFileSystem(std::move(FS)) {}
480480

481481
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
482-
openFileForRead(const llvm::Twine &Path) override {
482+
openFileForRead(const llvm::Twine &Path, bool IsText = true) override {
483483
WallTimerRegion T(Timer);
484-
auto FileOr = getUnderlyingFS().openFileForRead(Path);
484+
auto FileOr = getUnderlyingFS().openFileForRead(Path, IsText);
485485
if (!FileOr)
486486
return FileOr;
487487
return std::make_unique<TimerFile>(Timer, std::move(FileOr.get()));

clang-tools-extra/clangd/SemanticSelection.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
#include "Protocol.h"
1212
#include "Selection.h"
1313
#include "SourceCode.h"
14-
#include "clang-pseudo/Bracket.h"
15-
#include "clang-pseudo/DirectiveTree.h"
16-
#include "clang-pseudo/Token.h"
1714
#include "clang/AST/DeclBase.h"
1815
#include "clang/Basic/SourceLocation.h"
1916
#include "clang/Basic/SourceManager.h"
@@ -25,6 +22,9 @@
2522
#include "llvm/ADT/StringRef.h"
2623
#include "llvm/Support/Casting.h"
2724
#include "llvm/Support/Error.h"
25+
#include "support/Bracket.h"
26+
#include "support/DirectiveTree.h"
27+
#include "support/Token.h"
2828
#include <optional>
2929
#include <queue>
3030
#include <vector>
@@ -181,16 +181,16 @@ llvm::Expected<std::vector<FoldingRange>> getFoldingRanges(ParsedAST &AST) {
181181
// Related issue: https://github.com/clangd/clangd/issues/310
182182
llvm::Expected<std::vector<FoldingRange>>
183183
getFoldingRanges(const std::string &Code, bool LineFoldingOnly) {
184-
auto OrigStream = pseudo::lex(Code, clang::pseudo::genericLangOpts());
184+
auto OrigStream = lex(Code, genericLangOpts());
185185

186-
auto DirectiveStructure = pseudo::DirectiveTree::parse(OrigStream);
187-
pseudo::chooseConditionalBranches(DirectiveStructure, OrigStream);
186+
auto DirectiveStructure = DirectiveTree::parse(OrigStream);
187+
chooseConditionalBranches(DirectiveStructure, OrigStream);
188188

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

192-
auto ParseableStream = cook(Preprocessed, clang::pseudo::genericLangOpts());
193-
pseudo::pairBrackets(ParseableStream);
192+
auto ParseableStream = cook(Preprocessed, genericLangOpts());
193+
pairBrackets(ParseableStream);
194194

195195
std::vector<FoldingRange> Result;
196196
auto AddFoldingRange = [&](Position Start, Position End,
@@ -205,19 +205,19 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) {
205205
FR.kind = Kind.str();
206206
Result.push_back(FR);
207207
};
208-
auto OriginalToken = [&](const pseudo::Token &T) {
208+
auto OriginalToken = [&](const Token &T) {
209209
return OrigStream.tokens()[T.OriginalIndex];
210210
};
211-
auto StartOffset = [&](const pseudo::Token &T) {
211+
auto StartOffset = [&](const Token &T) {
212212
return OriginalToken(T).text().data() - Code.data();
213213
};
214-
auto StartPosition = [&](const pseudo::Token &T) {
214+
auto StartPosition = [&](const Token &T) {
215215
return offsetToPosition(Code, StartOffset(T));
216216
};
217-
auto EndOffset = [&](const pseudo::Token &T) {
217+
auto EndOffset = [&](const Token &T) {
218218
return StartOffset(T) + OriginalToken(T).Length;
219219
};
220-
auto EndPosition = [&](const pseudo::Token &T) {
220+
auto EndPosition = [&](const Token &T) {
221221
return offsetToPosition(Code, EndOffset(T));
222222
};
223223
auto Tokens = ParseableStream.tokens();
@@ -235,7 +235,7 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) {
235235
}
236236
}
237237
}
238-
auto IsBlockComment = [&](const pseudo::Token &T) {
238+
auto IsBlockComment = [&](const Token &T) {
239239
assert(T.Kind == tok::comment);
240240
return OriginalToken(T).Length >= 2 &&
241241
Code.substr(StartOffset(T), 2) == "/*";
@@ -246,10 +246,10 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) {
246246
T++;
247247
continue;
248248
}
249-
pseudo::Token *FirstComment = T;
249+
Token *FirstComment = T;
250250
// Show starting sentinals (// and /*) of the comment.
251251
Position Start = offsetToPosition(Code, 2 + StartOffset(*FirstComment));
252-
pseudo::Token *LastComment = T;
252+
Token *LastComment = T;
253253
Position End = EndPosition(*T);
254254
while (T != Tokens.end() && T->Kind == tok::comment &&
255255
StartPosition(*T).line <= End.line + 1) {

clang-tools-extra/pseudo/lib/Bracket.cpp renamed to clang-tools-extra/clangd/support/Bracket.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
//
6363
//===----------------------------------------------------------------------===//
6464

65-
#include "clang-pseudo/Bracket.h"
65+
#include "Bracket.h"
6666

6767
namespace clang {
68-
namespace pseudo {
68+
namespace clangd {
6969
namespace {
7070

7171
struct Bracket {
@@ -83,7 +83,7 @@ struct Bracket {
8383
// Find brackets in the stream and convert to Bracket struct.
8484
std::vector<Bracket> findBrackets(const TokenStream &Stream) {
8585
std::vector<Bracket> Brackets;
86-
auto Add = [&](const pseudo::Token &Tok, Bracket::BracketKind K,
86+
auto Add = [&](const Token &Tok, Bracket::BracketKind K,
8787
Bracket::Direction D) {
8888
Brackets.push_back(
8989
{K, D, Tok.Line, Tok.Indent, Stream.index(Tok), Bracket::None});
@@ -151,5 +151,5 @@ void pairBrackets(TokenStream &Stream) {
151151
applyPairings(Brackets, Stream);
152152
}
153153

154-
} // namespace pseudo
154+
} // namespace clangd
155155
} // namespace clang

0 commit comments

Comments
 (0)