Skip to content

Commit ca36508

Browse files
author
Pavel V Chupin
committed
Merge from 'main' to 'sycl-web' (intel#68)
CONFLICT (content): Merge conflict in clang/lib/Frontend/CompilerInvocation.cpp
2 parents f09f51e + 84c4754 commit ca36508

File tree

341 files changed

+9486
-2328
lines changed

Some content is hidden

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

341 files changed

+9486
-2328
lines changed

clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ class CERTModule : public ClangTidyModule {
125125
ClangTidyOptions Options;
126126
ClangTidyOptions::OptionMap &Opts = Options.CheckOptions;
127127
Opts["cert-dcl16-c.NewSuffixes"] = "L;LL;LU;LLU";
128-
Opts["cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField"] = "0";
129-
Opts["cert-str34-c.DiagnoseSignedUnsignedCharComparisons"] = "0";
128+
Opts["cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField"] = "false";
129+
Opts["cert-str34-c.DiagnoseSignedUnsignedCharComparisons"] = "false";
130130
return Options;
131131
}
132132
};

clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
101101
ClangTidyOptions::OptionMap &Opts = Options.CheckOptions;
102102

103103
Opts["cppcoreguidelines-non-private-member-variables-in-classes."
104-
"IgnoreClassesWithAllMemberVariablesBeingPublic"] = "1";
104+
"IgnoreClassesWithAllMemberVariablesBeingPublic"] = "true";
105105

106106
Opts["cppcoreguidelines-explicit-virtual-functions."
107-
"IgnoreDestructors"] = "1";
107+
"IgnoreDestructors"] = "true";
108108

109109
return Options;
110110
}

clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "clang/AST/ASTContext.h"
1111
#include "clang/ASTMatchers/ASTMatchFinder.h"
1212
#include "clang/ASTMatchers/ASTMatchers.h"
13+
#include "clang/Basic/TargetInfo.h"
1314

1415
using namespace clang::ast_matchers;
1516

@@ -60,8 +61,45 @@ namespace {
6061
AST_MATCHER(QualType, isVAList) {
6162
ASTContext &Context = Finder->getASTContext();
6263
QualType Desugar = Node.getDesugaredType(Context);
63-
return Context.getBuiltinVaListType().getDesugaredType(Context) == Desugar ||
64-
Context.getBuiltinMSVaListType().getDesugaredType(Context) == Desugar;
64+
QualType NodeTy = Node.getUnqualifiedType();
65+
66+
auto CheckVaList = [](QualType NodeTy, QualType Expected,
67+
const ASTContext &Context) {
68+
if (NodeTy == Expected)
69+
return true;
70+
QualType Desugar = NodeTy;
71+
QualType Ty;
72+
do {
73+
Ty = Desugar;
74+
Desugar = Ty.getSingleStepDesugaredType(Context);
75+
if (Desugar == Expected)
76+
return true;
77+
} while (Desugar != Ty);
78+
return false;
79+
};
80+
81+
// The internal implementation of __builtin_va_list depends on the target
82+
// type. Some targets implements va_list as 'char *' or 'void *'.
83+
// In these cases we need to remove all typedefs one by one to check this.
84+
using BuiltinVaListKind = TargetInfo::BuiltinVaListKind;
85+
BuiltinVaListKind VaListKind = Context.getTargetInfo().getBuiltinVaListKind();
86+
if (VaListKind == BuiltinVaListKind::CharPtrBuiltinVaList ||
87+
VaListKind == BuiltinVaListKind::VoidPtrBuiltinVaList) {
88+
if (CheckVaList(NodeTy, Context.getBuiltinVaListType(), Context))
89+
return true;
90+
} else if (Desugar ==
91+
Context.getBuiltinVaListType().getDesugaredType(Context)) {
92+
return true;
93+
}
94+
95+
// We also need to check the implementation of __builtin_ms_va_list in the
96+
// same way, because it may differ from the va_list implementation.
97+
if (Desugar == Context.getBuiltinMSVaListType().getDesugaredType(Context) &&
98+
CheckVaList(NodeTy, Context.getBuiltinMSVaListType(), Context)) {
99+
return true;
100+
}
101+
102+
return false;
65103
}
66104

67105
AST_MATCHER_P(AdjustedType, hasOriginalType,

clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ class LLVMModule : public ClangTidyModule {
4242

4343
ClangTidyOptions getModuleOptions() override {
4444
ClangTidyOptions Options;
45-
Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0";
46-
Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "0";
45+
Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "false";
46+
Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "false";
4747
Options.CheckOptions["llvm-else-after-return.WarnOnConditionVariables"] =
48-
"0";
48+
"false";
4949
return Options;
5050
}
5151
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ if (CLANGD_ENABLE_REMOTE)
3838

3939
add_subdirectory(marshalling)
4040
add_subdirectory(server)
41+
add_subdirectory(monitor)
4142
else()
4243
# Provides a no-op implementation of clangdRemoteIndex.
4344
add_subdirectory(unimplemented)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
set(LLVM_LINK_COMPONENTS
2+
Support
3+
)
4+
add_clang_executable(clangd-index-server-monitor
5+
Monitor.cpp
6+
7+
DEPENDS
8+
RemoteIndexServiceProto
9+
)
10+
11+
target_link_libraries(clangd-index-server-monitor
12+
PRIVATE
13+
clangBasic
14+
clangdSupport
15+
16+
MonitoringServiceProto
17+
RemoteIndexServiceProto
18+
)
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//===--- Monitor.cpp - Request server monitoring information through CLI --===//
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+
#include "MonitoringService.grpc.pb.h"
10+
#include "MonitoringService.pb.h"
11+
12+
#include "support/Logger.h"
13+
#include "clang/Basic/Version.h"
14+
#include "llvm/Support/CommandLine.h"
15+
#include "llvm/Support/Signals.h"
16+
17+
#include <chrono>
18+
#include <google/protobuf/util/json_util.h>
19+
#include <grpc++/grpc++.h>
20+
21+
namespace clang {
22+
namespace clangd {
23+
namespace remote {
24+
namespace {
25+
26+
static constexpr char Overview[] = R"(
27+
This tool requests monitoring information (uptime, index freshness) from the
28+
server and prints it to stdout.
29+
)";
30+
31+
llvm::cl::opt<std::string>
32+
ServerAddress("server-address", llvm::cl::Positional,
33+
llvm::cl::desc("Address of the invoked server."),
34+
llvm::cl::Required);
35+
36+
} // namespace
37+
} // namespace remote
38+
} // namespace clangd
39+
} // namespace clang
40+
41+
int main(int argc, char *argv[]) {
42+
using namespace clang::clangd::remote;
43+
llvm::cl::ParseCommandLineOptions(argc, argv, Overview);
44+
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
45+
46+
const auto Channel =
47+
grpc::CreateChannel(ServerAddress, grpc::InsecureChannelCredentials());
48+
const auto Stub = clang::clangd::remote::v1::Monitor::NewStub(Channel);
49+
grpc::ClientContext Context;
50+
Context.set_deadline(std::chrono::system_clock::now() +
51+
std::chrono::seconds(10));
52+
Context.AddMetadata("version", clang::getClangToolFullVersion("clangd"));
53+
const clang::clangd::remote::v1::MonitoringInfoRequest Request;
54+
clang::clangd::remote::v1::MonitoringInfoReply Response;
55+
const auto Status = Stub->MonitoringInfo(&Context, Request, &Response);
56+
if (!Status.ok()) {
57+
clang::clangd::elog("Can not request monitoring information ({0}): {1}\n",
58+
Status.error_code(), Status.error_message());
59+
return -1;
60+
}
61+
std::string Output;
62+
google::protobuf::util::JsonPrintOptions Options;
63+
Options.add_whitespace = true;
64+
Options.always_print_primitive_fields = true;
65+
Options.preserve_proto_field_names = true;
66+
const auto JsonStatus =
67+
google::protobuf::util::MessageToJsonString(Response, &Output, Options);
68+
if (!JsonStatus.ok()) {
69+
clang::clangd::elog("Can not convert response ({0}) to JSON ({1}): {2}\n",
70+
Response.DebugString(), JsonStatus.error_code(),
71+
JsonStatus.error_message().as_string());
72+
return -1;
73+
}
74+
llvm::outs() << Output;
75+
}

clang-tools-extra/clangd/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if(CLANGD_BUILD_XPC)
2222
endif()
2323

2424
if(CLANGD_ENABLE_REMOTE)
25-
list(APPEND CLANGD_TEST_DEPS clangd-index-server)
25+
list(APPEND CLANGD_TEST_DEPS clangd-index-server clangd-index-server-monitor)
2626
endif()
2727

2828
foreach(dep FileCheck count not llvm-config)

clang-tools-extra/clangd/test/remote-index/pipeline.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
# RUN: %python %S/pipeline_helper.py --input-file-name=%s --project-root=%S --index-file=%t.idx | FileCheck %s
44
# REQUIRES: clangd-remote-index
55

6+
# CHECK: "uptime_seconds": "{{.*}}",
7+
# CHECK-NEXT: "index_age_seconds": "{{.*}}",
8+
# CHECK-NEXT: "index_commit_hash": "{{.*}}",
9+
# CHECK-NEXT: "index_link": "{{.*}}"
10+
611
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
712
# CHECK: "id": 0,
813
# CHECK-NEXT: "jsonrpc": "2.0",

clang-tools-extra/clangd/test/remote-index/pipeline_helper.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import threading
1818

1919

20-
def kill_server_after_delay(server_process):
20+
def kill_process_after_delay(server_process):
2121
time.sleep(10)
2222
if server_process.poll() is None:
2323
server_process.kill()
@@ -48,7 +48,7 @@ def main():
4848
# This will kill index_server_process if it hangs without printing init
4949
# message.
5050
shutdown_thread = threading.Thread(
51-
target=kill_server_after_delay, args=(index_server_process,))
51+
target=kill_process_after_delay, args=(index_server_process,))
5252
shutdown_thread.daemon = True
5353
shutdown_thread.start()
5454

@@ -67,6 +67,13 @@ def main():
6767
print('Server initialization failed. Shutting down.', file=sys.stderr)
6868
sys.exit(1)
6969

70+
print('Running clangd-index-server-monitor...', file=sys.stderr)
71+
index_server_monitor_process = subprocess.Popen([
72+
'clangd-index-server-monitor', server_address,
73+
], stderr=subprocess.PIPE)
74+
75+
index_server_monitor_process.wait()
76+
7077
in_file = open(args.input_file_name)
7178

7279
print('Staring clangd...', file=sys.stderr)
@@ -84,6 +91,10 @@ def main():
8491
args.server_log.write(line)
8592
args.server_log.flush()
8693

94+
for line in index_server_monitor_process.stderr:
95+
args.server_log.write(line)
96+
args.server_log.flush()
97+
8798

8899
if __name__ == '__main__':
89100
main()

0 commit comments

Comments
 (0)