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;

clang/include/clang/Driver/Options.td

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -342,36 +342,53 @@ def ccc_objcmt_migrate : Separate<["-"], "ccc-objcmt-migrate">,
342342
InternalDriverOpt,
343343
HelpText<"Apply modifications and produces temporary files to migrate to "
344344
"modern ObjC syntax">;
345+
345346
def objcmt_migrate_literals : Flag<["-"], "objcmt-migrate-literals">, Flags<[CC1Option]>,
346-
HelpText<"Enable migration to modern ObjC literals">;
347+
HelpText<"Enable migration to modern ObjC literals">,
348+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_Literals">;
347349
def objcmt_migrate_subscripting : Flag<["-"], "objcmt-migrate-subscripting">, Flags<[CC1Option]>,
348-
HelpText<"Enable migration to modern ObjC subscripting">;
350+
HelpText<"Enable migration to modern ObjC subscripting">,
351+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_Subscripting">;
349352
def objcmt_migrate_property : Flag<["-"], "objcmt-migrate-property">, Flags<[CC1Option]>,
350-
HelpText<"Enable migration to modern ObjC property">;
353+
HelpText<"Enable migration to modern ObjC property">,
354+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_Property">;
351355
def objcmt_migrate_all : Flag<["-"], "objcmt-migrate-all">, Flags<[CC1Option]>,
352-
HelpText<"Enable migration to modern ObjC">;
356+
HelpText<"Enable migration to modern ObjC">,
357+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_MigrateDecls">;
353358
def objcmt_migrate_readonly_property : Flag<["-"], "objcmt-migrate-readonly-property">, Flags<[CC1Option]>,
354-
HelpText<"Enable migration to modern ObjC readonly property">;
359+
HelpText<"Enable migration to modern ObjC readonly property">,
360+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_ReadonlyProperty">;
355361
def objcmt_migrate_readwrite_property : Flag<["-"], "objcmt-migrate-readwrite-property">, Flags<[CC1Option]>,
356-
HelpText<"Enable migration to modern ObjC readwrite property">;
362+
HelpText<"Enable migration to modern ObjC readwrite property">,
363+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_ReadwriteProperty">;
357364
def objcmt_migrate_property_dot_syntax : Flag<["-"], "objcmt-migrate-property-dot-syntax">, Flags<[CC1Option]>,
358-
HelpText<"Enable migration of setter/getter messages to property-dot syntax">;
365+
HelpText<"Enable migration of setter/getter messages to property-dot syntax">,
366+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_PropertyDotSyntax">;
359367
def objcmt_migrate_annotation : Flag<["-"], "objcmt-migrate-annotation">, Flags<[CC1Option]>,
360-
HelpText<"Enable migration to property and method annotations">;
368+
HelpText<"Enable migration to property and method annotations">,
369+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_Annotation">;
361370
def objcmt_migrate_instancetype : Flag<["-"], "objcmt-migrate-instancetype">, Flags<[CC1Option]>,
362-
HelpText<"Enable migration to infer instancetype for method result type">;
371+
HelpText<"Enable migration to infer instancetype for method result type">,
372+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_Instancetype">;
363373
def objcmt_migrate_nsmacros : Flag<["-"], "objcmt-migrate-ns-macros">, Flags<[CC1Option]>,
364-
HelpText<"Enable migration to NS_ENUM/NS_OPTIONS macros">;
374+
HelpText<"Enable migration to NS_ENUM/NS_OPTIONS macros">,
375+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_NsMacros">;
365376
def objcmt_migrate_protocol_conformance : Flag<["-"], "objcmt-migrate-protocol-conformance">, Flags<[CC1Option]>,
366-
HelpText<"Enable migration to add protocol conformance on classes">;
377+
HelpText<"Enable migration to add protocol conformance on classes">,
378+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_ProtocolConformance">;
367379
def objcmt_atomic_property : Flag<["-"], "objcmt-atomic-property">, Flags<[CC1Option]>,
368-
HelpText<"Make migration to 'atomic' properties">;
380+
HelpText<"Make migration to 'atomic' properties">,
381+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_AtomicProperty">;
369382
def objcmt_returns_innerpointer_property : Flag<["-"], "objcmt-returns-innerpointer-property">, Flags<[CC1Option]>,
370-
HelpText<"Enable migration to annotate property with NS_RETURNS_INNER_POINTER">;
383+
HelpText<"Enable migration to annotate property with NS_RETURNS_INNER_POINTER">,
384+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_ReturnsInnerPointerProperty">;
371385
def objcmt_ns_nonatomic_iosonly: Flag<["-"], "objcmt-ns-nonatomic-iosonly">, Flags<[CC1Option]>,
372-
HelpText<"Enable migration to use NS_NONATOMIC_IOSONLY macro for setting property's 'atomic' attribute">;
386+
HelpText<"Enable migration to use NS_NONATOMIC_IOSONLY macro for setting property's 'atomic' attribute">,
387+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_NsAtomicIOSOnlyProperty">;
373388
def objcmt_migrate_designated_init : Flag<["-"], "objcmt-migrate-designated-init">, Flags<[CC1Option]>,
374-
HelpText<"Enable migration to infer NS_DESIGNATED_INITIALIZER for initializer methods">;
389+
HelpText<"Enable migration to infer NS_DESIGNATED_INITIALIZER for initializer methods">,
390+
MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", "FrontendOptions::ObjCMT_DesignatedInitializer">;
391+
375392
def objcmt_whitelist_dir_path: Joined<["-"], "objcmt-whitelist-dir-path=">, Flags<[CC1Option]>,
376393
HelpText<"Only modify files with a filename contained in the provided directory path">;
377394
// The misspelt "white-list" [sic] alias is due for removal.

clang/include/clang/Serialization/ASTReader.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,8 +1450,6 @@ class ASTReader
14501450
void Error(StringRef Msg) const;
14511451
void Error(unsigned DiagID, StringRef Arg1 = StringRef(),
14521452
StringRef Arg2 = StringRef(), StringRef Arg3 = StringRef()) const;
1453-
void Error(unsigned DiagID, StringRef Arg1, StringRef Arg2,
1454-
unsigned Select) const;
14551453
void Error(llvm::Error &&Err) const;
14561454

14571455
public:

clang/lib/AST/ASTContext.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7700,7 +7700,9 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
77007700
}
77017701

77027702
unsigned i = 0;
7703-
for (auto *Field : RDecl->fields()) {
7703+
for (FieldDecl *Field : RDecl->fields()) {
7704+
if (!Field->isZeroLengthBitField(*this) && Field->isZeroSize(*this))
7705+
continue;
77047706
uint64_t offs = layout.getFieldOffset(i);
77057707
FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs),
77067708
std::make_pair(offs, Field));

0 commit comments

Comments
 (0)