Skip to content

Commit 728375f

Browse files
authored
LLVM and SPIRV-LLVM-Translator pulldown (WW42) #2628
LLVM: llvm/llvm-project@70bf350 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@c3c7e24
2 parents 44354f0 + 97d7eec commit 728375f

File tree

1,280 files changed

+52970
-21842
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,280 files changed

+52970
-21842
lines changed

clang-tools-extra/clang-tidy/google/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ add_clang_library(clangTidyGoogleModule
1616
GlobalVariableDeclarationCheck.cpp
1717
GoogleTidyModule.cpp
1818
IntegerTypesCheck.cpp
19-
NonConstReferences.cpp
2019
OverloadedUnaryAndCheck.cpp
2120
TodoCommentCheck.cpp
2221
UnnamedNamespaceInHeaderCheck.cpp

clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "GlobalNamesInHeadersCheck.h"
2424
#include "GlobalVariableDeclarationCheck.h"
2525
#include "IntegerTypesCheck.h"
26-
#include "NonConstReferences.h"
2726
#include "OverloadedUnaryAndCheck.h"
2827
#include "TodoCommentCheck.h"
2928
#include "UnnamedNamespaceInHeaderCheck.h"
@@ -63,8 +62,6 @@ class GoogleModule : public ClangTidyModule {
6362
"google-runtime-int");
6463
CheckFactories.registerCheck<runtime::OverloadedUnaryAndCheck>(
6564
"google-runtime-operator");
66-
CheckFactories.registerCheck<runtime::NonConstReferences>(
67-
"google-runtime-references");
6865
CheckFactories
6966
.registerCheck<readability::AvoidUnderscoreInGoogletestNameCheck>(
7067
"google-readability-avoid-underscore-in-googletest-name");

clang-tools-extra/clang-tidy/google/NonConstReferences.cpp

-148
This file was deleted.

clang-tools-extra/clang-tidy/google/NonConstReferences.h

-41
This file was deleted.

clang-tools-extra/clangd/ClangdLSPServer.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,8 @@ void ClangdLSPServer::onWorkspaceSymbol(
794794
void ClangdLSPServer::onPrepareRename(const TextDocumentPositionParams &Params,
795795
Callback<llvm::Optional<Range>> Reply) {
796796
Server->prepareRename(
797-
Params.textDocument.uri.file(), Params.position, Opts.Rename,
797+
Params.textDocument.uri.file(), Params.position, /*NewName*/ llvm::None,
798+
Opts.Rename,
798799
[Reply = std::move(Reply)](llvm::Expected<RenameResult> Result) mutable {
799800
if (!Result)
800801
return Reply(Result.takeError());

clang-tools-extra/clangd/ClangdServer.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,11 @@ void ClangdServer::formatOnType(PathRef File, llvm::StringRef Code,
399399
}
400400

401401
void ClangdServer::prepareRename(PathRef File, Position Pos,
402+
llvm::Optional<std::string> NewName,
402403
const RenameOptions &RenameOpts,
403404
Callback<RenameResult> CB) {
404-
auto Action = [Pos, File = File.str(), CB = std::move(CB), RenameOpts,
405+
auto Action = [Pos, File = File.str(), CB = std::move(CB),
406+
NewName = std::move(NewName), RenameOpts,
405407
this](llvm::Expected<InputsAndAST> InpAST) mutable {
406408
if (!InpAST)
407409
return CB(InpAST.takeError());
@@ -412,9 +414,9 @@ void ClangdServer::prepareRename(PathRef File, Position Pos,
412414
// - for cross-file rename, we deliberately pass a nullptr index to save
413415
// the cost, thus the result may be incomplete as it only contains
414416
// main-file occurrences;
415-
auto Results = clangd::rename({Pos, /*NewName*/ "", InpAST->AST, File,
416-
RenameOpts.AllowCrossFile ? nullptr : Index,
417-
RenameOpts});
417+
auto Results = clangd::rename(
418+
{Pos, NewName.getValueOr("__clangd_rename_dummy"), InpAST->AST, File,
419+
RenameOpts.AllowCrossFile ? nullptr : Index, RenameOpts});
418420
if (!Results) {
419421
// LSP says to return null on failure, but that will result in a generic
420422
// failure message. If we send an LSP error response, clients can surface

clang-tools-extra/clangd/ClangdServer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ class ClangdServer {
274274

275275
/// Test the validity of a rename operation.
276276
///
277-
/// The returned result describes edits in the main-file only (all
278-
/// occurrences of the renamed symbol are simply deleted.
277+
/// If NewName is provided, it performs a name validation.
279278
void prepareRename(PathRef File, Position Pos,
279+
llvm::Optional<std::string> NewName,
280280
const RenameOptions &RenameOpts,
281281
Callback<RenameResult> CB);
282282

clang-tools-extra/clangd/FindSymbols.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,13 @@ getWorkspaceSymbols(llvm::StringRef Query, int Limit,
9696
return;
9797
}
9898

99-
SymbolKind SK = indexSymbolKindToSymbolKind(Sym.SymInfo.Kind);
100-
std::string Scope = std::string(Sym.Scope);
101-
llvm::StringRef ScopeRef = Scope;
102-
ScopeRef.consume_back("::");
103-
SymbolInformation Info = {(Sym.Name + Sym.TemplateSpecializationArgs).str(),
104-
SK, *Loc, std::string(ScopeRef)};
99+
llvm::StringRef Scope = Sym.Scope;
100+
Scope.consume_back("::");
101+
SymbolInformation Info;
102+
Info.name = (Sym.Name + Sym.TemplateSpecializationArgs).str();
103+
Info.kind = indexSymbolKindToSymbolKind(Sym.SymInfo.Kind);
104+
Info.location = *Loc;
105+
Info.containerName = Scope.str();
105106

106107
SymbolQualitySignals Quality;
107108
Quality.merge(Sym);
@@ -121,6 +122,8 @@ getWorkspaceSymbols(llvm::StringRef Query, int Limit,
121122
dlog("FindSymbols: {0}{1} = {2}\n{3}{4}\n", Sym.Scope, Sym.Name, Score,
122123
Quality, Relevance);
123124

125+
// Exposed score excludes fuzzy-match component, for client-side re-ranking.
126+
Info.score = Score / Relevance.NameMatch;
124127
Top.push({Score, std::move(Info)});
125128
});
126129
for (auto &R : std::move(Top).items())

clang-tools-extra/clangd/FindTarget.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,9 @@ struct TargetFinder {
342342
add(TND->getUnderlyingType(), Flags | Rel::Underlying);
343343
Flags |= Rel::Alias; // continue with the alias.
344344
} else if (const UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
345+
// no Underlying as this is a non-renaming alias.
345346
for (const UsingShadowDecl *S : UD->shadows())
346-
add(S->getUnderlyingDecl(), Flags | Rel::Underlying);
347+
add(S->getUnderlyingDecl(), Flags);
347348
Flags |= Rel::Alias; // continue with the alias.
348349
} else if (const auto *NAD = dyn_cast<NamespaceAliasDecl>(D)) {
349350
add(NAD->getUnderlyingDecl(), Flags | Rel::Underlying);
@@ -354,7 +355,7 @@ struct TargetFinder {
354355
UUVD->getQualifier()->getAsType(),
355356
[UUVD](ASTContext &) { return UUVD->getNameInfo().getName(); },
356357
ValueFilter)) {
357-
add(Target, Flags | Rel::Underlying);
358+
add(Target, Flags); // no Underlying as this is a non-renaming alias
358359
}
359360
Flags |= Rel::Alias; // continue with the alias
360361
} else if (const UsingShadowDecl *USD = dyn_cast<UsingShadowDecl>(D)) {
@@ -364,7 +365,6 @@ struct TargetFinder {
364365
// Shadow decls are synthetic and not themselves interesting.
365366
// Record the underlying decl instead, if allowed.
366367
D = USD->getTargetDecl();
367-
Flags |= Rel::Underlying; // continue with the underlying decl.
368368
} else if (const auto *DG = dyn_cast<CXXDeductionGuideDecl>(D)) {
369369
D = DG->getDeducedTemplate();
370370
} else if (const ObjCImplementationDecl *IID =

clang-tools-extra/clangd/FindTarget.h

+11-4
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,20 @@ enum class DeclRelation : unsigned {
102102
TemplatePattern,
103103

104104
// Alias options apply when the declaration is an alias.
105-
// e.g. namespace clang { [[StringRef]] S; }
105+
// e.g. namespace client { [[X]] x; }
106106

107107
/// This declaration is an alias that was referred to.
108-
/// e.g. using llvm::StringRef (the UsingDecl directly referenced).
108+
/// e.g. using ns::X (the UsingDecl directly referenced),
109+
/// using Z = ns::Y (the TypeAliasDecl directly referenced)
109110
Alias,
110-
/// This is the underlying declaration for an alias, decltype etc.
111-
/// e.g. class llvm::StringRef (the underlying declaration referenced).
111+
/// This is the underlying declaration for a renaming-alias, decltype etc.
112+
/// e.g. class ns::Y (the underlying declaration referenced).
113+
///
114+
/// Note that we don't treat `using ns::X` as a first-class declaration like
115+
/// `using Z = ns::Y`. Therefore reference to X that goes through this
116+
/// using-decl is considered a direct reference (without the Underlying bit).
117+
/// Nevertheless, we report `using ns::X` as an Alias, so that some features
118+
/// like go-to-definition can still target it.
112119
Underlying,
113120
};
114121
llvm::raw_ostream &operator<<(llvm::raw_ostream &, DeclRelation);

clang-tools-extra/clangd/Protocol.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,15 @@ bool fromJSON(const llvm::json::Value &Params, ExecuteCommandParams &R,
662662
}
663663

664664
llvm::json::Value toJSON(const SymbolInformation &P) {
665-
return llvm::json::Object{
665+
llvm::json::Object O{
666666
{"name", P.name},
667667
{"kind", static_cast<int>(P.kind)},
668668
{"location", P.location},
669669
{"containerName", P.containerName},
670670
};
671+
if (P.score)
672+
O["score"] = *P.score;
673+
return std::move(O);
671674
}
672675

673676
llvm::raw_ostream &operator<<(llvm::raw_ostream &O,

clang-tools-extra/clangd/Protocol.h

+13-5
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,14 @@ struct SymbolInformation {
10151015

10161016
/// The name of the symbol containing this symbol.
10171017
std::string containerName;
1018+
1019+
/// The score that clangd calculates to rank the returned symbols.
1020+
/// This excludes the fuzzy-matching score between `name` and the query.
1021+
/// (Specifically, the last ::-separated component).
1022+
/// This can be used to re-rank results as the user types, using client-side
1023+
/// fuzzy-matching (that score should be multiplied with this one).
1024+
/// This is a clangd extension, set only for workspace/symbol responses.
1025+
llvm::Optional<float> score;
10181026
};
10191027
llvm::json::Value toJSON(const SymbolInformation &);
10201028
llvm::raw_ostream &operator<<(llvm::raw_ostream &, const SymbolInformation &);
@@ -1175,11 +1183,11 @@ struct CompletionItem {
11751183
/// Indicates if this item is deprecated.
11761184
bool deprecated = false;
11771185

1178-
/// This is Clangd extension.
1179-
/// The score that Clangd calculates to rank completion items. This score can
1180-
/// be used to adjust the ranking on the client side.
1181-
/// NOTE: This excludes fuzzy matching score which is typically calculated on
1182-
/// the client side.
1186+
/// The score that clangd calculates to rank the returned completions.
1187+
/// This excludes the fuzzy-match between `filterText` and the partial word.
1188+
/// This can be used to re-rank results as the user types, using client-side
1189+
/// fuzzy-matching (that score should be multiplied with this one).
1190+
/// This is a clangd extension.
11831191
float score = 0.f;
11841192

11851193
// TODO: Add custom commitCharacters for some of the completion items. For

0 commit comments

Comments
 (0)