Skip to content

Commit 7131c31

Browse files
committed
Merge from 'main' to 'sycl-web' (#4)
Expected to build-fail until the next commit 2c03d92. CONFLICT (content): Merge conflict in llvm/unittests/Passes/CMakeLists.txt
2 parents 91ea564 + 2e4ec3e commit 7131c31

File tree

1,644 files changed

+168390
-36607
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,644 files changed

+168390
-36607
lines changed

clang-tools-extra/clangd/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# This is a no-op for building files in this dir, but is inherited by subdirs.
2+
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
3+
include_directories(${CMAKE_CURRENT_BINARY_DIR})
4+
15
add_subdirectory(support)
26

37
# Configure the Features.inc file.

clang-tools-extra/clangd/InlayHints.cpp

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> {
3232
TypeHintPolicy.SuppressScope = true; // keep type names short
3333
TypeHintPolicy.AnonymousTagLocations =
3434
false; // do not print lambda locations
35+
// Print canonical types. Otherwise, SuppressScope would result in
36+
// things like "metafunction<args>::type" being shorted to just "type",
37+
// which is useless. This is particularly important for structured
38+
// bindings that use the tuple_element protocol, where the non-canonical
39+
// types would be "tuple_element<I, A>::type".
40+
// Note, for "auto", we would often prefer sugared types, but the AST
41+
// doesn't currently retain them in DeducedType anyways.
42+
TypeHintPolicy.PrintCanonicalTypes = true;
3543
}
3644

3745
bool VisitCXXConstructExpr(CXXConstructExpr *E) {
@@ -76,20 +84,23 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> {
7684
if (auto *AT = D->getReturnType()->getContainedAutoType()) {
7785
QualType Deduced = AT->getDeducedType();
7886
if (!Deduced.isNull()) {
79-
addInlayHint(D->getFunctionTypeLoc().getRParenLoc(),
80-
InlayHintKind::TypeHint,
81-
"-> " + D->getReturnType().getAsString(TypeHintPolicy));
87+
addTypeHint(D->getFunctionTypeLoc().getRParenLoc(), D->getReturnType(),
88+
"-> ");
8289
}
8390
}
8491

8592
return true;
8693
}
8794

8895
bool VisitVarDecl(VarDecl *D) {
89-
// Do not show hints for the aggregate in a structured binding.
90-
// In the future, we may show hints for the individual bindings.
91-
if (isa<DecompositionDecl>(D))
96+
// Do not show hints for the aggregate in a structured binding,
97+
// but show hints for the individual bindings.
98+
if (auto *DD = dyn_cast<DecompositionDecl>(D)) {
99+
for (auto *Binding : DD->bindings()) {
100+
addTypeHint(Binding->getLocation(), Binding->getType(), ": ");
101+
}
92102
return true;
103+
}
93104

94105
if (D->getType()->getContainedAutoType()) {
95106
if (!D->getType()->isDependentType()) {
@@ -98,8 +109,7 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> {
98109
// (e.g. for `const auto& x = 42`, print `const int&`).
99110
// Alternatively, we could place the hint on the `auto`
100111
// (and then just print the type deduced for the `auto`).
101-
addInlayHint(D->getLocation(), InlayHintKind::TypeHint,
102-
": " + D->getType().getAsString(TypeHintPolicy));
112+
addTypeHint(D->getLocation(), D->getType(), ": ");
103113
}
104114
}
105115
return true;
@@ -311,6 +321,15 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> {
311321
Kind, Label.str()});
312322
}
313323

324+
void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix) {
325+
// Do not print useless "NULL TYPE" hint.
326+
if (!T.getTypePtrOrNull())
327+
return;
328+
329+
addInlayHint(R, InlayHintKind::TypeHint,
330+
std::string(Prefix) + T.getAsString(TypeHintPolicy));
331+
}
332+
314333
std::vector<InlayHint> &Results;
315334
ASTContext &AST;
316335
FileID MainFileID;

clang-tools-extra/clangd/TUScheduler.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,11 +1380,13 @@ bool ASTWorker::blockUntilIdle(Deadline Timeout) const {
13801380
};
13811381
// Make sure ASTWorker has processed all requests, which might issue new
13821382
// updates to PreamblePeer.
1383-
WaitUntilASTWorkerIsIdle();
1383+
if (!WaitUntilASTWorkerIsIdle())
1384+
return false;
13841385
// Now that ASTWorker processed all requests, ensure PreamblePeer has served
13851386
// all update requests. This might create new PreambleRequests for the
13861387
// ASTWorker.
1387-
PreamblePeer.blockUntilIdle(Timeout);
1388+
if (!PreamblePeer.blockUntilIdle(Timeout))
1389+
return false;
13881390
assert(Requests.empty() &&
13891391
"No new normal tasks can be scheduled concurrently with "
13901392
"blockUntilIdle(): ASTWorker isn't threadsafe");

clang-tools-extra/clangd/Transport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H_
1919
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H_
2020

21+
#include "Features.h"
2122
#include "llvm/ADT/StringRef.h"
2223
#include "llvm/Support/JSON.h"
2324
#include "llvm/Support/raw_ostream.h"

clang-tools-extra/clangd/benchmarks/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
2-
31
add_subdirectory(CompletionModel)
42

53
add_benchmark(IndexBenchmark IndexBenchmark.cpp)

clang-tools-extra/clangd/benchmarks/CompletionModel/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
2-
31
add_benchmark(DecisionForestBenchmark DecisionForestBenchmark.cpp)
42

53
target_link_libraries(DecisionForestBenchmark

clang-tools-extra/clangd/fuzzer/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..
2-
${CMAKE_CURRENT_BINARY_DIR}/..)
3-
41
set(LLVM_LINK_COMPONENTS
52
FuzzMutate
63
Support

clang-tools-extra/clangd/index/dex/Dex.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ namespace clangd {
3434
namespace dex {
3535

3636
/// In-memory Dex trigram-based index implementation.
37-
// FIXME(kbobyrev): Introduce serialization and deserialization of the symbol
38-
// index so that it can be loaded from the disk. Since static index is not
39-
// changed frequently, it's safe to assume that it has to be built only once
40-
// (when the clangd process starts). Therefore, it can be easier to store built
41-
// index on disk and then load it if available.
4237
class Dex : public SymbolIndex {
4338
public:
4439
// All data must outlive this index.

clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../)
2-
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../)
3-
41
set(LLVM_LINK_COMPONENTS
52
LineEditor
63
Support

clang-tools-extra/clangd/index/remote/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ if (CLANGD_ENABLE_REMOTE)
1313
MonitoringServiceProto
1414
)
1515
include_directories(${CMAKE_CURRENT_BINARY_DIR})
16-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
17-
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../)
1816

1917
# FIXME(kirillbobyrev): target_compile_definitions is not working with
2018
# add_clang_library for some reason. Is there any way to make this

clang-tools-extra/clangd/indexer/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
2-
31
set(LLVM_LINK_COMPONENTS
42
Support
53
)

clang-tools-extra/clangd/support/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
1515
list(APPEND CLANGD_ATOMIC_LIB "atomic")
1616
endif()
1717

18-
include_directories(..)
1918
add_clang_library(clangdSupport
2019
Cancellation.cpp
2120
Context.cpp

clang-tools-extra/clangd/support/Threading.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "support/Context.h"
1313
#include "llvm/ADT/FunctionExtras.h"
1414
#include "llvm/ADT/Twine.h"
15+
#include <atomic>
1516
#include <cassert>
1617
#include <condition_variable>
1718
#include <future>

clang-tools-extra/clangd/tool/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
2-
include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
3-
41
add_clang_tool(clangd
52
ClangdMain.cpp
63
Check.cpp

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Must be before Transport.h include.
10-
#include "Features.h"
11-
129
#include "ClangdLSPServer.h"
1310
#include "CodeComplete.h"
1411
#include "Config.h"
1512
#include "ConfigProvider.h"
13+
#include "Features.h"
1614
#include "PathMapping.h"
1715
#include "Protocol.h"
1816
#include "TidyProvider.h"

clang-tools-extra/clangd/unittests/CMakeLists.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ set(LLVM_LINK_COMPONENTS
44
FrontendOpenMP
55
)
66

7-
get_filename_component(CLANGD_SOURCE_DIR
8-
${CMAKE_CURRENT_SOURCE_DIR}/../../clangd REALPATH)
9-
get_filename_component(CLANGD_BINARY_DIR
10-
${CMAKE_CURRENT_BINARY_DIR}/../../clangd REALPATH)
11-
include_directories(
12-
${CLANGD_SOURCE_DIR}
13-
${CLANGD_BINARY_DIR}
14-
)
15-
167
if(CLANG_BUILT_STANDALONE)
178
# LLVMTestingSupport library is needed for clangd tests.
189
if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support

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

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -461,19 +461,70 @@ TEST(TypeHints, Lambda) {
461461
ExpectedHint{": int", "init"});
462462
}
463463

464-
TEST(TypeHints, StructuredBindings) {
465-
// FIXME: Not handled yet.
466-
// To handle it, we could print:
467-
// - the aggregate type next to the 'auto', or
468-
// - the individual types inside the brackets
469-
// The latter is probably more useful.
464+
// Structured bindings tests.
465+
// Note, we hint the individual bindings, not the aggregate.
466+
467+
TEST(TypeHints, StructuredBindings_PublicStruct) {
470468
assertTypeHints(R"cpp(
469+
// Struct with public fields.
471470
struct Point {
472471
int x;
473472
int y;
474473
};
475474
Point foo();
476-
auto [x, y] = foo();
475+
auto [$x[[x]], $y[[y]]] = foo();
476+
)cpp",
477+
ExpectedHint{": int", "x"}, ExpectedHint{": int", "y"});
478+
}
479+
480+
TEST(TypeHints, StructuredBindings_Array) {
481+
assertTypeHints(R"cpp(
482+
int arr[2];
483+
auto [$x[[x]], $y[[y]]] = arr;
484+
)cpp",
485+
ExpectedHint{": int", "x"}, ExpectedHint{": int", "y"});
486+
}
487+
488+
TEST(TypeHints, StructuredBindings_TupleLike) {
489+
assertTypeHints(R"cpp(
490+
// Tuple-like type.
491+
struct IntPair {
492+
int a;
493+
int b;
494+
};
495+
namespace std {
496+
template <typename T>
497+
struct tuple_size {};
498+
template <>
499+
struct tuple_size<IntPair> {
500+
constexpr static unsigned value = 2;
501+
};
502+
template <unsigned I, typename T>
503+
struct tuple_element {};
504+
template <unsigned I>
505+
struct tuple_element<I, IntPair> {
506+
using type = int;
507+
};
508+
}
509+
template <unsigned I>
510+
int get(const IntPair& p) {
511+
if constexpr (I == 0) {
512+
return p.a;
513+
} else if constexpr (I == 1) {
514+
return p.b;
515+
}
516+
}
517+
IntPair bar();
518+
auto [$x[[x]], $y[[y]]] = bar();
519+
)cpp",
520+
ExpectedHint{": int", "x"}, ExpectedHint{": int", "y"});
521+
}
522+
523+
TEST(TypeHints, StructuredBindings_NoInitializer) {
524+
assertTypeHints(R"cpp(
525+
// No initializer (ill-formed).
526+
// Do not show useless "NULL TYPE" hint.
527+
auto [x, y]; /*error-ok*/
477528
)cpp");
478529
}
479530

clang-tools-extra/clangd/unittests/xpc/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ set(LLVM_LINK_COMPONENTS
22
support
33
)
44

5-
get_filename_component(CLANGD_SOURCE_DIR
6-
${CMAKE_CURRENT_SOURCE_DIR}/../../clangd REALPATH)
7-
include_directories(
8-
${CLANGD_SOURCE_DIR}
9-
)
10-
115
add_custom_target(ClangdXpcUnitTests)
126
add_unittest(ClangdXpcUnitTests ClangdXpcTests
137
ConversionTests.cpp

clang-tools-extra/clangd/xpc/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ include(CreateClangdXPCFramework)
77
add_subdirectory(framework)
88
add_subdirectory(test-client)
99

10-
include_directories(
11-
${CMAKE_CURRENT_SOURCE_DIR}/../
12-
)
13-
1410
set(LLVM_LINK_COMPONENTS
1511
Support
1612
)

clang-tools-extra/clangd/xpc/test-client/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
include_directories(
2-
${CMAKE_CURRENT_SOURCE_DIR}/../../
3-
)
4-
51
add_clang_tool(
62
clangd-xpc-test-client
73
ClangdXPCTestClient.cpp

clang/docs/LibASTMatchersTutorial.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,12 @@ CMakeLists.txt should have the following contents:
105105
)
106106
target_link_libraries(loop-convert
107107
PRIVATE
108-
clangTooling
109-
clangBasic
108+
clangAST
110109
clangASTMatchers
110+
clangBasic
111+
clangFrontend
112+
clangSerialization
113+
clangTooling
111114
)
112115

113116
With that done, Ninja will be able to compile our tool. Let's give it

clang/include/clang/AST/Decl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,9 @@ class VarDecl : public DeclaratorDecl, public Redeclarable<VarDecl> {
14951495
NonParmVarDeclBits.EscapingByref = true;
14961496
}
14971497

1498+
/// Determines if this variable's alignment is dependent.
1499+
bool hasDependentAlignment() const;
1500+
14981501
/// Retrieve the variable declaration from which this variable could
14991502
/// be instantiated, if it is an instantiation (rather than a non-template).
15001503
VarDecl *getTemplateInstantiationPattern() const;

clang/include/clang/Basic/BuiltinsPPC.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ BUILTIN(__builtin_ppc_fetch_and_or, "UiUiD*Ui", "")
5555
BUILTIN(__builtin_ppc_fetch_and_orlp, "ULiULiD*ULi", "")
5656
BUILTIN(__builtin_ppc_fetch_and_swap, "UiUiD*Ui", "")
5757
BUILTIN(__builtin_ppc_fetch_and_swaplp, "ULiULiD*ULi", "")
58+
BUILTIN(__builtin_ppc_ldarx, "LiLiD*", "")
59+
BUILTIN(__builtin_ppc_lwarx, "iiD*", "")
60+
BUILTIN(__builtin_ppc_stdcx, "iLiD*Li", "")
61+
BUILTIN(__builtin_ppc_stwcx, "iiD*i", "")
5862

5963
BUILTIN(__builtin_ppc_get_timebase, "ULLi", "n")
6064

clang/include/clang/Basic/IdentifierTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>;
5656
/// of a pointer to one of these classes.
5757
enum { IdentifierInfoAlignment = 8 };
5858

59-
static constexpr int ObjCOrBuiltinIDBits = 15;
59+
static constexpr int ObjCOrBuiltinIDBits = 16;
6060

6161
/// One of these records is kept for each identifier that
6262
/// is lexed. This contains information about whether the token was \#define'd,

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ BENIGN_LANGOPT(ModulesDebugInfo , 1, 0, "Modules debug info")
281281
BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")
282282
BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd records")
283283
BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd records in a simple form")
284+
BENIGN_LANGOPT(DumpRecordLayoutsCanonical , 1, 0, "dumping the AST layout of records using canonical field types")
284285
BENIGN_LANGOPT(DumpRecordLayoutsComplete , 1, 0, "dumping the AST layout of all complete records")
285286
BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted vtables")
286287
LANGOPT(NoConstantCFStrings , 1, 0, "no constant CoreFoundation strings")

0 commit comments

Comments
 (0)