[LoopUtils] Add asserts to findStringMetadataForLoop. NFC

These ensure that operand array has at least one element and it is the
self-reference.

llvm-svn: 267015
This commit is contained in:
Adam Nemet 2016-04-21 17:33:20 +00:00
parent 963341c872
commit 293be666eb
1 changed files with 5 additions and 0 deletions

View File

@ -830,6 +830,11 @@ bool llvm::findStringMetadataForLoop(Loop *TheLoop, StringRef Name) {
// Return false if LoopID is false.
if (!LoopID)
return false;
// First operand should refer to the loop id itself.
assert(LoopID->getNumOperands() > 0 && "requires at least one operand");
assert(LoopID->getOperand(0) == LoopID && "invalid loop id");
// Iterate over LoopID operands and look for MDString Metadata
for (unsigned i = 1, e = LoopID->getNumOperands(); i < e; ++i) {
MDNode *MD = dyn_cast<MDNode>(LoopID->getOperand(i));