Skip to content

[4.0][Serialization] Simplify some code, tentatively fixing rdar://31888443 #9115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/Serialization/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3805,7 +3805,7 @@ class YamlGroupInputParser {
static llvm::StringMap<pFileNameToGroupNameMap> AllMaps;

bool parseRoot(FileNameToGroupNameMap &Map, llvm::yaml::Node *Root,
const llvm::Twine &ParentName) {
StringRef ParentName) {
llvm::yaml::MappingNode *MapNode = dyn_cast<llvm::yaml::MappingNode>(Root);
if (!MapNode) {
return true;
Expand All @@ -3819,14 +3819,13 @@ class YamlGroupInputParser {
}
llvm::SmallString<16> GroupNameStorage;
StringRef GroupName = Key->getValue(GroupNameStorage);
std::unique_ptr<llvm::Twine> pCombined;
if (!ParentName.isTriviallyEmpty()) {
pCombined.reset(new llvm::Twine(ParentName.concat(Separator).
concat(GroupName)));
std::string CombinedName;
if (!ParentName.empty()) {
CombinedName = (llvm::Twine(ParentName) + Separator + GroupName).str();
} else {
pCombined.reset(new llvm::Twine(GroupName));
CombinedName = GroupName;
}
std::string CombinedName = pCombined->str();

for (llvm::yaml::Node &Entry : *Value) {
if (auto *FileEntry= dyn_cast<llvm::yaml::ScalarNode>(&Entry)) {
llvm::SmallString<16> FileNameStorage;
Expand All @@ -3837,7 +3836,7 @@ class YamlGroupInputParser {
GroupNameAndFileName.append(llvm::sys::path::stem(FileName));
Map[FileName] = GroupNameAndFileName.str();
} else if (Entry.getType() == llvm::yaml::Node::NodeKind::NK_Mapping) {
if (parseRoot(Map, &Entry, *pCombined))
if (parseRoot(Map, &Entry, CombinedName))
return true;
} else
return true;
Expand Down Expand Up @@ -3886,7 +3885,8 @@ class YamlGroupInputParser {
return true;
}
pFileNameToGroupNameMap pMap(new FileNameToGroupNameMap());
if (parseRoot(*pMap, Root, llvm::Twine()))
std::string Empty;
if (parseRoot(*pMap, Root, Empty))
return true;

// Save the parsed map to the owner.
Expand Down