Skip to content

Commit d869f5a

Browse files
committed
Merge from 'main' to 'sycl-web' (#151)
CONFLICT (content): Merge conflict in llvm/lib/Support/Triple.cpp
2 parents 9f4c5ca + 21bfd06 commit d869f5a

File tree

705 files changed

+34779
-9592
lines changed

Some content is hidden

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

705 files changed

+34779
-9592
lines changed

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,13 @@ ClangdServer::Options::operator TUScheduler::Options() const {
139139
ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
140140
const ThreadsafeFS &TFS, const Options &Opts,
141141
Callbacks *Callbacks)
142-
: ConfigProvider(Opts.ConfigProvider), TFS(TFS), ServerCallbacks(Callbacks),
142+
: ConfigProvider(Opts.ConfigProvider), CDB(CDB), TFS(TFS),
143+
ServerCallbacks(Callbacks),
143144
DynamicIdx(Opts.BuildDynamicSymbolIndex
144145
? new FileIndex(Opts.HeavyweightDynamicSymbolIndex,
145146
Opts.CollectMainFileRefs)
146147
: nullptr),
147148
ClangTidyProvider(Opts.ClangTidyProvider),
148-
SuggestMissingIncludes(Opts.SuggestMissingIncludes),
149-
BuildRecoveryAST(Opts.BuildRecoveryAST),
150-
PreserveRecoveryASTType(Opts.PreserveRecoveryASTType),
151149
WorkspaceRoot(Opts.WorkspaceRoot),
152150
// Pass a callback into `WorkScheduler` to extract symbols from a newly
153151
// parsed file and rebuild the file index synchronously each time an AST
@@ -202,7 +200,6 @@ void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
202200
llvm::StringRef Version,
203201
WantDiagnostics WantDiags, bool ForceRebuild) {
204202
ParseOptions Opts;
205-
Opts.SuggestMissingIncludes = SuggestMissingIncludes;
206203

207204
// Compile command is set asynchronously during update, as it can be slow.
208205
ParseInputs Inputs;
@@ -213,8 +210,6 @@ void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
213210
Inputs.Opts = std::move(Opts);
214211
Inputs.Index = Index;
215212
Inputs.ClangTidyProvider = ClangTidyProvider;
216-
Inputs.Opts.BuildRecoveryAST = BuildRecoveryAST;
217-
Inputs.Opts.PreserveRecoveryASTType = PreserveRecoveryASTType;
218213
bool NewFile = WorkScheduler.update(File, Inputs, WantDiags);
219214
// If we loaded Foo.h, we want to make sure Foo.cpp is indexed.
220215
if (NewFile && BackgroundIdx)
@@ -252,8 +247,6 @@ void ClangdServer::codeComplete(PathRef File, Position Pos,
252247
}
253248
ParseInputs ParseInput{IP->Command, &TFS, IP->Contents.str()};
254249
ParseInput.Index = Index;
255-
ParseInput.Opts.BuildRecoveryAST = BuildRecoveryAST;
256-
ParseInput.Opts.PreserveRecoveryASTType = PreserveRecoveryASTType;
257250

258251
CodeCompleteOpts.MainFileSignals = IP->Signals;
259252
// FIXME(ibiryukov): even if Preamble is non-null, we may want to check
@@ -299,8 +292,6 @@ void ClangdServer::signatureHelp(PathRef File, Position Pos,
299292

300293
ParseInputs ParseInput{IP->Command, &TFS, IP->Contents.str()};
301294
ParseInput.Index = Index;
302-
ParseInput.Opts.BuildRecoveryAST = BuildRecoveryAST;
303-
ParseInput.Opts.PreserveRecoveryASTType = PreserveRecoveryASTType;
304295
CB(clangd::signatureHelp(File, Pos, *PreambleData, ParseInput));
305296
};
306297

@@ -870,6 +861,7 @@ Context ClangdServer::createProcessingContext(PathRef File) const {
870861
LLVM_NODISCARD bool
871862
ClangdServer::blockUntilIdleForTest(llvm::Optional<double> TimeoutSeconds) {
872863
return WorkScheduler.blockUntilIdle(timeoutSeconds(TimeoutSeconds)) &&
864+
CDB.blockUntilIdle(timeoutSeconds(TimeoutSeconds)) &&
873865
(!BackgroundIdx ||
874866
BackgroundIdx->blockUntilIdleForTest(TimeoutSeconds));
875867
}

clang-tools-extra/clangd/ClangdServer.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,6 @@ class ClangdServer {
118118
/// checks will be disabled.
119119
TidyProviderRef ClangTidyProvider;
120120

121-
/// If true, force -frecovery-ast flag.
122-
/// If false, respect the value in clang.
123-
bool BuildRecoveryAST = false;
124-
125-
/// If true, force -frecovery-ast-type flag.
126-
/// If false, respect the value in clang.
127-
bool PreserveRecoveryASTType = false;
128-
129121
/// Clangd's workspace root. Relevant for "workspace" operations not bound
130122
/// to a particular file.
131123
/// FIXME: If not set, should use the current working directory.
@@ -144,8 +136,6 @@ class ClangdServer {
144136
/*RebuildRatio=*/1,
145137
};
146138

147-
bool SuggestMissingIncludes = false;
148-
149139
/// Clangd will execute compiler drivers matching one of these globs to
150140
/// fetch system include path.
151141
std::vector<std::string> QueryDriverGlobs;
@@ -362,6 +352,7 @@ class ClangdServer {
362352
Context createProcessingContext(PathRef) const;
363353
config::Provider *ConfigProvider = nullptr;
364354

355+
const GlobalCompilationDatabase &CDB;
365356
const ThreadsafeFS &TFS;
366357
Callbacks *ServerCallbacks = nullptr;
367358
mutable std::mutex ConfigDiagnosticsMu;
@@ -383,15 +374,6 @@ class ClangdServer {
383374
// When set, provides clang-tidy options for a specific file.
384375
TidyProviderRef ClangTidyProvider;
385376

386-
// If this is true, suggest include insertion fixes for diagnostic errors that
387-
// can be caused by missing includes (e.g. member access in incomplete type).
388-
bool SuggestMissingIncludes = false;
389-
390-
// If true, preserve expressions in AST for broken code.
391-
bool BuildRecoveryAST = true;
392-
// If true, preserve the type for recovery AST.
393-
bool PreserveRecoveryASTType = false;
394-
395377
// GUARDED_BY(CachedCompletionFuzzyFindRequestMutex)
396378
llvm::StringMap<llvm::Optional<FuzzyFindRequest>>
397379
CachedCompletionFuzzyFindRequestByFile;

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#include "llvm/Support/ScopedPrinter.h"
7171
#include <algorithm>
7272
#include <iterator>
73+
#include <limits>
7374

7475
// We log detailed candidate here if you run with -debug-only=codecomplete.
7576
#define DEBUG_TYPE "CodeComplete"
@@ -1655,9 +1656,10 @@ class CodeCompleteFlow {
16551656
evaluateSymbolAndRelevance(Scores.Quality, Scores.Relevance);
16561657
// NameMatch is in fact a multiplier on total score, so rescoring is
16571658
// sound.
1658-
Scores.ExcludingName = Relevance.NameMatch
1659-
? Scores.Total / Relevance.NameMatch
1660-
: Scores.Quality;
1659+
Scores.ExcludingName =
1660+
Relevance.NameMatch > std::numeric_limits<float>::epsilon()
1661+
? Scores.Total / Relevance.NameMatch
1662+
: Scores.Quality;
16611663
return Scores;
16621664

16631665
case RM::DecisionForest:

clang-tools-extra/clangd/Compiler.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer &D,
8585
// Don't crash on `#pragma clang __debug parser_crash`
8686
CI->getPreprocessorOpts().DisablePragmaDebugCrash = true;
8787

88-
if (Inputs.Opts.BuildRecoveryAST)
89-
CI->getLangOpts()->RecoveryAST = true;
90-
if (Inputs.Opts.PreserveRecoveryASTType)
91-
CI->getLangOpts()->RecoveryASTType = true;
92-
9388
return CI;
9489
}
9590

clang-tools-extra/clangd/Compiler.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ class IgnoreDiagnostics : public DiagnosticConsumer {
3737

3838
// Options to run clang e.g. when parsing AST.
3939
struct ParseOptions {
40-
bool SuggestMissingIncludes = false;
41-
bool BuildRecoveryAST = false;
42-
bool PreserveRecoveryASTType = false;
40+
// (empty at present, formerly controlled recovery AST, include-fixer etc)
4341
};
4442

4543
/// Information required to run clang, e.g. to parse AST or do code completion.

clang-tools-extra/clangd/FindSymbols.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "llvm/Support/FormatVariadic.h"
2626
#include "llvm/Support/Path.h"
2727
#include "llvm/Support/ScopedPrinter.h"
28+
#include <limits>
2829
#include <tuple>
2930

3031
#define DEBUG_TYPE "FindSymbols"
@@ -146,8 +147,9 @@ getWorkspaceSymbols(llvm::StringRef Query, int Limit,
146147
return;
147148
}
148149
Relevance.merge(Sym);
149-
auto Score = evaluateSymbolAndRelevance(Quality.evaluateHeuristics(),
150-
Relevance.evaluateHeuristics());
150+
auto QualScore = Quality.evaluateHeuristics();
151+
auto RelScore = Relevance.evaluateHeuristics();
152+
auto Score = evaluateSymbolAndRelevance(QualScore, RelScore);
151153
dlog("FindSymbols: {0}{1} = {2}\n{3}{4}\n", Sym.Scope, Sym.Name, Score,
152154
Quality, Relevance);
153155

@@ -159,7 +161,9 @@ getWorkspaceSymbols(llvm::StringRef Query, int Limit,
159161
Info.containerName = Scope.str();
160162

161163
// Exposed score excludes fuzzy-match component, for client-side re-ranking.
162-
Info.score = Score / Relevance.NameMatch;
164+
Info.score = Relevance.NameMatch > std::numeric_limits<float>::epsilon()
165+
? Score / Relevance.NameMatch
166+
: QualScore;
163167
Top.push({Score, std::move(Info)});
164168
});
165169
for (auto &R : std::move(Top).items())

0 commit comments

Comments
 (0)