Skip to content

Commit bf07170

Browse files
committed
Merge from 'main' to 'sycl-web' (335 commits)
CONFLICT (content): Merge conflict in clang/test/Driver/linker-wrapper-image.c
2 parents cd04e86 + b9ee2ac commit bf07170

File tree

1,241 files changed

+69198
-42123
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,241 files changed

+69198
-42123
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: 17 additions & 2 deletions
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

@@ -2114,6 +2123,9 @@ bool isIndexedForCodeCompletion(const NamedDecl &ND, ASTContext &ASTCtx) {
21142123
};
21152124
return false;
21162125
};
2126+
auto InClassScope = [](const NamedDecl &ND) {
2127+
return ND.getDeclContext()->getDeclKind() == Decl::CXXRecord;
2128+
};
21172129
// We only complete symbol's name, which is the same as the name of the
21182130
// *primary* template in case of template specializations.
21192131
if (isExplicitTemplateSpecialization(&ND))
@@ -2129,8 +2141,11 @@ bool isIndexedForCodeCompletion(const NamedDecl &ND, ASTContext &ASTCtx) {
21292141
if (InTopLevelScope(ND))
21302142
return true;
21312143

2144+
// Always index enum constants, even if they're not in the top level scope:
2145+
// when
2146+
// --all-scopes-completion is set, we'll want to complete those as well.
21322147
if (const auto *EnumDecl = dyn_cast<clang::EnumDecl>(ND.getDeclContext()))
2133-
return InTopLevelScope(*EnumDecl) && !EnumDecl->isScoped();
2148+
return (InTopLevelScope(*EnumDecl) || InClassScope(*EnumDecl));
21342149

21352150
return false;
21362151
}

clang-tools-extra/clangd/CodeComplete.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ SignatureHelp signatureHelp(PathRef FileName, Position Pos,
291291
// For index-based completion, we only consider:
292292
// * symbols in namespaces or translation unit scopes (e.g. no class
293293
// members, no locals)
294-
// * enum constants in unscoped enum decl (e.g. "red" in "enum {red};")
294+
// * enum constants (both scoped and unscoped)
295295
// * primary templates (no specializations)
296296
// For the other cases, we let Clang do the completion because it does not
297297
// need any non-local information and it will be much better at following

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: 80 additions & 20 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) {
@@ -2962,14 +2967,20 @@ TEST(CompletionTest, AllScopesCompletion) {
29622967
}
29632968
)cpp",
29642969
{cls("nx::Clangd1"), cls("ny::Clangd2"), cls("Clangd3"),
2965-
cls("na::nb::Clangd4")},
2970+
cls("na::nb::Clangd4"), enmConstant("na::C::Clangd5")},
29662971
Opts);
29672972
EXPECT_THAT(
29682973
Results.Completions,
2969-
UnorderedElementsAre(AllOf(qualifier("nx::"), named("Clangd1")),
2970-
AllOf(qualifier("ny::"), named("Clangd2")),
2971-
AllOf(qualifier(""), scope(""), named("Clangd3")),
2972-
AllOf(qualifier("nb::"), named("Clangd4"))));
2974+
UnorderedElementsAre(AllOf(qualifier("nx::"), named("Clangd1"),
2975+
kind(CompletionItemKind::Class)),
2976+
AllOf(qualifier("ny::"), named("Clangd2"),
2977+
kind(CompletionItemKind::Class)),
2978+
AllOf(qualifier(""), scope(""), named("Clangd3"),
2979+
kind(CompletionItemKind::Class)),
2980+
AllOf(qualifier("nb::"), named("Clangd4"),
2981+
kind(CompletionItemKind::Class)),
2982+
AllOf(qualifier("C::"), named("Clangd5"),
2983+
kind(CompletionItemKind::EnumMember))));
29732984
}
29742985

29752986
TEST(CompletionTest, NoQualifierIfShadowed) {
@@ -3353,6 +3364,33 @@ TEST(CompletionTest, UsingDecl) {
33533364
kind(CompletionItemKind::Reference))));
33543365
}
33553366

3367+
TEST(CompletionTest, Enums) {
3368+
const char *Header(R"cpp(
3369+
namespace ns {
3370+
enum Unscoped { Clangd1 };
3371+
class C {
3372+
enum Unscoped { Clangd2 };
3373+
};
3374+
enum class Scoped { Clangd3 };
3375+
})cpp");
3376+
const char *Source(R"cpp(
3377+
void bar() {
3378+
Clangd^
3379+
})cpp");
3380+
auto Index = TestTU::withHeaderCode(Header).index();
3381+
clangd::CodeCompleteOptions Opts;
3382+
Opts.Index = Index.get();
3383+
Opts.AllScopes = true;
3384+
auto R = completions(Source, {}, Opts);
3385+
EXPECT_THAT(R.Completions, UnorderedElementsAre(
3386+
AllOf(scope("ns::"), named("Clangd1"),
3387+
kind(CompletionItemKind::EnumMember)),
3388+
AllOf(scope("ns::C::"), named("Clangd2"),
3389+
kind(CompletionItemKind::EnumMember)),
3390+
AllOf(scope("ns::Scoped::"), named("Clangd3"),
3391+
kind(CompletionItemKind::EnumMember))));
3392+
}
3393+
33563394
TEST(CompletionTest, ScopeIsUnresolved) {
33573395
clangd::CodeCompleteOptions Opts = {};
33583396
Opts.AllScopes = true;
@@ -3713,7 +3751,6 @@ TEST(CompletionTest, PreambleCodeComplete) {
37133751
}
37143752

37153753
TEST(CompletionTest, CommentParamName) {
3716-
clangd::CodeCompleteOptions Opts;
37173754
const std::string Code = R"cpp(
37183755
void fun(int foo, int bar);
37193756
void overloaded(int param_int);
@@ -3722,23 +3759,46 @@ TEST(CompletionTest, CommentParamName) {
37223759
int main() {
37233760
)cpp";
37243761

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());
3762+
EXPECT_THAT(completions(Code + "fun(/*^").Completions,
3763+
UnorderedElementsAre(labeled("foo=*/")));
3764+
EXPECT_THAT(completions(Code + "fun(1, /*^").Completions,
3765+
UnorderedElementsAre(labeled("bar=*/")));
3766+
EXPECT_THAT(completions(Code + "/*^").Completions, IsEmpty());
37303767
// Test de-duplication.
37313768
EXPECT_THAT(
3732-
completions(Code + "overloaded(/*^", {}, Opts).Completions,
3733-
UnorderedElementsAre(labeled("param_int="), labeled("param_char=")));
3769+
completions(Code + "overloaded(/*^").Completions,
3770+
UnorderedElementsAre(labeled("param_int=*/"), labeled("param_char=*/")));
37343771
// 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());
3772+
EXPECT_THAT(completions(Code + "fun(/* ^").Completions,
3773+
UnorderedElementsAre(labeled("foo=*/")));
3774+
EXPECT_THAT(completions(Code + "fun(/* f^").Completions,
3775+
UnorderedElementsAre(labeled("foo=*/")));
3776+
EXPECT_THAT(completions(Code + "fun(/* x^").Completions, IsEmpty());
3777+
EXPECT_THAT(completions(Code + "fun(/* f ^").Completions, IsEmpty());
3778+
3779+
// Test ranges
3780+
{
3781+
std::string CompletionRangeTest(Code + "fun(/*[[^]]");
3782+
auto Results = completions(CompletionRangeTest);
3783+
EXPECT_THAT(Results.CompletionRange,
3784+
llvm::ValueIs(Annotations(CompletionRangeTest).range()));
3785+
EXPECT_THAT(
3786+
Results.Completions,
3787+
testing::Each(
3788+
AllOf(replacesRange(Annotations(CompletionRangeTest).range()),
3789+
origin(SymbolOrigin::AST), kind(CompletionItemKind::Text))));
3790+
}
3791+
{
3792+
std::string CompletionRangeTest(Code + "fun(/*[[fo^]]");
3793+
auto Results = completions(CompletionRangeTest);
3794+
EXPECT_THAT(Results.CompletionRange,
3795+
llvm::ValueIs(Annotations(CompletionRangeTest).range()));
3796+
EXPECT_THAT(
3797+
Results.Completions,
3798+
testing::Each(
3799+
AllOf(replacesRange(Annotations(CompletionRangeTest).range()),
3800+
origin(SymbolOrigin::AST), kind(CompletionItemKind::Text))));
3801+
}
37423802
}
37433803

37443804
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

0 commit comments

Comments
 (0)