Hi Craig,

Looks like this caused PR14570.

On Thu, Oct 18, 2012 at 9:40 PM, Craig Topper <[email protected]> wrote:
> Author: ctopper
> Date: Thu Oct 18 23:40:38 2012
> New Revision: 166265
>
> URL: http://llvm.org/viewvc/llvm-project?rev=166265&view=rev
> Log:
> Teach getColumnNumber to use the line cache to get the start of the line if 
> its on the same line as the last call to getLineNumber. Prevents needing to 
> scan backwards for the new line. Fixes PR14106.
>
> Modified:
>     cfe/trunk/lib/Basic/SourceManager.cpp
>
> Modified: cfe/trunk/lib/Basic/SourceManager.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=166265&r1=166264&r2=166265&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Basic/SourceManager.cpp (original)
> +++ cfe/trunk/lib/Basic/SourceManager.cpp Thu Oct 18 23:40:38 2012
> @@ -1029,6 +1029,17 @@
>      return 1;
>    }
>
> +  // See if we just calculated the line number for this FilePos and can use
> +  // that to lookup the start of the line instead of searching for it.
> +  if (LastLineNoFileIDQuery == FID &&
> +      LastLineNoContentCache->SourceLineCache != 0) {
> +    unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache;
> +    unsigned LineStart = SourceLineCache[LastLineNoResult - 1];
> +    unsigned LineEnd = SourceLineCache[LastLineNoResult];
> +    if (FilePos >= LineStart && FilePos < LineEnd)
> +      return FilePos - LineStart + 1;
> +  }
> +
>    const char *Buf = MemBuf->getBufferStart();
>    unsigned LineStart = FilePos;
>    while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r')
>
>
> _______________________________________________
> cfe-commits mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to