-
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
Merged
ChuanqiXu9
merged 7 commits into
llvm:main
from
alejandro-alvarez-sonarsource:aa/port_serialization_no_body
Jan 6, 2025
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fe4adf2
[clang] Do not serialize function definitions without a body
alejandro-alvarez-sonarsource 300707b
Do not set `HasUpdatedBody`
alejandro-alvarez-sonarsource 6e0dbf5
Update clang/lib/Serialization/ASTWriter.cpp
alejandro-alvarez-sonarsource f0a8e43
Add missing braces
alejandro-alvarez-sonarsource 3e2c300
Move the check to FunctionDefinitionInstantiated and CompletedImplici…
alejandro-alvarez-sonarsource cefbcf0
Move comment above
alejandro-alvarez-sonarsource 4394ec9
Merge branch 'main' into aa/port_serialization_no_body
alejandro-alvarez-sonarsource 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
| 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 |
Oops, something went wrong.
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.
Sorry to skip this on the last iteration. We should use
doesThisDeclarationHaveABodyinstead ofhasBody. SincehasBodymay be more expensive.And also it is still slightly better to not set
UPD_CXX_ADDED_FUNCTION_DEFINITIONif the function doesn't have a body. We can check this in CompletedImplicitDefinition and VariableDefinitionInstantiated.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.
No problem! I want the get it right, not to rush it :D
Changed, although I imagine you meant FunctionDefinitionInstantiated (not VariableDefinitionInstantiated)