Skip to content

Revert "LLVM and SPIRV-LLVM-Translator pulldown (WW06)" #3165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion clang-tools-extra/clang-query/Query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
if (QS.DetailedASTOutput) {
OS << "Binding for \"" << BI->first << "\":\n";
const ASTContext &Ctx = AST->getASTContext();
ASTDumper Dumper(OS, Ctx, AST->getDiagnostics().getShowColors());
const SourceManager &SM = Ctx.getSourceManager();
ASTDumper Dumper(OS, Ctx, SM.getDiagnostics().getShowColors());
Dumper.SetTraversalKind(QS.TK);
Dumper.Visit(BI->second);
OS << "\n";
Expand Down
21 changes: 0 additions & 21 deletions clang-tools-extra/clang-query/tool/ClangQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ using namespace llvm;
static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
static cl::OptionCategory ClangQueryCategory("clang-query options");

static cl::opt<bool>
UseColor("use-color",
cl::desc(
R"(Use colors in detailed AST output. If not set, colors
will be used if the terminal connected to
standard output supports colors.)"),
cl::init(false), cl::cat(ClangQueryCategory));

static cl::list<std::string> Commands("c", cl::desc("Specify command to run"),
cl::value_desc("command"),
cl::cat(ClangQueryCategory));
Expand Down Expand Up @@ -117,19 +109,6 @@ int main(int argc, const char **argv) {

ClangTool Tool(OptionsParser->getCompilations(),
OptionsParser->getSourcePathList());

if (UseColor.getNumOccurrences() > 0) {
ArgumentsAdjuster colorAdjustor = [](const CommandLineArguments &Args, StringRef /*unused*/) {
CommandLineArguments AdjustedArgs = Args;
if (UseColor)
AdjustedArgs.push_back("-fdiagnostics-color");
else
AdjustedArgs.push_back("-fno-diagnostics-color");
return AdjustedArgs;
};
Tool.appendArgumentsAdjuster(colorAdjustor);
}

std::vector<std::unique_ptr<ASTUnit>> ASTs;
int ASTStatus = 0;
switch (Tool.buildASTs(ASTs)) {
Expand Down
38 changes: 6 additions & 32 deletions clang-tools-extra/clangd/ClangdLSPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,6 @@ class ClangdLSPServer::MessageHandler : public Transport::MessageHandler {
};
}

template <typename Result>
void bind(const char *Method,
void (ClangdLSPServer::*Handler)(Callback<Result>)) {
Calls[Method] = [Handler, this](llvm::json::Value RawParams,
ReplyOnce Reply) {
(Server.*Handler)(std::move(Reply));
};
}

// Bind a reply callback to a request. The callback will be invoked when
// clangd receives the reply from the LSP client.
// Return a call id of the request.
Expand Down Expand Up @@ -310,12 +301,6 @@ class ClangdLSPServer::MessageHandler : public Transport::MessageHandler {
};
}

void bind(const char *Method, void (ClangdLSPServer::*Handler)()) {
Notifications[Method] = [Handler, this](llvm::json::Value RawParams) {
(Server.*Handler)();
};
}

private:
// Function object to reply to an LSP call.
// Each instance must be called exactly once, otherwise:
Expand Down Expand Up @@ -458,14 +443,6 @@ class ClangdLSPServer::MessageHandler : public Transport::MessageHandler {
};
constexpr int ClangdLSPServer::MessageHandler::MaxReplayCallbacks;

template <>
void ClangdLSPServer::MessageHandler::bind<NoParams>(
const char *Method, void (ClangdLSPServer::*Handler)(const NoParams &)) {
Notifications[Method] = [Handler, this](llvm::json::Value RawParams) {
(Server.*Handler)(NoParams{});
};
}

// call(), notify(), and reply() wrap the Transport, adding logging and locking.
void ClangdLSPServer::callRaw(StringRef Method, llvm::json::Value Params,
Callback<llvm::json::Value> CB) {
Expand Down Expand Up @@ -510,11 +487,6 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
"semanticTokens request, choosing the latter (no notifications).");
Opts.TheiaSemanticHighlighting = false;
}
if (Opts.TheiaSemanticHighlighting) {
log("Using legacy semanticHighlights notification, which will be removed "
"in clangd 13. Clients should use the standard semanticTokens "
"request instead.");
}

if (Params.rootUri && *Params.rootUri)
Opts.WorkspaceRoot = std::string(Params.rootUri->file());
Expand All @@ -528,7 +500,6 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
if (Opts.UseDirBasedCDB) {
DirectoryBasedGlobalCompilationDatabase::Options CDBOpts(TFS);
CDBOpts.CompileCommandsDir = Opts.CompileCommandsDir;
CDBOpts.ContextProvider = Opts.ContextProvider;
BaseCDB =
std::make_unique<DirectoryBasedGlobalCompilationDatabase>(CDBOpts);
BaseCDB = getQueryDriverDatabase(llvm::makeArrayRef(Opts.QueryDriverGlobs),
Expand Down Expand Up @@ -676,15 +647,17 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,

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

void ClangdLSPServer::onShutdown(Callback<std::nullptr_t> Reply) {
void ClangdLSPServer::onShutdown(const ShutdownParams &Params,
Callback<std::nullptr_t> Reply) {
// Do essentially nothing, just say we're ready to exit.
ShutdownRequestReceived = true;
Reply(nullptr);
}

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

void ClangdLSPServer::onMemoryUsage(Callback<MemoryTree> Reply) {
void ClangdLSPServer::onMemoryUsage(const NoParams &,
Callback<MemoryTree> Reply) {
llvm::BumpPtrAllocator DetailAlloc;
MemoryTree MT(&DetailAlloc);
profile(MT);
Expand Down
6 changes: 3 additions & 3 deletions clang-tools-extra/clangd/ClangdLSPServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
// Calls have signature void(const Params&, Callback<Response>).
void onInitialize(const InitializeParams &, Callback<llvm::json::Value>);
void onInitialized(const InitializedParams &);
void onShutdown(Callback<std::nullptr_t>);
void onSync(Callback<std::nullptr_t>);
void onShutdown(const ShutdownParams &, Callback<std::nullptr_t>);
void onSync(const NoParams &, Callback<std::nullptr_t>);
void onDocumentDidOpen(const DidOpenTextDocumentParams &);
void onDocumentDidChange(const DidChangeTextDocumentParams &);
void onDocumentDidClose(const DidCloseTextDocumentParams &);
Expand Down Expand Up @@ -161,7 +161,7 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
Callback<SemanticTokensOrDelta>);
/// This is a clangd extension. Provides a json tree representing memory usage
/// hierarchy.
void onMemoryUsage(Callback<MemoryTree>);
void onMemoryUsage(const NoParams &, Callback<MemoryTree>);

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

Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/ClangdServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ void ClangdServer::formatOnType(PathRef File, llvm::StringRef Code,
Result.push_back(replacementToEdit(Code, R));
return CB(Result);
};
WorkScheduler.runQuick("FormatOnType", File, std::move(Action));
WorkScheduler.run("FormatOnType", File, std::move(Action));
}

void ClangdServer::prepareRename(PathRef File, Position Pos,
Expand Down Expand Up @@ -635,7 +635,7 @@ void ClangdServer::formatCode(PathRef File, llvm::StringRef Code,
tooling::calculateRangesAfterReplacements(IncludeReplaces, Ranges),
File)));
};
WorkScheduler.runQuick("Format", File, std::move(Action));
WorkScheduler.run("Format", File, std::move(Action));
}

void ClangdServer::findDocumentHighlights(
Expand Down
4 changes: 1 addition & 3 deletions clang-tools-extra/clangd/CodeComplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,9 +1123,7 @@ bool semaCodeComplete(std::unique_ptr<CodeCompleteConsumer> Consumer,
// skip all includes in this case; these completions are really simple.
PreambleBounds PreambleRegion =
ComputePreambleBounds(*CI->getLangOpts(), *ContentsBuffer, 0);
bool CompletingInPreamble = Input.Offset < PreambleRegion.Size ||
(!PreambleRegion.PreambleEndsAtStartOfLine &&
Input.Offset == PreambleRegion.Size);
bool CompletingInPreamble = PreambleRegion.Size > Input.Offset;
if (Input.Patch)
Input.Patch->apply(*CI);
// NOTE: we must call BeginSourceFile after prepareCompilerInstance. Otherwise
Expand Down
32 changes: 9 additions & 23 deletions clang-tools-extra/clangd/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringSet.h"
#include <string>
#include <vector>

Expand All @@ -52,19 +51,11 @@ struct Config {
Config(Config &&) = default;
Config &operator=(Config &&) = default;

struct CDBSearchSpec {
enum { Ancestors, FixedDir, NoCDBSearch } Policy = Ancestors;
// Absolute, native slashes, no trailing slash.
llvm::Optional<std::string> FixedCDBPath;
};

/// Controls how the compile command for the current file is determined.
struct {
/// Edits to apply to the compile command, in sequence.
// Edits to apply to the compile command, in sequence.
std::vector<llvm::unique_function<void(std::vector<std::string> &) const>>
Edits;
/// Where to search for compilation databases for this file's flags.
CDBSearchSpec CDBSearch = {CDBSearchSpec::Ancestors, llvm::None};
} CompileFlags;

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

/// Controls warnings and errors when parsing code.
struct {
bool SuppressAll = false;
llvm::StringSet<> Suppress;

/// Configures what clang-tidy checks to run and options to use with them.
struct {
// A comma-seperated list of globs specify which clang-tidy checks to run.
std::string Checks;
llvm::StringMap<std::string> CheckOptions;
} ClangTidy;
} Diagnostics;

/// Style of the codebase.
struct {
// Namespaces that should always be fully qualified, meaning no "using"
// declarations, always spell out the whole name (with or without leading
// ::). All nested namespaces are affected as well.
std::vector<std::string> FullyQualifiedNamespaces;
} Style;

/// Configures what clang-tidy checks to run and options to use with them.
struct {
// A comma-seperated list of globs to specify which clang-tidy checks to
// run.
std::string Checks;
llvm::StringMap<std::string> CheckOptions;
} ClangTidy;
};

} // namespace clangd
Expand Down
67 changes: 6 additions & 61 deletions clang-tools-extra/clangd/ConfigCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "Config.h"
#include "ConfigFragment.h"
#include "ConfigProvider.h"
#include "Diagnostics.h"
#include "Features.inc"
#include "TidyProvider.h"
#include "support/Logger.h"
Expand Down Expand Up @@ -188,7 +187,7 @@ struct FragmentCompiler {
compile(std::move(F.If));
compile(std::move(F.CompileFlags));
compile(std::move(F.Index));
compile(std::move(F.Diagnostics));
compile(std::move(F.ClangTidy));
}

void compile(Fragment::IfBlock &&F) {
Expand Down Expand Up @@ -262,36 +261,6 @@ struct FragmentCompiler {
});
});
}

if (F.CompilationDatabase) {
llvm::Optional<Config::CDBSearchSpec> Spec;
if (**F.CompilationDatabase == "Ancestors") {
Spec.emplace();
Spec->Policy = Config::CDBSearchSpec::Ancestors;
} else if (**F.CompilationDatabase == "None") {
Spec.emplace();
Spec->Policy = Config::CDBSearchSpec::NoCDBSearch;
} else {
if (auto Path =
makeAbsolute(*F.CompilationDatabase, "CompilationDatabase",
llvm::sys::path::Style::native)) {
// Drop trailing slash to put the path in canonical form.
// Should makeAbsolute do this?
llvm::StringRef Rel = llvm::sys::path::relative_path(*Path);
if (!Rel.empty() && llvm::sys::path::is_separator(Rel.back()))
Path->pop_back();

Spec.emplace();
Spec->Policy = Config::CDBSearchSpec::FixedDir;
Spec->FixedCDBPath = std::move(Path);
}
}
if (Spec)
Out.Apply.push_back(
[Spec(std::move(*Spec))](const Params &, Config &C) {
C.CompileFlags.CDBSearch = Spec;
});
}
}

void compile(Fragment::IndexBlock &&F) {
Expand Down Expand Up @@ -359,29 +328,6 @@ struct FragmentCompiler {
});
}

void compile(Fragment::DiagnosticsBlock &&F) {
std::vector<llvm::StringRef> Normalized;
for (const auto &Suppressed : F.Suppress) {
if (*Suppressed == "*") {
Out.Apply.push_back([&](const Params &, Config &C) {
C.Diagnostics.SuppressAll = true;
C.Diagnostics.Suppress.clear();
});
return;
}
Normalized.push_back(normalizeSuppressedCode(*Suppressed));
}
if (!Normalized.empty())
Out.Apply.push_back([Normalized](const Params &, Config &C) {
if (C.Diagnostics.SuppressAll)
return;
for (llvm::StringRef N : Normalized)
C.Diagnostics.Suppress.insert(N);
});

compile(std::move(F.ClangTidy));
}

void compile(Fragment::StyleBlock &&F) {
if (!F.FullyQualifiedNamespaces.empty()) {
std::vector<std::string> FullyQualifiedNamespaces;
Expand Down Expand Up @@ -423,7 +369,7 @@ struct FragmentCompiler {
CurSpec += Str;
}

void compile(Fragment::DiagnosticsBlock::ClangTidyBlock &&F) {
void compile(Fragment::ClangTidyBlock &&F) {
std::string Checks;
for (auto &CheckGlob : F.Add)
appendTidyCheckSpec(Checks, CheckGlob, true);
Expand All @@ -434,9 +380,8 @@ struct FragmentCompiler {
if (!Checks.empty())
Out.Apply.push_back(
[Checks = std::move(Checks)](const Params &, Config &C) {
C.Diagnostics.ClangTidy.Checks.append(
Checks,
C.Diagnostics.ClangTidy.Checks.empty() ? /*skip comma*/ 1 : 0,
C.ClangTidy.Checks.append(
Checks, C.ClangTidy.Checks.empty() ? /*skip comma*/ 1 : 0,
std::string::npos);
});
if (!F.CheckOptions.empty()) {
Expand All @@ -447,8 +392,8 @@ struct FragmentCompiler {
Out.Apply.push_back(
[CheckOptions = std::move(CheckOptions)](const Params &, Config &C) {
for (auto &StringPair : CheckOptions)
C.Diagnostics.ClangTidy.CheckOptions.insert_or_assign(
StringPair.first, StringPair.second);
C.ClangTidy.CheckOptions.insert_or_assign(StringPair.first,
StringPair.second);
});
}
}
Expand Down
Loading