Skip to content

Commit b625170

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:76883932014bcce2efb57be062f901de26317707 into amd-gfx:888e970457a7
Local branch amd-gfx 888e970 Merged main:999313debe8a87760b128e4469f17ec0ce1a4a8f into amd-gfx:72df466aa45e Remote branch main 7688393 [SandboxVec] Simple Instruction Interval class (llvm#108882)
2 parents 888e970 + 7688393 commit b625170

File tree

837 files changed

+52554
-26202
lines changed

Some content is hidden

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

837 files changed

+52554
-26202
lines changed

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/clang-tidy/modernize/AvoidCArraysCheck.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,18 @@ void AvoidCArraysCheck::check(const MatchFinder::MatchResult &Result) {
8080
enum class RecommendType { Array, Vector, Span };
8181
llvm::SmallVector<const char *> RecommendTypes{};
8282
if (IsVLA) {
83-
RecommendTypes.push_back("std::vector<>");
83+
RecommendTypes.push_back("'std::vector'");
8484
} else if (ArrayType->getTypePtr()->isIncompleteArrayType() && IsInParam) {
8585
// in function parameter, we also don't know the size of
8686
// IncompleteArrayType.
8787
if (Result.Context->getLangOpts().CPlusPlus20)
88-
RecommendTypes.push_back("std::span<>");
88+
RecommendTypes.push_back("'std::span'");
8989
else {
90-
RecommendTypes.push_back("std::array<>");
91-
RecommendTypes.push_back("std::vector<>");
90+
RecommendTypes.push_back("'std::array'");
91+
RecommendTypes.push_back("'std::vector'");
9292
}
9393
} else {
94-
RecommendTypes.push_back("std::array<>");
94+
RecommendTypes.push_back("'std::array'");
9595
}
9696
diag(ArrayType->getBeginLoc(),
9797
"do not declare %select{C-style|C VLA}0 arrays, use %1 instead")

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {
6262
.bind("positiveComparison"),
6363
this);
6464
AddSimpleMatcher(
65-
binaryOperator(hasLHS(CountCall), hasOperatorName("!="), hasRHS(Literal0))
66-
.bind("positiveComparison"));
67-
AddSimpleMatcher(
68-
binaryOperator(hasLHS(Literal0), hasOperatorName("!="), hasRHS(CountCall))
65+
binaryOperator(hasOperatorName("!="), hasOperands(CountCall, Literal0))
6966
.bind("positiveComparison"));
7067
AddSimpleMatcher(
7168
binaryOperator(hasLHS(CountCall), hasOperatorName(">"), hasRHS(Literal0))
@@ -82,10 +79,7 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {
8279

8380
// Find inverted membership tests which use `count()`.
8481
AddSimpleMatcher(
85-
binaryOperator(hasLHS(CountCall), hasOperatorName("=="), hasRHS(Literal0))
86-
.bind("negativeComparison"));
87-
AddSimpleMatcher(
88-
binaryOperator(hasLHS(Literal0), hasOperatorName("=="), hasRHS(CountCall))
82+
binaryOperator(hasOperatorName("=="), hasOperands(CountCall, Literal0))
8983
.bind("negativeComparison"));
9084
AddSimpleMatcher(
9185
binaryOperator(hasLHS(CountCall), hasOperatorName("<="), hasRHS(Literal0))
@@ -102,10 +96,10 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {
10296

10397
// Find membership tests based on `find() == end()`.
10498
AddSimpleMatcher(
105-
binaryOperator(hasLHS(FindCall), hasOperatorName("!="), hasRHS(EndCall))
99+
binaryOperator(hasOperatorName("!="), hasOperands(FindCall, EndCall))
106100
.bind("positiveComparison"));
107101
AddSimpleMatcher(
108-
binaryOperator(hasLHS(FindCall), hasOperatorName("=="), hasRHS(EndCall))
102+
binaryOperator(hasOperatorName("=="), hasOperands(FindCall, EndCall))
109103
.bind("negativeComparison"));
110104
}
111105

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

clang-tools-extra/pseudo/include/clang-pseudo/Bracket.h renamed to clang-tools-extra/clangd/support/Bracket.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@
2323
//
2424
//===----------------------------------------------------------------------===//
2525

26-
#ifndef CLANG_PSEUDO_BRACKET_H
27-
#define CLANG_PSEUDO_BRACKET_H
26+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_BRACKET_H
27+
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_BRACKET_H
2828

29-
#include "clang-pseudo/Token.h"
29+
#include "Token.h"
3030

3131
namespace clang {
32-
namespace pseudo {
32+
namespace clangd {
3333

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

38-
} // namespace pseudo
38+
} // namespace clangd
3939
} // namespace clang
4040

41-
#endif
41+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_BRACKET_H

clang-tools-extra/clangd/support/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
1616
endif()
1717

1818
add_clang_library(clangdSupport
19+
Bracket.cpp
1920
Cancellation.cpp
2021
Context.cpp
22+
DirectiveTree.cpp
2123
FileCache.cpp
24+
Lex.cpp
2225
Logger.cpp
2326
Markup.cpp
2427
MemoryTree.cpp
@@ -27,9 +30,16 @@ add_clang_library(clangdSupport
2730
ThreadCrashReporter.cpp
2831
Threading.cpp
2932
ThreadsafeFS.cpp
33+
Token.cpp
3034
Trace.cpp
3135

3236
LINK_LIBS
3337
${LLVM_PTHREAD_LIB}
3438
${CLANGD_ATOMIC_LIB}
3539
)
40+
41+
clang_target_link_libraries(clangdSupport
42+
PRIVATE
43+
clangBasic
44+
clangLex
45+
)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "clang-pseudo/DirectiveTree.h"
9+
#include "DirectiveTree.h"
1010
#include "clang/Basic/IdentifierTable.h"
1111
#include "clang/Basic/TokenKinds.h"
1212
#include "llvm/Support/FormatVariadic.h"
1313
#include <optional>
1414
#include <variant>
1515

1616
namespace clang {
17-
namespace pseudo {
17+
namespace clangd {
1818
namespace {
1919

2020
class DirectiveParser {
@@ -353,5 +353,5 @@ TokenStream DirectiveTree::stripDirectives(const TokenStream &In) const {
353353
return Out;
354354
}
355355

356-
} // namespace pseudo
356+
} // namespace clangd
357357
} // namespace clang

clang-tools-extra/pseudo/include/clang-pseudo/DirectiveTree.h renamed to clang-tools-extra/clangd/support/DirectiveTree.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
//
2626
//===----------------------------------------------------------------------===//
2727

28-
#ifndef CLANG_PSEUDO_DIRECTIVETREE_H
29-
#define CLANG_PSEUDO_DIRECTIVETREE_H
28+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIRECTIVETREE_H
29+
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIRECTIVETREE_H
3030

31-
#include "clang-pseudo/Token.h"
31+
#include "Token.h"
3232
#include "clang/Basic/TokenKinds.h"
3333
#include <optional>
3434
#include <variant>
3535
#include <vector>
3636

3737
namespace clang {
38-
namespace pseudo {
38+
namespace clangd {
3939

4040
/// Describes the structure of a source file, as seen by the preprocessor.
4141
///
@@ -124,7 +124,7 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &,
124124
/// The choices are stored in Conditional::Taken nodes.
125125
void chooseConditionalBranches(DirectiveTree &, const TokenStream &Code);
126126

127-
} // namespace pseudo
127+
} // namespace clangd
128128
} // namespace clang
129129

130-
#endif // CLANG_PSEUDO_DIRECTIVETREE_H
130+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIRECTIVETREE_H

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "clang-pseudo/Token.h"
9+
#include "Token.h"
1010
#include "clang/Basic/IdentifierTable.h"
1111
#include "clang/Basic/SourceLocation.h"
1212
#include "clang/Basic/TokenKinds.h"
1313
#include "clang/Lex/Lexer.h"
1414
#include "clang/Lex/LiteralSupport.h"
1515

1616
namespace clang {
17-
namespace pseudo {
17+
namespace clangd {
1818

1919
TokenStream lex(const std::string &Code, const clang::LangOptions &LangOpts) {
2020
clang::SourceLocation Start;
@@ -135,5 +135,5 @@ TokenStream cook(const TokenStream &Code, const LangOptions &LangOpts) {
135135
return Result;
136136
}
137137

138-
} // namespace pseudo
138+
} // namespace clangd
139139
} // namespace clang

clang-tools-extra/clangd/support/ThreadsafeFS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class VolatileFileSystem : public llvm::vfs::ProxyFileSystem {
2929
: ProxyFileSystem(std::move(FS)) {}
3030

3131
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
32-
openFileForRead(const llvm::Twine &InPath) override {
32+
openFileForRead(const llvm::Twine &InPath, bool IsText = true) override {
3333
llvm::SmallString<128> Path;
3434
InPath.toVector(Path);
3535

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "clang-pseudo/Token.h"
9+
#include "Token.h"
1010
#include "clang/Basic/LangOptions.h"
1111
#include "llvm/ADT/StringExtras.h"
1212
#include "llvm/Support/Format.h"
1313
#include "llvm/Support/FormatVariadic.h"
1414

1515
namespace clang {
16-
namespace pseudo {
16+
namespace clangd {
1717

1818
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Token &T) {
1919
OS << llvm::formatv("{0} {1}:{2} ", clang::tok::getTokenName(T.Kind), T.Line,
@@ -126,5 +126,5 @@ TokenStream stripComments(const TokenStream &Input) {
126126
return Out;
127127
}
128128

129-
} // namespace pseudo
129+
} // namespace clangd
130130
} // namespace clang

0 commit comments

Comments
 (0)