Skip to content

Commit 60c31c1

Browse files
author
Artem Gindinson
committed
Merge from 'main' to 'sycl-web' (#12)
CONFLICT (content): Merge conflict in clang/unittests/Frontend/CompilerInvocationTest.cpp CONFLICT (content): Merge conflict in clang/test/SemaSYCL/prohibit-thread-local.cpp CONFLICT (content): Merge conflict in clang/test/SemaSYCL/kernel-attribute.cpp CONFLICT (content): Merge conflict in clang/test/SemaSYCL/int128.cpp CONFLICT (content): Merge conflict in clang/test/SemaSYCL/float128.cpp CONFLICT (content): Merge conflict in clang/test/Preprocessor/sycl-macro.cpp CONFLICT (add/add): Merge conflict in clang/test/Frontend/sycl.cpp CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChains/Clang.cpp CONFLICT (content): Merge conflict in clang/include/clang/Driver/Options.td CONFLICT (content): Merge conflict in clang/include/clang/Basic/LangOptions.def
2 parents 7719524 + c165a99 commit 60c31c1

File tree

401 files changed

+13095
-4971
lines changed

Some content is hidden

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

401 files changed

+13095
-4971
lines changed

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

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ add_clang_library(clangTidyReadabilityModule
1010
ContainerSizeEmptyCheck.cpp
1111
ConvertMemberFunctionsToStatic.cpp
1212
DeleteNullPointerCheck.cpp
13-
DeletedDefaultCheck.cpp
1413
ElseAfterReturnCheck.cpp
1514
FunctionCognitiveComplexityCheck.cpp
1615
FunctionSizeCheck.cpp

clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.cpp

-68
This file was deleted.

clang-tools-extra/clang-tidy/readability/DeletedDefaultCheck.h

-35
This file was deleted.

clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "ContainerSizeEmptyCheck.h"
1616
#include "ConvertMemberFunctionsToStatic.h"
1717
#include "DeleteNullPointerCheck.h"
18-
#include "DeletedDefaultCheck.h"
1918
#include "ElseAfterReturnCheck.h"
2019
#include "FunctionCognitiveComplexityCheck.h"
2120
#include "FunctionSizeCheck.h"
@@ -67,8 +66,6 @@ class ReadabilityModule : public ClangTidyModule {
6766
"readability-convert-member-functions-to-static");
6867
CheckFactories.registerCheck<DeleteNullPointerCheck>(
6968
"readability-delete-null-pointer");
70-
CheckFactories.registerCheck<DeletedDefaultCheck>(
71-
"readability-deleted-default");
7269
CheckFactories.registerCheck<ElseAfterReturnCheck>(
7370
"readability-else-after-return");
7471
CheckFactories.registerCheck<FunctionCognitiveComplexityCheck>(

clang-tools-extra/clangd/ClangdServer.cpp

+19-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "ClangdServer.h"
1010
#include "CodeComplete.h"
1111
#include "Config.h"
12+
#include "Diagnostics.h"
1213
#include "DumpAST.h"
1314
#include "FindSymbols.h"
1415
#include "Format.h"
@@ -81,7 +82,9 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
8182
if (FIndex)
8283
FIndex->updateMain(Path, AST);
8384

84-
std::vector<Diag> Diagnostics = AST.getDiagnostics();
85+
assert(AST.getDiagnostics().hasValue() &&
86+
"We issue callback only with fresh preambles");
87+
std::vector<Diag> Diagnostics = *AST.getDiagnostics();
8588
if (ServerCallbacks)
8689
Publish([&]() {
8790
ServerCallbacks->onDiagnosticsReady(Path, AST.version(),
@@ -902,6 +905,21 @@ void ClangdServer::customAction(PathRef File, llvm::StringRef Name,
902905
WorkScheduler->runWithAST(Name, File, std::move(Action));
903906
}
904907

908+
void ClangdServer::diagnostics(PathRef File, Callback<std::vector<Diag>> CB) {
909+
auto Action =
910+
[CB = std::move(CB)](llvm::Expected<InputsAndAST> InpAST) mutable {
911+
if (!InpAST)
912+
return CB(InpAST.takeError());
913+
if (auto Diags = InpAST->AST.getDiagnostics())
914+
return CB(*Diags);
915+
// FIXME: Use ServerCancelled error once it is settled in LSP-3.17.
916+
return CB(llvm::make_error<LSPError>("server is busy parsing includes",
917+
ErrorCode::InternalError));
918+
};
919+
920+
WorkScheduler->runWithAST("Diagnostics", File, std::move(Action));
921+
}
922+
905923
llvm::StringMap<TUScheduler::FileStats> ClangdServer::fileStats() const {
906924
return WorkScheduler->fileStats();
907925
}

clang-tools-extra/clangd/ClangdServer.h

+12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "../clang-tidy/ClangTidyOptions.h"
1313
#include "CodeComplete.h"
1414
#include "ConfigProvider.h"
15+
#include "Diagnostics.h"
1516
#include "DraftStore.h"
1617
#include "FeatureModule.h"
1718
#include "GlobalCompilationDatabase.h"
@@ -40,6 +41,7 @@
4041
#include <string>
4142
#include <type_traits>
4243
#include <utility>
44+
#include <vector>
4345

4446
namespace clang {
4547
namespace clangd {
@@ -64,6 +66,8 @@ class ClangdServer {
6466
virtual ~Callbacks() = default;
6567

6668
/// Called by ClangdServer when \p Diagnostics for \p File are ready.
69+
/// These pushed diagnostics might correspond to an older version of the
70+
/// file, they do not interfere with "pull-based" ClangdServer::diagnostics.
6771
/// May be called concurrently for separate files, not for a single file.
6872
virtual void onDiagnosticsReady(PathRef File, llvm::StringRef Version,
6973
std::vector<Diag> Diagnostics) {}
@@ -345,6 +349,14 @@ class ClangdServer {
345349
void customAction(PathRef File, llvm::StringRef Name,
346350
Callback<InputsAndAST> Action);
347351

352+
/// Fetches diagnostics for current version of the \p File. This might fail if
353+
/// server is busy (building a preamble) and would require a long time to
354+
/// prepare diagnostics. If it fails, clients should wait for
355+
/// onSemanticsMaybeChanged and then retry.
356+
/// These 'pulled' diagnostics do not interfere with the diagnostics 'pushed'
357+
/// to Callbacks::onDiagnosticsReady, and clients may use either or both.
358+
void diagnostics(PathRef File, Callback<std::vector<Diag>> CB);
359+
348360
/// Returns estimated memory usage and other statistics for each of the
349361
/// currently open files.
350362
/// Overall memory usage of clangd may be significantly more than reported

clang-tools-extra/clangd/ParsedAST.cpp

+20-14
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,11 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
264264
StoreDiags ASTDiags;
265265

266266
llvm::Optional<PreamblePatch> Patch;
267+
bool PreserveDiags = true;
267268
if (Preamble) {
268269
Patch = PreamblePatch::create(Filename, Inputs, *Preamble);
269270
Patch->apply(*CI);
271+
PreserveDiags = Patch->preserveDiagnostics();
270272
}
271273
auto Clang = prepareCompilerInstance(
272274
std::move(CI), PreamblePCH,
@@ -441,14 +443,20 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
441443
// CompilerInstance won't run this callback, do it directly.
442444
ASTDiags.EndSourceFile();
443445

444-
std::vector<Diag> Diags = CompilerInvocationDiags;
445-
// Add diagnostics from the preamble, if any.
446-
if (Preamble)
447-
Diags.insert(Diags.end(), Preamble->Diags.begin(), Preamble->Diags.end());
448-
// Finally, add diagnostics coming from the AST.
449-
{
450-
std::vector<Diag> D = ASTDiags.take(CTContext.getPointer());
451-
Diags.insert(Diags.end(), D.begin(), D.end());
446+
llvm::Optional<std::vector<Diag>> Diags;
447+
// FIXME: Also skip generation of diagnostics alltogether to speed up ast
448+
// builds when we are patching a stale preamble.
449+
if (PreserveDiags) {
450+
Diags = CompilerInvocationDiags;
451+
// Add diagnostics from the preamble, if any.
452+
if (Preamble)
453+
Diags->insert(Diags->end(), Preamble->Diags.begin(),
454+
Preamble->Diags.end());
455+
// Finally, add diagnostics coming from the AST.
456+
{
457+
std::vector<Diag> D = ASTDiags.take(CTContext.getPointer());
458+
Diags->insert(Diags->end(), D.begin(), D.end());
459+
}
452460
}
453461
return ParsedAST(Inputs.Version, std::move(Preamble), std::move(Clang),
454462
std::move(Action), std::move(Tokens), std::move(Macros),
@@ -493,14 +501,12 @@ llvm::ArrayRef<Decl *> ParsedAST::getLocalTopLevelDecls() {
493501

494502
const MainFileMacros &ParsedAST::getMacros() const { return Macros; }
495503

496-
const std::vector<Diag> &ParsedAST::getDiagnostics() const { return Diags; }
497-
498504
std::size_t ParsedAST::getUsedBytes() const {
499505
auto &AST = getASTContext();
500506
// FIXME(ibiryukov): we do not account for the dynamically allocated part of
501507
// Message and Fixes inside each diagnostic.
502-
std::size_t Total =
503-
clangd::getUsedBytes(LocalTopLevelDecls) + clangd::getUsedBytes(Diags);
508+
std::size_t Total = clangd::getUsedBytes(LocalTopLevelDecls) +
509+
(Diags ? clangd::getUsedBytes(*Diags) : 0);
504510

505511
// FIXME: the rest of the function is almost a direct copy-paste from
506512
// libclang's clang_getCXTUResourceUsage. We could share the implementation.
@@ -541,8 +547,8 @@ ParsedAST::ParsedAST(llvm::StringRef Version,
541547
std::unique_ptr<FrontendAction> Action,
542548
syntax::TokenBuffer Tokens, MainFileMacros Macros,
543549
std::vector<Decl *> LocalTopLevelDecls,
544-
std::vector<Diag> Diags, IncludeStructure Includes,
545-
CanonicalIncludes CanonIncludes)
550+
llvm::Optional<std::vector<Diag>> Diags,
551+
IncludeStructure Includes, CanonicalIncludes CanonIncludes)
546552
: Version(Version), Preamble(std::move(Preamble)), Clang(std::move(Clang)),
547553
Action(std::move(Action)), Tokens(std::move(Tokens)),
548554
Macros(std::move(Macros)), Diags(std::move(Diags)),

clang-tools-extra/clangd/ParsedAST.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ class ParsedAST {
8888
/// (These should be const, but RecursiveASTVisitor requires Decl*).
8989
ArrayRef<Decl *> getLocalTopLevelDecls();
9090

91-
const std::vector<Diag> &getDiagnostics() const;
91+
const llvm::Optional<std::vector<Diag>> &getDiagnostics() const {
92+
return Diags;
93+
}
9294

9395
/// Returns the estimated size of the AST and the accessory structures, in
9496
/// bytes. Does not include the size of the preamble.
@@ -120,7 +122,7 @@ class ParsedAST {
120122
std::unique_ptr<CompilerInstance> Clang,
121123
std::unique_ptr<FrontendAction> Action, syntax::TokenBuffer Tokens,
122124
MainFileMacros Macros, std::vector<Decl *> LocalTopLevelDecls,
123-
std::vector<Diag> Diags, IncludeStructure Includes,
125+
llvm::Optional<std::vector<Diag>> Diags, IncludeStructure Includes,
124126
CanonicalIncludes CanonIncludes);
125127

126128
std::string Version;
@@ -142,8 +144,8 @@ class ParsedAST {
142144

143145
/// All macro definitions and expansions in the main file.
144146
MainFileMacros Macros;
145-
// Data, stored after parsing.
146-
std::vector<Diag> Diags;
147+
// Data, stored after parsing. None if AST was built with a stale preamble.
148+
llvm::Optional<std::vector<Diag>> Diags;
147149
// Top-level decls inside the current file. Not that this does not include
148150
// top-level decls from the preamble.
149151
std::vector<Decl *> LocalTopLevelDecls;

clang-tools-extra/clangd/Preamble.h

+3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ class PreamblePatch {
126126
/// Returns textual patch contents.
127127
llvm::StringRef text() const { return PatchContents; }
128128

129+
/// Whether diagnostics generated using this patch are trustable.
130+
bool preserveDiagnostics() const { return PatchContents.empty(); }
131+
129132
private:
130133
PreamblePatch() = default;
131134
std::string PatchContents;

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

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
if (CLANGD_ENABLE_REMOTE)
22
generate_protos(RemoteIndexProto "Index.proto")
3+
generate_protos(MonitoringServiceProto "MonitoringService.proto"
4+
GRPC)
35
generate_protos(RemoteIndexServiceProto "Service.proto"
46
DEPENDS "Index.proto"
57
GRPC)
@@ -8,6 +10,7 @@ if (CLANGD_ENABLE_REMOTE)
810
target_link_libraries(RemoteIndexServiceProto
911
PRIVATE
1012
RemoteIndexProto
13+
MonitoringServiceProto
1114
)
1215
include_directories(${CMAKE_CURRENT_BINARY_DIR})
1316
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===--- MonitoringService.proto - CLangd Remote index monitoring service -===//
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+
message MonitoringInfoRequest {}
14+
message MonitoringInfoReply {
15+
// Time since the server started (in seconds).
16+
optional uint64 uptime_seconds = 1;
17+
// Time since the index was built on the indexing machine.
18+
optional uint64 index_age_seconds = 2;
19+
// ID of the indexed commit in Version Control System.
20+
optional string index_commit_hash = 3;
21+
// URL to the index file.
22+
optional string index_link = 4;
23+
}
24+
25+
service Monitor {
26+
rpc MonitoringInfo(MonitoringInfoRequest) returns (MonitoringInfoReply) {}
27+
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ service SymbolIndex {
2323

2424
rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
2525
}
26-

0 commit comments

Comments
 (0)