summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TableGen/TGParser.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2014-11-30 01:20:17 +0000
committerCraig Topper <craig.topper@gmail.com>2014-11-30 01:20:17 +0000
commit4ca4001d442015b00f56abc7ccdba732b2a0b922 (patch)
treecccb9e546eeac43bb3310a13d41f69c257f8f0fe /llvm/lib/TableGen/TGParser.cpp
parent854df468fbd7139efe0188c75c361a39a0c8edd4 (diff)
downloadbcm5719-llvm-4ca4001d442015b00f56abc7ccdba732b2a0b922.tar.gz
bcm5719-llvm-4ca4001d442015b00f56abc7ccdba732b2a0b922.zip
Revert r222957 "Replace std::map<K, V*> with std::map<K, V> to handle ownership and deletion of the values."
Upon further review I think the MultiClass is being copied into the map instead of being moved due to the copy constructor on the nested Record type. This ultimately got exposed when the vector in DefPrototype vector was changed to hold unique_ptrs in another commit. This caused gcc 4.7 to fail due to the use of the copy constructor on unique_ptr with the error pointing back to one of the insert calls from this commit. Not sure why clang was able to build. This reverts commit 710cdf729f84b428bf41aa8d32dbdb35fff79fde. llvm-svn: 222971
Diffstat (limited to 'llvm/lib/TableGen/TGParser.cpp')
-rw-r--r--llvm/lib/TableGen/TGParser.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index b227de88896..4b7ccdca9b1 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -459,12 +459,12 @@ MultiClass *TGParser::ParseMultiClassID() {
return nullptr;
}
- auto it = MultiClasses.find(Lex.getCurStrVal());
- if (it == MultiClasses.end())
+ MultiClass *Result = MultiClasses[Lex.getCurStrVal()];
+ if (!Result)
TokError("Couldn't find multiclass '" + Lex.getCurStrVal() + "'");
Lex.Lex();
- return &it->second;
+ return Result;
}
/// ParseSubClassReference - Parse a reference to a subclass or to a templated
@@ -2290,13 +2290,11 @@ bool TGParser::ParseMultiClass() {
return TokError("expected identifier after multiclass for name");
std::string Name = Lex.getCurStrVal();
- auto Result =
- MultiClasses.insert(std::make_pair(Name,
- MultiClass(Name, Lex.getLoc(),Records)));
- if (!Result.second)
+ if (MultiClasses.count(Name))
return TokError("multiclass '" + Name + "' already defined");
- CurMultiClass = &Result.first->second;
+ CurMultiClass = MultiClasses[Name] = new MultiClass(Name,
+ Lex.getLoc(), Records);
Lex.Lex(); // Eat the identifier.
// If there are template args, parse them.
@@ -2557,9 +2555,8 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
// To instantiate a multiclass, we need to first get the multiclass, then
// instantiate each def contained in the multiclass with the SubClassRef
// template parameters.
- auto it = MultiClasses.find(Ref.Rec->getName());
- assert(it != MultiClasses.end() && "Didn't lookup multiclass correctly?");
- MultiClass *MC = &it->second;
+ MultiClass *MC = MultiClasses[Ref.Rec->getName()];
+ assert(MC && "Didn't lookup multiclass correctly?");
std::vector<Init*> &TemplateVals = Ref.TemplateArgs;
// Verify that the correct number of template arguments were specified.
OpenPOWER on IntegriCloud