Commit Graph
1280 Commits
Author SHA1 Message Date
8d5d48a4a7 [toolchain][parser] Parse for statement. (#2180)
Summary:

Add support for parsing `for` loops.

Co-authored-by: ergawy <kareem.ergawy@guardsquare.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-10-03 08:36:19 -07:00
Jon Ross-Perkins 11a138b467 Fix things up to make running clang-tidy easier. (#2246)
run_clang_tidy.py (the clang-tools-extras version) is parallel so should be feasible to work with. I'm trying to codify this mainly because finding out the right invocation can be difficult.

This fixes some loading of re2 and proto that's started to become an issue.

It's hard to see actual issues because of the identifier length warning being turned off in #2244, and just general issue creep. There may be more fixes to do but this should still be an improvement.
2022-09-30 18:15:16 -07:00
Jon Ross-Perkins ba226454d0 Disable readability-identifier-length in clang-tidy (#2244)
https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-length.html

This complains about `id` which I'm using a lot and feels like a reasonable name, and honestly single-letter variable names seem reasonable in certain contexts. Trying to make this work better doesn't seem like it'll be worth the time cost.
2022-09-30 17:01:48 -07:00
Geoff Romer 96735e89b8 Clarify that l-values and r-values are expressions (#2243) 2022-09-30 13:34:11 -07:00
Jon Ross-PerkinsandRichard Smith 1e1fa9295d Rewrite contribution tools documentation (#2203)
Key rewrite points:

- Making more use of apt now, since we no longer need `brew` for llvm on Linux.
  - Gets ahead of issues with brew's llvm 15 on Linux.
- Clear list of commands for a typical setup.
- Less verbose text about various tool options (I think this was just too much).

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-09-30 13:21:27 -07:00
Geoff Romer f7fd5656f0 Remove support for curly-braced "receiver" syntax (#2220) 2022-09-30 12:36:35 -07:00
Jon Ross-Perkins 9b03367449 Remove duplicate template (#2239) 2022-09-30 10:33:11 -07:00
Jon Ross-Perkins b0060e5cfb Rename issue template yaml to yml (#2233)
The config.yaml doesn't seem to be getting seen. Judging by https://github.com/carbon-language/carbon-lang/tree/trunk/.github/ISSUE_TEMPLATE ("Customize the issue creation experience with a config.yml file.") I think yaml is allowed for a lot of things (including the templates) but not config.yml.

I'm renaming other files for consistency.
2022-09-30 10:14:04 -07:00
Jon Ross-Perkins b94c496aee Fix incomplete TODO in driver (#2231)
From #2222
2022-09-30 08:10:10 -07:00
Jon Ross-Perkins df829f9ad4 Add a doc issue template (#2234) 2022-09-29 14:58:10 -07:00
Jon Ross-Perkins 768764787f Fix x/_ and y/z in faq example. (#2230) 2022-09-29 10:52:05 -07:00
Jon Ross-Perkins af92a1d2ab Add some issue templates (#2225)
ref: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository

example of how this is supposed to look: https://github.com/flutter/flutter/issues/new/choose
2022-09-29 10:25:34 -07:00
Jon Ross-Perkins 80570e1a5b Modify the driver to support using for semantics IR testing (#2222)
This unifies `dump-tokens` and `dump-parse-tree` so that we don't keep writing basically the same code repeatedly.

I'll need to modify the output of SemanticsIR::Print more, and may soon unify printing multiple IRs this way (particularly including the builtins SemanticsIR) but this is intended to offer a starting point.

I may eventually try to unify lit.cfg.py files, but I was thinking about whether that works in various contexts we may run in and eventually decided copying the driver/testdata/lit.cfg.py file would be the easiest solution.
2022-09-28 17:40:57 -07:00
Jon Ross-Perkins 59b0ac1616 Remove copyright from PR template (#2227)
The template gets inserted into the PR description verbatim, copyright included, which wasn't my intent.
2022-09-28 16:25:03 -07:00
Jon Ross-Perkins 094408935c Add a skeletal PR template (#2226)
e.g. https://github.com/flutter/flutter/blob/master/.github/PULL_REQUEST_TEMPLATE.md

But I feel weird adding a checklist
2022-09-28 16:06:30 -07:00
Geoff Romer 9b1a32b7b7 Miscellaneous code of conduct clarifications (#2219) 2022-09-27 12:01:06 -07:00
josh11bandBarry Revzin 29d8f9845e Clarifications to "checked and template parameters" (#2216)
This attempts to address concerns that @brevzin first tried to fix in #1443 .

Co-authored-by: Barry Revzin <barry.revzin@gmail.com>
2022-09-26 16:57:03 -07:00
pmqtt cfa295c0af Feature destructor (#2116) 2022-09-26 10:11:05 -07:00
micttyl c63ae9b05d Prefix Fail to Failing Test (#2212) 2022-09-24 11:40:08 -07:00
Jon Ross-Perkins f417be79d2 Run apt-get update and install together (#2192)
This is a recommended best practice: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#apt-get
2022-09-22 15:16:17 -07:00
Jon Ross-Perkins 1248831001 Emphasize Discord for design (#2206) 2022-09-22 12:38:26 -07:00
Jon Ross-Perkins 6293610cb0 Replace dashes with underscores in llvm-patches (#2211)
Dashes in bazel package names in particular can cause problems (which renaming `llvm-patches` to `llvm_patches` will fix for me). But we've generally named files with underscores, so there's also consistency.
2022-09-22 12:37:24 -07:00
Jon Ross-Perkins c87a914bbd pre-commit update (#2210)
pre-commit autoupdate --freeze && pre-commit run -a

(no other edits, just the one version update)
2022-09-22 11:00:29 -07:00
micttyl dc4e968373 Fix Markdown (#2208)
`explicit parameter` to have its closing rendered correctly.

Change all html-like(still supported though) notations into the Markdown style.
2022-09-22 09:01:36 -07:00
josh11b e941b90ac9 Correctly remove ## TODO section from proposals (#2207)
Fix bug introduced in #2139
2022-09-22 08:20:07 -07:00
Jon Ross-Perkins 1dcd15380c Remove stacked PR notes (#2205)
chandlerc had originally added these and previously expressed being okay with removing them. They've just proven too complex to be applied; it needs to be easier for people to want to do it.
2022-09-21 16:10:36 -07:00
micttyl 804a09bccd Do not lead people to github discussion (#2204) 2022-09-21 16:06:03 -07:00
Richard Smith ff1d69232b Switch proposal link text from pNNNN to #NN for consistency (#2202)
This is the only occurrence of using pNNNN in text to refer to a Carbon proposal in the repo. This gets us closer to following https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/design_style_guide.md.
2022-09-21 10:37:07 -07:00
micttyl 2df87ddacc Include Missing Libraries (#2201)
Minor Style: non-auto to auto
2022-09-21 09:09:13 -07:00
b464a0ac3d Unused Pattern Bindings (Unused Function Parameters) (#2022)
This proposal specifies how unused pattern bindings are written in the Carbon programming language. This is a more general problem statement of "how do users specify unused function parameters" as function parameter declarations are a more specific form of pattern

Related issue #1996

Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-09-20 17:44:22 -07:00
Jon Ross-Perkins 9be6939ee9 Fix LLVM compilation issues (#2198)
We've been having issues with asan builds on linux. This change should fix all of that. A build run can be found at:
https://github.com/carbon-language/carbon-lang/actions/runs/3093378863/jobs/5005683059

(currently in progress, but I'm expecting it to succeed at this point)

It may be that the issues with asan builds were actually related to caching. That is, maybe the brew build command didn't change enough between v14 and v15 that the cache hits were still an issue. We did notice this with 15.0.0 versus 15.0.1 include paths (that is, bazel wasn't happy using the cached results of a 15.0.0 build due to the skew in include paths). In order to address this, I've added CACHE_VERSION to the remote_cache setup. I've also set up corresponding buckets in Cloud.

However, I'm also switching Linux to llvm-15 and apt. I'd originally been looking at this because the issues were linux-specific, and we've previously had linux-specific issues with Homebrew. Although it may have been the cache all along, I would prefer to keep this setup (if nothing else, it made the caching issues more obvious, even though we were still confused by the include path manifestation).
2022-09-20 14:21:02 -07:00
Jon Ross-Perkins 174aff1f2d Remove legacy mention of bazel-clang-toolchain symlink (#2190) 2022-09-19 21:34:47 -07:00
Jon Ross-Perkins 7e4e73b6c0 Specify llvm@14 (#2195)
This should be temporary while trying to diagnose why llvm@15 fails.
2022-09-19 16:20:54 -07:00
Junhee Cho 69d4363ea5 Adds division to multiplicative expression. (#2091)
* Multiplication and division have the same priority.
* A new builtin interface DivWith is added.
* In some tests expecting a compilation error (syntax error), the error
  message now says it is expecting SLASH or binary *.
2022-09-19 15:02:29 -07:00
micttyl 57cc4c6dec Include Missing Libraries (#2193)
For better:
	`<iterator>` for `std::reverse_iterator`
	`Optional.h` for `llvm::Optional`
2022-09-19 11:22:01 -07:00
Jon Ross-Perkins c8faa47f83 Add llvm to PATH instead of CC (#2189)
This helps VS Code find clangd (instead of needing to pass in clangd-15 somehow), and seems like it'll work in general.
2022-09-16 08:29:37 -07:00
Jon Ross-Perkins b80e294b6c Make structs to distinguish ID versus NodeStore index (#2171)
WDYT of this, to avoid raw int32_t indices? I was looking at the code again and found it hard to sort out. I think this doesn't have overhead.
2022-09-15 14:36:50 -07:00
Jon Ross-PerkinsandRichard Smith 005ab78766 Remove indirection for builtin operator tests (#2109)
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-09-15 14:36:20 -07:00
Jon Ross-Perkins 360f905755 Remove update_label_access, which is obsolete (#2184)
The PyGithub import is causing problems for me in test execution, but TBH I don't think we need it anymore. I should probably update groups.md though.
2022-09-15 13:57:50 -07:00
Jon Ross-Perkins aba77b12b9 Modify clang configuration to make llvm-15 work better. (#2186)
The debug flag change is discussed at https://github.com/llvm/llvm-project/issues/57637

This modifies the devcontainer Dockerfile to switch to an ubuntu and apt-based llvm-15. That was used in testing of these changes. The move away from brew is partly necessary if we want llvm-15, but also installs much faster (roughly 90s setup).

This was based in part on #1618
2022-09-15 13:23:59 -07:00
Jon Ross-Perkins c25a2b23d2 Switch gtest to re2, adjust related tests (#2183)
See https://github.com/google/googletest/blob/main/docs/advanced.md#regular-expression-syntax for gtest regex notes.

Add framework suffix handling for includes because of a dep being triggered on macos.
2022-09-15 08:19:52 -07:00
Richard Smith bfcab23795 Implement == and != for bool. (#2182) 2022-09-14 21:55:39 -07:00
Jon Ross-Perkins 81cdbfe650 Move -pie to linux_flags, add -fpie for macos (#2175)
I think this partly addresses #1404
2022-09-14 14:04:34 -07:00
Jon Ross-Perkins 6ce534a1e3 Add support for silencing nano zone warnings that arise from asan+macOS (#2177)
Note this will need to be set per-cc_binary, but I don't think there's a good way to avoid that.

I didn't try hijacking the `cc_binary` rule name because that felt a bit excessive. We probably will have a few binaries we want to run directly, but I don't think it needs to be addressed on every last one.

This is part of addressing #1404
2022-09-14 10:30:06 -07:00
josh11b e873678c8f Link to Rust stabilizing Generic Associated Types (GATs) (#2178) 2022-09-13 16:39:19 -07:00
Jon Ross-Perkins a62e2dc21c Update things for clang-15 support. (#2174)
libprotobuf_mutator and abseil have warnings that are already fixed in newer versions.

bison outputs code that hits new warnings; there I'm just silencing it because testing a newer bison version is more difficult.

Fixes #1650

Fixes #1660
2022-09-13 15:18:55 -07:00
Richard Smith deee3a97de Implement #2140 in the design docs. (#2176)
This implements #2140 in the design docs.
2022-09-13 14:54:43 -07:00
Richard SmithandJon Ross-Perkins 0191e2e41e implement checking for pattern match exhaustiveness and for unreachable cases (#2164)
When checking for control flow falling off a function after a `match`, determine whether it's possible for no case to have matched. Using the same implementation, also detect whether `case`s in a `match` are unreachable.

For now, the implementation never considers a match against specific values for any type other than tuples, alternatives, and `bool` to be exhaustive. In particular, matching against the sole value `{}` of type `{}` is not considered exhaustive. This is probably best left until explorer supports matching on struct and maybe class types more generally.

This implementation closely follows the algorithm described in the paper [Warnings for pattern matching](http://moscova.inria.fr/~maranget/papers/warn/warn.pdf) by Luc Maranget. Various optimizations are possible, such as reducing the amount of copying done, but for the purposes of explorer, comprehensibility is being favored over efficiency.

The problem is, perhaps surprisingly, co-NP-hard (by reduction to the tautology problem for disjunctive normal form, which is in turn dual to the satisfaction problem for conjunctive normal form, which is well-known to be NP-hard). The algorithm is therefore exponential-time in the worst case, but seems to be well-studied and performs well enough on non-pathological examples. Nonetheless, a depth limit has been imposed to prevent pathological examples such as those generated by a fuzzer from causing long runtimes.

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
2022-09-13 13:40:25 -07:00
micttyl b5e55556be Include the Library of the added function in carbon-language#1341 (#2172)
`cstdlib` is added for `abort()` in carbon-language#1341

`unistd.h` was not removed with `exit()` in carbon-language#1175
2022-09-13 11:47:17 -07:00
Jon Ross-Perkins 2db09a1fd5 Rename dashes in a few test files to underscores (#2170)
This is somewhat https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/cpp_style_guide.md#file-names, but in general, underscores are more consistent.
2022-09-13 09:39:47 -07:00