Skip to content

Commit 66484f2

Browse files
authored
LLVM and SPIRV-LLVM-Translator pulldown (WW36)
LLVM: llvm/llvm-project@3fe01f0 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@cdede2c
2 parents bc8f0a4 + 761f738 commit 66484f2

File tree

1,616 files changed

+51751
-23127
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,616 files changed

+51751
-23127
lines changed

clang-tools-extra/clang-query/tool/ClangQuery.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,31 +110,33 @@ int main(int argc, const char **argv) {
110110
ClangTool Tool(OptionsParser->getCompilations(),
111111
OptionsParser->getSourcePathList());
112112
std::vector<std::unique_ptr<ASTUnit>> ASTs;
113-
int Status = Tool.buildASTs(ASTs);
114113
int ASTStatus = 0;
115-
if (Status == 1) {
116-
// Building ASTs failed.
114+
switch (Tool.buildASTs(ASTs)) {
115+
case 0:
116+
break;
117+
case 1: // Building ASTs failed.
117118
return 1;
118-
} else if (Status == 2) {
119+
case 2:
119120
ASTStatus |= 1;
120121
llvm::errs() << "Failed to build AST for some of the files, "
121122
<< "results may be incomplete."
122123
<< "\n";
123-
} else {
124-
assert(Status == 0 && "Unexpected status returned");
124+
break;
125+
default:
126+
llvm_unreachable("Unexpected status returned");
125127
}
126128

127129
QuerySession QS(ASTs);
128130

129131
if (!Commands.empty()) {
130-
for (auto I = Commands.begin(), E = Commands.end(); I != E; ++I) {
131-
QueryRef Q = QueryParser::parse(*I, QS);
132+
for (auto &Command : Commands) {
133+
QueryRef Q = QueryParser::parse(Command, QS);
132134
if (!Q->run(llvm::outs(), QS))
133135
return 1;
134136
}
135137
} else if (!CommandFiles.empty()) {
136-
for (auto I = CommandFiles.begin(), E = CommandFiles.end(); I != E; ++I) {
137-
if (runCommandsInFile(argv[0], *I, QS))
138+
for (auto &CommandFile : CommandFiles) {
139+
if (runCommandsInFile(argv[0], CommandFile, QS))
138140
return 1;
139141
}
140142
} else {

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,10 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
592592
{"codeActionProvider", std::move(CodeActionProvider)},
593593
{"completionProvider",
594594
llvm::json::Object{
595-
{"allCommitCharacters", " \t()[]{}<>:;,+-/*%^&#?.=\"'|"},
595+
{"allCommitCharacters",
596+
{" ", "\t", "(", ")", "[", "]", "{", "}", "<",
597+
">", ":", ";", ",", "+", "-", "/", "*", "%",
598+
"^", "&", "#", "?", ".", "=", "\"", "'", "|"}},
596599
{"resolveProvider", false},
597600
// We do extra checks, e.g. that > is part of ->.
598601
{"triggerCharacters", {".", "<", ">", ":", "\"", "/"}},

clang-tools-extra/clangd/ClangdServer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class ClangdServer {
131131
bool BuildRecoveryAST = true;
132132

133133
/// If true, turn on the `-frecovery-ast-type` clang flag.
134-
bool PreserveRecoveryASTType = false;
134+
bool PreserveRecoveryASTType = true;
135135

136136
/// Clangd's workspace root. Relevant for "workspace" operations not bound
137137
/// to a particular file.

clang-tools-extra/clangd/SemanticHighlighting.cpp

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -221,23 +221,51 @@ class HighlightingsBuilder {
221221
// the end of the Tokens).
222222
TokRef = TokRef.drop_front(Conflicting.size());
223223
}
224-
// Add tokens indicating lines skipped by the preprocessor.
225-
for (const Range &R : AST.getMacros().SkippedRanges) {
224+
const auto &SM = AST.getSourceManager();
225+
StringRef MainCode = SM.getBuffer(SM.getMainFileID())->getBuffer();
226+
227+
// Merge token stream with "inactive line" markers.
228+
std::vector<HighlightingToken> WithInactiveLines;
229+
auto SortedSkippedRanges = AST.getMacros().SkippedRanges;
230+
llvm::sort(SortedSkippedRanges);
231+
auto It = NonConflicting.begin();
232+
for (const Range &R : SortedSkippedRanges) {
226233
// Create one token for each line in the skipped range, so it works
227234
// with line-based diffing.
228235
assert(R.start.line <= R.end.line);
229236
for (int Line = R.start.line; Line <= R.end.line; ++Line) {
230-
// Don't bother computing the offset for the end of the line, just use
231-
// zero. The client will treat this highlighting kind specially, and
232-
// highlight the entire line visually (i.e. not just to where the text
233-
// on the line ends, but to the end of the screen).
234-
NonConflicting.push_back({HighlightingKind::InactiveCode,
235-
{Position{Line, 0}, Position{Line, 0}}});
237+
// Copy tokens before the inactive line
238+
for (; It != NonConflicting.end() && It->R.start.line < Line; ++It)
239+
WithInactiveLines.push_back(std::move(*It));
240+
// Add a token for the inactive line itself.
241+
auto StartOfLine = positionToOffset(MainCode, Position{Line, 0});
242+
if (StartOfLine) {
243+
StringRef LineText =
244+
MainCode.drop_front(*StartOfLine).take_until([](char C) {
245+
return C == '\n';
246+
});
247+
WithInactiveLines.push_back(
248+
{HighlightingKind::InactiveCode,
249+
{Position{Line, 0},
250+
Position{Line, static_cast<int>(lspLength(LineText))}}});
251+
} else {
252+
elog("Failed to convert position to offset: {0}",
253+
StartOfLine.takeError());
254+
}
255+
256+
// Skip any other tokens on the inactive line. e.g.
257+
// `#ifndef Foo` is considered as part of an inactive region when Foo is
258+
// defined, and there is a Foo macro token.
259+
// FIXME: we should reduce the scope of the inactive region to not
260+
// include the directive itself.
261+
while (It != NonConflicting.end() && It->R.start.line == Line)
262+
++It;
236263
}
237264
}
238-
// Re-sort the tokens because that's what the diffing expects.
239-
llvm::sort(NonConflicting);
240-
return NonConflicting;
265+
// Copy tokens after the last inactive line
266+
for (; It != NonConflicting.end(); ++It)
267+
WithInactiveLines.push_back(std::move(*It));
268+
return WithInactiveLines;
241269
}
242270

243271
private:
@@ -493,9 +521,6 @@ toSemanticTokens(llvm::ArrayRef<HighlightingToken> Tokens) {
493521
std::vector<SemanticToken> Result;
494522
const HighlightingToken *Last = nullptr;
495523
for (const HighlightingToken &Tok : Tokens) {
496-
// FIXME: support inactive code - we need to provide the actual bounds.
497-
if (Tok.Kind == HighlightingKind::InactiveCode)
498-
continue;
499524
Result.emplace_back();
500525
SemanticToken &Out = Result.back();
501526
// deltaStart/deltaLine are relative if possible.

clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ class UsingFinder : public RecursiveASTVisitor<UsingFinder> {
8686
const SourceManager &SM;
8787
};
8888

89+
bool isFullyQualified(const NestedNameSpecifier *NNS) {
90+
if (!NNS)
91+
return false;
92+
return NNS->getKind() == NestedNameSpecifier::Global ||
93+
isFullyQualified(NNS->getPrefix());
94+
}
95+
8996
struct InsertionPointData {
9097
// Location to insert the "using" statement. If invalid then the statement
9198
// should not be inserted at all (it already exists).
@@ -94,6 +101,9 @@ struct InsertionPointData {
94101
// insertion point is anchored to, we may need one or more \n to ensure
95102
// proper formatting.
96103
std::string Suffix;
104+
// Whether using should be fully qualified, even if what the user typed was
105+
// not. This is based on our detection of the local style.
106+
bool AlwaysFullyQualify = false;
97107
};
98108

99109
// Finds the best place to insert the "using" statement. Returns invalid
@@ -118,7 +128,13 @@ findInsertionPoint(const Tweak::Selection &Inputs,
118128
SM)
119129
.TraverseAST(Inputs.AST->getASTContext());
120130

131+
bool AlwaysFullyQualify = true;
121132
for (auto &U : Usings) {
133+
// Only "upgrade" to fully qualified is all relevant using decls are fully
134+
// qualified. Otherwise trust what the user typed.
135+
if (!isFullyQualified(U->getQualifier()))
136+
AlwaysFullyQualify = false;
137+
122138
if (SM.isBeforeInTranslationUnit(Inputs.Cursor, U->getUsingLoc()))
123139
// "Usings" is sorted, so we're done.
124140
break;
@@ -137,6 +153,7 @@ findInsertionPoint(const Tweak::Selection &Inputs,
137153
if (LastUsingLoc.isValid()) {
138154
InsertionPointData Out;
139155
Out.Loc = LastUsingLoc;
156+
Out.AlwaysFullyQualify = AlwaysFullyQualify;
140157
return Out;
141158
}
142159

@@ -278,6 +295,9 @@ Expected<Tweak::Effect> AddUsing::apply(const Selection &Inputs) {
278295
std::string UsingText;
279296
llvm::raw_string_ostream UsingTextStream(UsingText);
280297
UsingTextStream << "using ";
298+
if (InsertionPoint->AlwaysFullyQualify &&
299+
!isFullyQualified(QualifierToRemove.getNestedNameSpecifier()))
300+
UsingTextStream << "::";
281301
QualifierToRemove.getNestedNameSpecifier()->print(
282302
UsingTextStream, Inputs.AST->getASTContext().getPrintingPolicy());
283303
UsingTextStream << Name << ";" << InsertionPoint->Suffix;

clang-tools-extra/clangd/test/initialize-params.test

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,35 @@
77
# CHECK-NEXT: "capabilities": {
88
# CHECK-NEXT: "codeActionProvider": true,
99
# CHECK-NEXT: "completionProvider": {
10-
# CHECK-NEXT: "allCommitCharacters": " \t()[]{}<>:;,+-/*%^&#?.=\"'|",
10+
# CHECK-NEXT: "allCommitCharacters": [
11+
# CHECK-NEXT: " ",
12+
# CHECK-NEXT: "\t",
13+
# CHECK-NEXT: "(",
14+
# CHECK-NEXT: ")",
15+
# CHECK-NEXT: "[",
16+
# CHECK-NEXT: "]",
17+
# CHECK-NEXT: "{",
18+
# CHECK-NEXT: "}",
19+
# CHECK-NEXT: "<",
20+
# CHECK-NEXT: ">",
21+
# CHECK-NEXT: ":",
22+
# CHECK-NEXT: ";",
23+
# CHECK-NEXT: ",",
24+
# CHECK-NEXT: "+",
25+
# CHECK-NEXT: "-",
26+
# CHECK-NEXT: "/",
27+
# CHECK-NEXT: "*",
28+
# CHECK-NEXT: "%",
29+
# CHECK-NEXT: "^",
30+
# CHECK-NEXT: "&",
31+
# CHECK-NEXT: "#",
32+
# CHECK-NEXT: "?",
33+
# CHECK-NEXT: ".",
34+
# CHECK-NEXT: "=",
35+
# CHECK-NEXT: "\"",
36+
# CHECK-NEXT: "'",
37+
# CHECK-NEXT: "|"
38+
# CHECK-NEXT: ],
1139
# CHECK-NEXT: "resolveProvider": false,
1240
# CHECK-NEXT: "triggerCharacters": [
1341
# CHECK-NEXT: ".",

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,8 @@ opt<bool> RecoveryAST{
291291
opt<bool> RecoveryASTType{
292292
"recovery-ast-type",
293293
cat(Features),
294-
desc("Preserve the type for recovery AST. Note that "
295-
"this feature is experimental and may lead to crashes"),
296-
init(false),
294+
desc("Preserve the type for recovery AST."),
295+
init(ClangdServer::Options().PreserveRecoveryASTType),
297296
Hidden,
298297
};
299298

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -503,11 +503,11 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
503503
504504
#define $Macro[[test]]
505505
#undef $Macro[[test]]
506-
$InactiveCode[[]] #ifdef $Macro[[test]]
507-
$InactiveCode[[]] #endif
506+
$InactiveCode[[#ifdef test]]
507+
$InactiveCode[[#endif]]
508508
509-
$InactiveCode[[]] #if defined($Macro[[test]])
510-
$InactiveCode[[]] #endif
509+
$InactiveCode[[#if defined(test)]]
510+
$InactiveCode[[#endif]]
511511
)cpp",
512512
R"cpp(
513513
struct $Class[[S]] {
@@ -614,26 +614,26 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
614614
R"cpp(
615615
// Code in the preamble.
616616
// Inactive lines get an empty InactiveCode token at the beginning.
617-
$InactiveCode[[]] #ifdef $Macro[[test]]
618-
$InactiveCode[[]] #endif
617+
$InactiveCode[[#ifdef test]]
618+
$InactiveCode[[#endif]]
619619
620620
// A declaration to cause the preamble to end.
621621
int $Variable[[EndPreamble]];
622622
623623
// Code after the preamble.
624624
// Code inside inactive blocks does not get regular highlightings
625625
// because it's not part of the AST.
626-
$InactiveCode[[]] #ifdef $Macro[[test]]
627-
$InactiveCode[[]] int Inactive2;
628-
$InactiveCode[[]] #endif
626+
$InactiveCode[[#ifdef test]]
627+
$InactiveCode[[int Inactive2;]]
628+
$InactiveCode[[#endif]]
629629
630630
#ifndef $Macro[[test]]
631631
int $Variable[[Active1]];
632632
#endif
633633
634-
$InactiveCode[[]] #ifdef $Macro[[test]]
635-
$InactiveCode[[]] int Inactive3;
636-
$InactiveCode[[]] #else
634+
$InactiveCode[[#ifdef test]]
635+
$InactiveCode[[int Inactive3;]]
636+
$InactiveCode[[#else]]
637637
int $Variable[[Active2]];
638638
#endif
639639
)cpp",

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,6 +2723,63 @@ namespace foo { void fun(); }
27232723
27242724
void foo::fun() {
27252725
ff();
2726+
})cpp"},
2727+
// If all other using are fully qualified, add ::
2728+
{R"cpp(
2729+
#include "test.hpp"
2730+
2731+
using ::one::two::cc;
2732+
using ::one::two::ee;
2733+
2734+
void fun() {
2735+
one::two::f^f();
2736+
})cpp",
2737+
R"cpp(
2738+
#include "test.hpp"
2739+
2740+
using ::one::two::cc;
2741+
using ::one::two::ff;using ::one::two::ee;
2742+
2743+
void fun() {
2744+
ff();
2745+
})cpp"},
2746+
// Make sure we don't add :: if it's already there
2747+
{R"cpp(
2748+
#include "test.hpp"
2749+
2750+
using ::one::two::cc;
2751+
using ::one::two::ee;
2752+
2753+
void fun() {
2754+
::one::two::f^f();
2755+
})cpp",
2756+
R"cpp(
2757+
#include "test.hpp"
2758+
2759+
using ::one::two::cc;
2760+
using ::one::two::ff;using ::one::two::ee;
2761+
2762+
void fun() {
2763+
ff();
2764+
})cpp"},
2765+
// If even one using doesn't start with ::, do not add it
2766+
{R"cpp(
2767+
#include "test.hpp"
2768+
2769+
using ::one::two::cc;
2770+
using one::two::ee;
2771+
2772+
void fun() {
2773+
one::two::f^f();
2774+
})cpp",
2775+
R"cpp(
2776+
#include "test.hpp"
2777+
2778+
using ::one::two::cc;
2779+
using one::two::ff;using one::two::ee;
2780+
2781+
void fun() {
2782+
ff();
27262783
})cpp"}};
27272784
llvm::StringMap<std::string> EditedFiles;
27282785
for (const auto &Case : Cases) {

clang/docs/LTOVisibility.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ other classes receive hidden LTO visibility. Classes with internal linkage
3535
(e.g. classes declared in unnamed namespaces) also receive hidden LTO
3636
visibility.
3737

38+
During the LTO link, all classes with public LTO visibility will be refined
39+
to hidden LTO visibility when the ``--lto-whole-program-visibility`` lld linker
40+
option is applied (``-plugin-opt=whole-program-visibility`` for gold). This flag
41+
can be used to defer specifying whether classes have hidden LTO visibility until
42+
link time, to allow bitcode objects to be shared by different LTO links.
43+
Due to an implementation limitation, symbols associated with classes with hidden
44+
LTO visibility may still be exported from the binary when using this flag. It is
45+
unsafe to refer to these symbols, and their visibility may be relaxed to hidden
46+
in a future compiler release.
47+
3848
A class defined in a translation unit built without LTO receives public
3949
LTO visibility regardless of its object file visibility, linkage or other
4050
attributes.

clang/docs/ReleaseNotes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ X86 Support in Clang
188188
- The x86 intrinsics ``__rorb``, ``__rorw``, ``__rord``, ``__rorq`, ``_rotr``,
189189
``_rotwr`` and ``_lrotr`` may now be used within constant expressions.
190190

191+
- Support for -march=sapphirerapids was added.
192+
193+
- The -mtune command line option is no longer ignored for X86. This can be used
194+
to request microarchitectural optimizations independent on -march. -march=<cpu>
195+
implies -mtune=<cpu>. -mtune=generic is the default with no -march or -mtune
196+
specified.
197+
191198
Internal API Changes
192199
--------------------
193200

clang/docs/UndefinedBehaviorSanitizer.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ Available checks are:
153153
unsigned overflow in C++. You can use ``-fsanitize=shift-base`` or
154154
``-fsanitize=shift-exponent`` to check only left-hand side or
155155
right-hand side of shift operation, respectively.
156+
- ``-fsanitize=unsigned-shift-base``: check that an unsigned left-hand side of
157+
a left shift operation doesn't overflow.
156158
- ``-fsanitize=signed-integer-overflow``: Signed integer overflow, where the
157159
result of a signed integer computation cannot be represented in its type.
158160
This includes all the checks covered by ``-ftrapv``, as well as checks for

0 commit comments

Comments
 (0)