Skip to content

Commit

Permalink
Merge from 'main' to 'sycl-web' (intel#68)
Browse files Browse the repository at this point in the history
  CONFLICT (content): Merge conflict in clang/lib/Frontend/CompilerInvocation.cpp
  • Loading branch information
Pavel V Chupin committed May 5, 2021
2 parents f09f51e + 84c4754 commit ca36508
Show file tree
Hide file tree
Showing 341 changed files with 9,486 additions and 2,328 deletions.
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ class CERTModule : public ClangTidyModule {
ClangTidyOptions Options;
ClangTidyOptions::OptionMap &Opts = Options.CheckOptions;
Opts["cert-dcl16-c.NewSuffixes"] = "L;LL;LU;LLU";
Opts["cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField"] = "0";
Opts["cert-str34-c.DiagnoseSignedUnsignedCharComparisons"] = "0";
Opts["cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField"] = "false";
Opts["cert-str34-c.DiagnoseSignedUnsignedCharComparisons"] = "false";
return Options;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
ClangTidyOptions::OptionMap &Opts = Options.CheckOptions;

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

Opts["cppcoreguidelines-explicit-virtual-functions."
"IgnoreDestructors"] = "1";
"IgnoreDestructors"] = "true";

return Options;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Basic/TargetInfo.h"

using namespace clang::ast_matchers;

Expand Down Expand Up @@ -60,8 +61,45 @@ namespace {
AST_MATCHER(QualType, isVAList) {
ASTContext &Context = Finder->getASTContext();
QualType Desugar = Node.getDesugaredType(Context);
return Context.getBuiltinVaListType().getDesugaredType(Context) == Desugar ||
Context.getBuiltinMSVaListType().getDesugaredType(Context) == Desugar;
QualType NodeTy = Node.getUnqualifiedType();

auto CheckVaList = [](QualType NodeTy, QualType Expected,
const ASTContext &Context) {
if (NodeTy == Expected)
return true;
QualType Desugar = NodeTy;
QualType Ty;
do {
Ty = Desugar;
Desugar = Ty.getSingleStepDesugaredType(Context);
if (Desugar == Expected)
return true;
} while (Desugar != Ty);
return false;
};

// The internal implementation of __builtin_va_list depends on the target
// type. Some targets implements va_list as 'char *' or 'void *'.
// In these cases we need to remove all typedefs one by one to check this.
using BuiltinVaListKind = TargetInfo::BuiltinVaListKind;
BuiltinVaListKind VaListKind = Context.getTargetInfo().getBuiltinVaListKind();
if (VaListKind == BuiltinVaListKind::CharPtrBuiltinVaList ||
VaListKind == BuiltinVaListKind::VoidPtrBuiltinVaList) {
if (CheckVaList(NodeTy, Context.getBuiltinVaListType(), Context))
return true;
} else if (Desugar ==
Context.getBuiltinVaListType().getDesugaredType(Context)) {
return true;
}

// We also need to check the implementation of __builtin_ms_va_list in the
// same way, because it may differ from the va_list implementation.
if (Desugar == Context.getBuiltinMSVaListType().getDesugaredType(Context) &&
CheckVaList(NodeTy, Context.getBuiltinMSVaListType(), Context)) {
return true;
}

return false;
}

AST_MATCHER_P(AdjustedType, hasOriginalType,
Expand Down
6 changes: 3 additions & 3 deletions clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class LLVMModule : public ClangTidyModule {

ClangTidyOptions getModuleOptions() override {
ClangTidyOptions Options;
Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0";
Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "0";
Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "false";
Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "false";
Options.CheckOptions["llvm-else-after-return.WarnOnConditionVariables"] =
"0";
"false";
return Options;
}
};
Expand Down
1 change: 1 addition & 0 deletions clang-tools-extra/clangd/index/remote/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ if (CLANGD_ENABLE_REMOTE)

add_subdirectory(marshalling)
add_subdirectory(server)
add_subdirectory(monitor)
else()
# Provides a no-op implementation of clangdRemoteIndex.
add_subdirectory(unimplemented)
Expand Down
18 changes: 18 additions & 0 deletions clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
set(LLVM_LINK_COMPONENTS
Support
)
add_clang_executable(clangd-index-server-monitor
Monitor.cpp

DEPENDS
RemoteIndexServiceProto
)

target_link_libraries(clangd-index-server-monitor
PRIVATE
clangBasic
clangdSupport

MonitoringServiceProto
RemoteIndexServiceProto
)
75 changes: 75 additions & 0 deletions clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//===--- Monitor.cpp - Request server monitoring information through CLI --===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "MonitoringService.grpc.pb.h"
#include "MonitoringService.pb.h"

#include "support/Logger.h"
#include "clang/Basic/Version.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Signals.h"

#include <chrono>
#include <google/protobuf/util/json_util.h>
#include <grpc++/grpc++.h>

namespace clang {
namespace clangd {
namespace remote {
namespace {

static constexpr char Overview[] = R"(
This tool requests monitoring information (uptime, index freshness) from the
server and prints it to stdout.
)";

llvm::cl::opt<std::string>
ServerAddress("server-address", llvm::cl::Positional,
llvm::cl::desc("Address of the invoked server."),
llvm::cl::Required);

} // namespace
} // namespace remote
} // namespace clangd
} // namespace clang

int main(int argc, char *argv[]) {
using namespace clang::clangd::remote;
llvm::cl::ParseCommandLineOptions(argc, argv, Overview);
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);

const auto Channel =
grpc::CreateChannel(ServerAddress, grpc::InsecureChannelCredentials());
const auto Stub = clang::clangd::remote::v1::Monitor::NewStub(Channel);
grpc::ClientContext Context;
Context.set_deadline(std::chrono::system_clock::now() +
std::chrono::seconds(10));
Context.AddMetadata("version", clang::getClangToolFullVersion("clangd"));
const clang::clangd::remote::v1::MonitoringInfoRequest Request;
clang::clangd::remote::v1::MonitoringInfoReply Response;
const auto Status = Stub->MonitoringInfo(&Context, Request, &Response);
if (!Status.ok()) {
clang::clangd::elog("Can not request monitoring information ({0}): {1}\n",
Status.error_code(), Status.error_message());
return -1;
}
std::string Output;
google::protobuf::util::JsonPrintOptions Options;
Options.add_whitespace = true;
Options.always_print_primitive_fields = true;
Options.preserve_proto_field_names = true;
const auto JsonStatus =
google::protobuf::util::MessageToJsonString(Response, &Output, Options);
if (!JsonStatus.ok()) {
clang::clangd::elog("Can not convert response ({0}) to JSON ({1}): {2}\n",
Response.DebugString(), JsonStatus.error_code(),
JsonStatus.error_message().as_string());
return -1;
}
llvm::outs() << Output;
}
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if(CLANGD_BUILD_XPC)
endif()

if(CLANGD_ENABLE_REMOTE)
list(APPEND CLANGD_TEST_DEPS clangd-index-server)
list(APPEND CLANGD_TEST_DEPS clangd-index-server clangd-index-server-monitor)
endif()

foreach(dep FileCheck count not llvm-config)
Expand Down
5 changes: 5 additions & 0 deletions clang-tools-extra/clangd/test/remote-index/pipeline.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# RUN: %python %S/pipeline_helper.py --input-file-name=%s --project-root=%S --index-file=%t.idx | FileCheck %s
# REQUIRES: clangd-remote-index

# CHECK: "uptime_seconds": "{{.*}}",
# CHECK-NEXT: "index_age_seconds": "{{.*}}",
# CHECK-NEXT: "index_commit_hash": "{{.*}}",
# CHECK-NEXT: "index_link": "{{.*}}"

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
# CHECK: "id": 0,
# CHECK-NEXT: "jsonrpc": "2.0",
Expand Down
15 changes: 13 additions & 2 deletions clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import threading


def kill_server_after_delay(server_process):
def kill_process_after_delay(server_process):
time.sleep(10)
if server_process.poll() is None:
server_process.kill()
Expand Down Expand Up @@ -48,7 +48,7 @@ def main():
# This will kill index_server_process if it hangs without printing init
# message.
shutdown_thread = threading.Thread(
target=kill_server_after_delay, args=(index_server_process,))
target=kill_process_after_delay, args=(index_server_process,))
shutdown_thread.daemon = True
shutdown_thread.start()

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

print('Running clangd-index-server-monitor...', file=sys.stderr)
index_server_monitor_process = subprocess.Popen([
'clangd-index-server-monitor', server_address,
], stderr=subprocess.PIPE)

index_server_monitor_process.wait()

in_file = open(args.input_file_name)

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

for line in index_server_monitor_process.stderr:
args.server_log.write(line)
args.server_log.flush()


if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// RUN: %check_clang_tidy %s bugprone-argument-comment %t -- \
// RUN: -config="{CheckOptions: [ \
// RUN: {key: bugprone-argument-comment.IgnoreSingleArgument, value: 1}, \
// RUN: {key: bugprone-argument-comment.CommentBoolLiterals, value: 1}, \
// RUN: {key: bugprone-argument-comment.CommentIntegerLiterals, value: 1}, \
// RUN: {key: bugprone-argument-comment.CommentFloatLiterals, value: 1}, \
// RUN: {key: bugprone-argument-comment.CommentUserDefinedLiterals, value: 1}, \
// RUN: {key: bugprone-argument-comment.CommentStringLiterals, value: 1}, \
// RUN: {key: bugprone-argument-comment.CommentNullPtrs, value: 1}, \
// RUN: {key: bugprone-argument-comment.CommentCharacterLiterals, value: 1}]}" --
// RUN: {key: bugprone-argument-comment.IgnoreSingleArgument, value: true}, \
// RUN: {key: bugprone-argument-comment.CommentBoolLiterals, value: true}, \
// RUN: {key: bugprone-argument-comment.CommentIntegerLiterals, value: true}, \
// RUN: {key: bugprone-argument-comment.CommentFloatLiterals, value: true}, \
// RUN: {key: bugprone-argument-comment.CommentUserDefinedLiterals, value: true}, \
// RUN: {key: bugprone-argument-comment.CommentStringLiterals, value: true}, \
// RUN: {key: bugprone-argument-comment.CommentNullPtrs, value: true}, \
// RUN: {key: bugprone-argument-comment.CommentCharacterLiterals, value: true}]}" --

struct A {
void foo(bool abc);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// RUN: %check_clang_tidy %s bugprone-argument-comment %t -- \
// RUN: -config="{CheckOptions: [ \
// RUN: {key: bugprone-argument-comment.CommentBoolLiterals, value: 1}, \
// RUN: {key: bugprone-argument-comment.CommentIntegerLiterals, value: 1}, \
// RUN: {key: bugprone-argument-comment.CommentFloatLiterals, value: 1}, \
// RUN: {key: bugprone-argument-comment.CommentUserDefinedLiterals, value: 1}, \
// RUN: {key: bugprone-argument-comment.CommentStringLiterals, value: 1}, \
// RUN: {key: bugprone-argument-comment.CommentNullPtrs, value: 1}, \
// RUN: {key: bugprone-argument-comment.CommentCharacterLiterals, value: 1}]}" --
// RUN: {key: bugprone-argument-comment.CommentBoolLiterals, value: true}, \
// RUN: {key: bugprone-argument-comment.CommentIntegerLiterals, value: true}, \
// RUN: {key: bugprone-argument-comment.CommentFloatLiterals, value: true}, \
// RUN: {key: bugprone-argument-comment.CommentUserDefinedLiterals, value: true}, \
// RUN: {key: bugprone-argument-comment.CommentStringLiterals, value: true}, \
// RUN: {key: bugprone-argument-comment.CommentNullPtrs, value: true}, \
// RUN: {key: bugprone-argument-comment.CommentCharacterLiterals, value: true}]}" --

struct A {
void foo(bool abc);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %check_clang_tidy %s bugprone-argument-comment %t -- \
// RUN: -config="{CheckOptions: [{key: StrictMode, value: 1}]}" --
// RUN: -config="{CheckOptions: [{key: StrictMode, value: true}]}" --

void f(int _with_underscores_);
void g(int x_);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %check_clang_tidy %s bugprone-assert-side-effect %t -- -config="{CheckOptions: [{key: bugprone-assert-side-effect.CheckFunctionCalls, value: 1}, {key: bugprone-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert,msvc_assert'}]}" -- -fexceptions
// RUN: %check_clang_tidy %s bugprone-assert-side-effect %t -- -config="{CheckOptions: [{key: bugprone-assert-side-effect.CheckFunctionCalls, value: true}, {key: bugprone-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert,msvc_assert'}]}" -- -fexceptions

//===--- assert definition block ------------------------------------------===//
int abort() { return 0; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

// RUN: %check_clang_tidy -check-suffixes=ALL,C -std=c99 %s bugprone-implicit-widening-of-multiplication-result %t -- \
// RUN: -config='{CheckOptions: [ \
// RUN: {key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources, value: 0} \
// RUN: {key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources, value: false} \
// RUN: ]}' -- -target x86_64-unknown-unknown -x c
// RUN: %check_clang_tidy -check-suffixes=ALL,C %s bugprone-implicit-widening-of-multiplication-result %t -- \
// RUN: -config='{CheckOptions: [ \
// RUN: {key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources, value: 0} \
// RUN: {key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources, value: false} \
// RUN: ]}' -- -target x86_64-unknown-unknown -x c++

char *t0(char *base, int a, int b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

// RUN: %check_clang_tidy -check-suffixes=ALL,C -std=c99 %s bugprone-implicit-widening-of-multiplication-result %t -- \
// RUN: -config='{CheckOptions: [ \
// RUN: {key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources, value: 0} \
// RUN: {key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources, value: false} \
// RUN: ]}' -- -target x86_64-unknown-unknown -x c
// RUN: %check_clang_tidy -check-suffixes=ALL,C %s bugprone-implicit-widening-of-multiplication-result %t -- \
// RUN: -config='{CheckOptions: [ \
// RUN: {key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources, value: 0} \
// RUN: {key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources, value: false} \
// RUN: ]}' -- -target x86_64-unknown-unknown -x c++

long t0(int a, int b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

// RUN: %check_clang_tidy -check-suffixes=ALL,C -std=c99 %s bugprone-implicit-widening-of-multiplication-result %t -- \
// RUN: -config='{CheckOptions: [ \
// RUN: {key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources, value: 0} \
// RUN: {key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources, value: false} \
// RUN: ]}' -- -target x86_64-unknown-unknown -x c
// RUN: %check_clang_tidy -check-suffixes=ALL,C %s bugprone-implicit-widening-of-multiplication-result %t -- \
// RUN: -config='{CheckOptions: [ \
// RUN: {key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources, value: 0} \
// RUN: {key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources, value: false} \
// RUN: ]}' -- -target x86_64-unknown-unknown -x c++

char *t0(char *base, int a, int b) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %check_clang_tidy %s bugprone-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: bugprone-misplaced-widening-cast.CheckImplicitCasts, value: 0}]}" --
// RUN: %check_clang_tidy %s bugprone-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: bugprone-misplaced-widening-cast.CheckImplicitCasts, value: false}]}" --

void func(long arg) {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %check_clang_tidy %s bugprone-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: bugprone-misplaced-widening-cast.CheckImplicitCasts, value: 1}]}" --
// RUN: %check_clang_tidy %s bugprone-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: bugprone-misplaced-widening-cast.CheckImplicitCasts, value: true}]}" --

void func(long arg) {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- \
// RUN: -config="{CheckOptions: \
// RUN: [{key: bugprone-not-null-terminated-result.WantToUseSafeFunctions, \
// RUN: value: 1}]}" \
// RUN: value: true}]}" \
// RUN: -- -std=c11 -I %S/Inputs/bugprone-not-null-terminated-result

#include "not-null-terminated-result-c.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %check_clang_tidy %s bugprone-reserved-identifier %t -- \
// RUN: -config='{CheckOptions: [ \
// RUN: {key: bugprone-reserved-identifier.Invert, value: 1}, \
// RUN: {key: bugprone-reserved-identifier.Invert, value: true}, \
// RUN: {key: bugprone-reserved-identifier.AllowedIdentifiers, value: std;reference_wrapper;ref;cref;type;get}, \
// RUN: ]}' -- \
// RUN: -I%S/Inputs/bugprone-reserved-identifier \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %check_clang_tidy %s bugprone-sizeof-expression %t -- -config="{CheckOptions: [{key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression, value: 1}]}" --
// RUN: %check_clang_tidy %s bugprone-sizeof-expression %t -- -config="{CheckOptions: [{key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression, value: true}]}" --

class C {
int size() { return sizeof(this); }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %check_clang_tidy %s bugprone-suspicious-enum-usage %t -- -config="{CheckOptions: [{key: bugprone-suspicious-enum-usage.StrictMode, value: 1}]}" --
// RUN: %check_clang_tidy %s bugprone-suspicious-enum-usage %t -- -config="{CheckOptions: [{key: bugprone-suspicious-enum-usage.StrictMode, value: true}]}" --

enum A {
A = 1,
Expand Down
Loading

0 comments on commit ca36508

Please sign in to comment.