Skip to content

Commit ed8f788

Browse files
authored
Remove clang-pseudo (#109154)
The functionality is incomplete and the authors have since shifted gears to other work, so this is effectively unmaintained. The original design document for clang-pseudo can be found at: https://docs.google.com/document/d/1eGkTOsFja63wsv8v0vd5JdoTonj-NlN3ujGF0T7xDbM/edit in case anyone wishes to pick this project back up again in the future. Original RFC: https://discourse.llvm.org/t/removing-pseudo-parser/71131/
1 parent 94c024a commit ed8f788

File tree

103 files changed

+55
-9465
lines changed

Some content is hidden

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

103 files changed

+55
-9465
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/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/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: 4 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,6 +30,7 @@ add_clang_library(clangdSupport
2730
ThreadCrashReporter.cpp
2831
Threading.cpp
2932
ThreadsafeFS.cpp
33+
Token.cpp
3034
Trace.cpp
3135

3236
LINK_LIBS

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/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

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

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

28-
#ifndef CLANG_PSEUDO_TOKEN_H
29-
#define CLANG_PSEUDO_TOKEN_H
28+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TOKEN_H
29+
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TOKEN_H
3030

3131
#include "clang/Basic/LLVM.h"
3232
#include "clang/Basic/LangStandard.h"
@@ -41,7 +41,7 @@
4141

4242
namespace clang {
4343
class LangOptions;
44-
namespace pseudo {
44+
namespace clangd {
4545

4646
/// A single C++ or preprocessor token.
4747
///
@@ -249,7 +249,7 @@ TokenStream cook(const TokenStream &, const clang::LangOptions &);
249249
/// Drops comment tokens.
250250
TokenStream stripComments(const TokenStream &);
251251

252-
} // namespace pseudo
252+
} // namespace clangd
253253
} // namespace clang
254254

255-
#endif // CLANG_PSEUDO_TOKEN_H
255+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_TOKEN_H

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ infrastructure are described first, followed by tool-specific sections.
4343
Major New Features
4444
------------------
4545

46+
- The ``clang-pseudo`` tool is incomplete and does not have active maintainers,
47+
so it has been removed. See
48+
`the RFC <https://discourse.llvm.org/t/removing-pseudo-parser/71131/>`_ for
49+
more details.
50+
4651
...
4752

4853
Improvements to clangd

clang-tools-extra/pseudo/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)