Skip to content

Commit

Permalink
Merge branch 'trunk' into symbolic-param
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffromer committed Mar 3, 2025
2 parents 18815cc + 2d1bfca commit c305a30
Show file tree
Hide file tree
Showing 557 changed files with 12,987 additions and 8,430 deletions.
14 changes: 9 additions & 5 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ WarningsAsErrors: '*'
# - '-google-readability-function-size'
# # Suggests usernames on TODOs, which we don't want.
# - '-google-readability-todo'
# # Extremely slow. TODO: Re-enable once
# # https://github.com/llvm/llvm-project/issues/128797 is fixed.
# - '-misc-confusable-identifiers'
# # Overlaps with `-Wno-missing-prototypes`.
# - '-misc-use-internal-linkage'
# # Suggests `std::array`, which we could migrate to, but conflicts with the
Expand Down Expand Up @@ -107,11 +110,12 @@ Checks:
-bugprone-macro-parentheses, -bugprone-narrowing-conversions,
-bugprone-switch-missing-default-case, -bugprone-unchecked-optional-access,
-google-readability-function-size, -google-readability-todo,
-misc-use-internal-linkage, -modernize-avoid-c-arrays,
-modernize-use-designated-initializers, -modernize-use-nodiscard,
-performance-unnecessary-value-param, -readability-enum-initial-value,
-readability-function-cognitive-complexity, -readability-magic-numbers,
-readability-redundant-member-init, -readability-suspicious-call-argument
-misc-confusable-identifiers, -misc-use-internal-linkage,
-modernize-avoid-c-arrays, -modernize-use-designated-initializers,
-modernize-use-nodiscard, -performance-unnecessary-value-param,
-readability-enum-initial-value, -readability-function-cognitive-complexity,
-readability-magic-numbers, -readability-redundant-member-init,
-readability-suspicious-call-argument
CheckOptions:
# Don't warn on structs; done by ignoring when there are only public members.
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
# - Do some amount of testing prior to building and uploading the release.
# - Tempting to try to examine existing testing workflow, but maybe better to
# allow re-using any complex parts and do our own testing. That would, for
# allow reusing any complex parts and do our own testing. That would, for
# example, allow us to narrow or expand the set of tests uses for
# pre-release testing to potentially be different from continuous testing.
# - Some questions around what to do in the event of a failure... error? Where
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/triage_inactive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
stale-issue-message: >
We triage inactive PRs and issues in order to make it easier to find
active work. If this issue should remain active or becomes active
again, please comment or remove the `inactive` label. The `long
term` label can also be added for issues which are expected to take
again, please comment or remove the `inactive` label. The `long term
issue` label can also be added for issues which are expected to take
time.
Expand All @@ -56,7 +56,8 @@ jobs:
stale-issue-label: 'inactive'
stale-pr-label: 'inactive'
exempt-issue-labels:
'long term,design idea,design update,good first issue,leads question'
'long term issue,design idea,design update,good first issue,leads
question'
days-before-stale: 90
days-before-close: 14
days-before-issue-close: -1
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ repos:

# Formatters should be run late so that they can re-format any prior changes.
- repo: https://github.com/psf/black
rev: 1b2427a2b785cc4aac97c19bb4b9a0de063f9547 # frozen: 24.10.0
rev: 8a737e727ac5ab2f1d4cf5876720ed276dc8dc4b # frozen: 25.1.0
hooks:
- id: black
- repo: local
Expand Down Expand Up @@ -135,11 +135,11 @@ repos:
files: ^.*/BUILD$
pass_filenames: false
- repo: https://github.com/PyCQA/flake8
rev: e43806be3607110919eff72939fda031776e885a # frozen: 7.1.1
rev: bddd87797f8dfc07d2a10c894776018d9bec590b # frozen: 7.1.2
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'f56614daa94d5cd733d3b7004c5df9caad267b4a' # frozen: v1.13.0
rev: 'f40886d54c729f533f864ed6ce584e920feb0af7' # frozen: v1.15.0
hooks:
- id: mypy
# Use setup.cfg to match the command line.
Expand All @@ -161,7 +161,7 @@ repos:
.*_test\.py
)$
- repo: https://github.com/codespell-project/codespell
rev: 193cd7d27cd571f79358af09a8fb8997e54f8fff # frozen: v2.3.0
rev: 63c8f8312b7559622c0d82815639671ae42132ac # frozen: v2.4.1
hooks:
- id: codespell
args: ['-I', '.codespell_ignore', '--uri-ignore-words-list', '*']
Expand Down
5 changes: 4 additions & 1 deletion .vscode/gdb_launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"program": "bazel-bin/toolchain/testing/file_test",
"programArgs": "--file_tests=${relativeFile}",
"cwd": "${workspaceFolder}",
"env": { "TEST_TMPDIR": "/tmp" }
"env": {
"TEST_TARGET": "//toolchain/testing:file_test",
"TEST_TMPDIR": "/tmp"
}
},
{
"type": "by-gdb",
Expand Down
11 changes: 7 additions & 4 deletions .vscode/lldb_launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
"debuggerRoot": "${workspaceFolder}",
"initCommands": [
"command script import external/+llvm_project+llvm-project/llvm/utils/lldbDataFormatters.py",
"settings set target.source-map \".\" \"${workspaceFolder}\""
],
"env": { "TEST_TMPDIR": "/tmp" }
"settings set target.source-map \".\" \"${workspaceFolder}\"",
"settings set target.source-map \"/proc/self/cwd\" \"${workspaceFolder}\"",
"env TEST_TARGET=//toolchain/testing:file_test",
"env TEST_TMPDIR=/tmp"
]
},
{
"type": "lldb-dap",
Expand All @@ -29,7 +31,8 @@
"debuggerRoot": "${workspaceFolder}",
"initCommands": [
"command script import external/+llvm_project+llvm-project/llvm/utils/lldbDataFormatters.py",
"settings set target.source-map \".\" \"${workspaceFolder}\""
"settings set target.source-map \".\" \"${workspaceFolder}\"",
"settings set target.source-map \"/proc/self/cwd\" \"${workspaceFolder}\""
]
}
]
Expand Down
51 changes: 45 additions & 6 deletions bazel/manifest/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

"""Rule for producing a manifest for a filegroup."""

def _manifest(ctx):
out = ctx.actions.declare_file(ctx.label.name)

def _get_files(ctx):
files = []
for src in ctx.attr.srcs:
files.extend([f.path for f in src[DefaultInfo].files.to_list()])
Expand All @@ -17,11 +15,16 @@ def _manifest(ctx):

if ctx.attr.strip_package_dir:
package_dir = ctx.label.package + "/"
content = [f.removeprefix(package_dir) for f in files]
files_stripped = [f.removeprefix(package_dir) for f in files]
else:
content = files
files_stripped = files

ctx.actions.write(out, "\n".join(content) + "\n")
return files_stripped

def _manifest(ctx):
out = ctx.actions.declare_file(ctx.label.name)
files = _get_files(ctx)
ctx.actions.write(out, "\n".join(files) + "\n")

return [
DefaultInfo(
Expand All @@ -30,10 +33,46 @@ def _manifest(ctx):
),
]

# Produces the manifest as a series of lines.
manifest = rule(
implementation = _manifest,
attrs = {
"srcs": attr.label_list(allow_files = True, mandatory = True),
"strip_package_dir": attr.bool(default = False),
},
)

def _manifest_as_cpp(ctx):
out = ctx.actions.declare_file(ctx.label.name)
files = _get_files(ctx)
lines = [
"// Auto-generated by manifest_as_cpp.",
"const char* {0}[] = {{".format(ctx.attr.var_name),
]
lines += [
" \"{0}\",".format(file)
for file in files
]
lines += [
" nullptr,",
"};",
]
ctx.actions.write(out, "\n".join(lines) + "\n")

return [
DefaultInfo(
files = depset(direct = [out]),
runfiles = ctx.runfiles(files = [out]),
),
]

# Produces the manifest as a nullptr-terminated `const char* var_name[]`.
# Use with `extern const char* var_name[];`.
manifest_as_cpp = rule(
implementation = _manifest_as_cpp,
attrs = {
"srcs": attr.label_list(allow_files = True, mandatory = True),
"strip_package_dir": attr.bool(default = False),
"var_name": attr.string(mandatory = True),
},
)
2 changes: 1 addition & 1 deletion common/check_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ auto ConvertFormatValue(T&& t) -> T&& {
// without the user writing a cast.
template <typename T>
requires(std::is_enum_v<std::remove_reference_t<T>>)
auto ConvertFormatValue(T&& t) {
auto ConvertFormatValue(T&& t) -> auto {
if constexpr (std::is_signed_v<
std::underlying_type_t<std::remove_reference_t<T>>>) {
return static_cast<int64_t>(t);
Expand Down
2 changes: 1 addition & 1 deletion common/hashing_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using ::testing::Eq;
using ::testing::Le;
using ::testing::Ne;

TEST(HashingTest, HashCodeAPI) {
TEST(HashingTest, HashCodeApi) {
// Manually compute a few hash codes where we can exercise the underlying API.
HashCode empty = HashValue("");
HashCode a = HashValue("a");
Expand Down
12 changes: 6 additions & 6 deletions common/hashtable_key_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ auto HashtableEq(const LeftT& lhs, const RightT& rhs) -> bool;
// properties of hashes produced by the `hashing.h` infrastructure.
//
// The default for comparison is `operator==`. The `KeyEq` method is always
// called with a key *stored in the hashtable* as the second or "RHS" parameter.
// called with a key *stored in the hashtable* as the second or "Rhs" parameter.
// This is to allow simplifying the set of overloads needed for heterogeneous
// contexts: only the first, LHS, parameter needs to support different lookup
// key types.
Expand Down Expand Up @@ -217,13 +217,13 @@ auto TranslatingKeyContext<DerivedT>::KeyEq(const AnyKeyT& lhs_key,
const DerivedT& self = *static_cast<const DerivedT*>(this);
// Because we don't want to make no-op calls and potentially struggle with
// temporary lifetimes at runtime we have to fully expand the 4 states.
constexpr bool TranslateLHS = requires { self.TranslateKey(lhs_key); };
constexpr bool TranslateRHS = requires { self.TranslateKey(rhs_key); };
if constexpr (TranslateLHS && TranslateRHS) {
constexpr bool TranslateLhs = requires { self.TranslateKey(lhs_key); };
constexpr bool TranslateRhs = requires { self.TranslateKey(rhs_key); };
if constexpr (TranslateLhs && TranslateRhs) {
return HashtableEq(self.TranslateKey(lhs_key), self.TranslateKey(rhs_key));
} else if constexpr (TranslateLHS) {
} else if constexpr (TranslateLhs) {
return HashtableEq(self.TranslateKey(lhs_key), rhs_key);
} else if constexpr (TranslateRHS) {
} else if constexpr (TranslateRhs) {
return HashtableEq(lhs_key, self.TranslateKey(rhs_key));
} else {
return HashtableEq(lhs_key, rhs_key);
Expand Down
2 changes: 1 addition & 1 deletion common/map_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ TYPED_TEST(MapTest, Basic) {
m, MakeKeyValues([](int k) { return k * 100 + 1; }, llvm::seq(1, 512)));
}

TYPED_TEST(MapTest, FactoryAPI) {
TYPED_TEST(MapTest, FactoryApi) {
TypeParam m;
EXPECT_TRUE(m.Insert(1, [] { return 100; }).is_inserted());
ASSERT_TRUE(m.Contains(1));
Expand Down
2 changes: 1 addition & 1 deletion common/raw_hashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ class BaseImpl {
// returns `true`. If not found, returns `false`.
//
// Does not release any memory, just leaves a tombstone behind so this entry
// cannot be found and the slot can in theory be re-used.
// cannot be found and the slot can in theory be reused.
template <typename LookupKeyT>
auto EraseImpl(LookupKeyT lookup_key, KeyContextT key_context) -> bool;

Expand Down
Loading

0 comments on commit c305a30

Please sign in to comment.