diff options
author | Henrik G. Olsson <hnrklssn@gmail.com> | 2025-06-23 10:16:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-23 10:16:31 -0700 |
commit | 319a51a5ffb807b88ae7f73676894bf306a0d134 (patch) | |
tree | e863310011088db1c13a280db4316663c4dd2b63 /clang/lib/Sema/MultiplexExternalSemaSource.cpp | |
parent | 836ff367d0bca9369fd2db237e9b5d7b929bb593 (diff) | |
download | llvm-319a51a5ffb807b88ae7f73676894bf306a0d134.zip llvm-319a51a5ffb807b88ae7f73676894bf306a0d134.tar.gz llvm-319a51a5ffb807b88ae7f73676894bf306a0d134.tar.bz2 |
[Modules] Record whether VarDecl initializers contain side effects (#143739)
Calling `DeclMustBeEmitted` should not lead to more deserialization, as
it may occur before previous deserialization has finished.
When passed a `VarDecl` with an initializer however, `DeclMustBeEmitted`
needs to know whether that initializer contains side effects. When the
`VarDecl` is deserialized but the initializer is not, this triggers
deserialization of the initializer. To avoid this we add a bit to the
serialization format for `VarDecl`s, indicating whether its initializer
contains side effects or not, so that the `ASTReader` can query this
information directly without deserializing the initializer.
rdar://153085264
Diffstat (limited to 'clang/lib/Sema/MultiplexExternalSemaSource.cpp')
-rw-r--r-- | clang/lib/Sema/MultiplexExternalSemaSource.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Sema/MultiplexExternalSemaSource.cpp b/clang/lib/Sema/MultiplexExternalSemaSource.cpp index fbfb242..9f19f13 100644 --- a/clang/lib/Sema/MultiplexExternalSemaSource.cpp +++ b/clang/lib/Sema/MultiplexExternalSemaSource.cpp @@ -115,6 +115,14 @@ bool MultiplexExternalSemaSource::wasThisDeclarationADefinition( return false; } +bool MultiplexExternalSemaSource::hasInitializerWithSideEffects( + const VarDecl *VD) const { + for (const auto &S : Sources) + if (S->hasInitializerWithSideEffects(VD)) + return true; + return false; +} + bool MultiplexExternalSemaSource::FindExternalVisibleDeclsByName( const DeclContext *DC, DeclarationName Name, const DeclContext *OriginalDC) { |