Skip to content

Commit d7df6fe

Browse files
authored
Merge pull request #478 from secure-software-engineering/f-ClangTidyFixMisc22
clang-tidy: fixes for remaining files
2 parents 49989f4 + 82f2a21 commit d7df6fe

3 files changed

Lines changed: 40 additions & 37 deletions

File tree

lib/Controller/AnalysisController.cpp

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,18 @@ void AnalysisController::executeVariational() {}
130130

131131
void AnalysisController::executeWholeProgram() {
132132
size_t ConfigIdx = 0;
133-
for (auto _DataFlowAnalysis : DataFlowAnalyses) {
133+
for (const auto &DFA : DataFlowAnalyses) {
134134
std::string AnalysisConfigPath =
135135
(ConfigIdx < AnalysisConfigs.size()) ? AnalysisConfigs[ConfigIdx] : "";
136-
if (std::holds_alternative<DataFlowAnalysisType>(_DataFlowAnalysis)) {
137-
auto getTaintConfig = [&]() {
138-
if (!AnalysisConfigPath.empty()) {
139-
return TaintConfig(IRDB, parseTaintConfig(AnalysisConfigPath));
140-
}
141-
return TaintConfig(IRDB);
142-
};
143-
auto DataFlowAnalysis = std::get<DataFlowAnalysisType>(_DataFlowAnalysis);
136+
if (std::holds_alternative<DataFlowAnalysisType>(DFA)) {
137+
auto getTaintConfig // NOLINT
138+
= [&]() {
139+
if (!AnalysisConfigPath.empty()) {
140+
return TaintConfig(IRDB, parseTaintConfig(AnalysisConfigPath));
141+
}
142+
return TaintConfig(IRDB);
143+
};
144+
auto DataFlowAnalysis = std::get<DataFlowAnalysisType>(DFA);
144145
switch (DataFlowAnalysis) {
145146
case DataFlowAnalysisType::IFDSUninitializedVariables: {
146147
WholeProgramAnalysis<IFDSSolver_P<IFDSUninitializedVariables>,
@@ -295,34 +296,30 @@ void AnalysisController::executeWholeProgram() {
295296
default:
296297
break;
297298
}
298-
} else if (std::holds_alternative<IFDSPluginConstructor>(
299-
_DataFlowAnalysis)) {
300-
auto Problem = std::get<IFDSPluginConstructor>(_DataFlowAnalysis)(
301-
&IRDB, &TH, &ICF, &PT, EntryPoints);
299+
} else if (std::holds_alternative<IFDSPluginConstructor>(DFA)) {
300+
auto Problem = std::get<IFDSPluginConstructor>(DFA)(&IRDB, &TH, &ICF, &PT,
301+
EntryPoints);
302302
IFDSSolver_P<std::remove_reference<decltype(*Problem)>::type> Solver(
303303
*Problem);
304304
Solver.solve();
305305
emitRequestedDataFlowResults(Solver);
306-
} else if (std::holds_alternative<IDEPluginConstructor>(
307-
_DataFlowAnalysis)) {
308-
auto Problem = std::get<IDEPluginConstructor>(_DataFlowAnalysis)(
309-
&IRDB, &TH, &ICF, &PT, EntryPoints);
306+
} else if (std::holds_alternative<IDEPluginConstructor>(DFA)) {
307+
auto Problem = std::get<IDEPluginConstructor>(DFA)(&IRDB, &TH, &ICF, &PT,
308+
EntryPoints);
310309
IDESolver_P<std::remove_reference<decltype(*Problem)>::type> Solver(
311310
*Problem);
312311
Solver.solve();
313312
emitRequestedDataFlowResults(Solver);
314-
} else if (std::holds_alternative<IntraMonoPluginConstructor>(
315-
_DataFlowAnalysis)) {
313+
} else if (std::holds_alternative<IntraMonoPluginConstructor>(DFA)) {
316314

317-
auto Problem = std::get<IntraMonoPluginConstructor>(_DataFlowAnalysis)(
315+
auto Problem = std::get<IntraMonoPluginConstructor>(DFA)(
318316
&IRDB, &TH, &ICF, &PT, EntryPoints);
319317
IntraMonoSolver_P<std::remove_reference<decltype(*Problem)>::type> Solver(
320318
*Problem);
321319
Solver.solve();
322320
emitRequestedDataFlowResults(Solver);
323-
} else if (std::holds_alternative<InterMonoPluginConstructor>(
324-
_DataFlowAnalysis)) {
325-
auto Problem = std::get<InterMonoPluginConstructor>(_DataFlowAnalysis)(
321+
} else if (std::holds_alternative<InterMonoPluginConstructor>(DFA)) {
322+
auto Problem = std::get<InterMonoPluginConstructor>(DFA)(
326323
&IRDB, &TH, &ICF, &PT, EntryPoints);
327324
InterMonoSolver_P<std::remove_reference<decltype(*Problem)>::type, K>
328325
Solver(*Problem);

lib/DB/ProjectIRDB.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,15 @@ ProjectIRDB::getModuleDefiningFunction(const std::string &FunctionName) const {
389389
std::string ProjectIRDB::valueToPersistedString(const llvm::Value *V) {
390390
if (LLVMZeroValue::getInstance()->isLLVMZeroValue(V)) {
391391
return LLVMZeroValue::getInstance()->getName().str();
392-
} else if (const auto *I = llvm::dyn_cast<llvm::Instruction>(V)) {
392+
}
393+
if (const auto *I = llvm::dyn_cast<llvm::Instruction>(V)) {
393394
return I->getFunction()->getName().str() + "." + getMetaDataID(I);
394-
} else if (const auto *A = llvm::dyn_cast<llvm::Argument>(V)) {
395+
}
396+
if (const auto *A = llvm::dyn_cast<llvm::Argument>(V)) {
395397
return A->getParent()->getName().str() + ".f" +
396398
std::to_string(A->getArgNo());
397-
} else if (const auto *G = llvm::dyn_cast<llvm::GlobalValue>(V)) {
399+
}
400+
if (const auto *G = llvm::dyn_cast<llvm::GlobalValue>(V)) {
398401
std::cout << "special case: WE ARE AN GLOBAL VARIABLE\n";
399402
std::cout << "all user:\n";
400403
for (const auto *User : V->users()) {
@@ -403,7 +406,8 @@ std::string ProjectIRDB::valueToPersistedString(const llvm::Value *V) {
403406
}
404407
}
405408
return G->getName().str();
406-
} else if (llvm::isa<llvm::Value>(V)) {
409+
}
410+
if (llvm::isa<llvm::Value>(V)) {
407411
// In this case we should have an operand of an instruction which can be
408412
// identified by the instruction id and the operand index.
409413
std::cout << "special case: WE ARE AN OPERAND\n";
@@ -420,23 +424,25 @@ std::string ProjectIRDB::valueToPersistedString(const llvm::Value *V) {
420424
}
421425
llvm::report_fatal_error("Error: llvm::Value is of unexpected type.");
422426
return "";
423-
} else {
424-
llvm::report_fatal_error("Error: llvm::Value is of unexpected type.");
425-
return "";
426427
}
428+
llvm::report_fatal_error("Error: llvm::Value is of unexpected type.");
429+
return "";
427430
}
428431

429432
const llvm::Value *
430433
ProjectIRDB::persistedStringToValue(const std::string &S) const {
431434
if (S.find(LLVMZeroValue::getInstance()->getName()) != std::string::npos) {
432435
return LLVMZeroValue::getInstance();
433-
} else if (S.find('.') == std::string::npos) {
436+
}
437+
if (S.find('.') == std::string::npos) {
434438
return getGlobalVariableDefinition(S);
435-
} else if (S.find(".f") != std::string::npos) {
439+
}
440+
if (S.find(".f") != std::string::npos) {
436441
unsigned Argno = stoi(S.substr(S.find(".f") + 2, S.size()));
437442
return getNthFunctionArgument(
438443
getFunctionDefinition(S.substr(0, S.find(".f"))), Argno);
439-
} else if (S.find(".o.") != std::string::npos) {
444+
}
445+
if (S.find(".o.") != std::string::npos) {
440446
unsigned I = S.find('.');
441447
unsigned J = S.find(".o.");
442448
unsigned InstID = stoi(S.substr(I + 1, J));
@@ -529,7 +535,7 @@ bool ProjectIRDB::debugInfoAvailable() const {
529535
return wasCompiledWithDebugInfo(WPAModule);
530536
}
531537
// During unittests WPAMOD might not be set
532-
else if (!Modules.empty()) {
538+
if (!Modules.empty()) {
533539
for (const auto &[File, Module] : Modules) {
534540
if (!wasCompiledWithDebugInfo(Module.get())) {
535541
return false;

tools/phasar-llvm/phasar-llvm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void validateParamModule(const std::vector<std::string> &Modules) {
7979
}
8080
}
8181

82-
void validateParamExport(const std::string &Export) {
82+
void validateParamExport(const std::string & /*Export*/) {
8383
throw boost::program_options::error_with_option_name(
8484
"Parameter not supported, yet.");
8585
}
@@ -226,10 +226,10 @@ int main(int Argc, const char **Argv) {
226226
("emit-pta-as-dot", "Emit the points-to information as DOT graph")
227227
("emit-pta-as-json", "Emit the points-to information as JSON")
228228
("pamm-out,A", boost::program_options::value<std::string>()->notifier(validateParamPammOutputFile)->default_value("PAMM_data.json"), "Filename for PAMM's gathered data")
229-
229+
230230
("analysis-plugin", boost::program_options::value<std::vector<std::string>>()->notifier(&validateParamAnalysisPlugin), "Analysis plugin(s) (absolute path to the shared object file(s))")
231231
("callgraph-plugin", boost::program_options::value<std::string>()->notifier(&validateParamICFGPlugin), "ICFG plugin (absolute path to the shared object file)")
232-
232+
233233
("right-to-ludicrous-speed", "Uses ludicrous speed (shared memory parallelism) whenever possible");
234234
// clang-format on
235235
boost::program_options::options_description CmdlineOptions;

0 commit comments

Comments
 (0)