Commit Graph
362 Commits
Author SHA1 Message Date
josh11b c836ae78bb for uses in instead of :, and implement #542. (#563)
* `for` uses `in` instead of `:`, and implement #542.
2021-06-03 07:56:48 -07:00
josh11b 60fdda7aaf Update generics terminology to latest syntax (#560)
* Update generics terminology to latest syntax.
2021-06-03 07:54:44 -07:00
josh11b cf3c90ac3e Switch to name: type variable and parameter syntax in README.md. (#562) 2021-06-02 20:11:32 -07:00
Richard Smith 4911ede826 Proposal: return; should be valid only in functions with no declared return type. 2021-06-02 11:38:29 -07:00
Richard Smith 567b9bb5a4 Reverse 'type: identifier' to 'identifier: type' in executable
semantics.
2021-06-02 11:33:50 -07:00
Richard Smith da403db9ff Revert "Remove : from vars in exec semantics (#504)"
This reverts commit 05663633d3.
2021-06-02 11:33:50 -07:00
Geoff Romer c903eb3133 Remove Void (#540)
Implements resolution of #443.
2021-06-01 12:48:04 -07:00
Jon Meow e619d3d632 Shift migrate script to a workflow class, and file renames to .carbon (#535)
This might need some customization, e.g. `woff2_decompress.impl.carbon` (as a file with a `main`) might be better as `woff2_decompress.carbon`, but I thought at least putting on `.carbon` extensions would help perspectives on files.

This restructures the script to make it easier to access standard info (e.g. cpp_files) without passing everywhere.
2021-06-01 10:15:03 -07:00
Jon Meow 93e7a37493 Start updating control flow design (#544) 2021-06-01 10:14:18 -07:00
Chandler Carruth 4034fa223d Update LLVM (and llvm-bazel). (#550)
This picks up a newer version of LLVM and the LLVM Bazel integration.
The big change here is that we can configure the LLVM targets that are
built, which allows us to dramatically reduce the build costs by
focusing on a couple of CPUs for the time being.

There are a few API updates needed as well.

This also rotates the cache version so we start with a clean Bazel cache
from here. Otherwise we'd potentially pay the cost of carrying around
stale bits of LLVM endlessly.
2021-05-25 15:21:57 -07:00
Chandler Carruth 5fe800202b Tweak UBSan options to reduce object file size. (#547)
The recovery is mostly useful when triaging multiple failures, it seems
easy for us to skip. Giving up the nice diagnostics doesn't lose much
for some types of error where there isn't any real information to
convey, so seems worth doing that for a few cases.

Removing the nice diagnostics from the rest of UBSan saves another
20%-ish of output size on LLVM, but seems like it would be giving up
usability. I think there are other approaches we can use instead so this
PR just focuses on the easy wins.
2021-05-23 18:39:31 -07:00
Chandler Carruth 80883db252 Add caching to our tests to avoid clean rebuilds. (#534)
This is both a bit tricky and really easy with Bazel. The easy part,
especially compared to other build systems is that we can do this
regardless of the state of the repository -- Bazel will hermetically
check that everything is up-to-date, allowing the cache to be a bit
stale but still totally functional.

The easy part is that we can just ask Bazel to use an output base that
we cache and restore. This is super nice and even avoids most of the
Bazel installation bits.

The tricky part is that we need this to reconnect correctly to the
installed tree, so we need to exclude a crucial symlink that will then
get re-created at the right moment.

This gets really tricky due to LLVM and Clang (and this we would
struggle with no matter what build system we used). Building LLVM
creates a *ton* of object code. Just a huge amount. As a consequence,
we'd run into GitHub's limit for action cache size (5gb) really quickly
with 4 configurations.

So we can do another bit of tricky business and exclude the downloaded
`external` tree. This gets rebuilt easily, and there's no real need to
download it with the cached state -- its downloaded either way.

There are two follow-ups that I'd like to make here. One is to prod the
Bazel team to make things like persisting your output base a bit easier
to do reliably. Even better to make it easier to do *partial*
persisting.

Second follow-up is to work to make our usage of LLVM *much* less
wasteful. There are a bunch of steps here from changing how we use
sanitizers to how LLVM is built. Those will be follow-ups though.
2021-05-23 18:19:38 -07:00
59add8c8de Add statement syntax for function declarations (#438)
Add statement syntax (either `fn` or `func`, see proposal) for function declarations.

- Follows C++-style trailing return syntax.

Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
2021-05-19 14:43:11 -07:00
Jon Meow 29bf305539 Add tests to the cpp_refactoring tool. (#539)
This refactors the main.cpp out into a file structure that should make it easier to add more matchers/tests.
2021-05-17 16:55:50 -07:00
Jon MeowandRichard Smith 231264e0c0 Remove : in variable declarations (#503)
Starting to apply #339

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2021-05-17 15:24:20 -07:00
Jon Meow b1d11bae7e Fix 6c -> carbon ext (#536)
Chandler reminded me of this, the `.carbon` extension is noted here:
https://github.com/carbon-language/carbon-lang/tree/trunk/docs/design/code_and_name_organization#overview
2021-05-17 08:15:07 -07:00
66e5083b4b Add C++-like for loops (#353)
Add C++-like `for` loops

-  Omits `for (;;)` syntax for now.

Co-authored-by: Dmitri Gribenko <gribozavr@gmail.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: austern <austern@google.com>
2021-05-14 15:38:45 -07:00
Jon Meow 82f5c4224b Small fixes from #530 (#537) 2021-05-14 13:23:10 -07:00
Jon MeowandChandler Carruth c72c201133 Copy roadmap from proposal #253 (#533)
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-05-14 09:52:16 -07:00
Jon Meow 6f544494b3 Use AST to start inserting fn (#530) 2021-05-13 14:58:32 -07:00
Jon Meow 2942c97424 Exclude migrate_cpp from GH testing action due to build overhead (#532) 2021-05-13 14:36:56 -07:00
Jon MeowandMatthew Riley 88a9d244b7 Initial migration framework (#525)
What this does:

- Sets up a `migrate_cpp` tool which currently only runs `clang-tidy`.
  - This is intended to have more transformations in the future.
- Sets up a `migrate_cpp.sh` script.
  - This copies the original woff2 code into a `carbon` directory and runs the `migrate_cpp` tool on it there.
- Adds the initial `carbon` directory of woff2
  - To be clear, this is currently only updated via `clang-tidy`.
  - More transformations should be expected in the future.
- Minor related edits. For example:
  - Adjust pre-commit to skip the `carbon` directory, because it's third-party code and shouldn't be edited in the same way.
  - Adds `@brotli_carbon` as a local repository so that we can "build" outputs.
  - Makes clang-tidy from the bootstrap toolchain accessible for BUILD dependencies, as it's then used for `migrate_cpp`.

What this does not do:

- Any actual transformation of C++ code to Carbon

Co-authored-by: Matthew Riley <mdriley@gmail.com>
2021-05-11 10:13:47 -07:00
Jon Meow e6d5efe7d9 Copy woff2 code for migration (#527) 2021-05-11 08:35:14 -07:00
josh11bandRichard Smith fdb1893544 Generics terminology (#447)
To talk about generics as a programming language feature, you need a lot of
specialized terminology. We need to agree on the words we are using and their
meaning before we can meaningfully talk about the design of the feature itself.

There a number of problems a glossary solves:

Not everyone knows every term, so having a single place to look them up will
improve the ease of understanding, ease of contributing, and accessibility
of the project.
There may not be widespread agreement on the meaning of some terms. In
particular, individual programming languages tend to assign very specific
meanings to terms used within their ecosystem.
Some terms may be used in multiple ways, but we only use the term with one
specific meaning.
Some terms are our invention and we need to introduce them.


Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2021-05-10 16:42:01 -07:00
Matthew Riley cd8cc97185 return (#415)
Define syntax for `return` in Carbon.
2021-05-07 14:27:21 -07:00
Jon MeowandGeoff Romer 05663633d3 Remove : from vars in exec semantics (#504)
Going through tests, funptr1.6c is the main spot I see a real change, I added parens to get around an issue parsing fnty.

Co-authored-by: Geoff Romer <gromer@google.com>
2021-05-06 14:21:31 -07:00
Jeremy G. Siek 56b47bcfa9 Type computation tests (#511)
* test of a little type computation

* another test and some bug fixes
2021-05-05 14:46:10 -04:00
Jon Meow 190fab9530 Add missing clang includes to compile_flags.txt (#522)
This is needed to fix issues like:

```
bazel-clang-toolchain/include/c++/v1/cstddef:44:15: fatal error: 'stddef.h' file not found
#include_next <stddef.h>
              ^~~~~~~~~~
```
2021-05-05 10:48:28 -07:00
Jon Meow b88586d3fe Disable ubsan vptr checks due to clang AST (#513) 2021-05-03 12:09:41 -07:00
9d1863efb7 Add var <type> <identifier> [ = <value> ]; syntax for variables (#339)
Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: austern <austern@google.com>
2021-04-28 13:46:26 -07:00
Richard Smith a3614f153b Rename StartSubtree -> GetSubtreeStartPosition.
This function doesn't actually start a subtree, it just remembers a
position from which we could start a subtree.
2021-04-27 13:05:28 -07:00
Richard Smith 857a7e5cc6 Add convenience functions to inspect the kind of the next token. 2021-04-27 13:05:28 -07:00
Jeremy G. Siek 8924f5620b Private unions (#492)
* changed union of Statement to be private

* changed the union in Expression to be private

* changed union in Value to be private

* changed AST constructors to be static methods

* updates to syntax unit tests
2021-04-27 14:29:13 -04:00
Geoff Romer 1933cfeeeb Stop using std::pair in the implementation of tuples (#479) 2021-04-26 11:43:06 -07:00
Jon Meow 3ff01fa60d Remove ready for review action (#501)
I tried what I could, but I don't think this action will work while Carbon is private.

"Error: Resource not accessible by integration"
https://github.com/carbon-language/carbon-lang/runs/2441129284?check_suite_focus=true

I'd seen this mentioned on some actions:
https://github.com/marketplace/actions/github-project-automation#personal-access-token-secretsgithub_token

However, I thought it might've been a side-effect of the APIs they were using (I did have this running on a local repo), but I think fork PRs are where the problem lies...
2021-04-26 11:28:12 -07:00
Jon Meow e82cc5f73f Needs public repo (#500)
Using `jonmeow` was how #496 was originally set up, but I tested with `carbon-language`. I assume we do not want a public repo under `carbon-language`, and so I've already transferred ownership back to `jonmeow` in order to have a public repo again.

https://github.com/carbon-language/carbon-lang/runs/2440951027?check_suite_focus=true
2021-04-26 11:04:02 -07:00
Jon Meow 2b58192ffa Try automating 'ready for review' on proposals. (#496) 2021-04-26 10:46:57 -07:00
a6ddc03aa6 Generics goals (#24)
The "generics" feature of Carbon is a large design effort that needs to be broken up into manageable steps. The first thing we need is a high-level goals document. The goals here reflect the desirable properties that we have discovered as part of considering several alternative generics designs:

-   Use cases:
    -   Generic programming
    -   Upgrade path from C++ abstract interfaces
    -   Dependency injection
     -   Generics instead of open overloading and ADL
-   Performance
-   Better compiler experience
-   Encapsulation
-   Predictability
-   Dispatch control
-   Upgrade path from templates
-   Coherence
-   No novel name lookup
-   Learn from others
-   Interfaces are nominal
-   Interop and evolution
-   Bridge for C++ customization points

Goals are summarized in [this presentation](https://docs.google.com/presentation/d/12yGyu5Pvdag7CJp-_yLVkmbhyvuRIilBTNlkO0LKaHo/edit?usp=sharing&resourcekey=0-JB9yrUO4-6J8-zzGhnIyNg).

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
Co-authored-by: Matthew Riley <mdriley@gmail.com>
Co-authored-by: austern <austern@google.com>
Co-authored-by: Dmitri Gribenko <gribozavr@gmail.com>
2021-04-23 17:19:23 -07:00
Geoff Romer e022ff106f Factor Heap class out of State (#491)
Additional miscellaneous cleanup:

- Use the term "deallocate" instead of "kill" in function names, for symmetry with "allocate".
- Drop an unnecessary memory allocation in `AllocateValue`.
- Implement `PrintHeap` in terms of `PrintAddress`, so that dead values are flagged with `!!`.
2021-04-23 13:25:51 -07:00
Jon MeowandMatthew Riley a13cecccc6 Updates docs for community changes (#489)
- Generally replace Discourse mentions with GitHub Discussions, per #444 
- Switch from "Discord Chat" to just "Discord" because there's no more ambiguity, and "Discord" is the more common term.
- Fix mentions of "core team" to "Carbon leads" (because the touched docs overlap a lot).

Co-authored-by: Matthew Riley <mdriley@gmail.com>
2021-04-23 09:06:52 -07:00
Jeremy G. Siek 5946d9c033 Tuple restrictions (#486)
* implement tuple restrictions: (1) named fields after positional, (2) order matters

* after_named_member => seen_named_member
2021-04-22 17:51:43 -04:00
Jon Meow 8b78a85276 Action to label proposals based on project column (#484)
Note there's a roughly minute delay due to action latency.
2021-04-22 14:43:38 -07:00
Jon Meow f4ce5eafef Delete commenting guidelines, let code_review.md stand alone (#490)
Mainly I don't think this doc has been useful, and I think links that used to be there have drifted more towards code_review.md
2021-04-22 14:42:59 -07:00
Jon MeowandChandler Carruth 5a2db81039 Switch from Discourse Forums to GitHub Discussions (#444)
Switch from Discourse Forums to GitHub Discussions

For use of https://github.com/carbon-language/carbon-lang/discussions

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-04-22 09:56:26 -07:00
Richard Smith e3b732e564 Parsing support for return statements. 2021-04-21 17:53:54 -07:00
Richard Smith 7a74ac18a7 Parsing support for function return types. 2021-04-21 17:53:54 -07:00
Richard Smith 2726865940 Parse parameters in function declarations. 2021-04-21 17:53:54 -07:00
Jeremy G. Siek 928b92a428 a raw access to the heap field slipped through somehow, fixing that (#483) 2021-04-21 19:11:13 -04:00
Jeremy G. SiekandGeoff Romer e89b8daad7 more tests of tuples, mixing positional and explicit field names (#480)
* more tests of tuples, especially mixing positional and explicit field names

* test of match with nested tuple

* Update executable_semantics/testdata/fun_named_params2.6c

Co-authored-by: Geoff Romer <gromer@google.com>

Co-authored-by: Geoff Romer <gromer@google.com>
2021-04-21 17:23:16 -04:00
Jeremy G. SiekandGeoff Romer c1d651fc15 Fix equality for tuples (#446)
* fix tuple equality, added test cases

* added a comment to an old function

* Update executable_semantics/interpreter/value.cpp

Co-authored-by: Geoff Romer <gromer@google.com>

* fix error in Geoffrey's edit

Co-authored-by: Geoff Romer <gromer@google.com>
2021-04-21 17:12:10 -04:00