From: Ted Kremenek Date: Tue, 18 Mar 2008 21:00:57 +0000 (+0000) Subject: Bug fix in RewriteBuffer::getMappedOffset: potentially multiple deltas X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88ad97f17790b753e2e113b149d7f164e42fa2ba;p=clang Bug fix in RewriteBuffer::getMappedOffset: potentially multiple deltas need to be skipped over when AfterInserts == true, as multiple deltas may share the same FileLoc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48503 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Rewrite/Rewriter.cpp b/lib/Rewrite/Rewriter.cpp index 440d1d39fd..e3cc977bea 100644 --- a/lib/Rewrite/Rewriter.cpp +++ b/lib/Rewrite/Rewriter.cpp @@ -32,10 +32,12 @@ unsigned RewriteBuffer::getMappedOffset(unsigned OrigOffset, for (; DeltaIdx != Deltas.size() && Deltas[DeltaIdx].FileLoc < OrigOffset; ++DeltaIdx) ResultOffset += Deltas[DeltaIdx].Delta; - - if (AfterInserts && DeltaIdx != Deltas.size() && - OrigOffset == Deltas[DeltaIdx].FileLoc) - ResultOffset += Deltas[DeltaIdx].Delta; + + if (AfterInserts) + for (; DeltaIdx != Deltas.size() && + OrigOffset == Deltas[DeltaIdx].FileLoc; ++DeltaIdx) + ResultOffset += Deltas[DeltaIdx].Delta; + return ResultOffset; }