Skip to content

Commit

Permalink
Fix Value dangling reference debug output
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231889 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Andrew Kaylor committed Mar 10, 2015
1 parent 4ec858e commit dd3224b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/IR/TypeFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void TypeFinder::run(const Module &M, bool onlyNamed) {
// instructions with this loop.)
for (User::const_op_iterator OI = I.op_begin(), OE = I.op_end();
OI != OE; ++OI)
if (!isa<Instruction>(OI))
if (*OI && !isa<Instruction>(OI))
incorporateValue(*OI);

// Incorporate types hiding in metadata.
Expand Down
10 changes: 4 additions & 6 deletions lib/IR/Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,13 @@ Value::~Value() {
#ifndef NDEBUG // Only in -g mode...
// Check to make sure that there are no uses of this value that are still
// around when the value is destroyed. If there are, then we have a dangling
// reference and something is wrong. This code is here to print out what is
// still being referenced. The value in question should be printed as
// a <badref>
// reference and something is wrong. This code is here to print out where
// the value is still being referenced.
//
if (!use_empty()) {
dbgs() << "While deleting: " << *VTy << " %" << getName() << "\n";
for (use_iterator I = use_begin(), E = use_end(); I != E; ++I)
dbgs() << "Use still stuck around after Def is destroyed:"
<< **I << "\n";
for (auto *U : users())
dbgs() << "Use still stuck around after Def is destroyed:" << *U << "\n";
}
#endif
assert(use_empty() && "Uses remain when a value is destroyed!");
Expand Down

0 comments on commit dd3224b

Please sign in to comment.