-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang] Do not serialize function definitions without a body #121550
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
Changes from 2 commits
fe4adf2
300707b
6e0dbf5
f0a8e43
3e2c300
cefbcf0
4394ec9
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6092,9 +6092,10 @@ void ASTWriter::WriteDeclUpdatesBlocks(ASTContext &Context, | |||||
|
|
||||||
| // An updated body is emitted last, so that the reader doesn't need | ||||||
| // to skip over the lazy body to reach statements for other records. | ||||||
| if (Kind == UPD_CXX_ADDED_FUNCTION_DEFINITION) | ||||||
| HasUpdatedBody = true; | ||||||
| else if (Kind == UPD_CXX_ADDED_VAR_DEFINITION) | ||||||
| if (Kind == UPD_CXX_ADDED_FUNCTION_DEFINITION) { | ||||||
| assert(isa<FunctionDecl>(D) && "expected FunctionDecl"); | ||||||
| HasUpdatedBody = dyn_cast<FunctionDecl>(D)->hasBody(); | ||||||
| } else if (Kind == UPD_CXX_ADDED_VAR_DEFINITION) | ||||||
|
||||||
| } else if (Kind == UPD_CXX_ADDED_VAR_DEFINITION) | |
| } else if (Kind == UPD_CXX_ADDED_VAR_DEFINITION) { |
Please see LLVM's policy for the use of { : https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
we hope the style is consistent with the if-else branches
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.
Added
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.
ditto,
| else | |
| else { |
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.
Added
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // RUN: rm -rf %t | ||
| // RUN: split-file %s %t | ||
| // RUN: cd %t | ||
|
|
||
| // RUN: %clang_cc1 -std=c++23 mod1.cppm -emit-module-interface -o mod1.pcm -fallow-pcm-with-compiler-errors -verify | ||
| // RUN: %clang_cc1 -std=c++23 mod2.cppm -emit-module-interface -o mod2.pcm -fmodule-file=mod1=mod1.pcm -verify -fallow-pcm-with-compiler-errors | ||
| // RUN: %clang_cc1 -std=c++23 mod3.cppm -emit-module-interface -o mod3.pcm -fmodule-file=mod1=mod1.pcm -fmodule-file=mod2=mod2.pcm -verify -fallow-pcm-with-compiler-errors | ||
| // RUN: %clang_cc1 -std=c++23 main.cpp -fmodule-file=mod1=mod1.pcm -fmodule-file=mod2=mod2.pcm -fmodule-file=mod3=mod3.pcm -verify -fallow-pcm-with-compiler-errors -ast-dump-all | ||
|
|
||
| //--- mod1.cppm | ||
| export module mod1; | ||
|
|
||
| export template <unsigned N, unsigned M> | ||
| class A { | ||
| public: | ||
| constexpr A(const char[], const char[]) { | ||
| auto x = BrokenExpr; // expected-error {{use of undeclared identifier 'BrokenExpr'}} | ||
| } | ||
| }; | ||
|
|
||
| export template<A<1,1> NTTP> | ||
| struct B {}; | ||
|
|
||
| template < unsigned N, unsigned M > | ||
| A(const char (&)[N], const char (&)[M]) -> A< 1, 1 >; | ||
|
|
||
| //--- mod2.cppm | ||
| export module mod2; | ||
| import mod1; | ||
|
|
||
| struct C: B <A{"a", "b"}> { // expected-error {{non-type template argument is not a constant expression}} | ||
| constexpr C(int a) { } | ||
| }; | ||
|
|
||
| //--- mod3.cppm | ||
| // expected-no-diagnostics | ||
| export module mod3; | ||
| export import mod2; | ||
|
|
||
| //--- main.cpp | ||
| // expected-no-diagnostics | ||
| import mod3; // no crash |
Uh oh!
There was an error while loading. Please reload this page.