Changes in directory llvm/lib/VMCore:
Constants.cpp updated: 1.146 -> 1.147 --- Log message: Added a parameter to control whether Constant::getStringValue() would chop off the result string at the first null terminator. --- Diffs of the changes: (+8 -4) Constants.cpp | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.146 llvm/lib/VMCore/Constants.cpp:1.147 --- llvm/lib/VMCore/Constants.cpp:1.146 Wed Mar 8 12:11:07 2006 +++ llvm/lib/VMCore/Constants.cpp Fri Mar 10 17:52:03 2006 @@ -1715,8 +1715,10 @@ /// getStringValue - Turn an LLVM constant pointer that eventually points to a /// global into a string value. Return an empty string if we can't do it. +/// Parameter Chop determines if the result is chopped at the first null +/// terminator. /// -std::string Constant::getStringValue(unsigned Offset) { +std::string Constant::getStringValue(bool Chop, unsigned Offset) { if (GlobalVariable *GV = dyn_cast<GlobalVariable>(this)) { if (GV->hasInitializer() && isa<ConstantArray>(GV->getInitializer())) { ConstantArray *Init = cast<ConstantArray>(GV->getInitializer()); @@ -1727,9 +1729,11 @@ Result.erase(Result.begin(), Result.begin()+Offset); // Take off the null terminator, and any string fragments after it. - std::string::size_type NullPos = Result.find_first_of((char)0); - if (NullPos != std::string::npos) - Result.erase(Result.begin()+NullPos, Result.end()); + if (Chop) { + std::string::size_type NullPos = Result.find_first_of((char)0); + if (NullPos != std::string::npos) + Result.erase(Result.begin()+NullPos, Result.end()); + } return Result; } } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits