Skip to content

Commit e4b452e

Browse files
committed
Better solution for review comments
1 parent 7ff7531 commit e4b452e

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

llvm/tools/sycl-post-link/ModuleSplitter.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -663,16 +663,17 @@ class FunctionsCategorizer {
663663
StringRef IfPresentStr,
664664
StringRef IfAbsentStr = "") {
665665
Rules.emplace_back(Rule::RKind::K_FlagAttribute,
666-
std::tuple{AttrName, IfPresentStr, IfAbsentStr});
666+
Rule::FlagRuleData{AttrName, IfPresentStr, IfAbsentStr});
667667
}
668668

669669
// Creates a simple rule, which adds one or another value to a resulting
670670
// identifier based on a presence of a metadata on a function.
671671
void registerSimpleFlagMetadataRule(StringRef MetadataName,
672672
StringRef IfPresentStr,
673673
StringRef IfAbsentStr = "") {
674-
Rules.emplace_back(Rule::RKind::K_FlagMetadata,
675-
std::tuple{MetadataName, IfPresentStr, IfAbsentStr});
674+
Rules.emplace_back(
675+
Rule::RKind::K_FlagMetadata,
676+
Rule::FlagRuleData{MetadataName, IfPresentStr, IfAbsentStr});
676677
}
677678

678679
// Creates a rule, which adds a list of dash-separated integers converted
@@ -689,10 +690,12 @@ class FunctionsCategorizer {
689690

690691
private:
691692
struct Rule {
692-
using TupleOfThreeStringRef = std::tuple<StringRef, StringRef, StringRef>;
693+
struct FlagRuleData {
694+
StringRef Name, IfPresentStr, IfAbsentStr;
695+
};
693696

694697
private:
695-
std::variant<StringRef, TupleOfThreeStringRef,
698+
std::variant<StringRef, FlagRuleData,
696699
std::function<std::string(Function *)>>
697700
Storage;
698701

@@ -763,12 +766,11 @@ std::string FunctionsCategorizer::computeCategoryFor(Function *F) const {
763766
} break;
764767

765768
case Rule::RKind::K_FlagMetadata: {
766-
Rule::TupleOfThreeStringRef Data =
767-
R.getStorage<Rule::RKind::K_FlagMetadata>();
768-
if (F->hasMetadata(std::get<0>(Data)))
769-
Result += std::get<1>(Data);
769+
Rule::FlagRuleData Data = R.getStorage<Rule::RKind::K_FlagMetadata>();
770+
if (F->hasMetadata(Data.Name))
771+
Result += Data.IfPresentStr;
770772
else
771-
Result += std::get<2>(Data);
773+
Result += Data.IfAbsentStr;
772774
} break;
773775

774776
case Rule::RKind::K_IntegersListMetadata: {
@@ -801,12 +803,11 @@ std::string FunctionsCategorizer::computeCategoryFor(Function *F) const {
801803
} break;
802804

803805
case Rule::RKind::K_FlagAttribute: {
804-
Rule::TupleOfThreeStringRef Data =
805-
R.getStorage<Rule::RKind::K_FlagAttribute>();
806-
if (F->hasFnAttribute(std::get<0>(Data)))
807-
Result += std::get<1>(Data);
806+
Rule::FlagRuleData Data = R.getStorage<Rule::RKind::K_FlagAttribute>();
807+
if (F->hasFnAttribute(Data.Name))
808+
Result += Data.IfPresentStr;
808809
else
809-
Result += std::get<2>(Data);
810+
Result += Data.IfAbsentStr;
810811
} break;
811812
}
812813

0 commit comments

Comments
 (0)