summaryrefslogtreecommitdiff
path: root/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-08-28 17:28:16 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-08-28 17:28:16 +0000
commit980879e618d32f7516aa3bbf1ee084b06e52d0ef (patch)
treeb0277884dbaf6ab21572d5867b57715722122a3c /lib/IR/DebugInfo.cpp
parentcfe7a7c7e3846aa5548cb9cbcbd8fbf5c9c0b751 (diff)
downloadllvm-980879e618d32f7516aa3bbf1ee084b06e52d0ef.tar.gz
llvm-980879e618d32f7516aa3bbf1ee084b06e52d0ef.tar.bz2
llvm-980879e618d32f7516aa3bbf1ee084b06e52d0ef.tar.xz
PR16995: DebugInfo: Don't overwrite existing member lists when adding template arguments
With the added debug assertions this fix is covered by existing Clang tests. (& found some other issues, also fixed) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189495 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/DebugInfo.cpp')
-rw-r--r--lib/IR/DebugInfo.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp
index 8fad393e5a..8e062a0325 100644
--- a/lib/IR/DebugInfo.cpp
+++ b/lib/IR/DebugInfo.cpp
@@ -655,7 +655,24 @@ void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) {
"If you're setting the template parameters this should include a slot "
"for that!");
TrackingVH<MDNode> N(*this);
- N->replaceOperandWith(10, Elements);
+ if (Elements) {
+#ifndef NDEBUG
+ // Check that we're not dropping any elements on the floor here
+ if (const MDNode *El = cast_or_null<MDNode>(N->getOperand(10))) {
+ for (unsigned i = 0; i != El->getNumOperands(); ++i) {
+ if (i == 0 && isa<ConstantInt>(El->getOperand(i)))
+ continue;
+ const MDNode *E = cast<MDNode>(El->getOperand(i));
+ bool found = false;
+ for (unsigned j = 0; !found && j != Elements.getNumElements(); ++j) {
+ found = E == Elements.getElement(j);
+ }
+ assert(found && "Losing a member during member list replacement");
+ }
+ }
+#endif
+ N->replaceOperandWith(10, Elements);
+ }
if (TParams)
N->replaceOperandWith(13, TParams);
DbgNode = N;