summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation/TraceValues.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-10-17 16:22:08 +0000
committerChris Lattner <sabre@nondot.org>2002-10-17 16:22:08 +0000
commit26783a5be58bfe4e0c6f7d6f1cc8ac69b420caea (patch)
tree53e8162bd310b4ebf1611e8fa699431490580760 /llvm/lib/Transforms/Instrumentation/TraceValues.cpp
parent981c92a9e2bb1debaf33f1e400721b675e22833c (diff)
downloadbcm5719-llvm-26783a5be58bfe4e0c6f7d6f1cc8ac69b420caea.tar.gz
bcm5719-llvm-26783a5be58bfe4e0c6f7d6f1cc8ac69b420caea.zip
* Apparently string::find doesn't work right on our sun boxes. Work around this.
llvm-svn: 4219
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/TraceValues.cpp')
-rw-r--r--llvm/lib/Transforms/Instrumentation/TraceValues.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/TraceValues.cpp b/llvm/lib/Transforms/Instrumentation/TraceValues.cpp
index 7c9d60fa204..f17932b2ebf 100644
--- a/llvm/lib/Transforms/Instrumentation/TraceValues.cpp
+++ b/llvm/lib/Transforms/Instrumentation/TraceValues.cpp
@@ -212,10 +212,15 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, Instruction *InsertBefore,
string Message,
Function *Printf, Function* HashPtrToSeqNum) {
// Escape Message by replacing all % characters with %% chars.
- unsigned Offset = 0;
- while ((Offset = Message.find('%', Offset)) != string::npos) {
- Message.replace(Offset, 1, "%%");
- Offset += 2; // Skip over the new %'s
+ string Tmp;
+ std::swap(Tmp, Message);
+ string::iterator I = std::find(Tmp.begin(), Tmp.end(), '%');
+ while (I != Tmp.end()) {
+ Message.append(Tmp.begin(), I);
+ Message += "%%";
+ ++I; // Make sure to erase the % as well...
+ Tmp.erase(Tmp.begin(), I);
+ I = std::find(Tmp.begin(), Tmp.end(), '%');
}
Module *Mod = BB->getParent()->getParent();
OpenPOWER on IntegriCloud