Skip to content

Commit 42f5611

Browse files
authored
Revert "LLVM and SPIRV-LLVM-Translator pulldown (WW06) (#3130)"
This reverts commit db9151f.
1 parent c9d71d4 commit 42f5611

File tree

1,867 files changed

+29957
-852292
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,867 files changed

+29957
-852292
lines changed

clang-tools-extra/clang-query/Query.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
156156
if (QS.DetailedASTOutput) {
157157
OS << "Binding for \"" << BI->first << "\":\n";
158158
const ASTContext &Ctx = AST->getASTContext();
159-
ASTDumper Dumper(OS, Ctx, AST->getDiagnostics().getShowColors());
159+
const SourceManager &SM = Ctx.getSourceManager();
160+
ASTDumper Dumper(OS, Ctx, SM.getDiagnostics().getShowColors());
160161
Dumper.SetTraversalKind(QS.TK);
161162
Dumper.Visit(BI->second);
162163
OS << "\n";

clang-tools-extra/clang-query/tool/ClangQuery.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ using namespace llvm;
4949
static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
5050
static cl::OptionCategory ClangQueryCategory("clang-query options");
5151

52-
static cl::opt<bool>
53-
UseColor("use-color",
54-
cl::desc(
55-
R"(Use colors in detailed AST output. If not set, colors
56-
will be used if the terminal connected to
57-
standard output supports colors.)"),
58-
cl::init(false), cl::cat(ClangQueryCategory));
59-
6052
static cl::list<std::string> Commands("c", cl::desc("Specify command to run"),
6153
cl::value_desc("command"),
6254
cl::cat(ClangQueryCategory));
@@ -117,19 +109,6 @@ int main(int argc, const char **argv) {
117109

118110
ClangTool Tool(OptionsParser->getCompilations(),
119111
OptionsParser->getSourcePathList());
120-
121-
if (UseColor.getNumOccurrences() > 0) {
122-
ArgumentsAdjuster colorAdjustor = [](const CommandLineArguments &Args, StringRef /*unused*/) {
123-
CommandLineArguments AdjustedArgs = Args;
124-
if (UseColor)
125-
AdjustedArgs.push_back("-fdiagnostics-color");
126-
else
127-
AdjustedArgs.push_back("-fno-diagnostics-color");
128-
return AdjustedArgs;
129-
};
130-
Tool.appendArgumentsAdjuster(colorAdjustor);
131-
}
132-
133112
std::vector<std::unique_ptr<ASTUnit>> ASTs;
134113
int ASTStatus = 0;
135114
switch (Tool.buildASTs(ASTs)) {

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,6 @@ class ClangdLSPServer::MessageHandler : public Transport::MessageHandler {
258258
};
259259
}
260260

261-
template <typename Result>
262-
void bind(const char *Method,
263-
void (ClangdLSPServer::*Handler)(Callback<Result>)) {
264-
Calls[Method] = [Handler, this](llvm::json::Value RawParams,
265-
ReplyOnce Reply) {
266-
(Server.*Handler)(std::move(Reply));
267-
};
268-
}
269-
270261
// Bind a reply callback to a request. The callback will be invoked when
271262
// clangd receives the reply from the LSP client.
272263
// Return a call id of the request.
@@ -310,12 +301,6 @@ class ClangdLSPServer::MessageHandler : public Transport::MessageHandler {
310301
};
311302
}
312303

313-
void bind(const char *Method, void (ClangdLSPServer::*Handler)()) {
314-
Notifications[Method] = [Handler, this](llvm::json::Value RawParams) {
315-
(Server.*Handler)();
316-
};
317-
}
318-
319304
private:
320305
// Function object to reply to an LSP call.
321306
// Each instance must be called exactly once, otherwise:
@@ -458,14 +443,6 @@ class ClangdLSPServer::MessageHandler : public Transport::MessageHandler {
458443
};
459444
constexpr int ClangdLSPServer::MessageHandler::MaxReplayCallbacks;
460445

461-
template <>
462-
void ClangdLSPServer::MessageHandler::bind<NoParams>(
463-
const char *Method, void (ClangdLSPServer::*Handler)(const NoParams &)) {
464-
Notifications[Method] = [Handler, this](llvm::json::Value RawParams) {
465-
(Server.*Handler)(NoParams{});
466-
};
467-
}
468-
469446
// call(), notify(), and reply() wrap the Transport, adding logging and locking.
470447
void ClangdLSPServer::callRaw(StringRef Method, llvm::json::Value Params,
471448
Callback<llvm::json::Value> CB) {
@@ -510,11 +487,6 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
510487
"semanticTokens request, choosing the latter (no notifications).");
511488
Opts.TheiaSemanticHighlighting = false;
512489
}
513-
if (Opts.TheiaSemanticHighlighting) {
514-
log("Using legacy semanticHighlights notification, which will be removed "
515-
"in clangd 13. Clients should use the standard semanticTokens "
516-
"request instead.");
517-
}
518490

519491
if (Params.rootUri && *Params.rootUri)
520492
Opts.WorkspaceRoot = std::string(Params.rootUri->file());
@@ -528,7 +500,6 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
528500
if (Opts.UseDirBasedCDB) {
529501
DirectoryBasedGlobalCompilationDatabase::Options CDBOpts(TFS);
530502
CDBOpts.CompileCommandsDir = Opts.CompileCommandsDir;
531-
CDBOpts.ContextProvider = Opts.ContextProvider;
532503
BaseCDB =
533504
std::make_unique<DirectoryBasedGlobalCompilationDatabase>(CDBOpts);
534505
BaseCDB = getQueryDriverDatabase(llvm::makeArrayRef(Opts.QueryDriverGlobs),
@@ -676,15 +647,17 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
676647

677648
void ClangdLSPServer::onInitialized(const InitializedParams &Params) {}
678649

679-
void ClangdLSPServer::onShutdown(Callback<std::nullptr_t> Reply) {
650+
void ClangdLSPServer::onShutdown(const ShutdownParams &Params,
651+
Callback<std::nullptr_t> Reply) {
680652
// Do essentially nothing, just say we're ready to exit.
681653
ShutdownRequestReceived = true;
682654
Reply(nullptr);
683655
}
684656

685657
// sync is a clangd extension: it blocks until all background work completes.
686658
// It blocks the calling thread, so no messages are processed until it returns!
687-
void ClangdLSPServer::onSync(Callback<std::nullptr_t> Reply) {
659+
void ClangdLSPServer::onSync(const NoParams &Params,
660+
Callback<std::nullptr_t> Reply) {
688661
if (Server->blockUntilIdleForTest(/*TimeoutSeconds=*/60))
689662
Reply(nullptr);
690663
else
@@ -1472,7 +1445,8 @@ void ClangdLSPServer::onSemanticTokensDelta(
14721445
});
14731446
}
14741447

1475-
void ClangdLSPServer::onMemoryUsage(Callback<MemoryTree> Reply) {
1448+
void ClangdLSPServer::onMemoryUsage(const NoParams &,
1449+
Callback<MemoryTree> Reply) {
14761450
llvm::BumpPtrAllocator DetailAlloc;
14771451
MemoryTree MT(&DetailAlloc);
14781452
profile(MT);

clang-tools-extra/clangd/ClangdLSPServer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
9393
// Calls have signature void(const Params&, Callback<Response>).
9494
void onInitialize(const InitializeParams &, Callback<llvm::json::Value>);
9595
void onInitialized(const InitializedParams &);
96-
void onShutdown(Callback<std::nullptr_t>);
97-
void onSync(Callback<std::nullptr_t>);
96+
void onShutdown(const ShutdownParams &, Callback<std::nullptr_t>);
97+
void onSync(const NoParams &, Callback<std::nullptr_t>);
9898
void onDocumentDidOpen(const DidOpenTextDocumentParams &);
9999
void onDocumentDidChange(const DidChangeTextDocumentParams &);
100100
void onDocumentDidClose(const DidCloseTextDocumentParams &);
@@ -161,7 +161,7 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
161161
Callback<SemanticTokensOrDelta>);
162162
/// This is a clangd extension. Provides a json tree representing memory usage
163163
/// hierarchy.
164-
void onMemoryUsage(Callback<MemoryTree>);
164+
void onMemoryUsage(const NoParams &, Callback<MemoryTree>);
165165

166166
std::vector<Fix> getFixes(StringRef File, const clangd::Diagnostic &D);
167167

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ void ClangdServer::formatOnType(PathRef File, llvm::StringRef Code,
407407
Result.push_back(replacementToEdit(Code, R));
408408
return CB(Result);
409409
};
410-
WorkScheduler.runQuick("FormatOnType", File, std::move(Action));
410+
WorkScheduler.run("FormatOnType", File, std::move(Action));
411411
}
412412

413413
void ClangdServer::prepareRename(PathRef File, Position Pos,
@@ -635,7 +635,7 @@ void ClangdServer::formatCode(PathRef File, llvm::StringRef Code,
635635
tooling::calculateRangesAfterReplacements(IncludeReplaces, Ranges),
636636
File)));
637637
};
638-
WorkScheduler.runQuick("Format", File, std::move(Action));
638+
WorkScheduler.run("Format", File, std::move(Action));
639639
}
640640

641641
void ClangdServer::findDocumentHighlights(

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,9 +1123,7 @@ bool semaCodeComplete(std::unique_ptr<CodeCompleteConsumer> Consumer,
11231123
// skip all includes in this case; these completions are really simple.
11241124
PreambleBounds PreambleRegion =
11251125
ComputePreambleBounds(*CI->getLangOpts(), *ContentsBuffer, 0);
1126-
bool CompletingInPreamble = Input.Offset < PreambleRegion.Size ||
1127-
(!PreambleRegion.PreambleEndsAtStartOfLine &&
1128-
Input.Offset == PreambleRegion.Size);
1126+
bool CompletingInPreamble = PreambleRegion.Size > Input.Offset;
11291127
if (Input.Patch)
11301128
Input.Patch->apply(*CI);
11311129
// NOTE: we must call BeginSourceFile after prepareCompilerInstance. Otherwise

clang-tools-extra/clangd/Config.h

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "llvm/ADT/FunctionExtras.h"
2929
#include "llvm/ADT/Optional.h"
3030
#include "llvm/ADT/StringMap.h"
31-
#include "llvm/ADT/StringSet.h"
3231
#include <string>
3332
#include <vector>
3433

@@ -52,19 +51,11 @@ struct Config {
5251
Config(Config &&) = default;
5352
Config &operator=(Config &&) = default;
5453

55-
struct CDBSearchSpec {
56-
enum { Ancestors, FixedDir, NoCDBSearch } Policy = Ancestors;
57-
// Absolute, native slashes, no trailing slash.
58-
llvm::Optional<std::string> FixedCDBPath;
59-
};
60-
6154
/// Controls how the compile command for the current file is determined.
6255
struct {
63-
/// Edits to apply to the compile command, in sequence.
56+
// Edits to apply to the compile command, in sequence.
6457
std::vector<llvm::unique_function<void(std::vector<std::string> &) const>>
6558
Edits;
66-
/// Where to search for compilation databases for this file's flags.
67-
CDBSearchSpec CDBSearch = {CDBSearchSpec::Ancestors, llvm::None};
6859
} CompileFlags;
6960

7061
enum class BackgroundPolicy { Build, Skip };
@@ -86,26 +77,21 @@ struct Config {
8677
llvm::Optional<ExternalIndexSpec> External;
8778
} Index;
8879

89-
/// Controls warnings and errors when parsing code.
90-
struct {
91-
bool SuppressAll = false;
92-
llvm::StringSet<> Suppress;
93-
94-
/// Configures what clang-tidy checks to run and options to use with them.
95-
struct {
96-
// A comma-seperated list of globs specify which clang-tidy checks to run.
97-
std::string Checks;
98-
llvm::StringMap<std::string> CheckOptions;
99-
} ClangTidy;
100-
} Diagnostics;
101-
10280
/// Style of the codebase.
10381
struct {
10482
// Namespaces that should always be fully qualified, meaning no "using"
10583
// declarations, always spell out the whole name (with or without leading
10684
// ::). All nested namespaces are affected as well.
10785
std::vector<std::string> FullyQualifiedNamespaces;
10886
} Style;
87+
88+
/// Configures what clang-tidy checks to run and options to use with them.
89+
struct {
90+
// A comma-seperated list of globs to specify which clang-tidy checks to
91+
// run.
92+
std::string Checks;
93+
llvm::StringMap<std::string> CheckOptions;
94+
} ClangTidy;
10995
};
11096

11197
} // namespace clangd

clang-tools-extra/clangd/ConfigCompile.cpp

Lines changed: 6 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "Config.h"
2828
#include "ConfigFragment.h"
2929
#include "ConfigProvider.h"
30-
#include "Diagnostics.h"
3130
#include "Features.inc"
3231
#include "TidyProvider.h"
3332
#include "support/Logger.h"
@@ -188,7 +187,7 @@ struct FragmentCompiler {
188187
compile(std::move(F.If));
189188
compile(std::move(F.CompileFlags));
190189
compile(std::move(F.Index));
191-
compile(std::move(F.Diagnostics));
190+
compile(std::move(F.ClangTidy));
192191
}
193192

194193
void compile(Fragment::IfBlock &&F) {
@@ -262,36 +261,6 @@ struct FragmentCompiler {
262261
});
263262
});
264263
}
265-
266-
if (F.CompilationDatabase) {
267-
llvm::Optional<Config::CDBSearchSpec> Spec;
268-
if (**F.CompilationDatabase == "Ancestors") {
269-
Spec.emplace();
270-
Spec->Policy = Config::CDBSearchSpec::Ancestors;
271-
} else if (**F.CompilationDatabase == "None") {
272-
Spec.emplace();
273-
Spec->Policy = Config::CDBSearchSpec::NoCDBSearch;
274-
} else {
275-
if (auto Path =
276-
makeAbsolute(*F.CompilationDatabase, "CompilationDatabase",
277-
llvm::sys::path::Style::native)) {
278-
// Drop trailing slash to put the path in canonical form.
279-
// Should makeAbsolute do this?
280-
llvm::StringRef Rel = llvm::sys::path::relative_path(*Path);
281-
if (!Rel.empty() && llvm::sys::path::is_separator(Rel.back()))
282-
Path->pop_back();
283-
284-
Spec.emplace();
285-
Spec->Policy = Config::CDBSearchSpec::FixedDir;
286-
Spec->FixedCDBPath = std::move(Path);
287-
}
288-
}
289-
if (Spec)
290-
Out.Apply.push_back(
291-
[Spec(std::move(*Spec))](const Params &, Config &C) {
292-
C.CompileFlags.CDBSearch = Spec;
293-
});
294-
}
295264
}
296265

297266
void compile(Fragment::IndexBlock &&F) {
@@ -359,29 +328,6 @@ struct FragmentCompiler {
359328
});
360329
}
361330

362-
void compile(Fragment::DiagnosticsBlock &&F) {
363-
std::vector<llvm::StringRef> Normalized;
364-
for (const auto &Suppressed : F.Suppress) {
365-
if (*Suppressed == "*") {
366-
Out.Apply.push_back([&](const Params &, Config &C) {
367-
C.Diagnostics.SuppressAll = true;
368-
C.Diagnostics.Suppress.clear();
369-
});
370-
return;
371-
}
372-
Normalized.push_back(normalizeSuppressedCode(*Suppressed));
373-
}
374-
if (!Normalized.empty())
375-
Out.Apply.push_back([Normalized](const Params &, Config &C) {
376-
if (C.Diagnostics.SuppressAll)
377-
return;
378-
for (llvm::StringRef N : Normalized)
379-
C.Diagnostics.Suppress.insert(N);
380-
});
381-
382-
compile(std::move(F.ClangTidy));
383-
}
384-
385331
void compile(Fragment::StyleBlock &&F) {
386332
if (!F.FullyQualifiedNamespaces.empty()) {
387333
std::vector<std::string> FullyQualifiedNamespaces;
@@ -423,7 +369,7 @@ struct FragmentCompiler {
423369
CurSpec += Str;
424370
}
425371

426-
void compile(Fragment::DiagnosticsBlock::ClangTidyBlock &&F) {
372+
void compile(Fragment::ClangTidyBlock &&F) {
427373
std::string Checks;
428374
for (auto &CheckGlob : F.Add)
429375
appendTidyCheckSpec(Checks, CheckGlob, true);
@@ -434,9 +380,8 @@ struct FragmentCompiler {
434380
if (!Checks.empty())
435381
Out.Apply.push_back(
436382
[Checks = std::move(Checks)](const Params &, Config &C) {
437-
C.Diagnostics.ClangTidy.Checks.append(
438-
Checks,
439-
C.Diagnostics.ClangTidy.Checks.empty() ? /*skip comma*/ 1 : 0,
383+
C.ClangTidy.Checks.append(
384+
Checks, C.ClangTidy.Checks.empty() ? /*skip comma*/ 1 : 0,
440385
std::string::npos);
441386
});
442387
if (!F.CheckOptions.empty()) {
@@ -447,8 +392,8 @@ struct FragmentCompiler {
447392
Out.Apply.push_back(
448393
[CheckOptions = std::move(CheckOptions)](const Params &, Config &C) {
449394
for (auto &StringPair : CheckOptions)
450-
C.Diagnostics.ClangTidy.CheckOptions.insert_or_assign(
451-
StringPair.first, StringPair.second);
395+
C.ClangTidy.CheckOptions.insert_or_assign(StringPair.first,
396+
StringPair.second);
452397
});
453398
}
454399
}

0 commit comments

Comments
 (0)