[clang] [Modules] Record whether VarDecl initializers contain side effects (PR #143739)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 16 07:27:38 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- clang/include/clang/AST/Decl.h clang/include/clang/AST/ExternalASTSource.h clang/include/clang/Serialization/ASTReader.h clang/lib/AST/Decl.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriterDecl.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h
index 002706b6b..8cdfa7d20 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1446,7 +1446,7 @@ private:
/// VarDecls with initializers containing side effects must be emitted,
/// but DeclMustBeEmitted is not allowed to deserialize the intializer.
- llvm::SmallPtrSet<Decl*, 16> InitSideEffectVars;
+ llvm::SmallPtrSet<Decl *, 16> InitSideEffectVars;
public:
/// Get the buffer for resolving paths.
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 193b1c8ed..b9a753a21 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2448,12 +2448,13 @@ bool VarDecl::hasInitWithSideEffects() const {
if (auto *S = dyn_cast<Stmt *>(Init)) {
const Expr *E = cast<Expr>(S);
return E->HasSideEffects(getASTContext()) &&
- // We can get a value-dependent initializer during error recovery.
- (E->isValueDependent() || !evaluateValue());
+ // We can get a value-dependent initializer during error recovery.
+ (E->isValueDependent() || !evaluateValue());
}
// ASTReader tracks this without having to deserialize the initializer
- return getASTContext().getExternalSource()->hasInitializerWithSideEffects(this);
+ return getASTContext().getExternalSource()->hasInitializerWithSideEffects(
+ this);
}
bool VarDecl::isOutOfLine() const {
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index d4f4fae56..f6dab5ec5 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -9723,9 +9723,9 @@ ExternalASTSource::ExtKind ASTReader::hasExternalDefinitions(const Decl *FD) {
bool ASTReader::wasThisDeclarationADefinition(const FunctionDecl *FD) {
return ThisDeclarationWasADefinitionSet.contains(FD);
-bool ASTReader::hasInitializerWithSideEffects(const VarDecl *VD) const {
- return InitSideEffectVars.count(VD);
-}
+ bool ASTReader::hasInitializerWithSideEffects(const VarDecl *VD) const {
+ return InitSideEffectVars.count(VD);
+ }
Selector ASTReader::getLocalSelector(ModuleFile &M, unsigned LocalID) {
return DecodeSelector(getGlobalSelectorID(M, LocalID));
``````````
</details>
https://github.com/llvm/llvm-project/pull/143739
More information about the cfe-commits
mailing list