@@ -125,7 +125,8 @@ namespace printer {
125
125
types::PointerUsage usage,
126
126
std::optional<std::string_view> value,
127
127
std::optional<uint64_t > alignment,
128
- bool complete) {
128
+ bool complete,
129
+ ExternType externType) {
129
130
auto baseType = type.baseType ();
130
131
std::string arrayName{ name.data (), name.length () };
131
132
@@ -135,6 +136,18 @@ namespace printer {
135
136
}
136
137
137
138
ss << LINE_INDENT ();
139
+ switch (externType) {
140
+ case ExternType::C :
141
+ if (getLanguage () == utbot::Language::CXX) {
142
+ ss << " extern \" C\" " ;
143
+ break ;
144
+ }
145
+ case ExternType::SAME_LANGUAGE :
146
+ ss << " extern " ;
147
+ break ;
148
+ case ExternType::NONE :
149
+ break ;
150
+ }
138
151
printAlignmentIfExists (alignment);
139
152
ss << baseType << " " << arrayName;
140
153
std::vector<size_t > sizes = type.arraysSizes (usage);
@@ -539,15 +552,16 @@ namespace printer {
539
552
}
540
553
}
541
554
542
- void printer::Printer::writeExternForSymbolicStubs (const Tests::MethodDescription& testMethod) {
543
- std::unordered_map<std::string, std::string > symbolicNamesToTypesMap;
544
- for (const auto & testCase: testMethod.testCases ) {
555
+ void printer::Printer::writeExternForSymbolicStubs (const Tests::MethodDescription & testMethod) {
556
+ std::unordered_map<std::string, types::Type > symbolicNamesToTypesMap;
557
+ for (const auto & testCase: testMethod.testCases ) {
545
558
for (size_t i = 0 ; i < testCase.stubValues .size (); i++) {
546
- symbolicNamesToTypesMap[testCase.stubValues [i].name ] = testCase.stubValuesTypes [i].type . usedType () ;
559
+ symbolicNamesToTypesMap[testCase.stubValues [i].name ] = testCase.stubValuesTypes [i].type ;
547
560
}
548
561
}
549
- for (const auto & [name, type]: symbolicNamesToTypesMap) {
550
- strDeclareVar (" extern \" C\" " + type, name);
562
+ for (const auto &[name, type]: symbolicNamesToTypesMap) {
563
+ strDeclareArrayVar (type, name, types::PointerUsage::PARAMETER, std::nullopt, std::nullopt, true ,
564
+ ExternType::C);
551
565
}
552
566
}
553
567
0 commit comments