Skip to content

Commit cc4ee35

Browse files
author
Vladislav Kalugin
committed
Delete unused code, suppress warnings, fix formatting
1 parent 5ba9426 commit cc4ee35

File tree

6 files changed

+24
-34
lines changed

6 files changed

+24
-34
lines changed

server/src/KleeGenerator.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ class KleeGenerator {
112112
* @throws ExecutionProcessException if a Clang call returns non-zero code.
113113
*/
114114
void parseKTestsToFinalCode(
115-
const utbot::ProjectContext &projectContext,
116-
tests::Tests &tests,
117-
const std::unordered_map<std::string, types::Type> &methodNameToReturnTypeMap,
118-
const std::vector<MethodKtests> &kleeOutput,
119-
const std::shared_ptr<LineInfo> &lineInfo = nullptr,
120-
bool verbose = false,
121-
ErrorMode errorMode = ErrorMode::FAILING);
115+
const utbot::ProjectContext &projectContext,
116+
tests::Tests &tests,
117+
const std::unordered_map<std::string, types::Type> &methodNameToReturnTypeMap,
118+
const std::vector<MethodKtests> &kleeOutput,
119+
const std::shared_ptr<LineInfo> &lineInfo = nullptr,
120+
bool verbose = false,
121+
ErrorMode errorMode = ErrorMode::FAILING);
122122

123123
[[nodiscard]] fs::path getBitcodeFile(const fs::path &sourcePath) const;
124124

server/src/Paths.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ namespace Paths {
125125
return replaceExtension(path, StringUtils::stringFormat(".%s.err", suffix));
126126
}
127127

128-
static bool errorFileExists(const fs::path &path, std::string const& suffix) {
128+
bool errorFileExists(const fs::path &path, std::string const& suffix) {
129129
return fs::exists(errorFile(path, suffix));
130130
}
131131

server/src/Paths.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace Paths {
4242
const std::vector<fs::path> &dirNames,
4343
const std::function<bool(const fs::path &path)> &filter);
4444

45-
static bool errorFileExists(const fs::path &path, std::string const& suffix);
45+
bool errorFileExists(const fs::path &path, std::string const& suffix);
4646

4747
static inline void setOptPath(fs::path &path, const std::string &value) {
4848
path = fs::path(value);

server/src/printers/TestsPrinter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,8 @@ std::string TestsPrinter::constrVisitorFunctionCall(const Tests::MethodDescripti
757757
if (testCase.returnValue.view && testCase.returnValue.view->getEntryValue(nullptr) != PrinterUtils::C_NULL) {
758758
returnPointersCount = methodDescription.returnType.countReturnPointers(true);
759759
}
760-
std::string functionCall = constrFunctionCall(methodDescription.name, methodArgs, "", classObjName, false, returnPointersCount,
761-
castType);
760+
std::string functionCall = constrFunctionCall(methodDescription.name, methodArgs, "", classObjName,
761+
false, returnPointersCount, castType);
762762
switch (errorMode) {
763763
case ErrorMode::PASSING:
764764
if (testCase.errorInfo.errorType == ErrorType::EXCEPTION_THROWN) {
@@ -769,6 +769,7 @@ std::string TestsPrinter::constrVisitorFunctionCall(const Tests::MethodDescripti
769769
break;
770770
case ErrorMode::PASSING_IN_TARGET_ONLY:
771771
// TODO: generate EXPECT_ANY_THROW and ASSERT_DEATH only if runtime error was in target function
772+
default:
772773
break;
773774
}
774775
return functionCall;

server/src/utils/StringFormat.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@ namespace StringUtils {
3030
* @param args each of elements must either be primitive or have c_str method
3131
* (e.g. std::string, fs::path and others)
3232
*/
33-
template <typename... Args>
34-
std::string stringFormat(const std::string &format, Args&&... args) {
35-
size_t size = snprintf(nullptr, 0, format.c_str(), internal::extractCString(std::forward<Args>(args))...) + 1; // Extra space for '\0'
33+
template<typename... Args>
34+
std::string stringFormat(const std::string &format, Args &&... args) {
35+
#pragma GCC diagnostic push
36+
#pragma GCC diagnostic ignored "-Wformat-security"
37+
size_t size = snprintf(nullptr, 0, format.c_str(), internal::extractCString(std::forward<Args>(args))...) +
38+
1; // Extra space for '\0'
3639
if (size <= 0) {
3740
throw std::runtime_error("Error during formatting.");
3841
}
3942
formatBuffer.resize(std::max(formatBuffer.size(), size));
4043
snprintf(formatBuffer.data(), size, format.c_str(), internal::extractCString(std::forward<Args>(args))...);
4144
return {formatBuffer.begin(), formatBuffer.begin() + size - 1}; // We don't want the '\0' inside
4245
}
46+
#pragma GCC diagnostic pop
4347
}
4448

4549
#endif //UNITTESTBOT_STRINGFORMAT_H

server/src/utils/TraceUtils.cpp

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ bool errorInExceptionHeader(const std::string &fileWhereErrorFound) {
4040
}
4141

4242
[[nodiscard]]ErrorInfo getErrorInfo(const fs::path &path) {
43-
if (Paths::errorFileExists(path, "uncaught_exception") ||
44-
Paths::errorFileExists(path, "unexpected_exception")) {
43+
if (Paths::errorFileExists(path, "uncaught_exception") || Paths::errorFileExists(path, "unexpected_exception")) {
4544
return {ErrorType::EXCEPTION_THROWN};
4645
}
4746
if (Paths::errorFileExists(path, "ptr")) {
@@ -55,25 +54,11 @@ bool errorInExceptionHeader(const std::string &fileWhereErrorFound) {
5554
}
5655
}
5756
if (Paths::errorFileExists(path, "assert")) {
58-
ErrorInfo errorInfo;
59-
errorInfo.errorType = ErrorType::ASSERTION_FAILURE;
6057
fs::path errorFilePath = Paths::replaceExtension(path, ".assert.err");
61-
errorInfo.failureBody = getTypeOfError(errorFilePath);
62-
errorInfo.fileWithFailure = getFileErrorFound(errorFilePath);
63-
errorInfo.lineWithFailure = getLineErrorFound(errorFilePath);
64-
return errorInfo;
58+
return {ErrorType::ASSERTION_FAILURE,
59+
getTypeOfError(errorFilePath),
60+
getFileErrorFound(errorFilePath),
61+
getLineErrorFound(errorFilePath)};
6562
}
6663
return {ErrorType::NO_ERROR};
6764
}
68-
69-
//[[nodiscard]]ErrorInfo hasFailedAssert(const fs::path& path) {
70-
// ErrorInfo errorInfo;
71-
// if (Paths::errorFileExists(path, "assert")) {
72-
// errorInfo.errorType = ErrorType::ASSERTION_FAILURE;
73-
// fs::path errorFilePath = Paths::replaceExtension(path, ".assert.err");
74-
// errorInfo.assertBody = getTypeOfError(errorFilePath);
75-
// errorInfo.fileWithFailure = getFileErrorFound(errorFilePath);
76-
// errorInfo.lineWithFailure = getLineErrorFound(errorFilePath);
77-
// }
78-
// return errorInfo;
79-
//}

0 commit comments

Comments
 (0)