You've already forked linux-packaging-mono
acceptance-tests
data
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
change-namespace
clang-apply-replacements
clang-move
clang-query
clang-reorder-fields
clang-tidy
clang-tidy-vs
clangd
clients
fuzzer
global-symbol-builder
index
tool
CMakeLists.txt
ClangdLSPServer.cpp
ClangdLSPServer.h
ClangdServer.cpp
ClangdServer.h
ClangdUnit.cpp
ClangdUnit.h
ClangdUnitStore.cpp
ClangdUnitStore.h
CodeComplete.cpp
CodeComplete.h
CodeCompletionStrings.cpp
CodeCompletionStrings.h
Compiler.cpp
Compiler.h
Context.cpp
Context.h
DraftStore.cpp
DraftStore.h
Function.h
FuzzyMatch.cpp
FuzzyMatch.h
GlobalCompilationDatabase.cpp
GlobalCompilationDatabase.h
JSONExpr.cpp
JSONExpr.h
JSONRPCDispatcher.cpp
JSONRPCDispatcher.h
Logger.cpp
Logger.h
Path.h
Protocol.cpp
Protocol.h
ProtocolHandlers.cpp
ProtocolHandlers.h
SourceCode.cpp
SourceCode.h
Trace.cpp
Trace.h
XRefs.cpp
XRefs.h
docs
include-fixer
modularize
pp-trace
test
tool-template
unittests
.arcconfig
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
LICENSE.TXT
README.txt
compiler-rt
libcxx
libcxxabi
libunwind
lld
lldb
llvm
openmp
polly
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mk
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
88 lines
2.8 KiB
C
88 lines
2.8 KiB
C
![]() |
//===--- GlobalCompilationDatabase.h ----------------------------*- C++-*-===//
|
||
|
//
|
||
|
// The LLVM Compiler Infrastructure
|
||
|
//
|
||
|
// This file is distributed under the University of Illinois Open Source
|
||
|
// License. See LICENSE.TXT for details.
|
||
|
//
|
||
|
//===---------------------------------------------------------------------===//
|
||
|
|
||
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H
|
||
|
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_GLOBALCOMPILATIONDATABASE_H
|
||
|
|
||
|
#include "Path.h"
|
||
|
#include "llvm/ADT/StringMap.h"
|
||
|
#include <memory>
|
||
|
#include <mutex>
|
||
|
#include <vector>
|
||
|
|
||
|
namespace clang {
|
||
|
|
||
|
namespace tooling {
|
||
|
class CompilationDatabase;
|
||
|
struct CompileCommand;
|
||
|
} // namespace tooling
|
||
|
|
||
|
namespace clangd {
|
||
|
|
||
|
class Logger;
|
||
|
|
||
|
/// Provides compilation arguments used for parsing C and C++ files.
|
||
|
class GlobalCompilationDatabase {
|
||
|
public:
|
||
|
virtual ~GlobalCompilationDatabase() = default;
|
||
|
|
||
|
/// If there are any known-good commands for building this file, returns one.
|
||
|
virtual llvm::Optional<tooling::CompileCommand>
|
||
|
getCompileCommand(PathRef File) const = 0;
|
||
|
|
||
|
/// Makes a guess at how to build a file.
|
||
|
/// The default implementation just runs clang on the file.
|
||
|
/// Clangd should treat the results as unreliable.
|
||
|
virtual tooling::CompileCommand getFallbackCommand(PathRef File) const;
|
||
|
|
||
|
/// FIXME(ibiryukov): add facilities to track changes to compilation flags of
|
||
|
/// existing targets.
|
||
|
};
|
||
|
|
||
|
/// Gets compile args from tooling::CompilationDatabases built for parent
|
||
|
/// directories.
|
||
|
class DirectoryBasedGlobalCompilationDatabase
|
||
|
: public GlobalCompilationDatabase {
|
||
|
public:
|
||
|
DirectoryBasedGlobalCompilationDatabase(
|
||
|
llvm::Optional<Path> CompileCommandsDir);
|
||
|
|
||
|
/// Scans File's parents looking for compilation databases.
|
||
|
/// Any extra flags will be added.
|
||
|
llvm::Optional<tooling::CompileCommand>
|
||
|
getCompileCommand(PathRef File) const override;
|
||
|
|
||
|
/// Uses the default fallback command, adding any extra flags.
|
||
|
tooling::CompileCommand getFallbackCommand(PathRef File) const override;
|
||
|
|
||
|
/// Sets the extra flags that should be added to a file.
|
||
|
void setExtraFlagsForFile(PathRef File, std::vector<std::string> ExtraFlags);
|
||
|
|
||
|
private:
|
||
|
tooling::CompilationDatabase *getCDBForFile(PathRef File) const;
|
||
|
tooling::CompilationDatabase *getCDBInDirLocked(PathRef File) const;
|
||
|
void addExtraFlags(PathRef File, tooling::CompileCommand &C) const;
|
||
|
|
||
|
mutable std::mutex Mutex;
|
||
|
/// Caches compilation databases loaded from directories(keys are
|
||
|
/// directories).
|
||
|
mutable llvm::StringMap<std::unique_ptr<clang::tooling::CompilationDatabase>>
|
||
|
CompilationDatabases;
|
||
|
|
||
|
/// Stores extra flags per file.
|
||
|
llvm::StringMap<std::vector<std::string>> ExtraFlagsForFile;
|
||
|
/// Used for command argument pointing to folder where compile_commands.json
|
||
|
/// is located.
|
||
|
llvm::Optional<Path> CompileCommandsDir;
|
||
|
};
|
||
|
} // namespace clangd
|
||
|
} // namespace clang
|
||
|
|
||
|
#endif
|