Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into tuple-adapt
Browse files Browse the repository at this point in the history
  • Loading branch information
danakj committed Dec 20, 2024
2 parents c2d0cb3 + aca862c commit 9f1ca80
Show file tree
Hide file tree
Showing 838 changed files with 29,830 additions and 23,582 deletions.
4 changes: 3 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ build:linux --define=pfm=1
#
# Note: if using GDB, see documentation to get that working:
# https://docs.carbon-lang.dev/docs/project/contribution_tools.html#debugging-with-gdb-instead-of-lldb
build:linux --fission=yes
#
# TODO: Bazel has a bug where it doesn't manage dwo files in the cache correctly.
# build:linux --fission=yes

# Disables `actions.declare_symlink`. Done for cross-environment support.
build --allow_unresolved_symlinks=false
Expand Down
239 changes: 139 additions & 100 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -8,110 +8,149 @@ UseColor: true
# This is necessary for `--config=clang-tidy` to catch errors.
WarningsAsErrors: '*'

# We turn on all `bugprone`, `google`, `modernize`, `performance`, and
# `readability` by default. A few `misc` are selectively enabled, and a few
# other checks are selectively disabled.
# TODO: clang-tidy-16 doesn't support this format; it's retained for comments.
# Switch once we update the minimum version.
#
# Checks with nuanced reasons for disabling are:
# # We turn on all of a few categories by default.
# - '-*'
# - 'bugprone-*'
# - 'google-*'
# - 'misc-*'
# - 'modernize-*'
# - 'performance-*'
# - 'readability-*'
#
# - `bugprone-branch-clone` warns when we have multiple empty cases in switches,
# which we do for comment reasons.
# - `bugprone-easily-swappable-parameters` frequently warns on multiple
# parameters of the same type.
# - `bugprone-exception-escape` finds issues like out-of-memory in main(). We
# don't use exceptions, so it's unlikely to find real issues.
# - `bugprone-macro-parentheses` has false positives in places such as using an
# argument to declare a name, which cannot have parentheses. For our limited
# use of macros, this is a common conflict.
# - `bugprone-narrowing-conversions` conflicts with integer type C++ style.
# - `google-readability-todo` suggests usernames on TODOs, which we don't want.
# - `bugprone-switch-missing-default-case` has false positives for
# `enum_base.h`. Clang's built-in switch warnings cover most of our risk of
# bugs here.
# - `bugprone-unchecked-optional-access` in clang-tidy 16 has false positives on
# code like:
# while (auto name_ref = insts().Get(inst_id).TryAs<SemIR::NameRef>()) {
# inst_id = name_ref->value_id;
# ^ unchecked access to optional value
# }
# - `google-readability-function-size` overlaps with
# `readability-function-size`.
# - `modernize-avoid-c-arrays` suggests `std::array`, which we could migrate to,
# but conflicts with the status quo.
# - `modernize-use-designated-initializers` fires on creation of SemIR typed
# insts, for which we do not currently want to use designated initialization.
# - `modernize-use-nodiscard` is disabled because it only fixes const methods,
# not non-const, which yields distracting results on accessors.
# - `performance-unnecessary-value-param` duplicates `modernize-pass-by-value`.
# - `readability-enum-initial-value` warns on enums which use the
# `LastValue = Value` pattern if all the other discriminants aren't given an
# explicit value.
# - `readability-function-cognitive-complexity` warns too frequently.
# - `readability-magic-numbers` warns in reasonably documented situations.
# - `readability-redundant-member-init` warns on `= {}` which is also used to
# indicate which fields do not need to be explicitly initialized in aggregate
# initialization.
# - `readability-suspicious-call-argument` warns when callers use similar names
# as different parameters.
# # Disabled due to the implied style choices.
# - '-misc-const-correctness'
# - '-misc-include-cleaner'
# - '-misc-use-anonymous-namespace'
# - '-modernize-return-braced-init-list'
# - '-modernize-use-default-member-init'
# - '-modernize-use-integer-sign-comparison'
# - '-modernize-use-emplace'
# - '-readability-avoid-nested-conditional-operator'
# - '-readability-convert-member-functions-to-static'
# - '-readability-else-after-return'
# - '-readability-identifier-length'
# - '-readability-implicit-bool-conversion'
# - '-readability-make-member-function-const'
# - '-readability-math-missing-parentheses'
# - '-readability-static-definition-in-anonymous-namespace'
# - '-readability-use-anyofallof'
#
# Checks that are essentially style choices we don't apply are:
#
# - `modernize-return-braced-init-list`
# - `modernize-use-default-member-init`
# - `modernize-use-emplace`
# - `readability-convert-member-functions-to-static`
# - `readability-else-after-return`
# - `readability-identifier-length`
# - `readability-implicit-bool-conversion`
# - `readability-make-member-function-const`
# - `readability-static-definition-in-anonymous-namespace`
# - `readability-use-anyofallof`
# # Warns when we have multiple empty cases in switches, which we do for comment
# # reasons.
# - '-bugprone-branch-clone'
# # Frequently warns on multiple parameters of the same type.
# - '-bugprone-easily-swappable-parameters'
# # Finds issues like out-of-memory in main(). We don't use exceptions, so it's
# # unlikely to find real issues.
# - '-bugprone-exception-escape'
# # Has false positives in places such as using an argument to declare a name,
# # which cannot have parentheses. For our limited use of macros, this is a
# # common conflict.
# - '-bugprone-macro-parentheses'
# # Conflicts with integer type C++ style.
# - '-bugprone-narrowing-conversions'
# # Has false positives for `enum_base.h`. Clang's built-in switch warnings
# # cover most of our risk of bugs here.
# - '-bugprone-switch-missing-default-case'
# # In clang-tidy 16, has false positives on code like:
# # while (auto name_ref = insts().Get(inst_id).TryAs<SemIR::NameRef>()) {
# # inst_id = name_ref->value_id;
# # ^ unchecked access to optional value
# # }
# - '-bugprone-unchecked-optional-access'
# # Overlaps with `readability-function-size`.
# - '-google-readability-function-size'
# # Suggests usernames on TODOs, which we don't want.
# - '-google-readability-todo'
# # Overlaps with `-Wno-missing-prototypes`.
# - '-misc-use-internal-linkage'
# # Suggests `std::array`, which we could migrate to, but conflicts with the
# # status quo.
# - '-modernize-avoid-c-arrays'
# # Warns on creation of SemIR typed insts, for which we do not currently want
# # to use designated initialization.
# - '-modernize-use-designated-initializers'
# # Only fixes const methods, not non-const, which yields distracting results on
# # accessors.
# - '-modernize-use-nodiscard'
# # Duplicates `modernize-pass-by-value`.
# - '-performance-unnecessary-value-param'
# # Warns on enums which use the `LastValue = Value` pattern if all the other
# # discriminants aren't given an explicit value.
# - '-readability-enum-initial-value'
# # Warns too frequently.
# - '-readability-function-cognitive-complexity'
# # Warns in reasonably documented situations.
# - '-readability-magic-numbers'
# # Warns on `= {}` which is also used to indicate which fields do not need to
# # be explicitly initialized in aggregate initialization.
# - '-readability-redundant-member-init'
# # Warns when callers use similar names as different parameters.
# - '-readability-suspicious-call-argument'
Checks:
-*, bugprone-*, -bugprone-branch-clone, -bugprone-easily-swappable-parameters,
-bugprone-exception-escape, -bugprone-macro-parentheses,
-bugprone-narrowing-conversions, -bugprone-switch-missing-default-case,
-bugprone-unchecked-optional-access, google-*,
-google-readability-function-size, -google-readability-todo,
misc-definitions-in-headers, misc-misplaced-const, misc-redundant-expression,
misc-static-assert, misc-unconventional-assign-operator,
misc-uniqueptr-reset-release, misc-unused-*, modernize-*,
-modernize-avoid-c-arrays, -modernize-return-braced-init-list,
-modernize-use-default-member-init, -modernize-use-designated-initializers,
-modernize-use-emplace, -modernize-use-nodiscard, performance-*,
-performance-unnecessary-value-param, readability-*,
-*, bugprone-*, google-*, misc-*, modernize-*, performance-*, readability-*,
-misc-const-correctness, -misc-include-cleaner, -misc-use-anonymous-namespace,
-modernize-return-braced-init-list, -modernize-use-default-member-init,
-modernize-use-integer-sign-comparison, -modernize-use-emplace,
-readability-avoid-nested-conditional-operator,
-readability-convert-member-functions-to-static,
-readability-else-after-return, -readability-enum-initial-value,
-readability-function-cognitive-complexity, -readability-identifier-length,
-readability-implicit-bool-conversion, -readability-magic-numbers,
-readability-make-member-function-const, -readability-redundant-member-init,
-readability-else-after-return, -readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-make-member-function-const,
-readability-math-missing-parentheses,
-readability-static-definition-in-anonymous-namespace,
-readability-suspicious-call-argument, -readability-use-anyofallof
-readability-use-anyofallof, -bugprone-branch-clone,
-bugprone-easily-swappable-parameters, -bugprone-exception-escape,
-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
CheckOptions:
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.ClassConstantCase, value: CamelCase }
- {
key: readability-identifier-naming.ConstexprVariableCase,
value: CamelCase,
}
- { key: readability-identifier-naming.NamespaceCase, value: CamelCase }
- { key: readability-identifier-naming.StructCase, value: CamelCase }
- {
key: readability-identifier-naming.TemplateParameterCase,
value: CamelCase,
}
- { key: readability-identifier-naming.TypeAliasCase, value: CamelCase }
- { key: readability-identifier-naming.TypedefCase, value: CamelCase }
- { key: readability-identifier-naming.UnionCase, value: CamelCase }
- { key: readability-identifier-naming.VariableCase, value: lower_case }
- { key: readability-identifier-naming.ParameterCase, value: lower_case }
- { key: readability-identifier-naming.ClassMemberCase, value: lower_case }
- {
key: readability-identifier-naming.MethodIgnoredRegexp,
value: '^classof$',
}
- {
# This erroneously fires in C++20 mode with LLVM 16 clang-tidy, due to:
# https://github.com/llvm/llvm-project/issues/46097
key: readability-identifier-naming.TemplateParameterIgnoredRegexp,
value: '^expr-type$',
}
# Don't warn on structs; done by ignoring when there are only public members.
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: true

# CamelCase names.
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.ClassConstantCase
value: CamelCase
- key: readability-identifier-naming.ConstexprVariableCase
value: CamelCase
- key: readability-identifier-naming.NamespaceCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.TemplateParameterCase
value: CamelCase
- key: readability-identifier-naming.TypeAliasCase
value: CamelCase
- key: readability-identifier-naming.TypedefCase
value: CamelCase
- key: readability-identifier-naming.UnionCase
value: CamelCase

# lower_case names.
- key: readability-identifier-naming.ClassMemberCase
value: lower_case
- key: readability-identifier-naming.ParameterCase
value: lower_case
- key: readability-identifier-naming.VariableCase
value: lower_case

# TODO: This is for explorer's use of LLVM casting support, so we should be
# able to remove it once explorer is deleted.
- key: readability-identifier-naming.MethodIgnoredRegexp
value: '^classof$'

# This erroneously fires in C++20 mode with LLVM 16 clang-tidy, due to:
# https://github.com/llvm/llvm-project/issues/46097
- key: readability-identifier-naming.TemplateParameterIgnoredRegexp
value: '^expr-type$'
16 changes: 15 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,22 @@
{
"name": "carbon-lang",
"build": {
"dockerfile": "../docker/ubuntu2204/base/Dockerfile"
"dockerfile": "../docker/ubuntu2404/base/Dockerfile"
},
"mounts": [
{
"source": "carbon-cache",
"target": "/home/ubuntu/.cache",
"type": "volume"
}
],
"containerUser": "ubuntu",
"remoteUser": "ubuntu",
// When using devcontainer with podman, you may see /workspace being owned
// by root. To work around this, uncomment the following lines
// "runArgs": [
// "--userns=keep-id"
// ],
"customizations": {
"vscode": {
"extensions": [
Expand Down
3 changes: 2 additions & 1 deletion .gdbinit
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

source third_party/llvm-project/libcxx/utils/gdb/libcxx/printers.py
source external/_main~llvm_project~llvm-project/llvm/utils/gdb-scripts/prettyprinters.py
source external/_main~llvm_project~llvm-project/libcxx/utils/gdb/libcxx/printers.py
python register_libcxx_printer_loader()
9 changes: 8 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ repos:
name: prettier
language: node
additional_dependencies: ['[email protected]']
types_or: [html, javascript, markdown, yaml]
types_or: [html, javascript, json, markdown, yaml]
entry: npx prettier --write --log-level=warn
- repo: local
hooks:
Expand Down Expand Up @@ -189,6 +189,11 @@ repos:
- '// '
- ''
- --custom_format
- '\.(js|ts|mjs)$'
- '/*'
- ' * '
- ' */'
- --custom_format
- '\.(l|lpp|y)$'
- '/*'
- ''
Expand Down Expand Up @@ -221,9 +226,11 @@ repos:
compile_flags.txt|
github_tools/requirements.txt|
third_party/.*|
utils/vscode/esbuild.js|
website/.ruby-version|
website/Gemfile.lock|
.*\.def|
.*\.png|
.*\.svg|
.*/fuzzer_corpus/.*|
.*/testdata/.*\.golden
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"recommendations": [
"bazelbuild.vscode-bazel",
"bierner.github-markdown-preview",
"carbon-lang.carbon-vscode",
"esbenp.prettier-vscode",
"llvm-vs-code-extensions.vscode-clangd",
"ms-python.black-formatter",
Expand Down
1 change: 0 additions & 1 deletion .vscode/extensions/carbon-lang

This file was deleted.

22 changes: 22 additions & 0 deletions .vscode/gdb_launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "by-gdb",
"request": "launch",
"name": "file_test (gdb)",
"program": "bazel-bin/toolchain/testing/file_test",
"programArgs": "--file_tests=${relativeFile}",
"cwd": "${workspaceFolder}",
"env": { "TEST_TMPDIR": "/tmp" }
},
{
"type": "by-gdb",
"request": "launch",
"name": "carbon compile (gdb)",
"program": "bazel-bin/toolchain/carbon",
"programArgs": "compile --phase=lower --dump-sem-ir --stream-errors ${relativeFile}",
"cwd": "${workspaceFolder}"
}
]
}
36 changes: 36 additions & 0 deletions .vscode/lldb_launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb-dap",
"request": "launch",
"name": "file_test (lldb)",
"program": "bazel-bin/toolchain/testing/file_test",
"args": ["--file_tests=${relativeFile}"],
"debuggerRoot": "${workspaceFolder}",
"initCommands": [
"command script import external/_main~llvm_project~llvm-project/llvm/utils/lldbDataFormatters.py",
"settings set target.source-map \".\" \"${workspaceFolder}\""
],
"env": { "TEST_TMPDIR": "/tmp" }
},
{
"type": "lldb-dap",
"request": "launch",
"name": "carbon compile (lldb)",
"program": "bazel-bin/toolchain/carbon",
"args": [
"compile",
"--phase=lower",
"--dump-sem-ir",
"--stream-errors",
"${relativeFile}"
],
"debuggerRoot": "${workspaceFolder}",
"initCommands": [
"command script import external/_main~llvm_project~llvm-project/llvm/utils/lldbDataFormatters.py",
"settings set target.source-map \".\" \"${workspaceFolder}\""
]
}
]
}
Loading

0 comments on commit 9f1ca80

Please sign in to comment.