Skip to content

Commit

Permalink
Merged master:930a8c60b608 into amd-gfx:68d3270fef04
Browse files Browse the repository at this point in the history
Local branch amd-gfx 68d3270 Merged master:20a3931f8fad into amd-gfx:9e4c96697575
Remote branch master 930a8c6 [DebugInfo] [NFCI] Adding a missed out line in support for DW_TAG_generic_subrange.
  • Loading branch information
Sw authored and Sw committed Oct 29, 2020
2 parents 68d3270 + 930a8c6 commit 7c4e681
Show file tree
Hide file tree
Showing 33 changed files with 703 additions and 427 deletions.
28 changes: 18 additions & 10 deletions clang-tools-extra/clangd/ClangdLSPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,12 +993,24 @@ void ClangdLSPServer::onCodeAction(const CodeActionParams &Params,
if (!Code)
return Reply(llvm::make_error<LSPError>(
"onCodeAction called for non-added file", ErrorCode::InvalidParams));

// Checks whether a particular CodeActionKind is included in the response.
auto KindAllowed = [Only(Params.context.only)](llvm::StringRef Kind) {
if (Only.empty())
return true;
return llvm::any_of(Only, [&](llvm::StringRef Base) {
return Kind.consume_front(Base) && (Kind.empty() || Kind.startswith("."));
});
};

// We provide a code action for Fixes on the specified diagnostics.
std::vector<CodeAction> FixIts;
for (const Diagnostic &D : Params.context.diagnostics) {
for (auto &F : getFixes(File.file(), D)) {
FixIts.push_back(toCodeAction(F, Params.textDocument.uri));
FixIts.back().diagnostics = {D};
if (KindAllowed(CodeAction::QUICKFIX_KIND)) {
for (const Diagnostic &D : Params.context.diagnostics) {
for (auto &F : getFixes(File.file(), D)) {
FixIts.push_back(toCodeAction(F, Params.textDocument.uri));
FixIts.back().diagnostics = {D};
}
}
}

Expand Down Expand Up @@ -1038,14 +1050,10 @@ void ClangdLSPServer::onCodeAction(const CodeActionParams &Params,
}
return Reply(llvm::json::Array(Commands));
};

Server->enumerateTweaks(
File.file(), Params.range,
[&](const Tweak &T) {
if (!Opts.TweakFilter(T))
return false;
// FIXME: also consider CodeActionContext.only
return true;
[this, KindAllowed(std::move(KindAllowed))](const Tweak &T) {
return Opts.TweakFilter(T) && KindAllowed(T.kind());
},
std::move(ConsumeActions));
}
Expand Down
5 changes: 4 additions & 1 deletion clang-tools-extra/clangd/Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,10 @@ llvm::json::Value toJSON(const PublishDiagnosticsParams &PDP) {
bool fromJSON(const llvm::json::Value &Params, CodeActionContext &R,
llvm::json::Path P) {
llvm::json::ObjectMapper O(Params, P);
return O && O.map("diagnostics", R.diagnostics);
if (!O || !O.map("diagnostics", R.diagnostics))
return false;
O.map("only", R.only);
return true;
}

llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Diagnostic &D) {
Expand Down
13 changes: 12 additions & 1 deletion clang-tools-extra/clangd/Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -863,8 +863,19 @@ struct PublishDiagnosticsParams {
llvm::json::Value toJSON(const PublishDiagnosticsParams &);

struct CodeActionContext {
/// An array of diagnostics.
/// An array of diagnostics known on the client side overlapping the range
/// provided to the `textDocument/codeAction` request. They are provided so
/// that the server knows which errors are currently presented to the user for
/// the given range. There is no guarantee that these accurately reflect the
/// error state of the resource. The primary parameter to compute code actions
/// is the provided range.
std::vector<Diagnostic> diagnostics;

/// Requested kind of actions to return.
///
/// Actions not of this kind are filtered out by the client before being
/// shown. So servers can omit computing them.
std::vector<std::string> only;
};
bool fromJSON(const llvm::json::Value &, CodeActionContext &, llvm::json::Path);

Expand Down
11 changes: 3 additions & 8 deletions clang-tools-extra/clangd/index/remote/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
if (CLANGD_ENABLE_REMOTE)
generate_protos(RemoteIndexServiceProto "Service.proto" GRPC)
generate_protos(RemoteIndexProto "Index.proto")
# Ensure dependency headers are generated before dependent protos are built.
# FIXME: this should be encapsulated in generate_protos.
# FIXME: CMake docs say OBJECT_DEPENDS isn't needed, but I can't get the
# recommended add_dependencies() approach to work.
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/Service.pb.cc
PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Index.pb.h)
generate_protos(RemoteIndexServiceProto "Service.proto"
DEPENDS "Index.proto"
GRPC)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)

Expand Down
43 changes: 42 additions & 1 deletion clang-tools-extra/clangd/test/code-action-request.test
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,47 @@
# CHECK-NEXT: }
# CHECK-NEXT: ]
---
{
"jsonrpc": "2.0",
"id": 2,
"method": "textDocument/codeAction",
"params": {
"textDocument": { "uri": "test:///main.cpp" },
"range": {
"start": {"line": 0, "character": 0},
"end": {"line": 0, "character": 4}
},
"context": {
"diagnostics": [],
"only": ["quickfix"]
}
}
}
# CHECK: "id": 2,
# CHECK-NEXT: "jsonrpc": "2.0",
# CHECK-NEXT: "result": []
---
{
"jsonrpc": "2.0",
"id": 3,
"method": "textDocument/codeAction",
"params": {
"textDocument": { "uri": "test:///main.cpp" },
"range": {
"start": {"line": 0, "character": 0},
"end": {"line": 0, "character": 4}
},
"context": {
"diagnostics": [],
"only": ["refactor"]
}
}
}
# CHECK: "id": 3,
# CHECK-NEXT: "jsonrpc": "2.0",
# CHECK-NEXT: "result": [
# CHECK-NEXT: {
---
{"jsonrpc":"2.0","id":4,"method":"workspace/executeCommand","params":{"command":"clangd.applyTweak","arguments":[{"file":"test:///main.cpp","selection":{"end":{"character":4,"line":0},"start":{"character":0,"line":0}},"tweakID":"ExpandAutoType"}]}}
# CHECK: "newText": "int",
# CHECK-NEXT: "range": {
Expand All @@ -64,7 +105,7 @@
# CHECK-NEXT: }
# CHECK-NEXT: }
---
{"jsonrpc":"2.0","id":4,"method":"shutdown"}
{"jsonrpc":"2.0","id":5,"method":"shutdown"}
---
{"jsonrpc":"2.0","method":"exit"}
---
1 change: 1 addition & 0 deletions clang/tools/clang-format/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ add_clang_tool(clang-format
set(CLANG_FORMAT_LIB_DEPS
clangBasic
clangFormat
clangFrontend
clangRewrite
clangToolingCore
)
Expand Down
7 changes: 5 additions & 2 deletions clang/tools/clang-format/ClangFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/Version.h"
#include "clang/Format/Format.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
Expand Down Expand Up @@ -423,9 +424,11 @@ static bool format(StringRef FileName) {
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts(new DiagnosticOptions());
TextDiagnosticPrinter DiagnosticsConsumer(errs(), &*DiagOpts);
DiagnosticsEngine Diagnostics(
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
new DiagnosticOptions);
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), &*DiagOpts,
&DiagnosticsConsumer, false);
SourceManager Sources(Diagnostics, Files);
FileID ID = createInMemoryFile(AssumedFileName, Code.get(), Sources, Files,
InMemoryFileSystem.get());
Expand Down
1 change: 0 additions & 1 deletion lldb/scripts/lldb-test-qemu/rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
set -e

print_usage() {
echo "Usage:"
echo "Usage: $(basename $0) [options]"
echo -e "Creates a Ubuntu root file system image.\n"
echo -e " --help\t\t\tDisplay this information."
Expand Down
6 changes: 6 additions & 0 deletions lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4819,6 +4819,12 @@ lldb::Encoding TypeSystemClang::GetEncoding(lldb::opaque_compiler_type_t type,
case clang::BuiltinType::OCLIntelSubgroupAVCImeDualRefStreamin:
break;

// PowerPC -- Matrix Multiply Assist
case clang::BuiltinType::VectorPair:
case clang::BuiltinType::VectorQuad:
break;

// ARM -- Scalable Vector Extension
case clang::BuiltinType::SveBool:
case clang::BuiltinType::SveInt8:
case clang::BuiltinType::SveInt8x2:
Expand Down
23 changes: 22 additions & 1 deletion llvm/cmake/modules/FindGRPC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ endif()
# Proto headers are generated in ${CMAKE_CURRENT_BINARY_DIR}.
# Libraries that use these headers should adjust the include path.
# If the "GRPC" argument is given, services are also generated.
# The DEPENDS list should name *.proto source files that are imported.
# They may be relative to the source dir or absolute (for generated protos).
function(generate_protos LibraryName ProtoFile)
cmake_parse_arguments(PARSE_ARGV 2 PROTO "GRPC" "" "")
cmake_parse_arguments(PARSE_ARGV 2 PROTO "GRPC" "" "DEPENDS")
get_filename_component(ProtoSourceAbsolutePath "${CMAKE_CURRENT_SOURCE_DIR}/${ProtoFile}" ABSOLUTE)
get_filename_component(ProtoSourcePath ${ProtoSourceAbsolutePath} PATH)
get_filename_component(Basename ${ProtoSourceAbsolutePath} NAME_WLE)
Expand All @@ -111,4 +113,23 @@ function(generate_protos LibraryName ProtoFile)
add_clang_library(${LibraryName} ${GeneratedProtoSource}
PARTIAL_SOURCES_INTENDED
LINK_LIBS grpc++ protobuf)

# Ensure dependency headers are generated before dependent protos are built.
# DEPENDS arg is a list of "Foo.proto". While they're logically relative to
# the source dir, the generated headers we need are in the binary dir.
foreach(ImportedProto IN LISTS PROTO_DEPENDS)
# Foo.proto -> Foo.pb.h
STRING(REGEX REPLACE "\\.proto$" ".pb.h" ImportedHeader "${ImportedProto}")
# Foo.pb.h -> ${CMAKE_CURRENT_BINARY_DIR}/Foo.pb.h
get_filename_component(ImportedHeader "${ImportedHeader}"
ABSOLUTE
BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
# Compilation of each generated source depends on ${BINARY}/Foo.pb.h.
foreach(Generated IN LISTS GeneratedProtoSource)
# FIXME: CMake docs suggest OBJECT_DEPENDS isn't needed, but I can't get
# the recommended add_dependencies() approach to work.
set_source_files_properties("${Generated}"
PROPERTIES OBJECT_DEPENDS "${ImportedHeader}")
endforeach(Generated)
endforeach(ImportedProto)
endfunction()
23 changes: 15 additions & 8 deletions llvm/include/llvm/Analysis/ScalarEvolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -939,17 +939,23 @@ class ScalarEvolution {
bool isKnownOnEveryIteration(ICmpInst::Predicate Pred,
const SCEVAddRecExpr *LHS, const SCEV *RHS);

/// Return true if, for all loop invariant X, the predicate "LHS `Pred` X"
/// is monotonically increasing or decreasing. In the former case set
/// `Increasing` to true and in the latter case set `Increasing` to false.
///
/// A predicate is said to be monotonically increasing if may go from being
/// false to being true as the loop iterates, but never the other way
/// around. A predicate is said to be monotonically decreasing if may go
/// from being true to being false as the loop iterates, but never the other
/// way around.
bool isMonotonicPredicate(const SCEVAddRecExpr *LHS, ICmpInst::Predicate Pred,
bool &Increasing);
enum MonotonicPredicateType {
MonotonicallyIncreasing,
MonotonicallyDecreasing
};

/// If, for all loop invariant X, the predicate "LHS `Pred` X" is
/// monotonically increasing or decreasing, returns
/// Some(MonotonicallyIncreasing) and Some(MonotonicallyDecreasing)
/// respectively. If we could not prove either of these facts, returns None.
Optional<MonotonicPredicateType>
getMonotonicPredicateType(const SCEVAddRecExpr *LHS,
ICmpInst::Predicate Pred);

/// Return true if the result of the predicate LHS `Pred` RHS is loop
/// invariant with respect to L. Set InvariantPred, InvariantLHS and
Expand Down Expand Up @@ -1881,8 +1887,9 @@ class ScalarEvolution {
/// Try to prove NSW or NUW on \p AR relying on ConstantRange manipulation.
SCEV::NoWrapFlags proveNoWrapViaConstantRanges(const SCEVAddRecExpr *AR);

bool isMonotonicPredicateImpl(const SCEVAddRecExpr *LHS,
ICmpInst::Predicate Pred, bool &Increasing);
Optional<MonotonicPredicateType>
getMonotonicPredicateTypeImpl(const SCEVAddRecExpr *LHS,
ICmpInst::Predicate Pred);

/// Return SCEV no-wrap flags that can be proven based on reasoning about
/// how poison produced from no-wrap flags on this value (e.g. a nuw add)
Expand Down
24 changes: 24 additions & 0 deletions llvm/include/llvm/IR/Instructions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,30 @@ class ICmpInst: public CmpInst {
return !isEquality(P);
}

/// Return true if the predicate is SGT or UGT.
///
static bool isGT(Predicate P) {
return P == ICMP_SGT || P == ICMP_UGT;
}

/// Return true if the predicate is SLT or ULT.
///
static bool isLT(Predicate P) {
return P == ICMP_SLT || P == ICMP_ULT;
}

/// Return true if the predicate is SGE or UGE.
///
static bool isGE(Predicate P) {
return P == ICMP_SGE || P == ICMP_UGE;
}

/// Return true if the predicate is SLE or ULE.
///
static bool isLE(Predicate P) {
return P == ICMP_SLE || P == ICMP_ULE;
}

/// Exchange the two operands to this instruction in such a way that it does
/// not modify the semantics of the instruction. The predicate value may be
/// changed to retain the same result if the predicate is order dependent
Expand Down
Loading

0 comments on commit 7c4e681

Please sign in to comment.