-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Add code completion for C++20 keywords. #107982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
fedea9e
add co_return, co_await, co_yield, consteval, constinit, concept, req…
16bit-ykiko 36a0db2
make concept and requires more sensitive to context.
16bit-ykiko 9a1a85c
Merge branch 'llvm:main' into complete-cxx20-keywords
16bit-ykiko 326892a
format.
16bit-ykiko c8e555f
format and add test.
16bit-ykiko 0375e52
fix.
16bit-ykiko d9c6413
add newline in eof.
16bit-ykiko 3764782
add module keyword and Char8.
16bit-ykiko 08dc216
Merge branch 'main' into complete-cxx20-keywords
16bit-ykiko 585bc0a
Merge branch 'main' into complete-cxx20-keywords
16bit-ykiko e802aec
Merge branch 'main' into complete-cxx20-keywords
16bit-ykiko 2d7f476
Update ReleaseNote.
16bit-ykiko d489327
Remove extra braces.
16bit-ykiko 5cc6a8f
Update test file.
16bit-ykiko 74b7c74
Fix test.
16bit-ykiko 687ab4c
Merge branch 'main' into complete-cxx20-keywords
16bit-ykiko cc758c5
Remove extra brace.
16bit-ykiko 15f6982
Make completion for module keyword more context sensitive.
16bit-ykiko b6218b6
Fix unexpected compiler error when code complete in `export mod^`.
16bit-ykiko 75bb471
Remove `.clangd`.
16bit-ykiko 68cd292
Some format.
16bit-ykiko cf991be
Merge branch 'main' into complete-cxx20-keywords
16bit-ykiko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
module; | ||
|
||
export module M; | ||
|
||
export const char8_t x = 1; | ||
|
||
template<typename T> requires true | ||
const int y = requires { typename T::type; requires T::value; }; | ||
|
||
class co_test {}; | ||
|
||
int f(){ co_test test; return 1; } | ||
|
||
module: private; | ||
|
||
// RUN: %clang_cc1 -std=c++20 -code-completion-at=%s:1:3 %s | FileCheck --check-prefix=CHECK-MODULE1 %s | ||
// CHECK-MODULE1: module; | ||
// CHECK-MODULE1: module <#name#>; | ||
|
||
// RUN: %clang_cc1 -std=c++20 -code-completion-at=%s:3:11 %s | FileCheck --check-prefix=CHECK-MODULE2 %s | ||
// CHECK-MODULE2: module <#name#>; | ||
|
||
// RUN: %clang_cc1 -std=c++20 -code-completion-at=%s:14:3 %s | FileCheck --check-prefix=CHECK-MODULE3 %s | ||
// CHECK-MODULE3: module: private; | ||
|
||
// RUN: %clang_cc1 -std=c++20 -code-completion-at=%s:3:3 %s | FileCheck --check-prefix=CHECK-EXPORT %s | ||
// CHECK-EXPORT: export | ||
|
||
// RUN: %clang_cc1 -std=c++20 -code-completion-at=%s:5:11 %s | FileCheck --check-prefix=CHECK-CONST %s | ||
// CHECK-CONST: const | ||
// CHECK-CONST: consteval | ||
// CHECK-CONST: constexpr | ||
// CHECK-CONST: constinit | ||
|
||
// RUN: %clang_cc1 -std=c++20 -code-completion-at=%s:5:19 %s | FileCheck --check-prefix=CHECK-CHAR %s | ||
// CHECK-CHAR: char8_t | ||
|
||
// RUN: %clang_cc1 -std=c++20 -code-completion-at=%s:8:3 %s | FileCheck --check-prefix=CHECK-CONSTRAINT %s | ||
// CHECK-CONSTRAINT: concept | ||
// CHECK-CONSTRAINT: const | ||
// CHECK-CONSTRAINT: consteval | ||
// CHECK-CONSTRAINT: constexpr | ||
// CHECK-CONSTRAINT: constinit | ||
|
||
// RUN: %clang_cc1 -std=c++20 -code-completion-at=%s:7:27 %s | FileCheck --check-prefix=CHECK-REQUIRES2 %s | ||
// CHECK-REQUIRES2: requires | ||
|
||
// RUN: %clang_cc1 -std=c++20 -code-completion-at=%s:8:20 %s | FileCheck -check-prefix=CHECK-REQUIRE %s | ||
// CHECK-REQUIRE: [#bool#]requires (<#parameters#>) { | ||
// CHECK-REQUIRE: <#requirements#> | ||
// CHECK-REQUIRE: } | ||
|
||
// RUN: %clang_cc1 -std=c++20 -code-completion-at=%s:12:13 %s | FileCheck --check-prefix=CHECK-COROUTINE %s | ||
// CHECK-COROUTINE: co_await <#expression#> | ||
// CHECK-COROUTINE: co_return <#expression#>; | ||
// CHECK-COROUTINE: co_yield <#expression#> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we restrict that using
getCurrentModule()->Kind
@ChuanqiXu9 ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we can't do it here. Since we don't the kind of the current module before we see module declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, exactly.
If we haven't see
module;
, we should proposemodule;
andexport module
If we have seen
module;
- we should not propose it againIf we have seem
export module
, we should not proposeimport
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I push a new commit and try to make completion for module related keywords more context-sensitive.
And found something strange: https://godbolt.org/z/YM9dhEKKe
If I try to run code completion at
^
, only get a compiler error.The error shouldn't occur, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only happens during completion so there is probably a bug with that https://godbolt.org/z/7M8EPodoP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some modification to
ParseExportDeclaration
to fix the problem.