Skip to content

Commit 5a17132

Browse files
committed
Merge commit '41dba9e6a3096d54de6005ef4e648af1ff02b90c' into llvmspirv_pulldown45
2 parents e8a0a95 + 41dba9e commit 5a17132

File tree

1,018 files changed

+37249
-12984
lines changed

Some content is hidden

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

1,018 files changed

+37249
-12984
lines changed

bolt/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ if (BOLT_ENABLE_RUNTIME)
5555
-DCMAKE_BUILD_TYPE=Release
5656
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
5757
-DCMAKE_INSTALL_PREFIX=${LLVM_BINARY_DIR}
58+
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
5859
BUILD_ALWAYS True
5960
)
6061
install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/cmake_install.cmake \)"
@@ -87,3 +88,6 @@ option(BOLT_INCLUDE_DOCS "Generate build targets for the BOLT docs."
8788
if (BOLT_INCLUDE_DOCS)
8889
add_subdirectory(docs)
8990
endif()
91+
92+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/bolt/RuntimeLibs/RuntimeLibraryVariables.inc.in
93+
${CMAKE_CURRENT_BINARY_DIR}/include/bolt/RuntimeLibs/RuntimeLibraryVariables.inc @ONLY)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===-- RuntimeLibraryVariables.inc.in - bolt build variables -*- C++ -*---===//
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+
// This file is configured by the build system to define the runtime library
10+
// location.
11+
//
12+
// The variant of this file not ending with .in has been autogenerated by the
13+
// LLVM build. Do not edit!
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"

bolt/lib/RuntimeLibs/RuntimeLibrary.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "bolt/RuntimeLibs/RuntimeLibrary.h"
14+
#include "bolt/RuntimeLibs/RuntimeLibraryVariables.inc"
1415
#include "bolt/Utils/Utils.h"
1516
#include "llvm/BinaryFormat/Magic.h"
1617
#include "llvm/ExecutionEngine/RuntimeDyld.h"
@@ -28,12 +29,12 @@ std::string RuntimeLibrary::getLibPath(StringRef ToolPath,
2829
StringRef LibFileName) {
2930
StringRef Dir = llvm::sys::path::parent_path(ToolPath);
3031
SmallString<128> LibPath = llvm::sys::path::parent_path(Dir);
31-
llvm::sys::path::append(LibPath, "lib");
32+
llvm::sys::path::append(LibPath, "lib" LLVM_LIBDIR_SUFFIX);
3233
if (!llvm::sys::fs::exists(LibPath)) {
3334
// In some cases we install bolt binary into one level deeper in bin/,
3435
// we need to go back one more level to find lib directory.
3536
LibPath = llvm::sys::path::parent_path(llvm::sys::path::parent_path(Dir));
36-
llvm::sys::path::append(LibPath, "lib");
37+
llvm::sys::path::append(LibPath, "lib" LLVM_LIBDIR_SUFFIX);
3738
}
3839
llvm::sys::path::append(LibPath, LibFileName);
3940
if (!llvm::sys::fs::exists(LibPath)) {

bolt/runtime/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ add_library(bolt_rt_instr STATIC
1515
instr.cpp
1616
${CMAKE_CURRENT_BINARY_DIR}/config.h
1717
)
18+
set_target_properties(bolt_rt_instr PROPERTIES LIBRARY_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
1819
add_library(bolt_rt_hugify STATIC
1920
hugify.cpp
2021
${CMAKE_CURRENT_BINARY_DIR}/config.h
2122
)
23+
set_target_properties(bolt_rt_hugify PROPERTIES LIBRARY_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
2224

2325
set(BOLT_RT_FLAGS
2426
-ffreestanding
@@ -33,17 +35,18 @@ target_include_directories(bolt_rt_instr PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
3335
target_compile_options(bolt_rt_hugify PRIVATE ${BOLT_RT_FLAGS})
3436
target_include_directories(bolt_rt_hugify PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
3537

36-
install(TARGETS bolt_rt_instr DESTINATION "${CMAKE_INSTALL_LIBDIR}")
37-
install(TARGETS bolt_rt_hugify DESTINATION "${CMAKE_INSTALL_LIBDIR}")
38+
install(TARGETS bolt_rt_instr DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
39+
install(TARGETS bolt_rt_hugify DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
3840

3941
if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*")
4042
add_library(bolt_rt_instr_osx STATIC
4143
instr.cpp
4244
${CMAKE_CURRENT_BINARY_DIR}/config.h
4345
)
46+
set_target_properties(bolt_rt_instr_osx PROPERTIES LIBRARY_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
4447
target_include_directories(bolt_rt_instr_osx PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
4548
target_compile_options(bolt_rt_instr_osx PRIVATE
4649
-target x86_64-apple-darwin19.6.0
4750
${BOLT_RT_FLAGS})
48-
install(TARGETS bolt_rt_instr_osx DESTINATION "${CMAKE_INSTALL_LIBDIR}")
51+
install(TARGETS bolt_rt_instr_osx DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
4952
endif()

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2014,14 +2014,23 @@ CodeCompleteResult codeCompleteComment(PathRef FileName, unsigned Offset,
20142014
return CodeCompleteResult();
20152015

20162016
CodeCompleteResult Result;
2017+
Range CompletionRange;
2018+
// Skip /*
2019+
Offset += 2;
2020+
CompletionRange.start = offsetToPosition(ParseInput.Contents, Offset);
2021+
CompletionRange.end =
2022+
offsetToPosition(ParseInput.Contents, Offset + Prefix.size());
2023+
Result.CompletionRange = CompletionRange;
20172024
Result.Context = CodeCompletionContext::CCC_NaturalLanguage;
20182025
for (llvm::StringRef Name : ParamNames) {
20192026
if (!Name.startswith(Prefix))
20202027
continue;
20212028
CodeCompletion Item;
2022-
Item.Name = Name.str() + "=";
2029+
Item.Name = Name.str() + "=*/";
20232030
Item.FilterText = Item.Name;
20242031
Item.Kind = CompletionItemKind::Text;
2032+
Item.CompletionTokenRange = CompletionRange;
2033+
Item.Origin = SymbolOrigin::AST;
20252034
Result.Completions.push_back(Item);
20262035
}
20272036

clang-tools-extra/clangd/SemanticHighlighting.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,9 @@ class CollectExtraHighlightings
661661
}
662662

663663
bool VisitCXXMemberCallExpr(CXXMemberCallExpr *CE) {
664-
if (isa<CXXDestructorDecl>(CE->getMethodDecl())) {
664+
// getMethodDecl can return nullptr with member pointers, e.g.
665+
// `(foo.*pointer_to_member_fun)(arg);`
666+
if (isa_and_present<CXXDestructorDecl>(CE->getMethodDecl())) {
665667
if (auto *ME = dyn_cast<MemberExpr>(CE->getCallee())) {
666668
if (auto *TI = ME->getMemberNameInfo().getNamedTypeInfo()) {
667669
H.addExtraModifier(TI->getTypeLoc().getBeginLoc(),

clang-tools-extra/clangd/tool/Check.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "ParsedAST.h"
3535
#include "Preamble.h"
3636
#include "Protocol.h"
37+
#include "SemanticHighlighting.h"
3738
#include "SourceCode.h"
3839
#include "XRefs.h"
3940
#include "index/CanonicalIncludes.h"
@@ -206,6 +207,14 @@ class Checker {
206207
}
207208
}
208209

210+
void buildSemanticHighlighting(llvm::Optional<Range> LineRange) {
211+
log("Building semantic highlighting");
212+
auto Highlights = getSemanticHighlightings(*AST);
213+
for (const auto HL : Highlights)
214+
if (!LineRange || LineRange->contains(HL.R))
215+
vlog(" {0} {1} {2}", HL.R, HL.Kind, HL.Modifiers);
216+
}
217+
209218
// Run AST-based features at each token in the file.
210219
void testLocationFeatures(llvm::Optional<Range> LineRange,
211220
const bool EnableCodeCompletion) {
@@ -302,6 +311,7 @@ bool check(llvm::StringRef File, llvm::Optional<Range> LineRange,
302311
!C.buildAST())
303312
return false;
304313
C.buildInlayHints(LineRange);
314+
C.buildSemanticHighlighting(LineRange);
305315
C.testLocationFeatures(LineRange, EnableCodeCompletion);
306316

307317
log("All checks completed, {0} errors", C.ErrCount);

clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "TestTU.h"
2222
#include "index/Index.h"
2323
#include "index/MemIndex.h"
24+
#include "index/SymbolOrigin.h"
2425
#include "support/Threading.h"
2526
#include "clang/Sema/CodeCompleteConsumer.h"
2627
#include "clang/Tooling/CompilationDatabase.h"
@@ -29,6 +30,7 @@
2930
#include "llvm/Support/Path.h"
3031
#include "llvm/Testing/Support/Annotations.h"
3132
#include "llvm/Testing/Support/Error.h"
33+
#include "llvm/Testing/Support/SupportHelpers.h"
3234
#include "gmock/gmock.h"
3335
#include "gtest/gtest.h"
3436
#include <condition_variable>
@@ -83,6 +85,9 @@ MATCHER(insertInclude, "") {
8385
MATCHER_P(snippetSuffix, Text, "") { return arg.SnippetSuffix == Text; }
8486
MATCHER_P(origin, OriginSet, "") { return arg.Origin == OriginSet; }
8587
MATCHER_P(signature, S, "") { return arg.Signature == S; }
88+
MATCHER_P(replacesRange, Range, "") {
89+
return arg.CompletionTokenRange == Range;
90+
}
8691

8792
// Shorthand for Contains(named(Name)).
8893
Matcher<const std::vector<CodeCompletion> &> has(std::string Name) {
@@ -3713,7 +3718,6 @@ TEST(CompletionTest, PreambleCodeComplete) {
37133718
}
37143719

37153720
TEST(CompletionTest, CommentParamName) {
3716-
clangd::CodeCompleteOptions Opts;
37173721
const std::string Code = R"cpp(
37183722
void fun(int foo, int bar);
37193723
void overloaded(int param_int);
@@ -3722,23 +3726,46 @@ TEST(CompletionTest, CommentParamName) {
37223726
int main() {
37233727
)cpp";
37243728

3725-
EXPECT_THAT(completions(Code + "fun(/*^", {}, Opts).Completions,
3726-
UnorderedElementsAre(labeled("foo=")));
3727-
EXPECT_THAT(completions(Code + "fun(1, /*^", {}, Opts).Completions,
3728-
UnorderedElementsAre(labeled("bar=")));
3729-
EXPECT_THAT(completions(Code + "/*^", {}, Opts).Completions, IsEmpty());
3729+
EXPECT_THAT(completions(Code + "fun(/*^").Completions,
3730+
UnorderedElementsAre(labeled("foo=*/")));
3731+
EXPECT_THAT(completions(Code + "fun(1, /*^").Completions,
3732+
UnorderedElementsAre(labeled("bar=*/")));
3733+
EXPECT_THAT(completions(Code + "/*^").Completions, IsEmpty());
37303734
// Test de-duplication.
37313735
EXPECT_THAT(
3732-
completions(Code + "overloaded(/*^", {}, Opts).Completions,
3733-
UnorderedElementsAre(labeled("param_int="), labeled("param_char=")));
3736+
completions(Code + "overloaded(/*^").Completions,
3737+
UnorderedElementsAre(labeled("param_int=*/"), labeled("param_char=*/")));
37343738
// Comment already has some text in it.
3735-
EXPECT_THAT(completions(Code + "fun(/* ^", {}, Opts).Completions,
3736-
UnorderedElementsAre(labeled("foo=")));
3737-
EXPECT_THAT(completions(Code + "fun(/* f^", {}, Opts).Completions,
3738-
UnorderedElementsAre(labeled("foo=")));
3739-
EXPECT_THAT(completions(Code + "fun(/* x^", {}, Opts).Completions, IsEmpty());
3740-
EXPECT_THAT(completions(Code + "fun(/* f ^", {}, Opts).Completions,
3741-
IsEmpty());
3739+
EXPECT_THAT(completions(Code + "fun(/* ^").Completions,
3740+
UnorderedElementsAre(labeled("foo=*/")));
3741+
EXPECT_THAT(completions(Code + "fun(/* f^").Completions,
3742+
UnorderedElementsAre(labeled("foo=*/")));
3743+
EXPECT_THAT(completions(Code + "fun(/* x^").Completions, IsEmpty());
3744+
EXPECT_THAT(completions(Code + "fun(/* f ^").Completions, IsEmpty());
3745+
3746+
// Test ranges
3747+
{
3748+
std::string CompletionRangeTest(Code + "fun(/*[[^]]");
3749+
auto Results = completions(CompletionRangeTest);
3750+
EXPECT_THAT(Results.CompletionRange,
3751+
llvm::ValueIs(Annotations(CompletionRangeTest).range()));
3752+
EXPECT_THAT(
3753+
Results.Completions,
3754+
testing::Each(
3755+
AllOf(replacesRange(Annotations(CompletionRangeTest).range()),
3756+
origin(SymbolOrigin::AST), kind(CompletionItemKind::Text))));
3757+
}
3758+
{
3759+
std::string CompletionRangeTest(Code + "fun(/*[[fo^]]");
3760+
auto Results = completions(CompletionRangeTest);
3761+
EXPECT_THAT(Results.CompletionRange,
3762+
llvm::ValueIs(Annotations(CompletionRangeTest).range()));
3763+
EXPECT_THAT(
3764+
Results.Completions,
3765+
testing::Each(
3766+
AllOf(replacesRange(Annotations(CompletionRangeTest).range()),
3767+
origin(SymbolOrigin::AST), kind(CompletionItemKind::Text))));
3768+
}
37423769
}
37433770

37443771
TEST(CompletionTest, Concepts) {

clang-tools-extra/clangd/unittests/HoverTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ class Foo final {})cpp";
10671067
HI.LocalScope = "";
10681068
HI.Kind = index::SymbolKind::TypeAlias;
10691069
HI.Definition = "template <typename T> using AA = A<T>";
1070-
HI.Type = {"A<T>", "type-parameter-0-0"}; // FIXME: should be 'T'
1070+
HI.Type = {"A<T>", "T"};
10711071
HI.TemplateParameters = {{{"typename"}, std::string("T"), llvm::None}};
10721072
}},
10731073
{// Constant array

clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,17 @@ sizeof...($TemplateParameter[[Elements]]);
887887
$TemplateParameter[[T]] $Variable_def[[x]] = {};
888888
template <>
889889
int $Variable_def[[x]]<int> = (int)sizeof($Class[[Base]]);
890+
)cpp",
891+
// no crash
892+
R"cpp(
893+
struct $Class_def[[Foo]] {
894+
void $Method_decl[[foo]]();
895+
};
896+
897+
void $Function_def[[s]]($Class[[Foo]] $Parameter_def[[f]]) {
898+
auto $LocalVariable_def[[k]] = &$Class[[Foo]]::$Method[[foo]];
899+
($Parameter[[f]].*$LocalVariable[[k]])(); // no crash on VisitCXXMemberCallExpr
900+
}
890901
)cpp"};
891902
for (const auto &TestCase : TestCases)
892903
// Mask off scope modifiers to keep the tests manageable.

0 commit comments

Comments
 (0)