Hello Dehao,

Dehao Chen <de...@google.com> a écrit:

> This patch fixes the bug that when include a header file, if the
> header file is already included (with #define _HEADER_H_), libcpp
> should not decrease its highest_location, otherwise it'll cause
> incorrect source location when source location numbers are large
> enough to omit columns.

Just for my education, could you please explain why decreasing
pfile->line_table->highest_location here would incur incorrect source
location *when* location numbers are so large that we emit column
numbers?  As the patch lacks a test case, I cannot e.g, run this in a
debugger to understand precisely what you mean.  Thus it'd be helpful
for me to understand what code spots are involved exactly under the
conditions you are seeing.

I am CC-ing Tom for this as well.

Thanks.

[...]

> 2013-05-31  Dehao Chen  <de...@google.com>
>
>         * files.c (_cpp_stack_include): Fix the highest_location when header
>         file is guarded by #ifndef and is included twice.
>
>
> Index: libcpp/files.c
> ===================================================================
> --- libcpp/files.c (revision 199416)
> +++ libcpp/files.c (working copy)
> @@ -1002,7 +1002,8 @@ _cpp_stack_include (cpp_reader *pfile, const char
>       linemap_add is not called) or we were included from the
>       command-line.  */
>    if (file->pchname == NULL && file->err_no == 0
> -      && type != IT_CMDLINE && type != IT_DEFAULT)
> +      && type != IT_CMDLINE && type != IT_DEFAULT
> +      && !(file->cmacro && file->cmacro->type == NT_MACRO))
>      pfile->line_table->highest_location--;
>
>    return _cpp_stack_file (pfile, file, type == IT_IMPORT);

-- 
                Dodji

Reply via email to