summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-04-23 18:46:53 +0000
committerNico Weber <nicolasweber@gmx.de>2019-04-23 18:46:53 +0000
commit6967da8ffafe094507b153a93c607b95f2ab22a6 (patch)
treed53c7b223908c9a0d9b46ca1f6456d2d2b56afed /llvm/lib/Object
parent433eecadeef854782e8f789940bb35682ef7857e (diff)
downloadbcm5719-llvm-6967da8ffafe094507b153a93c607b95f2ab22a6.tar.gz
bcm5719-llvm-6967da8ffafe094507b153a93c607b95f2ab22a6.zip
llvm-cvtres: Split addChild(ID) into two functions
Before, there was an IsData parameter. Now, there are two different functions for data nodes and ID nodes. No behavior change, needed for a follow-up change to make two data nodes (but not two ID nodes) with the same ID an error. For consistency, rename another addChild() overload to addNameChild(). llvm-svn: 359024
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r--llvm/lib/Object/WindowsResource.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/llvm/lib/Object/WindowsResource.cpp b/llvm/lib/Object/WindowsResource.cpp
index 53fe4d5e280..2195a619605 100644
--- a/llvm/lib/Object/WindowsResource.cpp
+++ b/llvm/lib/Object/WindowsResource.cpp
@@ -214,35 +214,45 @@ WindowsResourceParser::TreeNode &
WindowsResourceParser::TreeNode::addTypeNode(const ResourceEntryRef &Entry,
bool &IsNewTypeString) {
if (Entry.checkTypeString())
- return addChild(Entry.getTypeString(), IsNewTypeString);
+ return addNameChild(Entry.getTypeString(), IsNewTypeString);
else
- return addChild(Entry.getTypeID());
+ return addIDChild(Entry.getTypeID());
}
WindowsResourceParser::TreeNode &
WindowsResourceParser::TreeNode::addNameNode(const ResourceEntryRef &Entry,
bool &IsNewNameString) {
if (Entry.checkNameString())
- return addChild(Entry.getNameString(), IsNewNameString);
+ return addNameChild(Entry.getNameString(), IsNewNameString);
else
- return addChild(Entry.getNameID());
+ return addIDChild(Entry.getNameID());
}
WindowsResourceParser::TreeNode &
WindowsResourceParser::TreeNode::addLanguageNode(
const ResourceEntryRef &Entry) {
- return addChild(Entry.getLanguage(), true, Entry.getMajorVersion(),
- Entry.getMinorVersion(), Entry.getCharacteristics());
+ return addDataChild(Entry.getLanguage(), Entry.getMajorVersion(),
+ Entry.getMinorVersion(), Entry.getCharacteristics());
}
-WindowsResourceParser::TreeNode &WindowsResourceParser::TreeNode::addChild(
- uint32_t ID, bool IsDataNode, uint16_t MajorVersion, uint16_t MinorVersion,
+WindowsResourceParser::TreeNode &WindowsResourceParser::TreeNode::addDataChild(
+ uint32_t ID, uint16_t MajorVersion, uint16_t MinorVersion,
uint32_t Characteristics) {
auto Child = IDChildren.find(ID);
if (Child == IDChildren.end()) {
- auto NewChild =
- IsDataNode ? createDataNode(MajorVersion, MinorVersion, Characteristics)
- : createIDNode();
+ auto NewChild = createDataNode(MajorVersion, MinorVersion, Characteristics);
+ WindowsResourceParser::TreeNode &Node = *NewChild;
+ IDChildren.emplace(ID, std::move(NewChild));
+ return Node;
+ } else
+ return *(Child->second);
+}
+
+WindowsResourceParser::TreeNode &WindowsResourceParser::TreeNode::addIDChild(
+ uint32_t ID) {
+ auto Child = IDChildren.find(ID);
+ if (Child == IDChildren.end()) {
+ auto NewChild = createIDNode();
WindowsResourceParser::TreeNode &Node = *NewChild;
IDChildren.emplace(ID, std::move(NewChild));
return Node;
@@ -251,8 +261,8 @@ WindowsResourceParser::TreeNode &WindowsResourceParser::TreeNode::addChild(
}
WindowsResourceParser::TreeNode &
-WindowsResourceParser::TreeNode::addChild(ArrayRef<UTF16> NameRef,
- bool &IsNewString) {
+WindowsResourceParser::TreeNode::addNameChild(ArrayRef<UTF16> NameRef,
+ bool &IsNewString) {
std::string NameString;
ArrayRef<UTF16> CorrectedName;
std::vector<UTF16> EndianCorrectedName;
OpenPOWER on IntegriCloud