-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[C++20][Modules] Implement P1857R3 Modules Dependency Discovery #107168
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
base: main
Are you sure you want to change the base?
Changes from all commits
2cce3d1
04ddbf6
8529a7f
b75b5ba
ece6382
008844c
db17bda
1ce4def
1fa3090
5a85243
687cdee
a7da327
8ce88a0
32c142e
4a84a31
21cb5ec
27ab41f
63a62ae
0a63a88
9fb7cc2
1171f7f
3821f67
eabc2a4
23bad11
dbaa113
b533184
f479274
695869e
0164d0d
0c3667c
0588245
49281ec
1c8b28f
14ba684
2b930da
5dc3c9a
3becb46
82612f8
cde2304
c07beac
d7e5043
d42fe78
80e8a3a
2b19d44
c9a6bd0
73bbd8f
fd72e45
cc8e0af
c69a88b
cef114c
b400909
00728a5
3cf170c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -466,6 +466,9 @@ def err_pp_embed_device_file : Error< | |
|
|
||
| def ext_pp_extra_tokens_at_eol : ExtWarn< | ||
| "extra tokens at end of #%0 directive">, InGroup<ExtraTokens>; | ||
| def ext_pp_extra_tokens_at_module_directive_eol | ||
| : Warning<"extra tokens at end of '%0' directive">, | ||
| InGroup<ExtraTokens>; | ||
|
|
||
| def ext_pp_comma_expr : Extension<"comma operator in operand of #if">; | ||
| def ext_pp_bad_vaargs_use : Extension< | ||
|
|
@@ -495,8 +498,8 @@ def warn_cxx98_compat_variadic_macro : Warning< | |
| InGroup<CXX98CompatPedantic>, DefaultIgnore; | ||
| def ext_named_variadic_macro : Extension< | ||
| "named variadic macros are a GNU extension">, InGroup<VariadicMacros>; | ||
| def err_embedded_directive : Error< | ||
| "embedding a #%0 directive within macro arguments is not supported">; | ||
| def err_embedded_directive : Error<"embedding a %select{#|C++ }0%1 directive " | ||
| "within macro arguments is not supported">; | ||
| def ext_embedded_directive : Extension< | ||
| "embedding a directive within macro arguments has undefined behavior">, | ||
| InGroup<DiagGroup<"embedded-directive">>; | ||
|
|
@@ -986,6 +989,14 @@ def warn_module_conflict : Warning< | |
| InGroup<ModuleConflict>; | ||
|
|
||
| // C++20 modules | ||
yronglin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def err_pp_module_name_is_macro : Error< | ||
| "%select{module|partition}0 name component %1 cannot be a object-like macro">; | ||
| def err_pp_module_expected_ident : Error< | ||
| "expected %select{identifier after '.' in |}0module name">; | ||
|
Comment on lines
+994
to
+995
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Contrast with the case where the module name is followed by TL;DR: Instead of having this preprocessor diagnostic, there should be preprocessor diagnostics for the disallowed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM! Since we have alread implement CWG2947 in this patch, I have a question about the following case: // #define m(x) x
export module m
(foo);Should we emit an diagnostic the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think you found a bug in the resolution of CWG2947. The restriction on As for diagnosing this in phase 7, how is phase 7 supposed to differentiate between the above and // #define m(x) x
// #define LPAREN (
export module m
LPAREN foo);? For the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We have a utility function
This because if we handle this case in clang's parser, the macro already expanded, so IIUC, I think it will be easy to handle this cases at there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If you mean that it determines what the next token is without trying to expand that token (if it is a macro name), then that's exactly what we want for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the very late reply! I have verified // #define m(x) x
export module m
(foo);The next token is // #define m(x) x
// #define LPAREN (
export module m
LPAREN foo); |
||
| def err_pp_module_decl_in_header | ||
| : Error<"module declaration must not come from an #include directive">; | ||
yronglin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def err_pp_cond_span_module_decl | ||
| : Error<"preprocessor conditionals shall not span a module declaration">; | ||
|
Comment on lines
+996
to
+999
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are both expressions of the fact that a In particular, such a diagnostic should only refer to "module directive"s and not to "module declaration"s. A diagnostic is required for the following: module;
#if 0
export module m;
#endif
// expected-error@-2 {{}}
export module m2;There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, these 2 diagnostic's wording is not correct here, need update There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't mean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, got it. |
||
| def err_header_import_semi_in_macro : Error< | ||
| "semicolon terminating header import declaration cannot be produced " | ||
| "by a macro">; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -142,6 +142,15 @@ void printDependencyDirectivesAsSource( | |||
| /// \returns true if any C++20 named modules related directive was found. | ||||
| bool scanInputForCXX20ModulesUsage(StringRef Source); | ||||
|
|
||||
| /// Scan an input source buffer, and check whether the input ssource is a | ||||
| /// preprocessed output. | ||||
| /// | ||||
| /// \param Source The input source buffer. | ||||
| /// | ||||
| /// \returns true if any '__preprocessed_module' or '__preprocessed_import' | ||||
| /// directive was found. | ||||
|
Comment on lines
+150
to
+151
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checking for Consider this as a preprocessed file: typedef int module;
module x;Compiling with An example of the
|
||||
| bool isPreprocessedModuleFile(StringRef Source); | ||||
|
|
||||
| /// Functor that returns the dependency directives for a given file. | ||||
| class DependencyDirectivesGetter { | ||||
| public: | ||||
|
|
||||
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.
The name should probably not start with
ext_.I'm not sure that having this in the same group as
ext_pp_extra_tokens_at_eolis the best design. It is more "legitimate" to want to suppress this message than the other one.Suggestion for the wording:
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.
SGTM, I'll update this.