diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-04-30 23:46:27 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-04-30 23:46:27 +0000 |
commit | 6b71cc7bac605ef64863e7179937bbcfd1b8814b (patch) | |
tree | 3d28d90425ab8b104b0a0a2193396513dd0527c6 /llvm/lib/CodeGen | |
parent | 998dedac98a918f03c1d70d5970652db1300344a (diff) | |
download | bcm5719-llvm-6b71cc7bac605ef64863e7179937bbcfd1b8814b.tar.gz bcm5719-llvm-6b71cc7bac605ef64863e7179937bbcfd1b8814b.zip |
LexicalScopes: Use unique_ptr to manage ownership of abstract LexicalScopes.
llvm-svn: 207726
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/LexicalScopes.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/LexicalScopes.cpp b/llvm/lib/CodeGen/LexicalScopes.cpp index cdc2cb2cc56..d4f3b70995b 100644 --- a/llvm/lib/CodeGen/LexicalScopes.cpp +++ b/llvm/lib/CodeGen/LexicalScopes.cpp @@ -33,7 +33,6 @@ LexicalScopes::~LexicalScopes() { reset(); } void LexicalScopes::reset() { MF = nullptr; CurrentFnLexicalScope = nullptr; - DeleteContainerSeconds(AbstractScopeMap); InlinedLexicalScopeMap.clear(); AbstractScopesList.clear(); } @@ -194,9 +193,11 @@ LexicalScope *LexicalScopes::getOrCreateAbstractScope(const MDNode *N) { DIDescriptor Scope(N); if (Scope.isLexicalBlockFile()) Scope = DILexicalBlockFile(Scope).getScope(); - LexicalScope *AScope = AbstractScopeMap.lookup(N); - if (AScope) - return AScope; + auto IterBool = AbstractScopeMap.insert( + std::make_pair(N, std::unique_ptr<LexicalScope>())); + auto &MapEntry = *IterBool.first; + if (!IterBool.second) + return MapEntry.second.get(); LexicalScope *Parent = nullptr; if (Scope.isLexicalBlock()) { @@ -204,11 +205,11 @@ LexicalScope *LexicalScopes::getOrCreateAbstractScope(const MDNode *N) { DIDescriptor ParentDesc = DB.getContext(); Parent = getOrCreateAbstractScope(ParentDesc); } - AScope = new LexicalScope(Parent, DIDescriptor(N), nullptr, true); - AbstractScopeMap[N] = AScope; + MapEntry.second = + make_unique<LexicalScope>(Parent, DIDescriptor(N), nullptr, true); if (DIDescriptor(N).isSubprogram()) - AbstractScopesList.push_back(AScope); - return AScope; + AbstractScopesList.push_back(MapEntry.second.get()); + return MapEntry.second.get(); } /// constructScopeNest |