-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[Modules] Record whether VarDecl initializers contain side effects #143739
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
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 |
---|---|---|
|
@@ -1442,6 +1442,12 @@ class ASTReader | |
const StringRef &operator*() && = delete; | ||
}; | ||
|
||
/// VarDecls with initializers containing side effects must be emitted, | ||
/// but DeclMustBeEmitted is not allowed to deserialize the intializer. | ||
/// FIXME: Lower memory usage by removing VarDecls once the initializer | ||
/// is deserialized. | ||
llvm::SmallPtrSet<Decl *, 16> InitSideEffectVars; | ||
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. Not a big deal, but do we have any kind of data informing us how many of these we typically see? 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. No idea! 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 we can erase elements from |
||
|
||
public: | ||
/// Get the buffer for resolving paths. | ||
SmallString<0> &getPathBuf() { return PathBuf; } | ||
|
@@ -2392,6 +2398,8 @@ class ASTReader | |
|
||
bool wasThisDeclarationADefinition(const FunctionDecl *FD) override; | ||
|
||
bool hasInitializerWithSideEffects(const VarDecl *VD) const override; | ||
|
||
/// Retrieve a selector from the given module with its local ID | ||
/// number. | ||
Selector getLocalSelector(ModuleFile &M, unsigned LocalID); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Tests referencing variable with initializer containing side effect across module boundary | ||
// | ||
// RUN: rm -rf %t | ||
// RUN: mkdir -p %t | ||
// RUN: split-file %s %t | ||
|
||
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/Foo.cppm \ | ||
// RUN: -o %t/Foo.pcm | ||
|
||
// RUN: %clang_cc1 -std=c++20 -emit-module-interface \ | ||
// RUN: -fmodule-file=Foo=%t/Foo.pcm \ | ||
// RUN: %t/Bar.cppm \ | ||
// RUN: -o %t/Bar.pcm | ||
|
||
// RUN: %clang_cc1 -std=c++20 -emit-obj \ | ||
// RUN: -main-file-name Bar.cppm \ | ||
// RUN: -fmodule-file=Foo=%t/Foo.pcm \ | ||
// RUN: -x pcm %t/Bar.pcm \ | ||
// RUN: -o %t/Bar.o | ||
|
||
//--- Foo.cppm | ||
export module Foo; | ||
|
||
export { | ||
class S {}; | ||
|
||
inline S s = S{}; | ||
} | ||
|
||
//--- Bar.cppm | ||
export module Bar; | ||
import Foo; | ||
|
||
S bar() { | ||
return s; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.