Skip to content

Commit be61cae

Browse files
committed
review: hande extract before any removal
1 parent 2bc1450 commit be61cae

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

llvm/lib/ObjCopy/DXContainer/DXContainerObjcopy.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,7 @@ static Error extractPartAsObject(StringRef PartName, StringRef OutFilename,
4343
}
4444

4545
static Error handleArgs(const CommonConfig &Config, Object &Obj) {
46-
std::function<bool(const Part &)> RemovePred = [](const Part &) {
47-
return false;
48-
};
49-
50-
if (!Config.ToRemove.empty())
51-
RemovePred = [&Config](const Part &P) {
52-
return Config.ToRemove.matches(P.Name);
53-
};
54-
46+
// Extract all sections before any modifications.
5547
for (StringRef Flag : Config.ExtractSection) {
5648
StringRef SectionName;
5749
StringRef FileName;
@@ -61,6 +53,15 @@ static Error handleArgs(const CommonConfig &Config, Object &Obj) {
6153
return E;
6254
}
6355

56+
std::function<bool(const Part &)> RemovePred = [](const Part &) {
57+
return false;
58+
};
59+
60+
if (!Config.ToRemove.empty())
61+
RemovePred = [&Config](const Part &P) {
62+
return Config.ToRemove.matches(P.Name);
63+
};
64+
6465
if (auto E = Obj.removeParts(RemovePred))
6566
return E;
6667

0 commit comments

Comments
 (0)