- auto IterBool = LexicalScopeMap.insert(std::make_pair(InlinedAt, std::unique_ptr<LexicalScope>()));
- auto &MapValue = *IterBool.first;
- if (!IterBool.second)
- return MapValue.second.get();
-
- DebugLoc InlinedLoc = DebugLoc::getFromDILocation(InlinedAt);
- MapValue.second = make_unique<LexicalScope>(getOrCreateLexicalScope(InlinedLoc),
- DIDescriptor(Scope), InlinedAt, false);
- InlinedLexicalScopeMap[InlinedLoc] = MapValue.second.get();
- return MapValue.second.get();
+ std::pair<const MDNode*, const MDNode*> P(ScopeNode, InlinedAt);
+ auto I = InlinedLexicalScopeMap.find(P);
+ if (I != InlinedLexicalScopeMap.end())
+ return &I->second;
+
+ LexicalScope *Parent;
+ DILexicalBlock Scope(ScopeNode);
+ if (Scope.isSubprogram())
+ Parent = getOrCreateLexicalScope(DebugLoc::getFromDILocation(InlinedAt));
+ else
+ Parent = getOrCreateInlinedScope(Scope.getContext(), InlinedAt);
+
+ // FIXME: Use forward_as_tuple instead of make_tuple, once MSVC2012
+ // compatibility is no longer required.
+ I = InlinedLexicalScopeMap.emplace(std::piecewise_construct,
+ std::make_tuple(P),
+ std::make_tuple(Parent, Scope, InlinedAt,
+ false)).first;
+ return &I->second;