Skip to content

Commit 239cc40

Browse files
authored
Merge branch 'main' into inbelic/rs-serial-rem
2 parents 39b633c + 6fb36db commit 239cc40

File tree

290 files changed

+3582
-2751
lines changed

Some content is hidden

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

290 files changed

+3582
-2751
lines changed

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,9 @@ static std::vector<llvm::StringRef> semanticTokenModifiers() {
494494
void ClangdLSPServer::onInitialize(const InitializeParams &Params,
495495
Callback<llvm::json::Value> Reply) {
496496
// Determine character encoding first as it affects constructed ClangdServer.
497-
if (Params.capabilities.offsetEncoding && !Opts.Encoding) {
497+
if (Params.capabilities.PositionEncodings && !Opts.Encoding) {
498498
Opts.Encoding = OffsetEncoding::UTF16; // fallback
499-
for (OffsetEncoding Supported : *Params.capabilities.offsetEncoding)
499+
for (OffsetEncoding Supported : *Params.capabilities.PositionEncodings)
500500
if (Supported != OffsetEncoding::UnsupportedEncoding) {
501501
Opts.Encoding = Supported;
502502
break;
@@ -686,13 +686,19 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
686686
ServerCaps["executeCommandProvider"] =
687687
llvm::json::Object{{"commands", Commands}};
688688

689+
if (Opts.Encoding)
690+
ServerCaps["positionEncoding"] = *Opts.Encoding;
691+
689692
llvm::json::Object Result{
690693
{{"serverInfo",
691694
llvm::json::Object{
692695
{"name", "clangd"},
693696
{"version", llvm::formatv("{0} {1} {2}", versionString(),
694697
featureString(), platformString())}}},
695698
{"capabilities", std::move(ServerCaps)}}};
699+
700+
// TODO: offsetEncoding capability is a deprecated clangd extension and should
701+
// be deleted.
696702
if (Opts.Encoding)
697703
Result["offsetEncoding"] = *Opts.Encoding;
698704
Reply(std::move(Result));

clang-tools-extra/clangd/Protocol.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,19 @@ bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R,
497497
if (auto Cancel = StaleRequestSupport->getBoolean("cancel"))
498498
R.CancelsStaleRequests = *Cancel;
499499
}
500+
if (auto *PositionEncodings = General->get("positionEncodings")) {
501+
R.PositionEncodings.emplace();
502+
if (!fromJSON(*PositionEncodings, *R.PositionEncodings,
503+
P.field("general").field("positionEncodings")))
504+
return false;
505+
}
500506
}
501507
if (auto *OffsetEncoding = O->get("offsetEncoding")) {
502-
R.offsetEncoding.emplace();
503-
if (!fromJSON(*OffsetEncoding, *R.offsetEncoding,
508+
R.PositionEncodings.emplace();
509+
elog("offsetEncoding capability is a deprecated clangd extension that'll "
510+
"go away with clangd 23. Migrate to standard positionEncodings "
511+
"capability introduced by LSP 3.17");
512+
if (!fromJSON(*OffsetEncoding, *R.PositionEncodings,
504513
P.field("offsetEncoding")))
505514
return false;
506515
}
@@ -536,8 +545,11 @@ bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R,
536545
}
537546
}
538547
if (auto *OffsetEncoding = Experimental->get("offsetEncoding")) {
539-
R.offsetEncoding.emplace();
540-
if (!fromJSON(*OffsetEncoding, *R.offsetEncoding,
548+
R.PositionEncodings.emplace();
549+
elog("offsetEncoding capability is a deprecated clangd extension that'll "
550+
"go away with clangd 23. Migrate to standard positionEncodings "
551+
"capability introduced by LSP 3.17");
552+
if (!fromJSON(*OffsetEncoding, *R.PositionEncodings,
541553
P.field("offsetEncoding")))
542554
return false;
543555
}

clang-tools-extra/clangd/Protocol.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,9 @@ struct ClientCapabilities {
528528
/// textDocument.semanticHighlightingCapabilities.semanticHighlighting
529529
bool TheiaSemanticHighlighting = false;
530530

531-
/// Supported encodings for LSP character offsets. (clangd extension).
532-
std::optional<std::vector<OffsetEncoding>> offsetEncoding;
531+
/// Supported encodings for LSP character offsets.
532+
/// general.positionEncodings
533+
std::optional<std::vector<OffsetEncoding>> PositionEncodings;
533534

534535
/// The content format that should be used for Hover requests.
535536
/// textDocument.hover.contentEncoding
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
2+
# This test verifies that we can negotiate UTF-8 offsets via the positionEncodings capability introduced in LSP 3.17.
3+
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"general":{"positionEncodings":["utf-8","utf-16"]}},"trace":"off"}}
4+
# CHECK: "positionEncoding": "utf-8"
5+
---
6+
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"/*ö*/int x;\nint y=x;"}}}
7+
---
8+
{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":1,"character":6}}}
9+
# /*ö*/int x;
10+
# 01234567890
11+
# x is character (and utf-16) range [9,10) but byte range [10,11).
12+
# CHECK: "id": 1,
13+
# CHECK-NEXT: "jsonrpc": "2.0",
14+
# CHECK-NEXT: "result": [
15+
# CHECK-NEXT: {
16+
# CHECK-NEXT: "range": {
17+
# CHECK-NEXT: "end": {
18+
# CHECK-NEXT: "character": 11,
19+
# CHECK-NEXT: "line": 0
20+
# CHECK-NEXT: },
21+
# CHECK-NEXT: "start": {
22+
# CHECK-NEXT: "character": 10,
23+
# CHECK-NEXT: "line": 0
24+
# CHECK-NEXT: }
25+
# CHECK-NEXT: },
26+
# CHECK-NEXT: "uri": "file://{{.*}}/main.cpp"
27+
# CHECK-NEXT: }
28+
# CHECK-NEXT: ]
29+
---
30+
{"jsonrpc":"2.0","id":10000,"method":"shutdown"}
31+
---
32+
{"jsonrpc":"2.0","method":"exit"}

clang-tools-extra/docs/clang-tidy/checks/performance/enum-size.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependent).
3434
.. code-block:: c++
3535

3636
// AFTER
37-
enum Color : std:int8_t {
37+
enum Color : std::int8_t {
3838
RED = -1,
3939
GREEN = 0,
4040
BLUE = 1

clang/docs/Toolchain.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,3 @@ workarounds for issues discovered in libstdc++, and these are removed
347347
as fixed libstdc++ becomes sufficiently old.
348348

349349
You can instruct Clang to use libstdc++ with the ``-stdlib=libstdc++`` flag.
350-
351-
GCC Installation
352-
=================
353-
Users can point to their GCC installation by using the ``-gcc-toolchain`` or by
354-
using ``-gcc-install-dir`` flag.

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,6 @@ def note_drv_available_multilibs : Note<
847847
"available multilibs are:%0">;
848848
def err_drv_multilib_custom_error : Error<
849849
"multilib configuration error: %0">;
850-
def warn_drv_multilib_not_available_for_target: Warning<
851-
"no multilib structure encoded for Arm, Aarch64 and PPC targets">,
852-
InGroup<DiagGroup<"multilib-not-found">>;
853850

854851
def err_drv_experimental_crel : Error<
855852
"-Wa,--allow-experimental-crel must be specified to use -Wa,--crel. "

clang/include/clang/Parse/Parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3598,7 +3598,7 @@ class Parser : public CodeCompletionHandler {
35983598
/// keyword.
35993599
bool isClassCompatibleKeyword(Token Tok) const;
36003600

3601-
void ParseMicrosoftRootSignatureAttributeArgs(ParsedAttributes &Attrs);
3601+
void ParseHLSLRootSignatureAttributeArgs(ParsedAttributes &Attrs);
36023602

36033603
///@}
36043604

clang/include/clang/Sema/SemaHLSL.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,19 @@ class SemaHLSL : public SemaBase {
119119
bool IsCompAssign);
120120
void emitLogicalOperatorFixIt(Expr *LHS, Expr *RHS, BinaryOperatorKind Opc);
121121

122+
/// Computes the unique Root Signature identifier from the given signature,
123+
/// then lookup if there is a previousy created Root Signature decl.
124+
///
125+
/// Returns the identifier and if it was found
126+
std::pair<IdentifierInfo *, bool>
127+
ActOnStartRootSignatureDecl(StringRef Signature);
128+
129+
/// Creates the Root Signature decl of the parsed Root Signature elements
130+
/// onto the AST and push it onto current Scope
131+
void ActOnFinishRootSignatureDecl(
132+
SourceLocation Loc, IdentifierInfo *DeclIdent,
133+
SmallVector<llvm::hlsl::rootsig::RootElement> &Elements);
134+
122135
void handleRootSignatureAttr(Decl *D, const ParsedAttr &AL);
123136
void handleNumThreadsAttr(Decl *D, const ParsedAttr &AL);
124137
void handleWaveSizeAttr(Decl *D, const ParsedAttr &AL);

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 49 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,7 @@ bool Compiler<Emitter>::VisitFloatingLiteral(const FloatingLiteral *E) {
748748
if (DiscardResult)
749749
return true;
750750

751-
APFloat F = E->getValue();
752-
return this->emitFloat(F, E);
751+
return this->emitConstFloat(E->getValue(), E);
753752
}
754753

755754
template <class Emitter>
@@ -4186,10 +4185,8 @@ bool Compiler<Emitter>::visitZeroInitializer(PrimType T, QualType QT,
41864185
nullptr, E);
41874186
case PT_MemberPtr:
41884187
return this->emitNullMemberPtr(0, nullptr, E);
4189-
case PT_Float: {
4190-
APFloat F = APFloat::getZero(Ctx.getFloatSemantics(QT));
4191-
return this->emitFloat(F, E);
4192-
}
4188+
case PT_Float:
4189+
return this->emitConstFloat(APFloat::getZero(Ctx.getFloatSemantics(QT)), E);
41934190
case PT_FixedPoint: {
41944191
auto Sem = Ctx.getASTContext().getFixedPointSemantics(E->getType());
41954192
return this->emitConstFixedPoint(FixedPoint::zero(Sem), E);
@@ -4677,7 +4674,10 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
46774674
if (!visitInitializer(Init))
46784675
return false;
46794676

4680-
return this->emitFinishInitGlobal(Init);
4677+
if (!this->emitFinishInit(Init))
4678+
return false;
4679+
4680+
return this->emitPopPtr(Init);
46814681
};
46824682

46834683
DeclScope<Emitter> LocalScope(this, VD);
@@ -4698,45 +4698,51 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
46984698
return false;
46994699

47004700
return !Init || (checkDecl() && initGlobal(*GlobalIndex));
4701-
}
4702-
// Local variables.
4703-
InitLinkScope<Emitter> ILS(this, InitLink::Decl(VD));
4701+
} else {
4702+
InitLinkScope<Emitter> ILS(this, InitLink::Decl(VD));
47044703

4705-
if (VarT) {
4706-
unsigned Offset = this->allocateLocalPrimitive(
4707-
VD, *VarT, VD->getType().isConstQualified(), nullptr, ScopeKind::Block,
4708-
IsConstexprUnknown);
4709-
if (Init) {
4710-
// If this is a toplevel declaration, create a scope for the
4711-
// initializer.
4712-
if (Toplevel) {
4713-
LocalScope<Emitter> Scope(this);
4714-
if (!this->visit(Init))
4715-
return false;
4716-
return this->emitSetLocal(*VarT, Offset, VD) && Scope.destroyLocals();
4717-
} else {
4718-
if (!this->visit(Init))
4719-
return false;
4720-
return this->emitSetLocal(*VarT, Offset, VD);
4704+
if (VarT) {
4705+
unsigned Offset = this->allocateLocalPrimitive(
4706+
VD, *VarT, VD->getType().isConstQualified(), nullptr,
4707+
ScopeKind::Block, IsConstexprUnknown);
4708+
if (Init) {
4709+
// If this is a toplevel declaration, create a scope for the
4710+
// initializer.
4711+
if (Toplevel) {
4712+
LocalScope<Emitter> Scope(this);
4713+
if (!this->visit(Init))
4714+
return false;
4715+
return this->emitSetLocal(*VarT, Offset, VD) && Scope.destroyLocals();
4716+
} else {
4717+
if (!this->visit(Init))
4718+
return false;
4719+
return this->emitSetLocal(*VarT, Offset, VD);
4720+
}
47214721
}
4722-
}
4723-
} else {
4724-
if (std::optional<unsigned> Offset = this->allocateLocal(
4725-
VD, VD->getType(), nullptr, ScopeKind::Block, IsConstexprUnknown)) {
4726-
if (!Init)
4727-
return true;
4722+
} else {
4723+
if (std::optional<unsigned> Offset =
4724+
this->allocateLocal(VD, VD->getType(), nullptr, ScopeKind::Block,
4725+
IsConstexprUnknown)) {
4726+
if (!Init)
4727+
return true;
47284728

4729-
if (!this->emitGetPtrLocal(*Offset, Init))
4730-
return false;
4729+
if (!this->emitGetPtrLocal(*Offset, Init))
4730+
return false;
47314731

4732-
if (!visitInitializer(Init))
4733-
return false;
4732+
if (!visitInitializer(Init))
4733+
return false;
4734+
4735+
if (!this->emitFinishInit(Init))
4736+
return false;
47344737

4735-
return this->emitFinishInitPop(Init);
4738+
return this->emitPopPtr(Init);
4739+
}
4740+
return false;
47364741
}
4737-
return false;
4742+
return true;
47384743
}
4739-
return true;
4744+
4745+
return false;
47404746
}
47414747

47424748
template <class Emitter>
@@ -4745,10 +4751,8 @@ bool Compiler<Emitter>::visitAPValue(const APValue &Val, PrimType ValType,
47454751
assert(!DiscardResult);
47464752
if (Val.isInt())
47474753
return this->emitConst(Val.getInt(), ValType, E);
4748-
else if (Val.isFloat()) {
4749-
APFloat F = Val.getFloat();
4750-
return this->emitFloat(F, E);
4751-
}
4754+
else if (Val.isFloat())
4755+
return this->emitConstFloat(Val.getFloat(), E);
47524756

47534757
if (Val.isLValue()) {
47544758
if (Val.isNullPointer())
@@ -6129,10 +6133,8 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
61296133
const auto &TargetSemantics = Ctx.getFloatSemantics(E->getType());
61306134
if (!this->emitLoadFloat(E))
61316135
return false;
6132-
APFloat F(TargetSemantics, 1);
6133-
if (!this->emitFloat(F, E))
6136+
if (!this->emitConstFloat(llvm::APFloat(TargetSemantics, 1), E))
61346137
return false;
6135-
61366138
if (!this->emitAddf(getFPOptions(E), E))
61376139
return false;
61386140
if (!this->emitStoreFloat(E))
@@ -6174,10 +6176,8 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
61746176
const auto &TargetSemantics = Ctx.getFloatSemantics(E->getType());
61756177
if (!this->emitLoadFloat(E))
61766178
return false;
6177-
APFloat F(TargetSemantics, 1);
6178-
if (!this->emitFloat(F, E))
6179+
if (!this->emitConstFloat(llvm::APFloat(TargetSemantics, 1), E))
61796180
return false;
6180-
61816181
if (!this->emitSubf(getFPOptions(E), E))
61826182
return false;
61836183
if (!this->emitStoreFloat(E))
@@ -6953,20 +6953,6 @@ bool Compiler<Emitter>::emitDummyPtr(const DeclTy &D, const Expr *E) {
69536953
return true;
69546954
}
69556955

6956-
template <class Emitter>
6957-
bool Compiler<Emitter>::emitFloat(const APFloat &F, const Expr *E) {
6958-
assert(!DiscardResult && "Should've been checked before");
6959-
6960-
if (Floating::singleWord(F.getSemantics()))
6961-
return this->emitConstFloat(Floating(F), E);
6962-
6963-
APInt I = F.bitcastToAPInt();
6964-
return this->emitConstFloat(
6965-
Floating(const_cast<uint64_t *>(I.getRawData()),
6966-
llvm::APFloatBase::SemanticsToEnum(F.getSemantics())),
6967-
E);
6968-
}
6969-
69706956
// This function is constexpr if and only if To, From, and the types of
69716957
// all subobjects of To and From are types T such that...
69726958
// (3.1) - is_union_v<T> is false;

0 commit comments

Comments
 (0)