[LLVMdev] Little question about Stringref

Hanbing Li hanbing.li at inria.fr
Tue Apr 22 09:55:04 PDT 2014


Hi, 

I tried to get the name of function+loop, so I write a small function as following: 



StringRef getStringofFL(const Function * F, const Loop * L){ 
StringRef sr; 
std::string s1 = F->getName(); 
std::string s2 = L->getHeader()->getName(); 
sr = s1+s2; 
return sr; 
} 




However, two questions came: 

1, if I output sr like: errs() << sr; it's ok (for instance: mainfor.cond ), but when I called this function and got the StringRef: StringRef s= getStringofFL(F, L); errs() << s; the result is: m\275[\377\177\000\0002\354\333\004\001, why? 

2, I used the StringMap, and the StringRef got from the function getStringofFL as a key. Then I stored something into this StringMap, but I couldn't get it with the same function and loop. why? 







Thank you! 




Hanbing 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140422/4df01ca5/attachment.html>


More information about the llvm-dev mailing list