Skip to content

Commit d08f715

Browse files
committed
test: Avoid nested designated initializers that crash MSVC
1 parent e749a7c commit d08f715

2 files changed

Lines changed: 39 additions & 38 deletions

File tree

test/liblangutil/DebugData.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,30 @@ BOOST_AUTO_TEST_CASE(carries_semantic_debug_data)
3838
ethdebugPointer.name = "value";
3939
ethdebugPointer.slot = "pointer:value";
4040

41-
auto semanticDebugData = std::make_shared<SemanticDebugData const>(SemanticDebugData{
42-
.lexicalScopeID = 17,
43-
.variableDefinitions = {{
44-
.name = "value",
45-
.declarationAstID = 23,
46-
.declarationLocation = SourceLocation{1, 6, std::make_shared<std::string>("input.sol")},
47-
.typeID = "type:uint256",
48-
.ethdebugType = SemanticDebugType{
49-
.typeClass = SemanticDebugType::Class::Elementary,
50-
.kind = SemanticDebugType::Kind::Uint,
51-
.bits = 256,
52-
.places = std::nullopt,
53-
.bytes = std::nullopt,
54-
.dataLocation = std::nullopt,
55-
.payable = std::nullopt,
56-
.dynamic = std::nullopt
57-
},
58-
.location = SemanticDebugVariableLocation{
59-
.kind = SemanticDebugVariableLocation::Kind::Stack,
60-
.pointerID = "pointer:value"
61-
},
62-
.ethdebugPointer = ethdebugPointer
63-
}}
64-
});
41+
// NOTE: Built imperatively instead of with nested designated initializers,
42+
// which crash MSVC with an internal compiler error.
43+
SemanticDebugType ethdebugType;
44+
ethdebugType.typeClass = SemanticDebugType::Class::Elementary;
45+
ethdebugType.kind = SemanticDebugType::Kind::Uint;
46+
ethdebugType.bits = 256;
47+
48+
SemanticDebugVariableLocation location;
49+
location.kind = SemanticDebugVariableLocation::Kind::Stack;
50+
location.pointerID = "pointer:value";
51+
52+
SemanticDebugVariable variable;
53+
variable.name = "value";
54+
variable.declarationAstID = 23;
55+
variable.declarationLocation = SourceLocation{1, 6, std::make_shared<std::string>("input.sol")};
56+
variable.typeID = "type:uint256";
57+
variable.ethdebugType = ethdebugType;
58+
variable.location = location;
59+
variable.ethdebugPointer = ethdebugPointer;
60+
61+
SemanticDebugData data;
62+
data.lexicalScopeID = 17;
63+
data.variableDefinitions.emplace_back(std::move(variable));
64+
auto semanticDebugData = std::make_shared<SemanticDebugData const>(std::move(data));
6565

6666
auto debugData = DebugData::create(
6767
SourceLocation{},
@@ -98,9 +98,9 @@ BOOST_AUTO_TEST_CASE(carries_semantic_debug_data)
9898

9999
BOOST_AUTO_TEST_CASE(semantic_debug_data_table_uses_ast_id)
100100
{
101-
auto semanticDebugData = std::make_shared<SemanticDebugData const>(SemanticDebugData{
102-
.lexicalScopeID = 17
103-
});
101+
SemanticDebugData data;
102+
data.lexicalScopeID = 17;
103+
auto semanticDebugData = std::make_shared<SemanticDebugData const>(std::move(data));
104104

105105
SemanticDebugDataTable table;
106106
BOOST_CHECK(table.empty());

test/libyul/DebugData.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@ SemanticDebugDataTable stackVariableTable(int64_t _astID, std::string _name, std
7878
};
7979
variable.ethdebugPointer = stackPointer(std::move(_slot));
8080

81+
SemanticDebugData data;
82+
data.lexicalScopeID = _astID;
83+
data.variableDefinitions.emplace_back(std::move(variable));
84+
8185
SemanticDebugDataTable table;
82-
table.set(_astID, std::make_shared<SemanticDebugData const>(SemanticDebugData{
83-
.lexicalScopeID = _astID,
84-
.variableDefinitions = {std::move(variable)}
85-
}));
86+
table.set(_astID, std::make_shared<SemanticDebugData const>(std::move(data)));
8687
return table;
8788
}
8889

@@ -145,9 +146,9 @@ BOOST_AUTO_TEST_CASE(semantic_debug_data_survives_reparse_by_ast_id)
145146
BOOST_REQUIRE(funDef->debugData->astID);
146147
BOOST_REQUIRE_EQUAL(*funDef->debugData->astID, 23);
147148

148-
auto semanticDebugData = std::make_shared<SemanticDebugData const>(SemanticDebugData{
149-
.lexicalScopeID = 17
150-
});
149+
SemanticDebugData data;
150+
data.lexicalScopeID = 17;
151+
auto semanticDebugData = std::make_shared<SemanticDebugData const>(std::move(data));
151152
funDef->debugData = DebugData::create(
152153
funDef->debugData->nativeLocation,
153154
funDef->debugData->originLocation,
@@ -202,10 +203,10 @@ BOOST_AUTO_TEST_CASE(reparse_marks_missing_stack_locations_optimized_out)
202203
};
203204
variable.ethdebugPointer = stackPointer("missing_slot");
204205

205-
auto semanticDebugData = std::make_shared<SemanticDebugData const>(SemanticDebugData{
206-
.lexicalScopeID = 17,
207-
.variableDefinitions = {std::move(variable)}
208-
});
206+
SemanticDebugData data;
207+
data.lexicalScopeID = 17;
208+
data.variableDefinitions.emplace_back(std::move(variable));
209+
auto semanticDebugData = std::make_shared<SemanticDebugData const>(std::move(data));
209210
funDef->debugData = DebugData::create(
210211
funDef->debugData->nativeLocation,
211212
funDef->debugData->originLocation,

0 commit comments

Comments
 (0)