Skip to content

Commit dee80e9

Browse files
committed
Merge from 'main' to 'sycl-web' (176 commits)
CONFLICT (content): Merge conflict in clang/include/clang/Basic/Attr.td
2 parents 22a4f6e + f63e8ed commit dee80e9

File tree

740 files changed

+14805
-8823
lines changed

Some content is hidden

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

740 files changed

+14805
-8823
lines changed

.github/workflows/build-ci-container.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
container-name-tag: ${{ steps.vars.outputs.container-name-tag }}
2828
container-name-agent-tag: ${{ steps.vars.outputs.container-name-agent-tag }}
2929
container-filename: ${{ steps.vars.outputs.container-filename }}
30+
container-agent-filename: ${{ steps.vars.outputs.container-agent-filename }}
3031
steps:
3132
- name: Checkout LLVM
3233
uses: actions/checkout@v4
@@ -42,6 +43,7 @@ jobs:
4243
echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT
4344
echo "container-name-agent-tag=$container_name-agent:$tag" >> $GITHUB_OUTPUT
4445
echo "container-filename=$(echo $container_name:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
46+
echo "container-agent-filename=$(echo $container_name-agent:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
4547
- name: Build container
4648
working-directory: ./.github/workflows/containers/github-action-ci/
4749
run: |
@@ -53,13 +55,14 @@ jobs:
5355
# maintain minimal permissions while building the container.
5456
- name: Save container image
5557
run: |
56-
podman save ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name-agent-tag }} > ${{ steps.vars.outputs.container-filename }}
58+
podman save ${{ steps.vars.outputs.container-name-tag }} > ${{ steps.vars.outputs.container-filename }}
59+
podman save ${{ steps.vars.outputs.container-name-agent-tag }} > ${{ steps.vars.outputs.container-agent-filename }}
5760
5861
- name: Upload container image
5962
uses: actions/upload-artifact@v4
6063
with:
6164
name: container
62-
path: ${{ steps.vars.outputs.container-filename }}
65+
path: "*.tar"
6366
retention-days: 14
6467

6568
- name: Test Container
@@ -92,6 +95,7 @@ jobs:
9295
podman push ${{ needs.build-ci-container.outputs.container-name-tag }}
9396
podman push ${{ needs.build-ci-container.outputs.container-name }}:latest
9497
98+
podman load -i ${{ needs.build-ci-container.outputs.container-agent-filename }}
9599
podman tag ${{ needs.build-ci-container.outputs.container-name-agent-tag }} ${{ needs.build-ci-container.outputs.container-name-agent }}:latest
96100
podman push ${{ needs.build-ci-container.outputs.container-name-agent-tag }}
97101
podman push ${{ needs.build-ci-container.outputs.container-name-agent }}:latest

.github/workflows/libcxx-restart-preempted-jobs.yaml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ jobs:
9292
check_run_id: check_run_id
9393
})
9494
95+
// For temporary debugging purposes to see the structure of the annotations.
96+
console.log(annotations);
97+
98+
has_failed_job = false;
99+
saved_failure_message = null;
100+
95101
for (annotation of annotations.data) {
96102
if (annotation.annotation_level != 'failure') {
97103
continue;
@@ -106,15 +112,32 @@ jobs:
106112
107113
const failure_match = annotation.message.match(failure_regex);
108114
if (failure_match != null) {
109-
// We only want to restart the workflow if all of the failures were due to preemption.
110-
// We don't want to restart the workflow if there were other failures.
111-
core.notice('Choosing not to rerun workflow because we found a non-preemption failure' +
112-
'Failure message: "' + annotation.message + '"');
113-
await create_check_run('skipped', 'Choosing not to rerun workflow because we found a non-preemption failure\n'
114-
+ 'Failure message: ' + annotation.message)
115-
return;
115+
has_failed_job = true;
116+
saved_failure_message = annotation.message;
116117
}
117118
}
119+
if (has_failed_job && (! has_preempted_job)) {
120+
// We only want to restart the workflow if all of the failures were due to preemption.
121+
// We don't want to restart the workflow if there were other failures.
122+
//
123+
// However, libcxx runners running inside docker containers produce both a preemption message and failure message.
124+
//
125+
// The desired approach is to ignore failure messages which appear on the same job as a preemption message
126+
// (An job is a single run with a specific configuration, ex generic-gcc, gcc-14).
127+
//
128+
// However, it's unclear that this code achieves the desired approach, and it may ignore all failures
129+
// if a preemption message is found at all on any run.
130+
//
131+
// For now, it's more important to restart preempted workflows than to avoid restarting workflows with
132+
// non-preemption failures.
133+
//
134+
// TODO Figure this out.
135+
core.notice('Choosing not to rerun workflow because we found a non-preemption failure' +
136+
'Failure message: "' + saved_failure_message + '"');
137+
await create_check_run('skipped', 'Choosing not to rerun workflow because we found a non-preemption failure\n'
138+
+ 'Failure message: ' + saved_failure_message)
139+
return;
140+
}
118141
}
119142
120143
if (!has_preempted_job) {

.github/workflows/premerge.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ jobs:
1818
concurrency:
1919
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
2020
cancel-in-progress: true
21-
container:
22-
image: ghcr.io/llvm/ci-ubuntu-22.04:latest
23-
defaults:
24-
run:
25-
shell: bash
2621
steps:
2722
- name: Checkout LLVM
2823
uses: actions/checkout@v4

clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,29 @@ findMembersUsedInInitExpr(const CXXCtorInitializer *Initializer,
118118
return Results;
119119
}
120120

121+
/// Returns the start of the leading comments before `Loc`.
122+
static SourceLocation getStartOfLeadingComment(SourceLocation Loc,
123+
const SourceManager &SM,
124+
const LangOptions &LangOpts) {
125+
// We consider any leading comment token that is on the same line or
126+
// indented similarly to the first comment to be part of the leading comment.
127+
const unsigned Line = SM.getPresumedLineNumber(Loc);
128+
const unsigned Column = SM.getPresumedColumnNumber(Loc);
129+
std::optional<Token> Tok =
130+
Lexer::findPreviousToken(Loc, SM, LangOpts, /*IncludeComments=*/true);
131+
while (Tok && Tok->is(tok::comment)) {
132+
const SourceLocation CommentLoc =
133+
Lexer::GetBeginningOfToken(Tok->getLocation(), SM, LangOpts);
134+
if (SM.getPresumedLineNumber(CommentLoc) != Line &&
135+
SM.getPresumedColumnNumber(CommentLoc) != Column) {
136+
break;
137+
}
138+
Loc = CommentLoc;
139+
Tok = Lexer::findPreviousToken(Loc, SM, LangOpts, /*IncludeComments=*/true);
140+
}
141+
return Loc;
142+
}
143+
121144
/// Returns the end of the trailing comments after `Loc`.
122145
static SourceLocation getEndOfTrailingComment(SourceLocation Loc,
123146
const SourceManager &SM,
@@ -159,6 +182,7 @@ static SourceRange getFullFieldSourceRange(const FieldDecl &Field,
159182
if (CurrentToken->is(tok::semi))
160183
break;
161184
}
185+
Begin = getStartOfLeadingComment(Begin, SM, LangOpts);
162186
End = getEndOfTrailingComment(End, SM, LangOpts);
163187
return SourceRange(Begin, End);
164188
}

clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ UseIntegerSignComparisonCheck::UseIntegerSignComparisonCheck(
8080
: ClangTidyCheck(Name, Context),
8181
IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
8282
utils::IncludeSorter::IS_LLVM),
83-
areDiagsSelfContained()) {}
83+
areDiagsSelfContained()),
84+
EnableQtSupport(Options.get("EnableQtSupport", false)) {}
8485

8586
void UseIntegerSignComparisonCheck::storeOptions(
8687
ClangTidyOptions::OptionMap &Opts) {
8788
Options.store(Opts, "IncludeStyle", IncludeInserter.getStyle());
89+
Options.store(Opts, "EnableQtSupport", EnableQtSupport);
8890
}
8991

9092
void UseIntegerSignComparisonCheck::registerMatchers(MatchFinder *Finder) {
@@ -154,8 +156,17 @@ void UseIntegerSignComparisonCheck::check(
154156
DiagnosticBuilder Diag =
155157
diag(BinaryOp->getBeginLoc(),
156158
"comparison between 'signed' and 'unsigned' integers");
157-
const std::string CmpNamespace = ("std::" + parseOpCode(OpCode)).str();
158-
const std::string CmpHeader = "<utility>";
159+
std::string CmpNamespace;
160+
llvm::StringRef CmpHeader;
161+
162+
if (getLangOpts().CPlusPlus20) {
163+
CmpHeader = "<utility>";
164+
CmpNamespace = llvm::Twine("std::" + parseOpCode(OpCode)).str();
165+
} else if (getLangOpts().CPlusPlus17 && EnableQtSupport) {
166+
CmpHeader = "<QtCore/q20utility.h>";
167+
CmpNamespace = llvm::Twine("q20::" + parseOpCode(OpCode)).str();
168+
}
169+
159170
// Prefer modernize-use-integer-sign-comparison when C++20 is available!
160171
Diag << FixItHint::CreateReplacement(
161172
CharSourceRange(R1, SubExprLHS != nullptr),

clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ class UseIntegerSignComparisonCheck : public ClangTidyCheck {
3030
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
3131
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
3232
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
33-
return LangOpts.CPlusPlus20;
33+
return LangOpts.CPlusPlus20 || (LangOpts.CPlusPlus17 && EnableQtSupport);
3434
}
3535

3636
private:
3737
utils::IncludeInserter IncludeInserter;
38+
const bool EnableQtSupport;
3839
};
3940

4041
} // namespace clang::tidy::modernize

clang-tools-extra/clang-tidy/utils/LexerUtils.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,16 @@ namespace clang::tidy::utils::lexer {
1717
std::pair<Token, SourceLocation>
1818
getPreviousTokenAndStart(SourceLocation Location, const SourceManager &SM,
1919
const LangOptions &LangOpts, bool SkipComments) {
20-
Token Token;
21-
Token.setKind(tok::unknown);
20+
const std::optional<Token> Tok =
21+
Lexer::findPreviousToken(Location, SM, LangOpts, !SkipComments);
2222

23-
Location = Location.getLocWithOffset(-1);
24-
if (Location.isInvalid())
25-
return {Token, Location};
26-
27-
const auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location));
28-
while (Location != StartOfFile) {
29-
Location = Lexer::GetBeginningOfToken(Location, SM, LangOpts);
30-
if (!Lexer::getRawToken(Location, Token, SM, LangOpts) &&
31-
(!SkipComments || !Token.is(tok::comment))) {
32-
break;
33-
}
34-
if (Location == StartOfFile)
35-
return {Token, Location};
36-
Location = Location.getLocWithOffset(-1);
23+
if (Tok.has_value()) {
24+
return {*Tok, Lexer::GetBeginningOfToken(Tok->getLocation(), SM, LangOpts)};
3725
}
38-
return {Token, Location};
26+
27+
Token Token;
28+
Token.setKind(tok::unknown);
29+
return {Token, SourceLocation()};
3930
}
4031

4132
Token getPreviousToken(SourceLocation Location, const SourceManager &SM,

clang-tools-extra/clangd/GlobalCompilationDatabase.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,16 @@ bool OverlayCDB::setCompileCommand(PathRef File,
830830
return true;
831831
}
832832

833+
std::unique_ptr<ProjectModules>
834+
OverlayCDB::getProjectModules(PathRef File) const {
835+
auto MDB = DelegatingCDB::getProjectModules(File);
836+
MDB->setCommandMangler([&Mangler = Mangler](tooling::CompileCommand &Command,
837+
PathRef CommandPath) {
838+
Mangler(Command, CommandPath);
839+
});
840+
return MDB;
841+
}
842+
833843
DelegatingCDB::DelegatingCDB(const GlobalCompilationDatabase *Base)
834844
: Base(Base) {
835845
if (Base)

clang-tools-extra/clangd/GlobalCompilationDatabase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ class OverlayCDB : public DelegatingCDB {
209209
setCompileCommand(PathRef File,
210210
std::optional<tooling::CompileCommand> CompilationCommand);
211211

212+
std::unique_ptr<ProjectModules>
213+
getProjectModules(PathRef File) const override;
214+
212215
private:
213216
mutable std::mutex Mutex;
214217
llvm::StringMap<tooling::CompileCommand> Commands; /* GUARDED_BY(Mut) */

clang-tools-extra/clangd/ProjectModules.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROJECTMODULES_H
1010
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROJECTMODULES_H
1111

12+
#include "support/Function.h"
1213
#include "support/Path.h"
1314
#include "support/ThreadsafeFS.h"
15+
#include "clang/Tooling/CompilationDatabase.h"
1416

1517
#include <memory>
1618

@@ -36,11 +38,16 @@ namespace clangd {
3638
/// `<primary-module-name>[:partition-name]`. So module names covers partitions.
3739
class ProjectModules {
3840
public:
41+
using CommandMangler =
42+
llvm::unique_function<void(tooling::CompileCommand &, PathRef) const>;
43+
3944
virtual std::vector<std::string> getRequiredModules(PathRef File) = 0;
4045
virtual PathRef
4146
getSourceForModuleName(llvm::StringRef ModuleName,
4247
PathRef RequiredSrcFile = PathRef()) = 0;
4348

49+
virtual void setCommandMangler(CommandMangler Mangler) {}
50+
4451
virtual ~ProjectModules() = default;
4552
};
4653

clang-tools-extra/clangd/ScanningProjectModules.cpp

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class ModuleDependencyScanner {
4848
};
4949

5050
/// Scanning the single file specified by \param FilePath.
51-
std::optional<ModuleDependencyInfo> scan(PathRef FilePath);
51+
std::optional<ModuleDependencyInfo>
52+
scan(PathRef FilePath, const ProjectModules::CommandMangler &Mangler);
5253

5354
/// Scanning every source file in the current project to get the
5455
/// <module-name> to <module-unit-source> map.
@@ -57,7 +58,7 @@ class ModuleDependencyScanner {
5758
/// a global module dependency scanner to monitor every file. Or we
5859
/// can simply require the build systems (or even the end users)
5960
/// to provide the map.
60-
void globalScan();
61+
void globalScan(const ProjectModules::CommandMangler &Mangler);
6162

6263
/// Get the source file from the module name. Note that the language
6364
/// guarantees all the module names are unique in a valid program.
@@ -69,7 +70,9 @@ class ModuleDependencyScanner {
6970

7071
/// Return the direct required modules. Indirect required modules are not
7172
/// included.
72-
std::vector<std::string> getRequiredModules(PathRef File);
73+
std::vector<std::string>
74+
getRequiredModules(PathRef File,
75+
const ProjectModules::CommandMangler &Mangler);
7376

7477
private:
7578
std::shared_ptr<const clang::tooling::CompilationDatabase> CDB;
@@ -87,7 +90,8 @@ class ModuleDependencyScanner {
8790
};
8891

8992
std::optional<ModuleDependencyScanner::ModuleDependencyInfo>
90-
ModuleDependencyScanner::scan(PathRef FilePath) {
93+
ModuleDependencyScanner::scan(PathRef FilePath,
94+
const ProjectModules::CommandMangler &Mangler) {
9195
auto Candidates = CDB->getCompileCommands(FilePath);
9296
if (Candidates.empty())
9397
return std::nullopt;
@@ -97,10 +101,8 @@ ModuleDependencyScanner::scan(PathRef FilePath) {
97101
// DirectoryBasedGlobalCompilationDatabase::getCompileCommand.
98102
tooling::CompileCommand Cmd = std::move(Candidates.front());
99103

100-
static int StaticForMainAddr; // Just an address in this process.
101-
Cmd.CommandLine.push_back("-resource-dir=" +
102-
CompilerInvocation::GetResourcesPath(
103-
"clangd", (void *)&StaticForMainAddr));
104+
if (Mangler)
105+
Mangler(Cmd, FilePath);
104106

105107
using namespace clang::tooling::dependencies;
106108

@@ -130,9 +132,10 @@ ModuleDependencyScanner::scan(PathRef FilePath) {
130132
return Result;
131133
}
132134

133-
void ModuleDependencyScanner::globalScan() {
135+
void ModuleDependencyScanner::globalScan(
136+
const ProjectModules::CommandMangler &Mangler) {
134137
for (auto &File : CDB->getAllFiles())
135-
scan(File);
138+
scan(File, Mangler);
136139

137140
GlobalScanned = true;
138141
}
@@ -150,9 +153,9 @@ PathRef ModuleDependencyScanner::getSourceForModuleName(
150153
return {};
151154
}
152155

153-
std::vector<std::string>
154-
ModuleDependencyScanner::getRequiredModules(PathRef File) {
155-
auto ScanningResult = scan(File);
156+
std::vector<std::string> ModuleDependencyScanner::getRequiredModules(
157+
PathRef File, const ProjectModules::CommandMangler &Mangler) {
158+
auto ScanningResult = scan(File, Mangler);
156159
if (!ScanningResult)
157160
return {};
158161

@@ -177,20 +180,25 @@ class ScanningAllProjectModules : public ProjectModules {
177180
~ScanningAllProjectModules() override = default;
178181

179182
std::vector<std::string> getRequiredModules(PathRef File) override {
180-
return Scanner.getRequiredModules(File);
183+
return Scanner.getRequiredModules(File, Mangler);
184+
}
185+
186+
void setCommandMangler(CommandMangler Mangler) override {
187+
this->Mangler = std::move(Mangler);
181188
}
182189

183190
/// RequiredSourceFile is not used intentionally. See the comments of
184191
/// ModuleDependencyScanner for detail.
185192
PathRef
186193
getSourceForModuleName(llvm::StringRef ModuleName,
187194
PathRef RequiredSourceFile = PathRef()) override {
188-
Scanner.globalScan();
195+
Scanner.globalScan(Mangler);
189196
return Scanner.getSourceForModuleName(ModuleName);
190197
}
191198

192199
private:
193200
ModuleDependencyScanner Scanner;
201+
CommandMangler Mangler;
194202
};
195203

196204
std::unique_ptr<ProjectModules> scanningProjectModules(

0 commit comments

Comments
 (0)