Skip to content

Commit 6a86fef

Browse files
Saveliy Grigoryevsava-cska
Saveliy Grigoryev
authored andcommitted
Remove unnecessary 'using std::'
1 parent ac3e9d5 commit 6a86fef

File tree

172 files changed

+1568
-1679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+1568
-1679
lines changed

server/src/BordersFinder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using namespace clang::ast_matchers;
1818

1919
BordersFinder::BordersFinder(const fs::path &filePath,
2020
unsigned line,
21-
const shared_ptr<CompilationDatabase> &compilationDatabase,
21+
const std::shared_ptr<CompilationDatabase> &compilationDatabase,
2222
const fs::path &compileCommandsJsonPath)
2323
: line(line), classBorder(std::nullopt), clangToolRunner(compilationDatabase) {
2424
buildRootPath = Paths::subtractPath(compileCommandsJsonPath.string(), CompilationUtils::MOUNTED_CC_JSON_DIR_NAME);
@@ -93,7 +93,7 @@ void BordersFinder::run(const MatchFinder::MatchResult &Result) {
9393
lineInfo.functionReturnType = ParamsHandler::getType(realReturnType, realReturnType, sourceManager);
9494
lineInfo.initialized = true;
9595

96-
string strRepresentation = ASTPrinter::getSourceText(currentStmt->getSourceRange(), sourceManager);
96+
std::string strRepresentation = ASTPrinter::getSourceText(currentStmt->getSourceRange(), sourceManager);
9797
auto parents = Result.Context->getParents(*currentStmt);
9898
const int MAX_ITERATIONS = 50;
9999
// if more than MAX_ITERATIONS happen, something is wrong

server/src/BordersFinder.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@
1717
#include <string>
1818
#include <utility>
1919

20-
using std::string;
21-
using std::unique_ptr;
22-
using std::shared_ptr;
23-
2420
class BordersFinder : public clang::ast_matchers::MatchFinder::MatchCallback {
2521
public:
2622
BordersFinder(const fs::path &filePath,
2723
unsigned line,
28-
const shared_ptr<CompilationDatabase> &compilationDatabase,
24+
const std::shared_ptr<CompilationDatabase> &compilationDatabase,
2925
const fs::path &compileCommandsJsonPath);
3026

3127
void run(const clang::ast_matchers::MatchFinder::MatchResult &Result) override;

server/src/FeaturesFilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void FeaturesFilter::filter(utbot::SettingsContext const &settingsContext,
2323
tests::TestsMap &testsMap,
2424
bool throwIfZeroFunctions) {
2525
bool hasSupportedMethods = false;
26-
std::unordered_map<string, int> unsupportedStatistics;
26+
std::unordered_map<std::string, int> unsupportedStatistics;
2727
for (auto testsMapIterator = testsMap.begin(); testsMapIterator != testsMap.end();
2828
testsMapIterator++) {
2929
fs::path const &sourceFile = testsMapIterator.key();

server/src/KleeGenerator.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ KleeGenerator::KleeGenerator(
4242
}
4343
}
4444

45-
vector<KleeGenerator::BuildFileInfo>
45+
std::vector<KleeGenerator::BuildFileInfo>
4646
KleeGenerator::buildByCDb(const CollectionUtils::MapFileTo<fs::path> &filesToBuild,
4747
const CollectionUtils::FileSet &stubSources) {
4848
LOG_SCOPE_FUNCTION(DEBUG);
4949
auto compileCommands = getCompileCommandsForKlee(filesToBuild, stubSources);
5050
printer::DefaultMakefilePrinter makefilePrinter;
5151

52-
vector<fs::path> outfilePaths;
52+
std::vector<fs::path> outfilePaths;
5353
for (const auto &compileCommand : compileCommands) {
5454
fs::path output = compileCommand.getOutput();
5555
outfilePaths.emplace_back(output);
@@ -79,7 +79,7 @@ KleeGenerator::buildByCDb(const CollectionUtils::MapFileTo<fs::path> &filesToBui
7979
return outFiles;
8080
}
8181

82-
vector<KleeGenerator::BuildFileInfo>
82+
std::vector<KleeGenerator::BuildFileInfo>
8383
KleeGenerator::buildByCDb(const CollectionUtils::FileSet &filesToBuild,
8484
const CollectionUtils::FileSet &stubSources) {
8585
CollectionUtils::MapFileTo<fs::path> filesMap;
@@ -89,7 +89,7 @@ KleeGenerator::buildByCDb(const CollectionUtils::FileSet &filesToBuild,
8989
return buildByCDb(filesMap, stubSources);
9090
}
9191

92-
static string getUTBotClangCompilerPath(fs::path clientCompilerPath) {
92+
static std::string getUTBotClangCompilerPath(fs::path clientCompilerPath) {
9393
auto compilerName = CompilationUtils::getCompilerName(clientCompilerPath);
9494
switch (compilerName) {
9595
case CompilationUtils::CompilerName::GCC:
@@ -108,11 +108,11 @@ static string getUTBotClangCompilerPath(fs::path clientCompilerPath) {
108108
std::optional<utbot::CompileCommand>
109109
KleeGenerator::getCompileCommandForKlee(const fs::path &hintPath,
110110
const CollectionUtils::FileSet &stubSources,
111-
const vector<string> &flags) const {
111+
const std::vector<std::string> &flags) const {
112112
auto compilationUnitInfo = buildDatabase->getClientCompilationUnitInfo(hintPath);
113113
auto command = compilationUnitInfo->command;
114114
auto srcFilePath = compilationUnitInfo->getSourcePath();
115-
string newCompilerPath = getUTBotClangCompilerPath(command.getCompiler());
115+
std::string newCompilerPath = getUTBotClangCompilerPath(command.getCompiler());
116116
command.setCompiler(newCompilerPath);
117117

118118
srcFilePath = pathSubstitution.substituteLineFlag(srcFilePath);
@@ -126,17 +126,17 @@ KleeGenerator::getCompileCommandForKlee(const fs::path &hintPath,
126126
command.setOutput(outFilePath);
127127
command.setOptimizationLevel("-O0");
128128
command.removeGccFlags();
129-
vector<string> extraFlags{ "-emit-llvm",
130-
"-c",
131-
"-Xclang",
132-
"-disable-O0-optnone",
133-
"-g",
134-
"-fstandalone-debug",
135-
"-fno-discard-value-names",
136-
"-fno-elide-constructors",
137-
"-D" + PrinterUtils::KLEE_MODE + "=1",
138-
SanitizerUtils::CLANG_SANITIZER_CHECKS_FLAG };
139-
if(Paths::isCXXFile(srcFilePath)) {
129+
std::vector<std::string> extraFlags{ "-emit-llvm",
130+
"-c",
131+
"-Xclang",
132+
"-disable-O0-optnone",
133+
"-g",
134+
"-fstandalone-debug",
135+
"-fno-discard-value-names",
136+
"-fno-elide-constructors",
137+
"-D" + PrinterUtils::KLEE_MODE + "=1",
138+
SanitizerUtils::CLANG_SANITIZER_CHECKS_FLAG };
139+
if (Paths::isCXXFile(srcFilePath)) {
140140
command.addFlagToBegin(StringUtils::stringFormat("-I%s", Paths::getAccessPrivateLibPath()));
141141
}
142142
command.addFlagsToBegin(flags);
@@ -147,10 +147,10 @@ KleeGenerator::getCompileCommandForKlee(const fs::path &hintPath,
147147
return command;
148148
}
149149

150-
vector<utbot::CompileCommand>
150+
std::vector<utbot::CompileCommand>
151151
KleeGenerator::getCompileCommandsForKlee(const CollectionUtils::MapFileTo<fs::path> &filesToBuild,
152152
const CollectionUtils::FileSet &stubSources) const {
153-
vector<utbot::CompileCommand> compileCommands;
153+
std::vector<utbot::CompileCommand> compileCommands;
154154
compileCommands.reserve(filesToBuild.size());
155155
for (const auto &[fileToBuild, bitcode] : filesToBuild) {
156156
auto optionalCommand = getCompileCommandForKlee(fileToBuild, stubSources, {});
@@ -167,12 +167,12 @@ KleeGenerator::getCompileCommandsForKlee(const CollectionUtils::MapFileTo<fs::pa
167167
Result<fs::path> KleeGenerator::defaultBuild(const fs::path &hintPath,
168168
const fs::path &sourceFilePath,
169169
const fs::path &buildDirPath,
170-
const vector<string> &flags) {
170+
const std::vector<std::string> &flags) {
171171
LOG_SCOPE_FUNCTION(DEBUG);
172172
auto bitcodeFilePath = buildDatabase->getBitcodeFile(sourceFilePath);
173173
auto optionalCommand = getCompileCommandForKlee(hintPath, {}, flags);
174174
if (!optionalCommand.has_value()) {
175-
string message = StringUtils::stringFormat(
175+
std::string message = StringUtils::stringFormat(
176176
"Couldn't get command for klee file: %s\n"
177177
"Please check if directory is in source directories in UTBot extension settings: %s",
178178
sourceFilePath, hintPath.parent_path().string());
@@ -194,7 +194,7 @@ Result<fs::path> KleeGenerator::defaultBuild(const fs::path &hintPath,
194194

195195
Result<fs::path> KleeGenerator::defaultBuild(const fs::path &sourceFilePath,
196196
const fs::path &buildDirPath,
197-
const vector<string> &flags) {
197+
const std::vector<std::string> &flags) {
198198
return defaultBuild(sourceFilePath, sourceFilePath, buildDirPath, flags);
199199
}
200200

@@ -214,9 +214,9 @@ fs::path KleeGenerator::writeKleeFile(
214214
}
215215
}
216216

217-
vector<fs::path> KleeGenerator::buildKleeFiles(const tests::TestsMap &testsMap,
217+
std::vector<fs::path> KleeGenerator::buildKleeFiles(const tests::TestsMap &testsMap,
218218
const std::shared_ptr<LineInfo> &lineInfo) {
219-
vector<fs::path> outFiles;
219+
std::vector<fs::path> outFiles;
220220
LOG_S(DEBUG) << "Building generated klee files...";
221221
printer::KleePrinter kleePrinter(&typesHandler, buildDatabase, utbot::Language::UNKNOWN);
222222
ExecUtils::doWorkWithProgress(
@@ -251,7 +251,7 @@ vector<fs::path> KleeGenerator::buildKleeFiles(const tests::TestsMap &testsMap,
251251
<< " couldn't be compiled so it's copy is backed up in " << tempKleeFilePath
252252
<< ". Proceeding with generating klee file containing restricted number "
253253
"of functions";
254-
std::unordered_set<string> correctMethods;
254+
std::unordered_set<std::string> correctMethods;
255255
for (const auto &[methodName, methodDescription] : tests.methods) {
256256
fs::path currentKleeFilePath = kleePrinter.writeTmpKleeFile(
257257
tests, projectTmpPath, pathSubstitution, std::nullopt,
@@ -292,8 +292,8 @@ vector<fs::path> KleeGenerator::buildKleeFiles(const tests::TestsMap &testsMap,
292292

293293
void KleeGenerator::parseKTestsToFinalCode(
294294
tests::Tests &tests,
295-
const std::unordered_map<string, types::Type> &methodNameToReturnTypeMap,
296-
const vector<MethodKtests> &kleeOutput,
295+
const std::unordered_map<std::string, types::Type> &methodNameToReturnTypeMap,
296+
const std::vector<MethodKtests> &kleeOutput,
297297
const std::shared_ptr<LineInfo> &lineInfo,
298298
bool verbose) {
299299
for (const auto &batch : kleeOutput) {
@@ -305,7 +305,7 @@ void KleeGenerator::parseKTestsToFinalCode(
305305
}
306306
printer::TestsPrinter testsPrinter(&typesHandler, Paths::getSourceLanguage(tests.sourceFilePath));
307307
for (auto it = tests.methods.begin(); it != tests.methods.end(); it++) {
308-
const string &methodName = it.key();
308+
const std::string &methodName = it.key();
309309
Tests::MethodDescription &methodDescription = it.value();
310310
if (lineInfo) {
311311
bool methodNotMatch = lineInfo->forMethod && methodName != lineInfo->methodName;
@@ -330,7 +330,7 @@ void KleeGenerator::parseKTestsToFinalCode(
330330
LOG_S(DEBUG) << "Generated code for " << tests.methods.size() << " tests";
331331
}
332332

333-
shared_ptr<BuildDatabase> KleeGenerator::getBuildDatabase() const {
333+
std::shared_ptr<BuildDatabase> KleeGenerator::getBuildDatabase() const {
334334
return buildDatabase;
335335
}
336336

server/src/KleeGenerator.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#include <sstream>
2626
#include <string>
2727

28-
using std::string;
29-
3028
using json = nlohmann::json;
3129

3230
/**
@@ -76,18 +74,18 @@ class KleeGenerator {
7674
* @return Vector of paths to output files "*.bc".
7775
* @throws ExecutionProcessException if any of Clang calls returns non-zero code.
7876
*/
79-
vector<BuildFileInfo> buildByCDb(const CollectionUtils::MapFileTo<fs::path> &compileCommand,
80-
const CollectionUtils::FileSet &stubSources = {});
77+
std::vector<BuildFileInfo> buildByCDb(const CollectionUtils::MapFileTo<fs::path> &compileCommand,
78+
const CollectionUtils::FileSet &stubSources = {});
8179

82-
vector<KleeGenerator::BuildFileInfo>
80+
std::vector<KleeGenerator::BuildFileInfo>
8381
buildByCDb(const CollectionUtils::FileSet &filesToBuild,
8482
const CollectionUtils::FileSet &stubSources = {});
8583

8684

8785
Result<fs::path> defaultBuild(const fs::path &hintPath,
8886
const fs::path &sourceFilePath,
8987
const fs::path &buildDirPath = "",
90-
const vector<string> &flags = {});
88+
const std::vector<std::string> &flags = {});
9189

9290
/**
9391
* @brief Builds source file with default compilation flags.
@@ -101,7 +99,7 @@ class KleeGenerator {
10199
*/
102100
Result<fs::path> defaultBuild(const fs::path &sourceFilePath,
103101
const fs::path &buildDirPath = "",
104-
const vector<string> &flags = {});
102+
const std::vector<std::string> &flags = {});
105103

106104
/**
107105
* @brief Writes temporary Klee files and builds them.
@@ -115,8 +113,8 @@ class KleeGenerator {
115113
* @return Vector of paths to built binary files.
116114
* @throws ExecutionProcessException if a Clang call returns non-zero code.
117115
*/
118-
vector<fs::path> buildKleeFiles(const TestsMap &testsMap,
119-
const std::shared_ptr<LineInfo> &lineInfo);
116+
std::vector<fs::path> buildKleeFiles(const TestsMap &testsMap,
117+
const std::shared_ptr<LineInfo> &lineInfo);
120118

121119
/**
122120
* @brief Parse JSON chunks into final tests code.
@@ -129,8 +127,8 @@ class KleeGenerator {
129127
*/
130128
void
131129
parseKTestsToFinalCode(tests::Tests &tests,
132-
const std::unordered_map<string, types::Type> &methodNameToReturnTypeMap,
133-
const vector<MethodKtests> &kleeOutput,
130+
const std::unordered_map<std::string, types::Type> &methodNameToReturnTypeMap,
131+
const std::vector<MethodKtests> &kleeOutput,
134132
const std::shared_ptr<LineInfo> &lineInfo = nullptr,
135133
bool verbose = false);
136134

@@ -152,9 +150,9 @@ class KleeGenerator {
152150
std::optional<utbot::CompileCommand>
153151
getCompileCommandForKlee(const fs::path &hintPath,
154152
const CollectionUtils::FileSet &stubSources,
155-
const vector<string> &flags) const;
153+
const std::vector<std::string> &flags) const;
156154

157-
vector<utbot::CompileCommand>
155+
std::vector<utbot::CompileCommand>
158156
getCompileCommandsForKlee(const CollectionUtils::MapFileTo<fs::path> &filesToBuild,
159157
const CollectionUtils::FileSet &stubSources) const;
160158

server/src/KleeRunner.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ KleeRunner::KleeRunner(utbot::ProjectContext projectContext,
3030
void KleeRunner::runKlee(const std::vector<tests::TestMethod> &testMethods,
3131
tests::TestsMap &testsMap,
3232
const std::shared_ptr<KleeGenerator> &generator,
33-
const std::unordered_map<string, types::Type> &methodNameToReturnTypeMap,
33+
const std::unordered_map<std::string, types::Type> &methodNameToReturnTypeMap,
3434
const std::shared_ptr<LineInfo> &lineInfo,
3535
TestsWriter *testsWriter,
3636
bool isBatched,
@@ -137,11 +137,11 @@ void KleeRunner::processBatchWithoutInteractive(MethodKtests &ktestChunk,
137137
LOG_S(WARNING) << message;
138138
}
139139

140-
string entryPoint = KleeUtils::entryPointFunction(tests, testMethod.methodName, true);
141-
string entryPointFlag = StringUtils::stringFormat("--entry-point=%s", entryPoint);
140+
std::string entryPoint = KleeUtils::entryPointFunction(tests, testMethod.methodName, true);
141+
std::string entryPointFlag = StringUtils::stringFormat("--entry-point=%s", entryPoint);
142142
auto kleeOut = getKleeMethodOutFile(testMethod);
143143
fs::create_directories(kleeOut.parent_path());
144-
string outputDir = "--output-dir=" + kleeOut.string();
144+
std::string outputDir = "--output-dir=" + kleeOut.string();
145145
std::vector<std::string> argvData = { "klee",
146146
entryPointFlag,
147147
"--libc=klee",
@@ -249,8 +249,8 @@ void KleeRunner::processBatchWithInteractive(const std::vector<tests::TestMethod
249249
}
250250

251251
TestMethod testMethod = testMethods[0];
252-
string entryPoint = KleeUtils::entryPointFunction(tests, testMethod.methodName, true);
253-
string entryPointFlag = StringUtils::stringFormat("--entry-point=%s", entryPoint);
252+
std::string entryPoint = KleeUtils::entryPointFunction(tests, testMethod.methodName, true);
253+
std::string entryPointFlag = StringUtils::stringFormat("--entry-point=%s", entryPoint);
254254
auto kleeOut = getKleeMethodOutFile(testMethod);
255255
fs::create_directories(kleeOut.parent_path());
256256

server/src/KleeRunner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class KleeRunner {
3434
void runKlee(const std::vector<tests::TestMethod> &testMethods,
3535
tests::TestsMap &testsMap,
3636
const std::shared_ptr<KleeGenerator>& generator,
37-
const std::unordered_map<string, types::Type> &methodNameToReturnTypeMap,
37+
const std::unordered_map<std::string, types::Type> &methodNameToReturnTypeMap,
3838
const std::shared_ptr<LineInfo> &lineInfo,
3939
TestsWriter *testsWriter,
4040
bool isBatched,

0 commit comments

Comments
 (0)