Skip to content

Commit 3999e42

Browse files
Merge from 'master' to 'sycl-web' (#2)
CONFLICT (content): Merge conflict in clang/lib/Sema/SemaDeclAttr.cpp
2 parents a009106 + 66b876c commit 3999e42

File tree

285 files changed

+6369
-2812
lines changed

Some content is hidden

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

285 files changed

+6369
-2812
lines changed

clang-tools-extra/clangd/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ if (NOT DEFINED CLANGD_BUILD_XPC)
1414
unset(CLANGD_BUILD_XPC_DEFAULT)
1515
endif ()
1616

17-
llvm_canonicalize_cmake_booleans(CLANGD_BUILD_XPC)
18-
llvm_canonicalize_cmake_booleans(CLANGD_ENABLE_REMOTE)
17+
llvm_canonicalize_cmake_booleans(
18+
CLANGD_BUILD_XPC
19+
CLANGD_ENABLE_REMOTE
20+
LLVM_ENABLE_ZLIB
21+
)
1922

2023
configure_file(
2124
${CMAKE_CURRENT_SOURCE_DIR}/Features.inc.in

clang-tools-extra/clangd/index/Serialization.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "llvm/Support/Endian.h"
2222
#include "llvm/Support/Error.h"
2323
#include "llvm/Support/raw_ostream.h"
24+
#include <cstdint>
2425
#include <vector>
2526

2627
namespace clang {
@@ -81,12 +82,17 @@ class Reader {
8182

8283
uint32_t consumeVar() {
8384
constexpr static uint8_t More = 1 << 7;
84-
uint8_t B = consume8();
85+
86+
// Use a 32 bit unsigned here to prevent promotion to signed int (unless int
87+
// is wider than 32 bits).
88+
uint32_t B = consume8();
8589
if (LLVM_LIKELY(!(B & More)))
8690
return B;
8791
uint32_t Val = B & ~More;
8892
for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
8993
B = consume8();
94+
// 5th byte of a varint can only have lowest 4 bits set.
95+
assert((Shift != 28 || B == (B & 0x0f)) && "Invalid varint encoding");
9096
Val |= (B & ~More) << Shift;
9197
}
9298
return Val;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Include a file to ensure we have multiple sources.
2+
#include "sample.h"
3+
4+
// This introduces a symbol, a reference and a relation.
5+
struct Bar : public Foo {};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#pragma once
2+
3+
// Introduce a symbol.
4+
struct Foo {};
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# REQUIRES: zlib
2+
This test tries to parse a checked-in binary index.
3+
If this test fails it means there has been a backward incompatilbe change to
4+
serialization format.
5+
Please bump the version number in
6+
clang-tools-extra/clangd/index/Serialization.cpp and regenarate sample.idx with
7+
8+
clangd-indexer \
9+
clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp > \
10+
clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
11+
12+
Also if you've introduced new slabs/chunks to serialized index, make sure
13+
indexing sample.cpp would yield non-trivial values for those.
14+
# RUN: dexp %/S/Inputs/sample.idx -c="find B" | grep Bar || not grep -v '^#' %s

clang-tools-extra/clangd/test/lit.cfg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ def calculate_arch_features(arch_string):
3030

3131
if config.clangd_enable_remote:
3232
config.available_features.add('clangd-remote-index')
33+
34+
if config.have_zlib:
35+
config.available_features.add('zlib')

clang-tools-extra/clangd/test/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ config.clangd_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/.."
2525
config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."
2626
config.clangd_build_xpc = @CLANGD_BUILD_XPC@
2727
config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
28+
config.have_zlib = @LLVM_ENABLE_ZLIB@
2829

2930
# Delegate logic to lit.cfg.py.
3031
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")

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

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ TEST(RenameTest, WithinFileRename) {
141141
~[[F^oo]]();
142142
void f([[F^oo]] x);
143143
};
144+
145+
template<typename T>
146+
[[F^oo]]<T>::[[Fo^o]]() {}
147+
148+
template<typename T>
149+
[[F^oo]]<T>::~[[Fo^o]]() {}
144150
)cpp",
145151

146152
// Template class constructor.
@@ -152,6 +158,9 @@ TEST(RenameTest, WithinFileRename) {
152158
template<typename T>
153159
[[F^oo]](T t);
154160
};
161+
162+
template<typename T>
163+
[[F^oo]]::[[Fo^o]]() {}
155164
)cpp",
156165

157166
// Class in template argument.
@@ -199,6 +208,30 @@ TEST(RenameTest, WithinFileRename) {
199208
}
200209
)cpp",
201210

211+
// Templated method instantiation.
212+
R"cpp(
213+
template<typename T>
214+
class Foo {
215+
public:
216+
static T [[f^oo]]() {}
217+
};
218+
219+
void bar() {
220+
Foo<int>::[[f^oo]]();
221+
}
222+
)cpp",
223+
R"cpp(
224+
template<typename T>
225+
class Foo {
226+
public:
227+
T [[f^oo]]() {}
228+
};
229+
230+
void bar() {
231+
Foo<int>().[[f^oo]]();
232+
}
233+
)cpp",
234+
202235
// Template class (partial) specializations.
203236
R"cpp(
204237
template <typename T>
@@ -272,6 +305,80 @@ TEST(RenameTest, WithinFileRename) {
272305
}
273306
)cpp",
274307

308+
// Templated class specialization.
309+
R"cpp(
310+
template<typename T, typename U=bool>
311+
class [[Foo^]];
312+
313+
template<typename T, typename U>
314+
class [[Foo^]] {};
315+
316+
template<typename T=int, typename U>
317+
class [[Foo^]];
318+
)cpp",
319+
R"cpp(
320+
template<typename T=float, typename U=int>
321+
class [[Foo^]];
322+
323+
template<typename T, typename U>
324+
class [[Foo^]] {};
325+
)cpp",
326+
327+
// Function template specialization.
328+
R"cpp(
329+
template<typename T=int, typename U=bool>
330+
U [[foo^]]();
331+
332+
template<typename T, typename U>
333+
U [[foo^]]() {};
334+
)cpp",
335+
R"cpp(
336+
template<typename T, typename U>
337+
U [[foo^]]() {};
338+
339+
template<typename T=int, typename U=bool>
340+
U [[foo^]]();
341+
)cpp",
342+
R"cpp(
343+
template<typename T=int, typename U=bool>
344+
U [[foo^]]();
345+
346+
template<typename T, typename U>
347+
U [[foo^]]();
348+
)cpp",
349+
R"cpp(
350+
template <typename T>
351+
void [[f^oo]](T t);
352+
353+
template <>
354+
void [[f^oo]](int a);
355+
356+
void test() {
357+
[[f^oo]]<double>(1);
358+
}
359+
)cpp",
360+
361+
// Variable template.
362+
R"cpp(
363+
template <typename T, int U>
364+
bool [[F^oo]] = true;
365+
366+
// Explicit template specialization
367+
template <>
368+
bool [[F^oo]]<int, 0> = false;
369+
370+
// Partial template specialization
371+
template <typename T>
372+
bool [[F^oo]]<T, 1> = false;
373+
374+
void foo() {
375+
// Ref to the explicit template specialization
376+
[[F^oo]]<int, 0>;
377+
// Ref to the primary template.
378+
[[F^oo]]<double, 2>;
379+
}
380+
)cpp",
381+
275382
// Complicated class type.
276383
R"cpp(
277384
// Forward declaration.
@@ -307,6 +414,19 @@ TEST(RenameTest, WithinFileRename) {
307414
}
308415
)cpp",
309416

417+
// Static class member.
418+
R"cpp(
419+
struct Foo {
420+
static Foo *[[Static^Member]];
421+
};
422+
423+
Foo* Foo::[[Static^Member]] = nullptr;
424+
425+
void foo() {
426+
Foo* Pointer = Foo::[[Static^Member]];
427+
}
428+
)cpp",
429+
310430
// Reference in lambda parameters.
311431
R"cpp(
312432
template <class T>
@@ -588,6 +708,26 @@ TEST(RenameTest, WithinFileRename) {
588708
ns::[[Old^Alias]] Bar;
589709
}
590710
)cpp",
711+
712+
// User defined conversion.
713+
R"cpp(
714+
class [[F^oo]] {
715+
public:
716+
[[F^oo]]() {}
717+
};
718+
719+
class Baz {
720+
public:
721+
operator [[F^oo]]() {
722+
return [[F^oo]]();
723+
}
724+
};
725+
726+
int main() {
727+
Baz boo;
728+
[[F^oo]] foo = static_cast<[[F^oo]]>(boo);
729+
}
730+
)cpp",
591731
};
592732
llvm::StringRef NewName = "NewName";
593733
for (llvm::StringRef T : Tests) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,9 @@ TEST(SerializationTest, NoCrashOnBadArraySize) {
366366
Pos += FileDigest.size();
367367

368368
// Varints are little-endian base-128 numbers, where the top-bit of each byte
369-
// indicates whether there are more. 8fffffff7f -> 0xffffffff.
369+
// indicates whether there are more. ffffffff0f -> 0xffffffff.
370370
std::string CorruptSrcs =
371-
(Srcs->Data.take_front(Pos) + llvm::fromHex("8fffffff7f") +
371+
(Srcs->Data.take_front(Pos) + llvm::fromHex("ffffffff0f") +
372372
"some_random_garbage")
373373
.str();
374374
Srcs->Data = CorruptSrcs;

0 commit comments

Comments
 (0)