Skip to content

Commit

Permalink
Revert "[C++20] [Modules] Serialize the evaluated constant values for…
Browse files Browse the repository at this point in the history
… VarDecl"

This reverts commit c0d6f85. The asan
bot detected a memory leak after this patch. Revert it for now.
  • Loading branch information
ChuanqiXu9 committed May 24, 2023
1 parent bea2ff6 commit 651b40e
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 150 deletions.
4 changes: 0 additions & 4 deletions clang/lib/Serialization/ASTReaderDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,10 +1659,6 @@ void ASTDeclReader::ReadVarDeclInit(VarDecl *VD) {
EvaluatedStmt *Eval = VD->ensureEvaluatedStmt();
Eval->HasConstantInitialization = (Val & 2) != 0;
Eval->HasConstantDestruction = (Val & 4) != 0;
Eval->WasEvaluated = (Val & 8) != 0;
if (Eval->WasEvaluated)
Eval->Evaluated = Record.readAPValue();

// Store the offset of the initializer. Don't deserialize it yet: it might
// not be needed, and might refer back to the variable, for example if it
// contains a lambda.
Expand Down
11 changes: 2 additions & 9 deletions clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5987,20 +5987,13 @@ void ASTRecordWriter::AddVarDeclInit(const VarDecl *VD) {
return;
}

uint64_t Val = 1;
unsigned Val = 1;
if (EvaluatedStmt *ES = VD->getEvaluatedStmt()) {
Val |= (ES->HasConstantInitialization ? 2 : 0);
Val |= (ES->HasConstantDestruction ? 4 : 0);
APValue *Evaluated = VD->getEvaluatedValue();
// If the evaluted result is constant, emit it.
if (Evaluated && (Evaluated->isInt() || Evaluated->isFloat()))
Val |= 8;
// FIXME: Also emit the constant initializer value.
}
push_back(Val);
if (Val & 8) {
AddAPValue(*VD->getEvaluatedValue());
}

writeStmtRef(Init);
}

Expand Down
2 changes: 0 additions & 2 deletions clang/unittests/Serialization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ add_clang_unittest(SerializationTests
InMemoryModuleCacheTest.cpp
ModuleCacheTest.cpp
SourceLocationEncodingTest.cpp
VarDeclConstantInitTest.cpp
)

clang_target_link_libraries(SerializationTests
Expand All @@ -19,5 +18,4 @@ clang_target_link_libraries(SerializationTests
clangLex
clangSema
clangSerialization
clangTooling
)
135 changes: 0 additions & 135 deletions clang/unittests/Serialization/VarDeclConstantInitTest.cpp

This file was deleted.

0 comments on commit 651b40e

Please sign in to comment.