[clangd] Provide help text to users who run `clangd` in a terminal.

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65201

llvm-svn: 366992
This commit is contained in:
Sam McCall 2019-07-25 08:00:54 +00:00
parent 8faffec4e2
commit 85d2fe7861
1 changed files with 5 additions and 0 deletions

View File

@ -515,6 +515,11 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
if (Tracer)
TracingSession.emplace(*Tracer);
// If a user ran `clangd` in a terminal without redirecting anything,
// it's somewhat likely they're confused about how to use clangd.
// Show them the help overview, which explains.
if (llvm::outs().is_displayed() && llvm::errs().is_displayed())
llvm::errs() << Overview << "\n";
// Use buffered stream to stderr (we still flush each log message). Unbuffered
// stream can cause significant (non-deterministic) latency for the logger.
llvm::errs().SetBuffered();