summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-08-28 20:42:43 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-08-28 20:42:43 +0000
commit53b833b24b0ed200ae46bee4346fd0d47800e469 (patch)
treefd45ea924ab8d871c6374fc6a82b2b82fa8cdb25 /llvm/lib/IR/DebugInfo.cpp
parent2afb63c0010ae69eefb34ce5926dcec21934e394 (diff)
downloadbcm5719-llvm-53b833b24b0ed200ae46bee4346fd0d47800e469.tar.gz
bcm5719-llvm-53b833b24b0ed200ae46bee4346fd0d47800e469.zip
r189495: Pull out some debug logic into a function for legibility
Code review feedback from Eric Christopher. llvm-svn: 189512
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 8e062a03257..416b7d19821 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -649,6 +649,21 @@ MDString *DICompositeType::getIdentifier() const {
return cast_or_null<MDString>(getField(DbgNode, 14));
}
+#ifndef NDEBUG
+static void VerifySubsetOf(const MDNode *LHS, const MDNode *RHS) {
+ for (unsigned i = 0; i != LHS->getNumOperands(); ++i) {
+ // Skip the 'empty' list (that's a single i32 0, rather than truly empty)
+ if (i == 0 && isa<ConstantInt>(LHS->getOperand(i)))
+ continue;
+ const MDNode *E = cast<MDNode>(LHS->getOperand(i));
+ bool found = false;
+ for (unsigned j = 0; !found && j != RHS->getNumOperands(); ++j)
+ found = E == RHS->getOperand(j);
+ assert(found && "Losing a member during member list replacement");
+ }
+}
+#endif
+
/// \brief Set the array of member DITypes.
void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) {
assert((!TParams || DbgNode->getNumOperands() == 15) &&
@@ -657,19 +672,9 @@ void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) {
TrackingVH<MDNode> N(*this);
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");
- }
- }
+ // Check that the new list of members contains all the old members as well
+ if (const MDNode *El = cast_or_null<MDNode>(N->getOperand(10)))
+ VerifySubsetOf(El, Elements);
#endif
N->replaceOperandWith(10, Elements);
}
OpenPOWER on IntegriCloud