summaryrefslogtreecommitdiff
path: root/clang-tools-extra/clangd/ConfigCompile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/ConfigCompile.cpp')
-rw-r--r--clang-tools-extra/clangd/ConfigCompile.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/clang-tools-extra/clangd/ConfigCompile.cpp b/clang-tools-extra/clangd/ConfigCompile.cpp
index a5745727dca7..31beb6ac10cb 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -101,6 +101,7 @@ struct FragmentCompiler {
llvm::SourceMgr *SourceMgr;
// Normalized Fragment::SourceInfo::Directory.
std::string FragmentDirectory;
+ bool Trusted = false;
llvm::Optional<llvm::Regex>
compileRegex(const Located<std::string> &Text,
@@ -183,6 +184,7 @@ struct FragmentCompiler {
}
void compile(Fragment &&F) {
+ Trusted = F.Source.Trusted;
if (!F.Source.Directory.empty()) {
FragmentDirectory = llvm::sys::path::convert_to_slash(F.Source.Directory);
if (FragmentDirectory.back() != '/')
@@ -320,6 +322,13 @@ struct FragmentCompiler {
void compile(Fragment::IndexBlock::ExternalBlock &&External,
llvm::SMRange BlockRange) {
+ if (External.Server && !Trusted) {
+ diag(Error,
+ "Remote index may not be specified by untrusted configuration. "
+ "Copy this into user config to use it.",
+ External.Server->Range);
+ return;
+ }
#ifndef CLANGD_ENABLE_REMOTE
if (External.Server) {
elog("Clangd isn't compiled with remote index support, ignoring Server: "
@@ -510,8 +519,8 @@ CompiledFragment Fragment::compile(DiagnosticCallback D) && {
trace::Span Tracer("ConfigCompile");
SPAN_ATTACH(Tracer, "ConfigFile", ConfigFile);
auto Result = std::make_shared<CompiledFragmentImpl>();
- vlog("Config fragment: compiling {0}:{1} -> {2}", ConfigFile, LineCol.first,
- Result.get());
+ vlog("Config fragment: compiling {0}:{1} -> {2} (trusted={3})", ConfigFile,
+ LineCol.first, Result.get(), Source.Trusted);
FragmentCompiler{*Result, D, Source.Manager.get()}.compile(std::move(*this));
// Return as cheaply-copyable wrapper.