Skip to content

Commit e983093

Browse files
committed
rebase
1 parent 2b0fccd commit e983093

File tree

10 files changed

+28
-36
lines changed

10 files changed

+28
-36
lines changed

server/src/FeaturesFilter.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,14 @@ static void updateIfNotCompleteType(types::TypeSupport &typeSupport,
1616

1717
bool has_private_array(const types::Type &type, const types::TypesHandler &typesHandler) {
1818
switch (typesHandler.getTypeKind(type)) {
19-
case types::TypeKind::STRUCT:
19+
case types::TypeKind::STRUCT_LIKE:
2020
for (const auto &field: typesHandler.getStructInfo(type).fields) {
2121
if (field.type.isArray() && field.accessSpecifier != types::AccessSpecifier::AS_pubic) {
2222
return true;
2323
}
2424
return has_private_array(field.type, typesHandler);
2525
}
2626
break;
27-
case types::TypeKind::UNION:
28-
for (const auto &field: typesHandler.getUnionInfo(type).fields) {
29-
if (field.type.isArray() && field.accessSpecifier != types::AccessSpecifier::AS_pubic) {
30-
return true;
31-
}
32-
return has_private_array(field.type, typesHandler);
33-
}
34-
break;
3527
case types::TypeKind::OBJECT_POINTER:
3628
return has_private_array(type.baseTypeObj(), typesHandler);
3729
case types::TypeKind::ARRAY:
@@ -124,7 +116,7 @@ void FeaturesFilter::filter(utbot::SettingsContext const &settingsContext,
124116
}
125117

126118
for (const auto &param: method.params) {
127-
if (typesHandler.isStruct(param.type)) {
119+
if (typesHandler.isStructLike(param.type)) {
128120
for (const auto &field: typesHandler.getStructInfo(param.type).fields) {
129121
if (field.type.isArray() && field.accessSpecifier != types::AccessSpecifier::AS_pubic) {
130122
std::stringstream message;
@@ -140,7 +132,7 @@ void FeaturesFilter::filter(utbot::SettingsContext const &settingsContext,
140132
}
141133
}
142134

143-
if (typesHandler.isStruct(method.returnType)) {
135+
if (typesHandler.isStructLike(method.returnType)) {
144136
for (const auto &field: typesHandler.getStructInfo(method.returnType).fields) {
145137
if (field.type.isArray() && field.accessSpecifier != types::AccessSpecifier::AS_pubic) {
146138
std::stringstream message;

server/src/Paths.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ namespace Paths {
112112
fs::path getCCJsonFileFullPath(const std::string &filename, const fs::path &directory) {
113113
fs::path path1 = fs::path(filename);
114114
fs::path path2 = fs::weakly_canonical(directory / path1);
115-
return fs::exists(path2.parent_path()) ? path2 : path1;
115+
return fs::exists(path2) ? path2 : path1;
116116
}
117117

118118
bool isPath(const std::string &possibleFilePath) noexcept {

server/src/Server.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,8 @@ Status Server::TestsGenServiceImpl::ProcessProjectStubsRequest(BaseTestGen *test
562562
}
563563

564564
Status Server::TestsGenServiceImpl::failedToLoadCDbStatus(const CompilationDatabaseException &e) {
565-
return {StatusCode::INVALID_ARGUMENT, "Failed to find compile_commands.json:\n" + std::string(e.what())};
565+
return {StatusCode::INVALID_ARGUMENT,
566+
"Failed to find compile_commands.json:\n" + std::string(e.what())};
566567
}
567568

568569
Status Server::TestsGenServiceImpl::PrintModulesContent(ServerContext *context,

server/src/printers/KleePrinter.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,14 @@ fs::path KleePrinter::writeTmpKleeFile(
143143
strInclude("klee/klee.h") << NL;
144144
ss << CALLOC_DECLARATION << NL;
145145
writeStubsForStructureFields(tests);
146-
writeAccessPrivateMacros(typesHandler, tests, false, [methodFilter, onlyForOneClass, onlyForOneFunction, testedMethod, testedClass] (
147-
tests::Tests::MethodDescription const &testMethod) {
148-
return methodFilter(testMethod) && !((onlyForOneFunction && testMethod.name != testedMethod) ||
149-
(onlyForOneClass && testMethod.isClassMethod() && testMethod.classObj->type.typeName() != testedClass));
150-
});
146+
writeAccessPrivateMacros(typesHandler, tests, false,
147+
[methodFilter, onlyForOneClass, onlyForOneFunction, testedMethod, testedClass](
148+
tests::Tests::MethodDescription const &testMethod) {
149+
return methodFilter(testMethod) &&
150+
!((onlyForOneFunction && testMethod.name != testedMethod) ||
151+
(onlyForOneClass && testMethod.isClassMethod() &&
152+
testMethod.classObj->type.typeName() != testedClass));
153+
});
151154

152155
strDeclareSetOfVars(tests.externVariables);
153156
ss << NL;

server/src/printers/Printer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,10 @@ namespace printer {
583583
stubName, "stub", methodName, fInfo->name, makeStatic);
584584
}
585585

586-
void Printer::writeAccessPrivateMacros(types::TypesHandler const *typesHandler, const Tests &tests, bool onlyChangeable,
587-
const std::function<bool(tests::Tests::MethodDescription const &)> &methodFilter) {
586+
void
587+
Printer::writeAccessPrivateMacros(types::TypesHandler const *typesHandler, const Tests &tests, bool onlyChangeable,
588+
const std::function<bool(
589+
tests::Tests::MethodDescription const &)> &methodFilter) {
588590
if (srcLanguage == utbot::Language::CXX) {
589591
ss << NL;
590592
strInclude("access_private.hpp");

server/src/stubs/StubSourcesFinder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ std::vector<fs::path> StubSourcesFinder::excludeFind(const fs::path &testedFileP
2626
if (CollectionUtils::contains(libraryBitcodeFiles, bitcodeFile))
2727
continue;
2828
fs::path sourcePath =
29-
buildDatabase->getClientCompilationUnitInfo(bitcodeFile)->getSourcePath();
29+
buildDatabase->getClientCompilationUnitInfo(bitcodeFile)->getSourcePath();
3030
// TODO Support stubs for c++ code
3131
if (Paths::isCXXFile(sourcePath)) {
3232
LOG_S(DEBUG) << "CXX stubs not supported now, file: " << sourcePath;

server/src/types/Types.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,6 @@ namespace types {
310310
bool hasUnnamedFields;
311311
//TODO delete then can construct without initializer list
312312
bool canBeConstruct;
313-
bool isCLike;
314-
};
315-
316-
struct UnionInfo: TypeInfo {
317-
std::vector<Field> fields{};
318-
bool hasUnnamedFields;
319313
};
320314

321315
struct EnumInfo: TypeInfo {
@@ -687,6 +681,7 @@ namespace types {
687681
};
688682
std::vector<FunctionParamInfo> params;
689683
};
684+
690685
}
691686

692687
#endif //UNITTESTBOT_TYPES_H

server/src/types/TypesResolver.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static size_t getDeclAlignment(const clang::TagDecl *T) {
4242

4343
template<class Info>
4444
static void addInfo(uint64_t id, std::unordered_map<uint64_t, Info> &someMap, Info info) {
45-
auto[iterator, inserted] = someMap.emplace(id, info);
45+
auto [iterator, inserted] = someMap.emplace(id, info);
4646
LOG_IF_S(MAX, !inserted) << "Type with id=" << id << " already existed";
4747
if (!inserted) {
4848
std::string nameInMap = iterator->second.name;
@@ -103,15 +103,8 @@ void TypesResolver::resolveStructEx(const clang::RecordDecl *D, const std::strin
103103
structInfo.filePath = Paths::getCCJsonFileFullPath(filename, parent->buildRootPath);
104104
structInfo.name = getFullname(D, canonicalType, id, sourceFilePath);
105105
structInfo.hasAnonymousStructOrUnion = false;
106-
if (Paths::getSourceLanguage(sourceFilePath) == utbot::Language::CXX) {
107-
const auto *cppD = llvm::dyn_cast<const clang::CXXRecordDecl>(D);
108-
structInfo.isCLike = cppD != nullptr && cppD->isCLike();
109-
} else {
110-
structInfo.isCLike = true;
111-
}
112106
structInfo.hasUnnamedFields = false;
113107
structInfo.canBeConstruct = false;
114-
structInfo.isCLike = true;
115108

116109
if (Paths::isGtest(structInfo.filePath)) {
117110
return;

server/test/suites/server/multiple_classes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ int second_class::third_class::get3() {
1313
}
1414

1515
first_class::first_class() {}
16+
1617
second_class::second_class() {}
18+
1719
second_class::third_class::third_class() {}
1820

server/test/suites/server/multiple_classes.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@
55
class first_class {
66
public:
77
first_class();
8+
89
int get1();
910
};
1011

1112
struct second_class {
1213
public:
1314
second_class();
15+
1416
struct third_class {
15-
third_class();
17+
third_class();
18+
1619
public:
1720
int get3();
1821
};
22+
1923
int get2();
2024
};
2125

0 commit comments

Comments
 (0)