StringRef Iterator Variable Display

I want to display the variable names in stringref iterator. But it is not displayed using following code.

for (set::iterator sit = L.begin(); sit != L.end(); sit++) {

errs() << *sit << " ";

How to do this?
Please help…

Does the code compile and execute? If so, I guess the strings in your
set are empty/zero-length.

Oh, sorry, adding the mailing list back (since I don't know if/how to
get the numbers) - perhaps someone else can suggest how to do that.

I'd go and look at how the IR AsmPrinter does this, if I were trying
to figure it out.

Assuming you have an `Instruction *` or a `Value *`, you probably want
`X->printAsOperand(errs(), /*PrintType=*/false)` or so.

David Blaikie via llvm-dev <> writes:

it is working fine for alphabetic labels…but numeric labels are not displayed by stringref.

what is the issue?
please help…

PrintAsOperand works on a Value object. You tried to call it on a StringRef. You need to change the set to use std::string instead of StringRef and call printAsOperand when you put data into the set.