Skip to content

Commit e2060ee

Browse files
committed
fix: update clang-tidy checks for potential issues in control flow passes
1 parent d1e8da1 commit e2060ee

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ Checks: >
22
-*,
33
bugprone-*,
44
clang-analyzer-*,
5+
-clang-analyzer-security.ArrayBound,
6+
-clang-analyzer-optin.core.EnumCastOutOfRange,
57
modernize-*,
68
performance-*,
79
readability-*,

passes/src/PassPlugin.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,24 @@ using namespace llvm;
66
using namespace obfuscator;
77

88
static BasicBlockFission parseBBFissionParams(StringRef Params) {
9-
unsigned Junk = 2, Max = 64, Split = 1;
9+
unsigned Junk = 2;
10+
unsigned Max = 64;
11+
unsigned Split = 1;
1012
while (!Params.empty()) {
11-
StringRef Token;
12-
std::tie(Token, Params) = Params.split(';');
13-
StringRef K, V;
14-
std::tie(K, V) = Token.split('=');
15-
if (K == "junk") V.getAsInteger(10, Junk);
16-
else if (K == "max") V.getAsInteger(10, Max);
17-
else if (K == "split") V.getAsInteger(10, Split);
13+
auto [Token, Rest] = Params.split(';');
14+
Params = Rest;
15+
auto [K, V] = Token.split('=');
16+
if (K == "junk") {
17+
V.getAsInteger(10, Junk);
18+
} else if (K == "max") {
19+
V.getAsInteger(10, Max);
20+
} else if (K == "split") {
21+
V.getAsInteger(10, Split);
22+
}
23+
}
24+
if (Split == 0) {
25+
Split = 1;
1826
}
19-
if (Split == 0) Split = 1;
2027
return {Junk, Max, Split};
2128
}
2229

@@ -54,8 +61,9 @@ llvm::PassPluginLibraryInfo getObfuscatorPluginInfo() {
5461
}
5562
if (Name == "bbfission" || Name.starts_with("bbfission<")) {
5663
StringRef Params;
57-
if (Name.starts_with("bbfission<") && Name.ends_with(">"))
64+
if (Name.starts_with("bbfission<") && Name.ends_with(">")) {
5865
Params = Name.slice(10, Name.size() - 1);
66+
}
5967
FPM.addPass(parseBBFissionParams(Params));
6068
return true;
6169
}

0 commit comments

Comments
 (0)