Skip to content

Commit 42a9539

Browse files
Merge from 'master' to 'sycl-web' (#2)
CONFLICT (content): Merge conflict in libclc/r600/libspirv/workitem/get_work_dim.cl CONFLICT (modify/delete): libclc/r600/lib/workitem/get_num_groups.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/r600/lib/workitem/get_num_groups.cl left in tree. CONFLICT (modify/delete): libclc/r600/lib/workitem/get_local_size.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/r600/lib/workitem/get_local_size.cl left in tree. CONFLICT (modify/delete): libclc/r600/lib/workitem/get_local_id.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/r600/lib/workitem/get_local_id.cl left in tree. CONFLICT (modify/delete): libclc/r600/lib/workitem/get_group_id.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/r600/lib/workitem/get_group_id.cl left in tree. CONFLICT (modify/delete): libclc/r600/lib/workitem/get_global_size.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/r600/lib/workitem/get_global_size.cl left in tree. CONFLICT (modify/delete): libclc/r600/lib/workitem/get_global_offset.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/r600/lib/workitem/get_global_offset.cl left in tree. CONFLICT (modify/delete): libclc/ptx-nvidiacl/lib/workitem/get_num_groups.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/ptx-nvidiacl/lib/workitem/get_num_groups.cl left in tree. CONFLICT (modify/delete): libclc/ptx-nvidiacl/lib/workitem/get_local_size.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/ptx-nvidiacl/lib/workitem/get_local_size.cl left in tree. CONFLICT (modify/delete): libclc/ptx-nvidiacl/lib/workitem/get_local_id.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/ptx-nvidiacl/lib/workitem/get_local_id.cl left in tree. CONFLICT (modify/delete): libclc/ptx-nvidiacl/lib/workitem/get_group_id.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/ptx-nvidiacl/lib/workitem/get_group_id.cl left in tree. CONFLICT (modify/delete): libclc/ptx-nvidiacl/lib/workitem/get_global_id.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/ptx-nvidiacl/lib/workitem/get_global_id.cl left in tree. CONFLICT (modify/delete): libclc/ptx-nvidiacl/lib/synchronization/barrier.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/ptx-nvidiacl/lib/synchronization/barrier.cl left in tree. CONFLICT (content): Merge conflict in libclc/generic/lib/workitem/get_global_size.cl CONFLICT (content): Merge conflict in libclc/generic/lib/workitem/get_global_id.cl CONFLICT (content): Merge conflict in libclc/generic/lib/async/wait_group_events.cl CONFLICT (modify/delete): libclc/amdgcn/lib/workitem/get_work_dim.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/amdgcn/lib/workitem/get_work_dim.cl left in tree. CONFLICT (modify/delete): libclc/amdgcn/lib/workitem/get_num_groups.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/amdgcn/lib/workitem/get_num_groups.cl left in tree. CONFLICT (modify/delete): libclc/amdgcn/lib/workitem/get_local_size.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/amdgcn/lib/workitem/get_local_size.cl left in tree. CONFLICT (modify/delete): libclc/amdgcn/lib/workitem/get_local_id.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/amdgcn/lib/workitem/get_local_id.cl left in tree. CONFLICT (modify/delete): libclc/amdgcn/lib/workitem/get_group_id.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/amdgcn/lib/workitem/get_group_id.cl left in tree. CONFLICT (modify/delete): libclc/amdgcn/lib/workitem/get_global_size.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/amdgcn/lib/workitem/get_global_size.cl left in tree. CONFLICT (modify/delete): libclc/amdgcn/lib/workitem/get_global_offset.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/amdgcn/lib/workitem/get_global_offset.cl left in tree. CONFLICT (modify/delete): libclc/amdgcn-amdhsa/lib/workitem/get_num_groups.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/amdgcn-amdhsa/lib/workitem/get_num_groups.cl left in tree. CONFLICT (modify/delete): libclc/amdgcn-amdhsa/lib/workitem/get_local_size.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/amdgcn-amdhsa/lib/workitem/get_local_size.cl left in tree. CONFLICT (modify/delete): libclc/amdgcn-amdhsa/lib/workitem/get_global_size.cl deleted in HEAD and modified in 3d21fa5. Version 3d21fa5 of libclc/amdgcn-amdhsa/lib/workitem/get_global_size.cl left in tree.
2 parents 8b7805c + 3d21fa5 commit 42a9539

File tree

1,196 files changed

+50067
-18016
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,196 files changed

+50067
-18016
lines changed

clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ AST_POLYMORPHIC_MATCHER(
5050
static const char *AbseilLibraries[] = {
5151
"algorithm", "base", "container", "debugging", "flags",
5252
"hash", "iterator", "memory", "meta", "numeric",
53-
"random", "strings", "synchronization", "time", "types",
54-
"utility"};
53+
"random", "strings", "synchronization", "status", "time",
54+
"types", "utility"};
5555
return std::any_of(
5656
std::begin(AbseilLibraries), std::end(AbseilLibraries),
5757
[&](const char *Library) { return Path.startswith(Library); });

clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ static bool hasAnyNestedLocalQualifiers(QualType Type) {
261261
}
262262

263263
SourceRange UseTrailingReturnTypeCheck::findReturnTypeAndCVSourceRange(
264-
const FunctionDecl &F, const ASTContext &Ctx, const SourceManager &SM,
265-
const LangOptions &LangOpts) {
264+
const FunctionDecl &F, const TypeLoc &ReturnLoc, const ASTContext &Ctx,
265+
const SourceManager &SM, const LangOptions &LangOpts) {
266266

267267
// We start with the range of the return type and expand to neighboring
268268
// qualifiers (const, volatile and restrict).
@@ -274,6 +274,35 @@ SourceRange UseTrailingReturnTypeCheck::findReturnTypeAndCVSourceRange(
274274
return {};
275275
}
276276

277+
// If the return type is a constrained 'auto' or 'decltype(auto)', we need to
278+
// include the tokens after the concept. Unfortunately, the source range of an
279+
// AutoTypeLoc, if it is constrained, does not include the 'auto' or
280+
// 'decltype(auto)'. If the return type is a plain 'decltype(...)', the
281+
// source range only contains the first 'decltype' token.
282+
auto ATL = ReturnLoc.getAs<AutoTypeLoc>();
283+
if ((ATL && (ATL.isConstrained() ||
284+
ATL.getAutoKeyword() == AutoTypeKeyword::DecltypeAuto)) ||
285+
ReturnLoc.getAs<DecltypeTypeLoc>()) {
286+
SourceLocation End =
287+
expandIfMacroId(ReturnLoc.getSourceRange().getEnd(), SM);
288+
SourceLocation BeginNameF = expandIfMacroId(F.getLocation(), SM);
289+
290+
// Extend the ReturnTypeRange until the last token before the function
291+
// name.
292+
std::pair<FileID, unsigned> Loc = SM.getDecomposedLoc(End);
293+
StringRef File = SM.getBufferData(Loc.first);
294+
const char *TokenBegin = File.data() + Loc.second;
295+
Lexer Lexer(SM.getLocForStartOfFile(Loc.first), LangOpts, File.begin(),
296+
TokenBegin, File.end());
297+
Token T;
298+
SourceLocation LastTLoc = End;
299+
while (!Lexer.LexFromRawLexer(T) &&
300+
SM.isBeforeInTranslationUnit(T.getLocation(), BeginNameF)) {
301+
LastTLoc = T.getLocation();
302+
}
303+
ReturnTypeRange.setEnd(LastTLoc);
304+
}
305+
277306
// If the return type has no local qualifiers, it's source range is accurate.
278307
if (!hasAnyNestedLocalQualifiers(F.getReturnType()))
279308
return ReturnTypeRange;
@@ -317,7 +346,7 @@ SourceRange UseTrailingReturnTypeCheck::findReturnTypeAndCVSourceRange(
317346
return ReturnTypeRange;
318347
}
319348

320-
bool UseTrailingReturnTypeCheck::keepSpecifiers(
349+
void UseTrailingReturnTypeCheck::keepSpecifiers(
321350
std::string &ReturnType, std::string &Auto, SourceRange ReturnTypeCVRange,
322351
const FunctionDecl &F, const FriendDecl *Fr, const ASTContext &Ctx,
323352
const SourceManager &SM, const LangOptions &LangOpts) {
@@ -327,14 +356,14 @@ bool UseTrailingReturnTypeCheck::keepSpecifiers(
327356
if (!F.isConstexpr() && !F.isInlineSpecified() &&
328357
F.getStorageClass() != SC_Extern && F.getStorageClass() != SC_Static &&
329358
!Fr && !(M && M->isVirtualAsWritten()))
330-
return true;
359+
return;
331360

332361
// Tokenize return type. If it contains macros which contain a mix of
333362
// qualifiers, specifiers and types, give up.
334363
llvm::Optional<SmallVector<ClassifiedToken, 8>> MaybeTokens =
335364
classifyTokensBeforeFunctionName(F, Ctx, SM, LangOpts);
336365
if (!MaybeTokens)
337-
return false;
366+
return;
338367

339368
// Find specifiers, remove them from the return type, add them to 'auto'.
340369
unsigned int ReturnTypeBeginOffset =
@@ -367,14 +396,12 @@ bool UseTrailingReturnTypeCheck::keepSpecifiers(
367396
ReturnType.erase(TOffsetInRT, TLengthWithWS);
368397
DeletedChars += TLengthWithWS;
369398
}
370-
371-
return true;
372399
}
373400

374401
void UseTrailingReturnTypeCheck::registerMatchers(MatchFinder *Finder) {
375-
auto F = functionDecl(unless(anyOf(hasTrailingReturn(), returns(voidType()),
376-
returns(autoType()), cxxConversionDecl(),
377-
cxxMethodDecl(isImplicit()))))
402+
auto F = functionDecl(
403+
unless(anyOf(hasTrailingReturn(), returns(voidType()),
404+
cxxConversionDecl(), cxxMethodDecl(isImplicit()))))
378405
.bind("Func");
379406

380407
Finder->addMatcher(F, this);
@@ -397,11 +424,17 @@ void UseTrailingReturnTypeCheck::check(const MatchFinder::MatchResult &Result) {
397424
if (F->getLocation().isInvalid())
398425
return;
399426

427+
// Skip functions which return just 'auto'.
428+
const auto *AT = F->getDeclaredReturnType()->getAs<AutoType>();
429+
if (AT != nullptr && !AT->isConstrained() &&
430+
AT->getKeyword() == AutoTypeKeyword::Auto &&
431+
!hasAnyNestedLocalQualifiers(F->getDeclaredReturnType()))
432+
return;
433+
400434
// TODO: implement those
401435
if (F->getDeclaredReturnType()->isFunctionPointerType() ||
402436
F->getDeclaredReturnType()->isMemberFunctionPointerType() ||
403-
F->getDeclaredReturnType()->isMemberPointerType() ||
404-
F->getDeclaredReturnType()->getAs<DecltypeType>() != nullptr) {
437+
F->getDeclaredReturnType()->isMemberPointerType()) {
405438
diag(F->getLocation(), Message);
406439
return;
407440
}
@@ -435,7 +468,7 @@ void UseTrailingReturnTypeCheck::check(const MatchFinder::MatchResult &Result) {
435468
// discards user formatting and order of const, volatile, type, whitespace,
436469
// space before & ... .
437470
SourceRange ReturnTypeCVRange =
438-
findReturnTypeAndCVSourceRange(*F, Ctx, SM, LangOpts);
471+
findReturnTypeAndCVSourceRange(*F, FTL.getReturnLoc(), Ctx, SM, LangOpts);
439472
if (ReturnTypeCVRange.isInvalid())
440473
return;
441474

clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ class UseTrailingReturnTypeCheck : public ClangTidyCheck {
5050
const SourceManager &SM,
5151
const LangOptions &LangOpts);
5252
SourceRange findReturnTypeAndCVSourceRange(const FunctionDecl &F,
53+
const TypeLoc &ReturnLoc,
5354
const ASTContext &Ctx,
5455
const SourceManager &SM,
5556
const LangOptions &LangOpts);
56-
bool keepSpecifiers(std::string &ReturnType, std::string &Auto,
57+
void keepSpecifiers(std::string &ReturnType, std::string &Auto,
5758
SourceRange ReturnTypeCVRange, const FunctionDecl &F,
5859
const FriendDecl *Fr, const ASTContext &Ctx,
5960
const SourceManager &SM, const LangOptions &LangOpts);

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 62 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "llvm/ADT/Optional.h"
4141
#include "llvm/ADT/STLExtras.h"
4242
#include "llvm/ADT/ScopeExit.h"
43+
#include "llvm/ADT/StringExtras.h"
4344
#include "llvm/ADT/StringRef.h"
4445
#include "llvm/Support/Errc.h"
4546
#include "llvm/Support/Error.h"
@@ -52,6 +53,7 @@
5253
#include <future>
5354
#include <memory>
5455
#include <mutex>
56+
#include <string>
5557
#include <type_traits>
5658

5759
namespace clang {
@@ -109,6 +111,41 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
109111
ClangdServer::Callbacks *ServerCallbacks;
110112
bool TheiaSemanticHighlighting;
111113
};
114+
115+
// Set of clang-tidy checks that don't work well in clangd, either due to
116+
// crashes or false positives.
117+
// Returns a clang-tidy filter string: -check1,-check2.
118+
llvm::StringRef getUnusableTidyChecks() {
119+
static const std::string FalsePositives =
120+
llvm::join_items(", ",
121+
// Check relies on seeing ifndef/define/endif directives,
122+
// clangd doesn't replay those when using a preamble.
123+
"-llvm-header-guard");
124+
static const std::string CrashingChecks =
125+
llvm::join_items(", ",
126+
// Check can choke on invalid (intermediate) c++ code,
127+
// which is often the case when clangd tries to build an
128+
// AST.
129+
"-bugprone-use-after-move");
130+
static const std::string UnusableTidyChecks =
131+
llvm::join_items(", ", FalsePositives, CrashingChecks);
132+
return UnusableTidyChecks;
133+
}
134+
135+
// Returns a clang-tidy options string: check1,check2.
136+
llvm::StringRef getDefaultTidyChecks() {
137+
// These default checks are chosen for:
138+
// - low false-positive rate
139+
// - providing a lot of value
140+
// - being reasonably efficient
141+
static const std::string DefaultChecks = llvm::join_items(
142+
",", "readability-misleading-indentation", "readability-deleted-default",
143+
"bugprone-integer-division", "bugprone-sizeof-expression",
144+
"bugprone-suspicious-missing-comma", "bugprone-unused-raii",
145+
"bugprone-unused-return-value", "misc-unused-using-decls",
146+
"misc-unused-alias-decls", "misc-definitions-in-headers");
147+
return DefaultChecks;
148+
}
112149
} // namespace
113150

114151
ClangdServer::Options ClangdServer::optsForTest() {
@@ -171,16 +208,20 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
171208
if (Opts.StaticIndex)
172209
AddIndex(Opts.StaticIndex);
173210
if (Opts.BackgroundIndex) {
211+
BackgroundIndex::Options BGOpts;
212+
BGOpts.ThreadPoolSize = std::max(Opts.AsyncThreadsCount, 1u);
213+
BGOpts.OnProgress = [Callbacks](BackgroundQueue::Stats S) {
214+
if (Callbacks)
215+
Callbacks->onBackgroundIndexProgress(S);
216+
};
217+
BGOpts.ContextProvider = [this](PathRef P) {
218+
return createProcessingContext(P);
219+
};
174220
BackgroundIdx = std::make_unique<BackgroundIndex>(
175-
Context::current().clone(), TFS, CDB,
221+
TFS, CDB,
176222
BackgroundIndexStorage::createDiskBackedStorageFactory(
177223
[&CDB](llvm::StringRef File) { return CDB.getProjectInfo(File); }),
178-
std::max(Opts.AsyncThreadsCount, 1u),
179-
[Callbacks](BackgroundQueue::Stats S) {
180-
if (Callbacks)
181-
Callbacks->onBackgroundIndexProgress(S);
182-
},
183-
[this](PathRef P) { return createProcessingContext(P); });
224+
std::move(BGOpts));
184225
AddIndex(BackgroundIdx.get());
185226
}
186227
if (DynamicIdx)
@@ -196,6 +237,15 @@ void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
196237
if (GetClangTidyOptions)
197238
Opts.ClangTidyOpts =
198239
GetClangTidyOptions(*TFS.view(/*CWD=*/llvm::None), File);
240+
if (Opts.ClangTidyOpts.Checks.hasValue()) {
241+
// If the set of checks was configured, make sure clangd incompatible ones
242+
// are disabled.
243+
Opts.ClangTidyOpts.Checks = llvm::join_items(
244+
", ", *Opts.ClangTidyOpts.Checks, getUnusableTidyChecks());
245+
} else {
246+
// Otherwise provide a nice set of defaults.
247+
Opts.ClangTidyOpts.Checks = getDefaultTidyChecks().str();
248+
}
199249
Opts.SuggestMissingIncludes = SuggestMissingIncludes;
200250

201251
// Compile command is set asynchronously during update, as it can be slow.
@@ -525,26 +575,6 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
525575
WorkScheduler.runWithAST("ApplyTweak", File, std::move(Action));
526576
}
527577

528-
void ClangdServer::dumpAST(PathRef File,
529-
llvm::unique_function<void(std::string)> Callback) {
530-
auto Action = [Callback = std::move(Callback)](
531-
llvm::Expected<InputsAndAST> InpAST) mutable {
532-
if (!InpAST) {
533-
llvm::consumeError(InpAST.takeError());
534-
return Callback("<no-ast>");
535-
}
536-
std::string Result;
537-
538-
llvm::raw_string_ostream ResultOS(Result);
539-
clangd::dumpAST(InpAST->AST, ResultOS);
540-
ResultOS.flush();
541-
542-
Callback(Result);
543-
};
544-
545-
WorkScheduler.runWithAST("DumpAST", File, std::move(Action));
546-
}
547-
548578
void ClangdServer::locateSymbolAt(PathRef File, Position Pos,
549579
Callback<std::vector<LocatedSymbol>> CB) {
550580
auto Action = [Pos, CB = std::move(CB),
@@ -754,6 +784,11 @@ void ClangdServer::semanticHighlights(
754784
TUScheduler::InvalidateOnUpdate);
755785
}
756786

787+
void ClangdServer::customAction(PathRef File, llvm::StringRef Name,
788+
Callback<InputsAndAST> Action) {
789+
WorkScheduler.runWithAST(Name, File, std::move(Action));
790+
}
791+
757792
llvm::StringMap<TUScheduler::FileStats> ClangdServer::fileStats() const {
758793
return WorkScheduler.fileStats();
759794
}

clang-tools-extra/clangd/ClangdServer.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,6 @@ class ClangdServer {
295295
void applyTweak(PathRef File, Range Sel, StringRef ID,
296296
Callback<Tweak::Effect> CB);
297297

298-
/// Only for testing purposes.
299-
/// Waits until all requests to worker thread are finished and dumps AST for
300-
/// \p File. \p File must be in the list of added documents.
301-
void dumpAST(PathRef File, llvm::unique_function<void(std::string)> Callback);
302298
/// Called when an event occurs for a watched file in the workspace.
303299
void onFileEvent(const DidChangeWatchedFilesParams &Params);
304300

@@ -317,6 +313,13 @@ class ClangdServer {
317313
void semanticHighlights(PathRef File,
318314
Callback<std::vector<HighlightingToken>>);
319315

316+
/// Runs an arbitrary action that has access to the AST of the specified file.
317+
/// The action will execute on one of ClangdServer's internal threads.
318+
/// The AST is only valid for the duration of the callback.
319+
/// As with other actions, the file must have been opened.
320+
void customAction(PathRef File, llvm::StringRef Name,
321+
Callback<InputsAndAST> Action);
322+
320323
/// Returns estimated memory usage and other statistics for each of the
321324
/// currently open files.
322325
/// Overall memory usage of clangd may be significantly more than reported

clang-tools-extra/clangd/ParsedAST.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,6 @@ class ReplayPreamble : private PPCallbacks {
238238

239239
} // namespace
240240

241-
void dumpAST(ParsedAST &AST, llvm::raw_ostream &OS) {
242-
AST.getASTContext().getTranslationUnitDecl()->dump(OS, true);
243-
}
244-
245241
llvm::Optional<ParsedAST>
246242
ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
247243
std::unique_ptr<clang::CompilerInvocation> CI,
@@ -428,15 +424,15 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
428424
CTFinder.matchAST(Clang->getASTContext());
429425
}
430426

427+
// XXX: This is messy: clang-tidy checks flush some diagnostics at EOF.
428+
// However Action->EndSourceFile() would destroy the ASTContext!
429+
// So just inform the preprocessor of EOF, while keeping everything alive.
430+
Clang->getPreprocessor().EndSourceFile();
431431
// UnitDiagsConsumer is local, we can not store it in CompilerInstance that
432432
// has a longer lifetime.
433433
Clang->getDiagnostics().setClient(new IgnoreDiagnostics);
434434
// CompilerInstance won't run this callback, do it directly.
435435
ASTDiags.EndSourceFile();
436-
// XXX: This is messy: clang-tidy checks flush some diagnostics at EOF.
437-
// However Action->EndSourceFile() would destroy the ASTContext!
438-
// So just inform the preprocessor of EOF, while keeping everything alive.
439-
Clang->getPreprocessor().EndSourceFile();
440436

441437
std::vector<Diag> Diags = CompilerInvocationDiags;
442438
// Add diagnostics from the preamble, if any.

clang-tools-extra/clangd/ParsedAST.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ class ParsedAST {
146146
CanonicalIncludes CanonIncludes;
147147
};
148148

149-
/// For testing/debugging purposes. Note that this method deserializes all
150-
/// unserialized Decls, so use with care.
151-
void dumpAST(ParsedAST &AST, llvm::raw_ostream &OS);
152-
153149
} // namespace clangd
154150
} // namespace clang
155151

clang-tools-extra/clangd/index/Background.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,28 +91,25 @@ bool shardIsStale(const LoadedShard &LS, llvm::vfs::FileSystem *FS) {
9191
} // namespace
9292

9393
BackgroundIndex::BackgroundIndex(
94-
Context BackgroundContext, const ThreadsafeFS &TFS,
95-
const GlobalCompilationDatabase &CDB,
96-
BackgroundIndexStorage::Factory IndexStorageFactory, size_t ThreadPoolSize,
97-
std::function<void(BackgroundQueue::Stats)> OnProgress,
98-
std::function<Context(PathRef)> ContextProvider)
94+
const ThreadsafeFS &TFS, const GlobalCompilationDatabase &CDB,
95+
BackgroundIndexStorage::Factory IndexStorageFactory, Options Opts)
9996
: SwapIndex(std::make_unique<MemIndex>()), TFS(TFS), CDB(CDB),
100-
BackgroundContext(std::move(BackgroundContext)),
101-
ContextProvider(std::move(ContextProvider)),
102-
Rebuilder(this, &IndexedSymbols, ThreadPoolSize),
97+
ContextProvider(std::move(Opts.ContextProvider)),
98+
Rebuilder(this, &IndexedSymbols, Opts.ThreadPoolSize),
10399
IndexStorageFactory(std::move(IndexStorageFactory)),
104-
Queue(std::move(OnProgress)),
100+
Queue(std::move(Opts.OnProgress)),
105101
CommandsChanged(
106102
CDB.watch([&](const std::vector<std::string> &ChangedFiles) {
107103
enqueue(ChangedFiles);
108104
})) {
109-
assert(ThreadPoolSize > 0 && "Thread pool size can't be zero.");
105+
assert(Opts.ThreadPoolSize > 0 && "Thread pool size can't be zero.");
110106
assert(this->IndexStorageFactory && "Storage factory can not be null!");
111-
for (unsigned I = 0; I < ThreadPoolSize; ++I) {
112-
ThreadPool.runAsync("background-worker-" + llvm::Twine(I + 1), [this] {
113-
WithContext Ctx(this->BackgroundContext.clone());
114-
Queue.work([&] { Rebuilder.idle(); });
115-
});
107+
for (unsigned I = 0; I < Opts.ThreadPoolSize; ++I) {
108+
ThreadPool.runAsync("background-worker-" + llvm::Twine(I + 1),
109+
[this, Ctx(Context::current().clone())]() mutable {
110+
WithContext BGContext(std::move(Ctx));
111+
Queue.work([&] { Rebuilder.idle(); });
112+
});
116113
}
117114
}
118115

0 commit comments

Comments
 (0)