[cfe-dev] test failure in SourceManager::getLineNumber()

Daniel Dunbar daniel at zuster.org
Mon May 18 10:31:15 PDT 2009


Hi Jay,

I haven't been able to convince myself that the patch is correct (in
the 5 minutes I've taken to stare at the code). LastLineNoResult
should be a valid line number, which I would presume to be a valid
offset into Content->SourceLineCache, so the +1 seems reasonable to
me.

I'd like to chat with Chris about this code but he is gallivanting
about on vacation, so I applied what is I believe an obviously correct
patch which should fix your problem, and added some FIXMEs to the
code, here: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090518/017397.html

 - Daniel

On Mon, May 18, 2009 at 5:52 AM, Jay Foad <jay.foad at gmail.com> wrote:
> If I build with ENABLE_EXPENSIVE_CHECKS=1, I get this failure in
> Preprocessor/header_lookup1.c. The "are not partitioned" error comes
> from the fact that __last is actually pointing not to *just* past the
> end of the sorted values, but to one element further on than that.
>
> The attached patch fixes it for me, and I think it's correct, but
> there are a lot of ad hoc "+1" and "-1"s in that function that make me
> feel a bit uncomfortable (in particular maybe this one could do with a
> comment:
>
>  unsigned QueriedFilePos = FilePos+1;
>
> )
>
> Thanks,
> Jay.
>
>
> /usr/include/c++/4.3/bits/stl_algo.h:2082:error: elements in iterator range
>    [__first, __last) are not partitioned by the value __val.
>
> Objects involved in the operation:
> iterator "__first" @ 0x0xbf859830 {
> type = Pj;
> }
> iterator "__last" @ 0x0xbf859834 {
> type = Pj;
> }
> 0   clang-cc       0x091e2c4f
> 1   clang-cc       0x091e32ee
> 2                  0x4001c400 __kernel_sigreturn + 0
> 3   libc.so.6      0x4019d018 abort + 392
> 4   libstdc++.so.6 0x4009f531
> __gnu_debug::_Error_formatter::_M_error() const + 529
> 5   clang-cc       0x0827f584
> 6   clang-cc       0x085637db
> 7   clang-cc       0x085638f3
> 8   clang-cc       0x080d73d9
> 9   clang-cc       0x080d76af
> 10  clang-cc       0x080d77bc
> 11  clang-cc       0x080d7ef7
> 12  clang-cc       0x0811514c
> 13  clang-cc       0x081166ec main + 2626
> 14  libc.so.6      0x40186455 __libc_start_main + 229
> 15  clang-cc       0x08096561
> Stack dump:
> 0.      Program arguments:
> /home/foad/llvm/objdir-svn/Debug+Checks/bin/clang-cc -I /usr/include
> /home/foad/svn/llvm-project/cfe/trunk/test/Preprocessor/header_lookup1.c
> -E
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>




More information about the cfe-dev mailing list