Skip to content

Commit e508384

Browse files
authored
Merge branch 'main' into tltao/vfs_tempfile_flags
2 parents 97ce4a6 + 0a5be0f commit e508384

File tree

1,538 files changed

+16689
-9662
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,538 files changed

+16689
-9662
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ concurrency:
3636
jobs:
3737
stage1:
3838
if: github.repository_owner == 'llvm'
39-
runs-on: llvm-premerge-libcxx-next-runners
39+
runs-on: llvm-premerge-libcxx-runners
4040
continue-on-error: false
4141
strategy:
4242
fail-fast: false
@@ -73,7 +73,7 @@ jobs:
7373
**/crash_diagnostics/*
7474
stage2:
7575
if: github.repository_owner == 'llvm'
76-
runs-on: llvm-premerge-libcxx-next-runners
76+
runs-on: llvm-premerge-libcxx-runners
7777
needs: [ stage1 ]
7878
continue-on-error: false
7979
strategy:
@@ -148,19 +148,19 @@ jobs:
148148
'generic-static',
149149
'bootstrapping-build'
150150
]
151-
machine: [ 'llvm-premerge-libcxx-next-runners' ]
151+
machine: [ 'llvm-premerge-libcxx-runners' ]
152152
include:
153153
- config: 'generic-cxx26'
154-
machine: llvm-premerge-libcxx-next-runners
154+
machine: llvm-premerge-libcxx-runners
155155
- config: 'generic-asan'
156-
machine: llvm-premerge-libcxx-next-runners
156+
machine: llvm-premerge-libcxx-runners
157157
- config: 'generic-tsan'
158-
machine: llvm-premerge-libcxx-next-runners
158+
machine: llvm-premerge-libcxx-runners
159159
- config: 'generic-ubsan'
160-
machine: llvm-premerge-libcxx-next-runners
160+
machine: llvm-premerge-libcxx-runners
161161
# Use a larger machine for MSAN to avoid timeout and memory allocation issues.
162162
- config: 'generic-msan'
163-
machine: llvm-premerge-libcxx-next-runners
163+
machine: llvm-premerge-libcxx-runners
164164
runs-on: ${{ matrix.machine }}
165165
steps:
166166
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

.github/workflows/libcxx-build-containers.yml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ on:
1515
branches:
1616
- main
1717
paths:
18-
- 'libcxx/utils/ci/**'
18+
- 'libcxx/utils/ci/docker/**'
1919
- '.github/workflows/libcxx-build-containers.yml'
2020
pull_request:
2121
paths:
22-
- 'libcxx/utils/ci/**'
22+
- 'libcxx/utils/ci/docker/**'
2323
- '.github/workflows/libcxx-build-containers.yml'
2424

2525
jobs:
@@ -40,17 +40,18 @@ jobs:
4040
echo '{ "data-root": "/mnt/docker" }' | sudo tee /etc/docker/daemon.json
4141
sudo systemctl restart docker
4242
43-
- name: Build the Linux builder image
44-
working-directory: libcxx/utils/ci
45-
run: |
46-
docker compose build builder-base
47-
docker compose build actions-builder
43+
- name: Build the base image
44+
run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml build libcxx-linux-builder-base
45+
env:
46+
TAG: ${{ github.sha }}
47+
48+
- name: Build the Linux Github Actions image
49+
run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml build libcxx-linux-builder
4850
env:
4951
TAG: ${{ github.sha }}
5052

5153
- name: Build the Android builder image
52-
working-directory: libcxx/utils/ci
53-
run: docker compose build android-buildkite-builder
54+
run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml build libcxx-android-builder
5455
env:
5556
TAG: ${{ github.sha }}
5657

@@ -61,19 +62,21 @@ jobs:
6162
username: ${{ github.actor }}
6263
password: ${{ secrets.GITHUB_TOKEN }}
6364

64-
- name: Push the Linux builder image
65+
- name: Push the images
6566
if: github.event_name == 'push'
66-
working-directory: libcxx/utils/ci
67-
run: |
68-
docker compose push builder-base
69-
docker compose push actions-builder
70-
env:
71-
TAG: ${{ github.sha }}
67+
run: docker compose push libcxx-linux-builder-base libcxx-linux-builder libcxx-android-builder
7268

73-
- name: Push the Android builder image
74-
if: github.event_name == 'push'
75-
working-directory: libcxx/utils/ci
69+
# We create tarballs with the images and upload them as artifacts, since that's useful for testing
70+
# the images when making changes.
71+
- name: Create image tarballs
7672
run: |
77-
docker compose push android-buildkite-builder
78-
env:
79-
TAG: ${{ github.sha }}
73+
docker image save ghcr.io/llvm/libcxx-linux-builder-base:${{ github.sha }} | gzip > libcxx-linux-builder-base.tar.gz
74+
docker image save ghcr.io/llvm/libcxx-linux-builder:${{ github.sha }} | gzip > libcxx-linux-builder.tar.gz
75+
docker image save ghcr.io/llvm/libcxx-android-builder:${{ github.sha }} | gzip > libcxx-android-builder.tar.gz
76+
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
77+
with:
78+
name: libcxx-docker-images
79+
path: |
80+
libcxx-linux-builder-base.tar.gz
81+
libcxx-linux-builder.tar.gz
82+
libcxx-android-builder.tar.gz
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
BasedOnStyle: LLVM
22
QualifierAlignment: Left
33
LineEnding: LF
4+
InsertNewlineAtEOF: true

clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,102 @@
1111
#include "clang/Lex/Preprocessor.h"
1212
#include <optional>
1313

14-
namespace clang::tidy::google::readability {
14+
namespace clang::tidy {
15+
16+
namespace google::readability {
17+
18+
enum class StyleKind { Parentheses, Hyphen };
19+
20+
} // namespace google::readability
21+
22+
template <> struct OptionEnumMapping<google::readability::StyleKind> {
23+
static ArrayRef<std::pair<google::readability::StyleKind, StringRef>>
24+
getEnumMapping() {
25+
static constexpr std::pair<google::readability::StyleKind, StringRef>
26+
Mapping[] = {
27+
{google::readability::StyleKind::Hyphen, "Hyphen"},
28+
{google::readability::StyleKind::Parentheses, "Parentheses"},
29+
};
30+
return {Mapping};
31+
}
32+
};
33+
34+
} // namespace clang::tidy
1535

36+
namespace clang::tidy::google::readability {
1637
class TodoCommentCheck::TodoCommentHandler : public CommentHandler {
1738
public:
1839
TodoCommentHandler(TodoCommentCheck &Check, std::optional<std::string> User)
1940
: Check(Check), User(User ? *User : "unknown"),
20-
TodoMatch("^// *TODO *(\\(.*\\))?:?( )?(.*)$") {}
41+
TodoMatch(R"(^// *TODO *((\((.*)\))?:?( )?|: *(.*) *- *)?(.*)$)") {
42+
const llvm::StringRef TodoStyleString =
43+
Check.Options.get("Style", "Hyphen");
44+
for (const auto &[Value, Name] :
45+
OptionEnumMapping<StyleKind>::getEnumMapping()) {
46+
if (Name == TodoStyleString) {
47+
TodoStyle = Value;
48+
return;
49+
}
50+
}
51+
Check.configurationDiag(
52+
"invalid value '%0' for "
53+
"google-readability-todo.Style; valid values are "
54+
"'Parentheses' and 'Hyphen'. Defaulting to 'Hyphen'")
55+
<< TodoStyleString;
56+
}
2157

2258
bool HandleComment(Preprocessor &PP, SourceRange Range) override {
2359
const StringRef Text =
2460
Lexer::getSourceText(CharSourceRange::getCharRange(Range),
2561
PP.getSourceManager(), PP.getLangOpts());
2662

27-
SmallVector<StringRef, 4> Matches;
63+
SmallVector<StringRef, 7> Matches;
2864
if (!TodoMatch.match(Text, &Matches))
2965
return false;
3066

31-
const StringRef Username = Matches[1];
32-
const StringRef Comment = Matches[3];
67+
const StyleKind ParsedStyle =
68+
!Matches[3].empty() ? StyleKind::Parentheses : StyleKind::Hyphen;
69+
const StringRef Username =
70+
ParsedStyle == StyleKind::Parentheses ? Matches[3] : Matches[5];
71+
const StringRef Comment = Matches[6];
3372

34-
if (!Username.empty())
73+
if (!Username.empty() &&
74+
(ParsedStyle == StyleKind::Parentheses || !Comment.empty())) {
3575
return false;
76+
}
3677

37-
const std::string NewText =
38-
("// TODO(" + Twine(User) + "): " + Comment).str();
78+
if (Username.empty()) {
79+
Check.diag(Range.getBegin(), "missing username/bug in TODO")
80+
<< FixItHint::CreateReplacement(
81+
CharSourceRange::getCharRange(Range),
82+
createReplacementString(Username, Comment));
83+
}
84+
85+
if (Comment.empty())
86+
Check.diag(Range.getBegin(), "missing details in TODO");
3987

40-
Check.diag(Range.getBegin(), "missing username/bug in TODO")
41-
<< FixItHint::CreateReplacement(CharSourceRange::getCharRange(Range),
42-
NewText);
4388
return false;
4489
}
4590

91+
std::string createReplacementString(const StringRef Username,
92+
const StringRef Comment) const {
93+
if (TodoStyle == StyleKind::Parentheses) {
94+
return ("// TODO(" + Twine(User) +
95+
"): " + (Comment.empty() ? "some details" : Comment))
96+
.str();
97+
}
98+
return ("// TODO: " + Twine(User) + " - " +
99+
(Comment.empty() ? "some details" : Comment))
100+
.str();
101+
}
102+
103+
StyleKind getTodoStyle() const { return TodoStyle; }
104+
46105
private:
47106
TodoCommentCheck &Check;
48107
std::string User;
49108
llvm::Regex TodoMatch;
109+
StyleKind TodoStyle = StyleKind::Hyphen;
50110
};
51111

52112
TodoCommentCheck::TodoCommentCheck(StringRef Name, ClangTidyContext *Context)
@@ -62,4 +122,8 @@ void TodoCommentCheck::registerPPCallbacks(const SourceManager &SM,
62122
PP->addCommentHandler(Handler.get());
63123
}
64124

125+
void TodoCommentCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
126+
Options.store(Opts, "Style", Handler->getTodoStyle());
127+
}
128+
65129
} // namespace clang::tidy::google::readability

clang-tools-extra/clang-tidy/google/TodoCommentCheck.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class TodoCommentCheck : public ClangTidyCheck {
2727
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
2828
Preprocessor *ModuleExpanderPP) override;
2929

30+
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
31+
3032
private:
3133
class TodoCommentHandler;
3234
std::unique_ptr<TodoCommentHandler> Handler;

clang-tools-extra/clangd/SourceCode.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,26 @@ EligibleRegion getEligiblePoints(llvm::StringRef Code,
12171217
return ER;
12181218
}
12191219

1220+
std::string getNamespaceAtPosition(StringRef Code, const Position &Pos,
1221+
const LangOptions &LangOpts) {
1222+
std::vector<std::string> Enclosing = {""};
1223+
parseNamespaceEvents(Code, LangOpts, [&](NamespaceEvent Event) {
1224+
if (Pos < Event.Pos)
1225+
return;
1226+
if (Event.Trigger == NamespaceEvent::UsingDirective)
1227+
return;
1228+
if (!Event.Payload.empty())
1229+
Event.Payload.append("::");
1230+
if (Event.Trigger == NamespaceEvent::BeginNamespace) {
1231+
Enclosing.emplace_back(std::move(Event.Payload));
1232+
} else {
1233+
Enclosing.pop_back();
1234+
assert(Enclosing.back() == Event.Payload);
1235+
}
1236+
});
1237+
return Enclosing.back();
1238+
}
1239+
12201240
bool isHeaderFile(llvm::StringRef FileName,
12211241
std::optional<LangOptions> LangOpts) {
12221242
// Respect the langOpts, for non-file-extension cases, e.g. standard library

clang-tools-extra/clangd/SourceCode.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@ EligibleRegion getEligiblePoints(llvm::StringRef Code,
309309
llvm::StringRef FullyQualifiedName,
310310
const LangOptions &LangOpts);
311311

312+
/// Returns the fully qualified name of the namespace at \p Pos in the \p Code.
313+
/// Employs pseudo-parsing to determine the start and end of namespaces.
314+
std::string getNamespaceAtPosition(llvm::StringRef Code, const Position &Pos,
315+
const LangOptions &LangOpts);
316+
312317
struct DefinedMacro {
313318
llvm::StringRef Name;
314319
const MacroInfo *Info;

0 commit comments

Comments
 (0)