Commit Graph
33 Commits
Author SHA1 Message Date
David Blaikie a17480133f Remove excess use of auto on initializers (auto x = Y(z) -> Y x(z)) (#4239) 2024-08-22 20:29:35 +00:00
Jon Ross-Perkins a3b1c433be Remove legacy repo_name settings (#3772)
I'd kept these in to separate the bazel module update from the BUILD
file changes, then forgot about it. I think all of these can be cleanly
removed now. I think it's something we should clean up for consistency
with the bazel central repository names; I think it's best to reduce
that divergence.

llvm_zlib and llvm_zstd remain because of how llvm depends on the
particular names.
2024-03-13 22:58:56 +00:00
Jonathan B. CoeandChandler Carruth 8c28a0494e Add size="small" to test targets where advised (#3326)
Running `bazel test //...` reported:

```
Test execution time outside of range for MODERATE tests.
Consider setting timeout="short" or size="small".
```

This change adds size="small" to avoid such warnings being reported.

---------

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2023-10-24 06:52:00 +00:00
Jon Ross-Perkins c66283b7c8 Update LLVM and fix related breaks (#3237)
Updates to a recent LLVM commit.

The patch file changes because there's now an upstream BUILD.bazel for
compiler-rt in the overlay, although it still doesn't expose the
libfuzzer target, so we need to keep patching it.

Clang's FileManager API changed slightly so we update migrate_cpp for
that.
2023-09-15 00:03:05 +00:00
Jon Ross-Perkins 605763d62d Add lint fixes to the buildifier setup. (#3109)
The main motivation for this is to get python loads in using the
`native-py` lint fix. However, enabling that made me wonder, maybe we
should fix in general?

`native-cc` is delayed, but not wholly cancelled (and `native-py`
picking up might indicate `native-cc` won't be too far behind). There's
also some automated fixes for `.append` and dict sorting -- this felt
okay to me, maybe not something to eagerly add but probably not worth
stopping buildifier from fixing (I've noticed the warnings in the past
and had been ignoring them).

Running everything does mean that load orders are sorted automatically
now, which I think is a positive. Most generally, I think these fixes
aren't _harmful_, and having them done automatically seems beneficial:
my biggest concern about `native-py` and `native-cc` was actually that
regressions wouldn't be caught, but this addresses that issue
automatically.
2023-08-22 21:01:42 +00:00
Jon Ross-Perkins fa857e42be Rename //testing/util to base (#3104)
Renaming per #3100
2023-08-15 21:28:56 +00:00
Jon Ross-Perkins 8e940d9724 Migrate //common test libraries to //testing/util. (#2890)
This is just a cleanup. Since we now have a testing directory, I think this is a better home for testonly libraries than //common. (I was thinking about this when I was considering adding more test_raw_ostream deps)
2023-06-13 16:38:08 -07:00
Richard Smith 4daaa4866f Rename Type -> type, per #2360. (#2507)
Also make minor updates to the skeletal design in
docs/design/name_lookup.md following #2113, as there are no longer any prelude names that are made available to unqualified name lookup by default.

Add `type` to the keyword list in
docs/design/lexical_conventions/words.md, following #2360.
2023-01-04 14:22:30 -08:00
Jon Ross-Perkins f6248a4b6f Manual clang-tidy fixes (#2319)
Note, not trying to address every last error, just some obvious/easy ones.

```
/usr/local/google/home/jperkins/dev/carbon-lang/common/string_helpers.cpp:200:13: warning: prefer transparent functors 'less_equal<>' [modernize-use-transparent-functors]
  auto le = std::less_equal<const char*>();
            ^
/usr/local/google/home/jperkins/dev/carbon-lang/toolchain/semantics/nodes/function.h:22:45: warning: pass by value and use std::move [modernize-pass-by-value]
  Function(ParseTree::Node node, NodeId id, llvm::SmallVector<NodeRef> body)
                                            ^
/usr/local/google/home/jperkins/dev/carbon-lang/explorer/ast/declaration.cpp:230:14: warning: static member accessed through instance [readability-static-accessed-through-instance]
      return cast<SelfDeclaration>(declaration).name();
             ^
/usr/local/google/home/jperkins/dev/carbon-lang/explorer/interpreter/type_checker.cpp:1104:33: warning: std::move of the variable 'impl' of the trivially-copyable type 'ConstraintType::ImplConstraint' has no effect [performance-move-const-arg]
    impl_constraints_.push_back(std::move(impl));
                                ^
/usr/local/google/home/jperkins/dev/carbon-lang/explorer/interpreter/type_checker.cpp:1145:36: warning: std::move of the variable 'rewrite' of the trivially-copyable type 'ConstraintType::RewriteConstraint' has no effect [performance-move-const-arg]
    rewrite_constraints_.push_back(std::move(rewrite));
                                   ^
/usr/local/google/home/jperkins/dev/carbon-lang/explorer/interpreter/type_checker.cpp:1156:32: warning: std::move of the variable 'context' of the trivially-copyable type 'ConstraintType::LookupContext' has no effect [performance-move-const-arg]
    lookup_contexts_.push_back(std::move(context));
                               ^
/usr/local/google/home/jperkins/dev/carbon-lang/explorer/fuzzing/fuzzverter.cpp:74:42: warning: argument name 'trace' in comment does not match parameter name 'parser_debug' [bugprone-argument-comment]
                                         /*trace=*/false);
                                         ^
./explorer/syntax/parse.h:19:17: note: 'parser_debug' declared here
           bool parser_debug) -> ErrorOr<Carbon::AST>;
                ^
/usr/local/google/home/jperkins/dev/carbon-lang/explorer/fuzzing/proto_to_carbon_test.cpp:34:55: warning: argument name 'trace' in comment does not match parameter name 'parser_debug' [bugprone-argument-comment]
    const ErrorOr<AST> ast = Carbon::Parse(&arena, f, /*trace=*/false);
                                                      ^
./explorer/syntax/parse.h:19:17: note: 'parser_debug' declared here
           bool parser_debug) -> ErrorOr<Carbon::AST>;
                ^
/usr/local/google/home/jperkins/dev/carbon-lang/explorer/fuzzing/proto_to_carbon_test.cpp:42:41: warning: argument name 'trace' in comment does not match parameter name 'parser_debug' [bugprone-argument-comment]
          &arena, f, source_from_proto, /*trace=*/false);
                                        ^
./explorer/syntax/parse.h:25:59: note: 'parser_debug' declared here
                     std::string_view file_contents, bool parser_debug)
                                                          ^
/usr/local/google/home/jperkins/dev/carbon-lang/explorer/syntax/parse_test.cpp:27:60: warning: argument name 'trace' in comment does not match parameter name 'parser_debug' [bugprone-argument-comment]
      ParseFromString(&arena, "file.carbon", FileContents, /*trace=*/false);
                                                           ^
./explorer/syntax/parse.h:25:59: note: 'parser_debug' declared here
                     std::string_view file_contents, bool parser_debug)
                                                          ^
/usr/local/google/home/jperkins/dev/carbon-lang/migrate_cpp/cpp_refactoring/var_decl.cpp:57:58: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
      segments.push_back({type_loc_class, qual_str + " " + range_str});
                                                         ^
/usr/local/google/home/jperkins/dev/carbon-lang/explorer/fuzzing/ast_to_proto_test.cpp:105:55: warning: argument name 'trace' in comment does not match parameter name 'parser_debug' [bugprone-argument-comment]
    const ErrorOr<AST> ast = Carbon::Parse(&arena, f, /*trace=*/false);
                                                      ^
./explorer/syntax/parse.h:19:17: note: 'parser_debug' declared here
           bool parser_debug) -> ErrorOr<Carbon::AST>;
                ^
```
2022-10-20 09:02:14 -07:00
Josh Soref 066b103881 Spelling (#1580)
This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling).

The misspellings have been reported at https://github.com/jsoref/carbon-lang/commit/38a1c1640151899fd6da0442a92557f9543b6280#commitcomment-79197316

The action reports that the changes in this PR would make it happy: https://github.com/jsoref/carbon-lang/commit/173c8f9083a68aa61f7cfe94f720f1e5dc7f1ea3

Note: this PR does not include the action. If you're interested in running a spell check on every PR and push, that can be offered separately.

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-07-22 16:14:21 -07:00
Jon Meow 20728dbd3a CARBON_ header guards (#1261)
This modifies scripts/check_header_guards.py to add the CARBON_ prefix; everything else is pre-commit.
2022-05-12 17:25:43 -07:00
pk19604014 9ec2a0bb98 Added googletest deps removed in #1215 as the deps are still required in strict headers mode for the googletest.h include (#1218) 2022-04-27 13:25:57 -04:00
Jon MeowandChandler Carruth d3700d5cd0 Changes tests to init LLVM stack tracing (#1215)
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2022-04-26 16:19:51 -07:00
Jon Meow eda43faa5a Note namespace and static recommendations in C++ style guide (#1041) 2022-01-27 11:26:47 -08:00
Jon MeowandGeoff Romer 1b4c81fa69 Add script for generating missing C++ deps (#1012)
Co-authored-by: Geoff Romer <gromer@google.com>
2022-01-07 14:44:40 -08:00
Chandler Carruth 5f67029479 Use upstream GoogleTest and add related test utils. (#876)
This moves over to the vanilla upstream GoogleTest pulled in the more
expected manner with Bazel. It also adds Abseil and Google Benchmark
libraries in the same fashion (there are cross dependencies here).

As part of this, also introduce a dependency check test that can enforce
basic layering of dependencies. For example, this lets us ensure that
non-test Carbon code only depends on LLVM and Clang despite having other
libraries available. There remains some cleanup to improve the way these
dependency tests work, but this at least ensures we don't regress.

I've also provided workarounds to allow both Carbon code and LLVM code
to freely be used with GoogleTest (and other `std::ostream` based
output code). This is done by extending the code in
`//common/ostream.h`. One downside is that it requires opening the
`llvm` namespace and adding an ADL_found overload there. I think on
balance this is still a win and doesn't make me too nervous.

The new version of GoogleTest requires printing more often from matchers
and so I've also added several printing routines to types that
previously didn't require them. Otherwise, most of the updates are just
using the more conventional upstream style of including the headers and
adding `ostream.h` where it is needed.

I did consider moving code over to use `std::ostream` instead of LLVM's
`raw_ostream`, but the advantages of not doing virtual dispatch still
seem significant, and it also seems good to retain access to LLVM's
formatting utilities built around `raw_ostream` given that we can't pull
arbitrary dependencies into Carbon code outside of test code.

All of this was slightly motivated by requests for newer features in
GoogleTest, but much more-so by my desire to have access to Google
Benchmark and Abseil when writing benchmarks. For example, using
Abseil's random number generator seems extremely helpful when generating
inputs for benchmarks. The growing dependencies between these packages
further motivated me to just pull them all in and ensure they worked
well.
2021-11-02 20:14:12 -07:00
Chandler Carruth ec7a670d84 Update the LLVM submodule. (#935)
Among other things, this brings compatibility fixes with upstream
GoogleTest and Windows Bazel build support fixes.
2021-11-02 18:14:58 -07:00
Jon Meow d7b2c9b580 Remove uses of rules_cc (#776)
Per https://github.com/bazelbuild/rules_cc this still isn't necessary. There's no build-time enforcement, so usage is inconsistent/incorrect. Rather than letting this linger, remove it pending Bazel tooling enforcing it.
2021-08-24 08:55:17 -07:00
Jon Meow 6fa42a7f3c For-range in replacement logic (#631)
This replaces GetAstMatcher with AddMatcher because cxxForRangeStmt is a StatementMatcher. addMatcher has multiple definitions (https://clang.llvm.org/doxygen/classclang_1_1ast__matchers_1_1MatchFinder.html) and so this approach allows using the right addMatcher without writing per-call overloads.

To handle the `var`, I'm considering something like moving VarDecl logic into a VarMatcherBase so that I can just use CXXForRangeStmt's getLoopVariable. The problem is a for-range statement has multiple VarDecls, and getLoopVariable may be the easiest way to identify the real one.
2021-07-12 16:20:44 -07:00
Jon Meow 3082d05f80 Handle var initialization. (#628) 2021-07-09 11:29:38 -07:00
Jon Meow 4f1b2198ff Refactor Matcher code to reduce per-Matcher boilerplate (#615)
This is in part to eliminate the "sm" and "lang_opts" variables that received comment, but also cuts back on the use of auto.
2021-07-08 12:42:24 -07:00
Jon MeowandGeoff Romer e7a1093eb9 Fix fn placement around keywords (#613)
Co-authored-by: Geoff Romer <gromer@google.com>
2021-07-01 09:43:14 -07:00
Jon MeowandChandler Carruth 1071ec52b7 Head further towards reconstructing the type as written. (#612)
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-06-30 14:42:37 -07:00
Jon Meow 8e31e46c66 Don't use VarDecl replacements on range for loops. (#604) 2021-06-29 09:41:15 -07:00
Chandler CarruthandJon Meow 1057eda8f7 Fix formatting by removing a comment. (#608)
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
2021-06-28 16:39:28 -07:00
Jon MeowandChandler Carruth 2d95993bd5 Improve handling for let and auto (#599)
Range-based for loops remain messed up -- I'm just disabling the test here and turning a blind eye.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-06-28 10:03:17 -07:00
Jon Meow 9bdabda851 Insert fn for void functions (#596) 2021-06-24 10:16:21 -07:00
Jon Meow 2344a52e24 Start handling variable declarations (#571)
TODOs in the test for known issues.

I may switch the approach to getting the variable type (on examination, this isn't working quite as well as I'd thought) but for now I think it's okay. I had an earlier approach though that may work better overall -- I'd been thinking this would work better, but as you can see in the null check for type information, I think I missed a key point.

Anyways, what'd really been vexing me was `int i, j` which I think I handle passably well now. There's obviously room for improvement, but given I've been going at this for a couple days now, I thought it best to checkpoint where I was.

This also includes some related framework changes to fix bumps I was running into. Overall the tool should operate a bit more smoothly with these changes. There are still issues with overlapping replacements, but I think it's primarily with range-based for loops which I just need to take some time to fix.
2021-06-23 10:58:32 -07:00
Jon Meow f180c64454 Change how replacements are filtered (#541)
This replaces the use of `isExpansionInMainFile` with instead taking the list of input files, and only touching them. This doesn't keep `isExpansionInMainFile` because it should be redundant, and as such it'd be easy to forget. Unless it starts being a performance issue, it's probably better to omit.
2021-06-03 16:35:55 -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
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 Meow 82f5c4224b Small fixes from #530 (#537) 2021-05-14 13:23:10 -07:00
Jon Meow 6f544494b3 Use AST to start inserting fn (#530) 2021-05-13 14:58:32 -07:00