clang-tools  7.0.0
Enumerations | Functions
ClangdMain.cpp File Reference
#include "ClangdLSPServer.h"
#include "JSONRPCDispatcher.h"
#include "Path.h"
#include "Trace.h"
#include "index/SymbolYAML.h"
#include "clang/Basic/Version.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdlib>
#include <iostream>
#include <memory>
#include <string>
#include <thread>
Include dependency graph for ClangdMain.cpp:

Go to the source code of this file.

Enumerations

enum  PCHStorageFlag
 
enum  CompletionStyleFlag { Detailed, Bundled }
 

Functions

static llvm::cl::opt< PathCompileCommandsDir ("compile-commands-dir", llvm::cl::desc("Specify a path to look for compile_commands.json. If path " "is invalid, clangd will look in the current directory and " "parent paths of each source file."))
 
static llvm::cl::opt< unsigned > WorkerThreadsCount ("j", llvm::cl::desc("Number of async workers used by clangd"), llvm::cl::init(getDefaultAsyncThreadsCount()))
 
static llvm::cl::opt< CompletionStyleFlagCompletionStyle ("completion-style", llvm::cl::desc("Granularity of code completion suggestions"), llvm::cl::values(clEnumValN(Detailed, "detailed", "One completion item for each semantically distinct " "completion, with full type information."), clEnumValN(Bundled, "bundled", "Similar completion items (e.g. function overloads) are " "combined. Type information shown where possible.")), llvm::cl::init(Detailed))
 
static llvm::cl::opt< bool > IncludeIneligibleResults ("include-ineligible-results", llvm::cl::desc("Include ineligible completion results (e.g. private members)"), llvm::cl::init(clangd::CodeCompleteOptions().IncludeIneligibleResults), llvm::cl::Hidden)
 
static llvm::cl::opt< JSONStreamStyleInputStyle ("input-style", llvm::cl::desc("Input JSON stream encoding"), llvm::cl::values(clEnumValN(JSONStreamStyle::Standard, "standard", "usual LSP protocol"), clEnumValN(JSONStreamStyle::Delimited, "delimited", "messages delimited by --- lines, with # comment support")), llvm::cl::init(JSONStreamStyle::Standard))
 
static llvm::cl::opt< bool > PrettyPrint ("pretty", llvm::cl::desc("Pretty-print JSON output"), llvm::cl::init(false))
 
static llvm::cl::opt< Logger::LevelLogLevel ("log", llvm::cl::desc("Verbosity of log messages written to stderr"), llvm::cl::values(clEnumValN(Logger::Error, "error", "Error messages only"), clEnumValN(Logger::Info, "info", "High level execution tracing"), clEnumValN(Logger::Debug, "verbose", "Low level details")), llvm::cl::init(Logger::Info))
 
static llvm::cl::opt< bool > Test ("lit-test", llvm::cl::desc("Abbreviation for -input-style=delimited -pretty -run-synchronously. " "Intended to simplify lit tests."), llvm::cl::init(false), llvm::cl::Hidden)
 
static llvm::cl::opt< PCHStorageFlagPCHStorage ("pch-storage", llvm::cl::desc("Storing PCHs in memory increases memory usages, but may " "improve performance"), llvm::cl::values(clEnumValN(PCHStorageFlag::Disk, "disk", "store PCHs on disk"), clEnumValN(PCHStorageFlag::Memory, "memory", "store PCHs in memory")), llvm::cl::init(PCHStorageFlag::Disk))
 
static llvm::cl::opt< int > LimitResults ("limit-results", llvm::cl::desc("Limit the number of results returned by clangd. " "0 means no limit."), llvm::cl::init(100))
 
static llvm::cl::opt< bool > RunSynchronously ("run-synchronously", llvm::cl::desc("Parse on main thread. If set, -j is ignored"), llvm::cl::init(false), llvm::cl::Hidden)
 
static llvm::cl::opt< PathResourceDir ("resource-dir", llvm::cl::desc("Directory for system clang headers"), llvm::cl::init(""), llvm::cl::Hidden)
 
static llvm::cl::opt< PathInputMirrorFile ("input-mirror-file", llvm::cl::desc("Mirror all LSP input to the specified file. Useful for debugging."), llvm::cl::init(""), llvm::cl::Hidden)
 
static llvm::cl::opt< bool > EnableIndex ("index", llvm::cl::desc("Enable index-based features such as global code completion " "and searching for symbols." "Clang uses an index built from symbols in opened files"), llvm::cl::init(true))
 
static llvm::cl::opt< bool > ShowOrigins ("debug-origin", llvm::cl::desc("Show origins of completion items"), llvm::cl::init(clangd::CodeCompleteOptions().ShowOrigins), llvm::cl::Hidden)
 
static llvm::cl::opt< bool > HeaderInsertionDecorators ("header-insertion-decorators", llvm::cl::desc("Prepend a circular dot or space before the completion " "label, depending on wether " "an include line will be inserted or not."), llvm::cl::init(true))
 
static llvm::cl::opt< PathYamlSymbolFile ("yaml-symbol-file", llvm::cl::desc("YAML-format global symbol file to build the static index. Clangd will " "use the static index for global code completion.\ "WARNING:This option is experimental only, and will be removed " "eventually. Don 't rely on it."), llvm::cl::init(""), llvm::cl::Hidden)
 
int main (int argc, char *argv[])
 

Enumeration Type Documentation

◆ CompletionStyleFlag

Enumerator
Detailed 
Bundled 

Definition at line 64 of file ClangdMain.cpp.

◆ PCHStorageFlag

enum PCHStorageFlag
strong

Definition at line 32 of file ClangdMain.cpp.

Function Documentation

◆ CompileCommandsDir()

static llvm::cl::opt<Path> CompileCommandsDir ( "compile-commands-dir"  ,
llvm::cl::desc("Specify a path to look for compile_commands.json. If path " "is invalid, clangd will look in the current directory and " "parent paths of each source file.")   
)
static

◆ CompletionStyle()

static llvm::cl::opt<CompletionStyleFlag> CompletionStyle ( "completion-style"  ,
llvm::cl::desc("Granularity of code completion suggestions")  ,
llvm::cl::values(clEnumValN(Detailed, "detailed", "One completion item for each semantically distinct " "completion, with full type information."), clEnumValN(Bundled, "bundled", "Similar completion items (e.g. function overloads) are " "combined. Type information shown where possible."))  ,
llvm::cl::init(Detailed  
)
static

◆ EnableIndex()

static llvm::cl::opt<bool> EnableIndex ( "index"  ,
llvm::cl::desc("Enable index-based features such as global code completion " "and searching for symbols." "Clang uses an index built from symbols in opened files")  ,
llvm::cl::init(true)   
)
static

◆ HeaderInsertionDecorators()

static llvm::cl::opt<bool> HeaderInsertionDecorators ( "header-insertion-decorators"  ,
llvm::cl::desc("Prepend a circular dot or space before the completion " "label, depending on wether " "an include line will be inserted or not.")  ,
llvm::cl::init(true)   
)
static

◆ IncludeIneligibleResults()

static llvm::cl::opt<bool> IncludeIneligibleResults ( "include-ineligible-results"  ,
llvm::cl::desc("Include ineligible completion results (e.g. private members)")  ,
llvm::cl::init(clangd::CodeCompleteOptions().IncludeIneligibleResults)  ,
llvm::cl::Hidden   
)
static

◆ InputMirrorFile()

static llvm::cl::opt<Path> InputMirrorFile ( "input-mirror-file"  ,
llvm::cl::desc("Mirror all LSP input to the specified file. Useful for debugging.")  ,
llvm::cl::init("")  ,
llvm::cl::Hidden   
)
static

Referenced by main().

◆ InputStyle()

static llvm::cl::opt<JSONStreamStyle> InputStyle ( "input-style"  ,
llvm::cl::desc("Input JSON stream encoding")  ,
llvm::cl::values(clEnumValN(JSONStreamStyle::Standard, "standard", "usual LSP protocol"), clEnumValN(JSONStreamStyle::Delimited, "delimited", "messages delimited by --- lines, with # comment support"))  ,
llvm::cl::init(JSONStreamStyle::Standard)   
)
static

Referenced by main().

◆ LimitResults()

static llvm::cl::opt<int> LimitResults ( "limit-results"  ,
llvm::cl::desc("Limit the number of results returned by clangd. " "0 means no limit.")  ,
llvm::cl::init(100)   
)
static

◆ LogLevel()

static llvm::cl::opt<Logger::Level> LogLevel ( "log"  ,
llvm::cl::desc("Verbosity of log messages written to stderr")  ,
llvm::cl::values(clEnumValN(Logger::Error, "error", "Error messages only"), clEnumValN(Logger::Info, "info", "High level execution tracing"), clEnumValN(Logger::Debug, "verbose", "Low level details"))  ,
llvm::cl::init(Logger::Info  
)
static

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ PCHStorage()

static llvm::cl::opt<PCHStorageFlag> PCHStorage ( "pch-storage"  ,
llvm::cl::desc("Storing PCHs in memory increases memory usages, but may " "improve performance")  ,
llvm::cl::values(clEnumValN(PCHStorageFlag::Disk, "disk", "store PCHs on disk"), clEnumValN(PCHStorageFlag::Memory, "memory", "store PCHs in memory"))  ,
llvm::cl::init(PCHStorageFlag::Disk)   
)
static

◆ PrettyPrint()

static llvm::cl::opt<bool> PrettyPrint ( "pretty"  ,
llvm::cl::desc("Pretty-print JSON output")  ,
llvm::cl::init(false)   
)
static

Referenced by main().

◆ ResourceDir()

static llvm::cl::opt<Path> ResourceDir ( "resource-dir"  ,
llvm::cl::desc("Directory for system clang headers")  ,
llvm::cl::init("")  ,
llvm::cl::Hidden   
)
static

◆ RunSynchronously()

static llvm::cl::opt<bool> RunSynchronously ( "run-synchronously"  ,
llvm::cl::desc("Parse on main thread. If set, -j is ignored")  ,
llvm::cl::init(false)  ,
llvm::cl::Hidden   
)
static

Referenced by main().

◆ ShowOrigins()

static llvm::cl::opt<bool> ShowOrigins ( "debug-origin"  ,
llvm::cl::desc("Show origins of completion items")  ,
llvm::cl::init(clangd::CodeCompleteOptions().ShowOrigins)  ,
llvm::cl::Hidden   
)
static

◆ Test()

static llvm::cl::opt<bool> Test ( "lit-test"  ,
llvm::cl::desc("Abbreviation for -input-style=delimited -pretty -run-synchronously. " "Intended to simplify lit tests.")  ,
llvm::cl::init(false)  ,
llvm::cl::Hidden   
)
static

Referenced by main().

◆ WorkerThreadsCount()

static llvm::cl::opt<unsigned> WorkerThreadsCount ( "j"  ,
llvm::cl::desc("Number of async workers used by clangd")  ,
llvm::cl::init(getDefaultAsyncThreadsCount())   
)
static

Referenced by main().

◆ YamlSymbolFile()

static llvm::cl::opt<Path> YamlSymbolFile ( "yaml-symbol-file"  ,
llvm::cl::desc("YAML-format global symbol file to build the static index. Clangd will " "use the static index for global code completion.\"WARNING:This option is experimental only, and will be removed " "eventually. Don 't rely on it.")  ,
llvm::cl::init("")  ,
llvm::cl::Hidden   
)
static