Skip to content

Commit 18eb83e

Browse files
committed
Merge from 'master' to 'sycl-web' (#2)
CONFLICT (content): Merge conflict in llvm/include/llvm/InitializePasses.h
2 parents 7fddda6 + baffd05 commit 18eb83e

File tree

510 files changed

+22241
-5604
lines changed

Some content is hidden

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

510 files changed

+22241
-5604
lines changed

clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,22 @@
1313
#include "clang/Lex/PreprocessorOptions.h"
1414
#include "clang/Serialization/ASTReader.h"
1515

16+
#define DEBUG_TYPE "clang-tidy"
17+
1618
namespace clang {
1719
namespace tooling {
1820

1921
class ExpandModularHeadersPPCallbacks::FileRecorder {
2022
public:
2123
/// Records that a given file entry is needed for replaying callbacks.
22-
void addNecessaryFile(const FileEntry *File) { FilesToRecord.insert(File); }
24+
void addNecessaryFile(const FileEntry *File) {
25+
// Don't record modulemap files because it breaks same file detection.
26+
if (!(File->getName().endswith("module.modulemap") ||
27+
File->getName().endswith("module.private.modulemap") ||
28+
File->getName().endswith("module.map") ||
29+
File->getName().endswith("module_private.map")))
30+
FilesToRecord.insert(File);
31+
}
2332

2433
/// Records content for a file and adds it to the FileSystem.
2534
void recordFileContent(const FileEntry *File,
@@ -30,12 +39,12 @@ class ExpandModularHeadersPPCallbacks::FileRecorder {
3039
return;
3140

3241
// FIXME: Why is this happening? We might be losing contents here.
33-
if (!ContentCache.getRawBuffer())
42+
llvm::Optional<StringRef> Data = ContentCache.getBufferDataIfLoaded();
43+
if (!Data)
3444
return;
3545

3646
InMemoryFs.addFile(File->getName(), /*ModificationTime=*/0,
37-
llvm::MemoryBuffer::getMemBufferCopy(
38-
ContentCache.getRawBuffer()->getBuffer()));
47+
llvm::MemoryBuffer::getMemBufferCopy(*Data));
3948
// Remove the file from the set of necessary files.
4049
FilesToRecord.erase(File);
4150
}
@@ -44,8 +53,8 @@ class ExpandModularHeadersPPCallbacks::FileRecorder {
4453
/// `FilesToRecord` should be empty.
4554
void checkAllFilesRecorded() {
4655
for (auto FileEntry : FilesToRecord)
47-
llvm::errs() << "Did not record contents for input file: "
48-
<< FileEntry->getName() << "\n";
56+
LLVM_DEBUG(llvm::dbgs() << "Did not record contents for input file: "
57+
<< FileEntry->getName() << "\n");
4958
}
5059

5160
private:

clang-tools-extra/clangd/index/remote/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
if (CLANGD_ENABLE_REMOTE)
2-
generate_grpc_protos(RemoteIndexProtos "Index.proto")
2+
generate_protos(RemoteIndexServiceProto "Service.proto" GRPC)
3+
generate_protos(RemoteIndexProto "Index.proto")
34
include_directories(${CMAKE_CURRENT_BINARY_DIR})
45
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
56

@@ -12,7 +13,8 @@ if (CLANGD_ENABLE_REMOTE)
1213
Client.cpp
1314

1415
LINK_LIBS
15-
RemoteIndexProtos
16+
RemoteIndexProto
17+
RemoteIndexServiceProto
1618
clangdRemoteMarshalling
1719

1820
protobuf
@@ -21,7 +23,8 @@ if (CLANGD_ENABLE_REMOTE)
2123
clangdSupport
2224

2325
DEPENDS
24-
RemoteIndexProtos
26+
RemoteIndexProto
27+
RemoteIndexServiceProto
2528
)
2629

2730
add_subdirectory(marshalling)

clang-tools-extra/clangd/index/remote/Client.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
#include <grpc++/grpc++.h>
1010

1111
#include "Client.h"
12-
#include "Index.grpc.pb.h"
12+
#include "Service.grpc.pb.h"
1313
#include "index/Index.h"
1414
#include "index/Serialization.h"
1515
#include "marshalling/Marshalling.h"
1616
#include "support/Logger.h"
1717
#include "support/Trace.h"
18+
#include "clang/Basic/Version.h"
1819
#include "llvm/ADT/StringRef.h"
1920
#include "llvm/Support/Error.h"
2021

@@ -28,7 +29,8 @@ namespace {
2829
class IndexClient : public clangd::SymbolIndex {
2930
template <typename RequestT, typename ReplyT>
3031
using StreamingCall = std::unique_ptr<grpc::ClientReader<ReplyT>> (
31-
remote::SymbolIndex::Stub::*)(grpc::ClientContext *, const RequestT &);
32+
remote::v1::SymbolIndex::Stub::*)(grpc::ClientContext *,
33+
const RequestT &);
3234

3335
template <typename RequestT, typename ReplyT, typename ClangdRequestT,
3436
typename CallbackT>
@@ -40,6 +42,7 @@ class IndexClient : public clangd::SymbolIndex {
4042
const auto RPCRequest = ProtobufMarshaller->toProtobuf(Request);
4143
SPAN_ATTACH(Tracer, "Request", RPCRequest.DebugString());
4244
grpc::ClientContext Context;
45+
Context.AddMetadata("version", clang::getClangToolFullVersion("clangd"));
4346
std::chrono::system_clock::time_point Deadline =
4447
std::chrono::system_clock::now() + DeadlineWaitingTime;
4548
Context.set_deadline(Deadline);
@@ -73,7 +76,7 @@ class IndexClient : public clangd::SymbolIndex {
7376
IndexClient(
7477
std::shared_ptr<grpc::Channel> Channel, llvm::StringRef ProjectRoot,
7578
std::chrono::milliseconds DeadlineTime = std::chrono::milliseconds(1000))
76-
: Stub(remote::SymbolIndex::NewStub(Channel)),
79+
: Stub(remote::v1::SymbolIndex::NewStub(Channel)),
7780
ProtobufMarshaller(new Marshaller(/*RemoteIndexRoot=*/"",
7881
/*LocalIndexRoot=*/ProjectRoot)),
7982
DeadlineWaitingTime(DeadlineTime) {
@@ -82,25 +85,26 @@ class IndexClient : public clangd::SymbolIndex {
8285

8386
void lookup(const clangd::LookupRequest &Request,
8487
llvm::function_ref<void(const clangd::Symbol &)> Callback) const {
85-
streamRPC(Request, &remote::SymbolIndex::Stub::Lookup, Callback);
88+
streamRPC(Request, &remote::v1::SymbolIndex::Stub::Lookup, Callback);
8689
}
8790

8891
bool
8992
fuzzyFind(const clangd::FuzzyFindRequest &Request,
9093
llvm::function_ref<void(const clangd::Symbol &)> Callback) const {
91-
return streamRPC(Request, &remote::SymbolIndex::Stub::FuzzyFind, Callback);
94+
return streamRPC(Request, &remote::v1::SymbolIndex::Stub::FuzzyFind,
95+
Callback);
9296
}
9397

9498
bool refs(const clangd::RefsRequest &Request,
9599
llvm::function_ref<void(const clangd::Ref &)> Callback) const {
96-
return streamRPC(Request, &remote::SymbolIndex::Stub::Refs, Callback);
100+
return streamRPC(Request, &remote::v1::SymbolIndex::Stub::Refs, Callback);
97101
}
98102

99103
void
100104
relations(const clangd::RelationsRequest &Request,
101105
llvm::function_ref<void(const SymbolID &, const clangd::Symbol &)>
102106
Callback) const {
103-
streamRPC(Request, &remote::SymbolIndex::Stub::Relations,
107+
streamRPC(Request, &remote::v1::SymbolIndex::Stub::Relations,
104108
// Unpack protobuf Relation.
105109
[&](std::pair<SymbolID, clangd::Symbol> SubjectAndObject) {
106110
Callback(SubjectAndObject.first, SubjectAndObject.second);
@@ -112,7 +116,7 @@ class IndexClient : public clangd::SymbolIndex {
112116
size_t estimateMemoryUsage() const { return 0; }
113117

114118
private:
115-
std::unique_ptr<remote::SymbolIndex::Stub> Stub;
119+
std::unique_ptr<remote::v1::SymbolIndex::Stub> Stub;
116120
std::unique_ptr<Marshaller> ProtobufMarshaller;
117121
// Each request will be terminated if it takes too long.
118122
std::chrono::milliseconds DeadlineWaitingTime;

clang-tools-extra/clangd/index/remote/Index.proto

Lines changed: 39 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,10 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
syntax = "proto3";
9+
syntax = "proto2";
1010

1111
package clang.clangd.remote;
1212

13-
// Semantics of SymbolIndex match clangd::SymbolIndex with all required
14-
// structures corresponding to their clangd::* counterparts.
15-
service SymbolIndex {
16-
rpc Lookup(LookupRequest) returns (stream LookupReply) {}
17-
18-
rpc FuzzyFind(FuzzyFindRequest) returns (stream FuzzyFindReply) {}
19-
20-
rpc Refs(RefsRequest) returns (stream RefsReply) {}
21-
22-
rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
23-
}
24-
2513
message LookupRequest { repeated string ids = 1; }
2614

2715
// The response is a stream of symbol messages and the terminating message
@@ -34,11 +22,11 @@ message LookupReply {
3422
}
3523

3624
message FuzzyFindRequest {
37-
string query = 1;
25+
optional string query = 1;
3826
repeated string scopes = 2;
39-
bool any_scope = 3;
40-
uint32 limit = 4;
41-
bool restricted_for_code_completion = 5;
27+
optional bool any_scope = 3;
28+
optional uint32 limit = 4;
29+
optional bool restricted_for_code_completion = 5;
4230
repeated string proximity_paths = 6;
4331
repeated string preferred_types = 7;
4432
}
@@ -54,8 +42,8 @@ message FuzzyFindReply {
5442

5543
message RefsRequest {
5644
repeated string ids = 1;
57-
uint32 filter = 2;
58-
uint32 limit = 3;
45+
optional uint32 filter = 2;
46+
optional uint32 limit = 3;
5947
}
6048

6149
// The response is a stream of reference messages, and one terminating has_more
@@ -68,59 +56,59 @@ message RefsReply {
6856
}
6957

7058
message Symbol {
71-
string id = 1;
72-
SymbolInfo info = 2;
73-
string name = 3;
74-
SymbolLocation definition = 4;
75-
string scope = 5;
76-
SymbolLocation canonical_declaration = 6;
77-
int32 references = 7;
78-
uint32 origin = 8;
79-
string signature = 9;
80-
string template_specialization_args = 10;
81-
string completion_snippet_suffix = 11;
82-
string documentation = 12;
83-
string return_type = 13;
84-
string type = 14;
59+
optional string id = 1;
60+
optional SymbolInfo info = 2;
61+
optional string name = 3;
62+
optional SymbolLocation definition = 4;
63+
optional string scope = 5;
64+
optional SymbolLocation canonical_declaration = 6;
65+
optional int32 references = 7;
66+
optional uint32 origin = 8;
67+
optional string signature = 9;
68+
optional string template_specialization_args = 10;
69+
optional string completion_snippet_suffix = 11;
70+
optional string documentation = 12;
71+
optional string return_type = 13;
72+
optional string type = 14;
8573
repeated HeaderWithReferences headers = 15;
86-
uint32 flags = 16;
74+
optional uint32 flags = 16;
8775
}
8876

8977
message Ref {
90-
SymbolLocation location = 1;
91-
uint32 kind = 2;
78+
optional SymbolLocation location = 1;
79+
optional uint32 kind = 2;
9280
}
9381

9482
message SymbolInfo {
95-
uint32 kind = 1;
96-
uint32 subkind = 2;
97-
uint32 language = 3;
98-
uint32 properties = 4;
83+
optional uint32 kind = 1;
84+
optional uint32 subkind = 2;
85+
optional uint32 language = 3;
86+
optional uint32 properties = 4;
9987
}
10088

10189
message SymbolLocation {
102-
Position start = 1;
103-
Position end = 2;
90+
optional Position start = 1;
91+
optional Position end = 2;
10492
// clangd::SymbolLocation stores FileURI, but the protocol transmits a the
10593
// relative path. Because paths are different on the remote and local machines
10694
// they will be translated in the marshalling layer.
107-
string file_path = 3;
95+
optional string file_path = 3;
10896
}
10997

11098
message Position {
111-
uint32 line = 1;
112-
uint32 column = 2;
99+
optional uint32 line = 1;
100+
optional uint32 column = 2;
113101
}
114102

115103
message HeaderWithReferences {
116-
string header = 1;
117-
uint32 references = 2;
104+
optional string header = 1;
105+
optional uint32 references = 2;
118106
}
119107

120108
message RelationsRequest {
121109
repeated string subjects = 1;
122-
uint32 predicate = 2;
123-
uint32 limit = 3;
110+
optional uint32 predicate = 2;
111+
optional uint32 limit = 3;
124112
}
125113

126114
// The response is a stream of reference messages, and one terminating has_more
@@ -135,6 +123,6 @@ message RelationsReply {
135123
// This struct does not mirror clangd::Relation but rather the arguments of
136124
// SymbolIndex::relations callback.
137125
message Relation {
138-
string subject_id = 1;
139-
Symbol object = 2;
126+
optional string subject_id = 1;
127+
optional Symbol object = 2;
140128
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===--- Service.proto - Remote index service definition ------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
syntax = "proto2";
10+
11+
package clang.clangd.remote.v1;
12+
13+
import "Index.proto";
14+
15+
// Semantics of SymbolIndex match clangd::SymbolIndex with all required
16+
// structures corresponding to their clangd::* counterparts.
17+
service SymbolIndex {
18+
rpc Lookup(LookupRequest) returns (stream LookupReply) {}
19+
20+
rpc FuzzyFind(FuzzyFindRequest) returns (stream FuzzyFindReply) {}
21+
22+
rpc Refs(RefsRequest) returns (stream RefsReply) {}
23+
24+
rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
25+
}
26+

clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ add_clang_library(clangdRemoteMarshalling
22
Marshalling.cpp
33

44
LINK_LIBS
5-
RemoteIndexProtos
5+
RemoteIndexProto
66

77
protobuf
88
clangDaemon
99
clangdSupport
1010

1111
DEPENDS
12-
RemoteIndexProtos
12+
RemoteIndexProto
1313
)

0 commit comments

Comments
 (0)