[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] PDOMWriter and IncludeInformation
|
I see. I've copied this to bug 413768, we can continue there.
Thanks,
-Andrew
On 13-07-26 02:05 AM, Schorn, Markus wrote:
> Hi Andrew,
>
> The 3 includes are necessary to deal with pragma-once files that include non-pragma-once files.
>
> I try to explain:
>
>
>
> (1) Consider a non-pragma once file like stddef.h that is parsed in 2 versions. Let’s assume that version S1 contains
> what we want and version S2 is used when stddef.h gets included for the second time in the same compilation unit.
>
> (2) Consider a pragma once header file header.h that needs some declarations out of stddef.h plus an arbitrary source
> file with the following include structure:
>
> a.c
>
> |_ stddef.h (version S1)
>
> |_ header.h
>
> |_ stddef.h (version S2)
>
> |_ use declaration found in S1
>
>
>
> (3) Consider a second source file that makes use of header.h and needs some declaration out of stddef.h. However
> rather than including stddef.h it relies on the fact that header.h already includes stddef.h:
>
> b.c
>
> |_ header.h
>
> | |_ stddef.h (version S1)
>
> |_ use declaration found in S1
>
>
>
>
>
> (4) Now, when the indexer looks at b.c, it finds that header.h is pragma once and instead of parsing the file it uses
> whatever is stored in the index. Therefore, when the index would only store the inclusion header.h->stddef(S2), it would
> miss out on the declarations within stddef(S1).
>
>
>
> To overcome this problem the index needs to store <all> versions of a non-pragma once include that have been loaded
> within the translation unit before.
>