From: Konrad Eisele <eiselekd@gmail.com>
To: Christopher Li <sparse@chrisli.org>
Cc: Konrad Eisele <konrad@gaisler.com>,
Linux-Sparse <linux-sparse@vger.kernel.org>
Subject: Re: Fwd: dependency tee from c parser entities downto token
Date: Tue, 15 May 2012 15:03:49 +0200 [thread overview]
Message-ID: <4FB25435.1030604@gmail.com> (raw)
In-Reply-To: <CANeU7QmfxzQ8xXObV+PzLBZ62Amw13dY+-9OEa2K9QLGh4eKRg@mail.gmail.com>
On 05/15/2012 11:44 AM, Christopher Li wrote:
> On Tue, May 15, 2012 at 12:52 AM, Konrad Eisele<konrad@gaisler.com> wrote:
>> The last patch with mdep.c and test-mdep.c was also nothing to
>> apply, only a work in progress to go further...
>
> OK, I mistaken that as apply request. Never mind some of the
> coding style comment then.
>
>> One thing you can see is how I propagate the token sources
>> using:
>>
>> 137: n->from = list->pos;
>> ...
>> 143: list->pos.line = id;
>> 144: list->pos.stream = pps;
>>
>> here you get an argument why it is better to have a
>> (1) ->macro_begin(a)
>> ->macro_end(b)
>> instead of only one
>> (2) expand_macro(a,b)
>> If you want to use the preprocessorhooks to output human readable macro
>> expansion history line similar to LLVM you probably want a pointer
>> to the "pre-expanded" token location, that is in (a). In (1) you can buildup
>> the token-source-paths going from post-expand buffer (b) through the
>> pre-expanded buffers (a)
>> in (2) you only have the paths going through the expanded buffers, can use
>> (a) to reason
>> about where (b) came from, but not in a simple way...
>
> At this point I think 1) is actually better for your requirement.
> I start out as hoping the expand_macro() can abstract away the
> internal implementation detail of macro expand and just give you the
> text before and after the macro expand. But with all this extra
> manipulations of the macro tokens, especially the substitute_argument()
> is clear indicate tightening into the implementation details.
>
> I would take 1) over substitute_arguments() if 1) don't need call back like
> substitute_arguments().
substitute_arguments() is because I am not allowed extra token
TOKEN_M_EMPTY. it is unrelated to the upper cases...
>
>
>> Kindof something like this:
>> #define E1
>> #define E2
>> #define S1(a) struct a { E1 int d1; };
>> #define S2(a) struct a { E2 int d2; };
>> #define xdef S1(sx) S2(sy)
>> xdef
>> main() {
>> struct sx v;
>> }
>>
>> The xdef expands in one-line to "struct sx { int d1; }; struct sy { int d1;
>> };"
>> main() only uses "struct sx". Therefore the dependency analysis should not
>> have "E2 and S2" as dependencies. I think you need the location of empty
>
> That is surprising to me. I previously have different assumptions.
> I assume you want to back trace all the way back to the source macro.
> I would just say main() depend on xdef, which depend one S1 and S2.
> S1 also depend on E1 and S2 depend on E2.
I'm not shure who is wrong here or weather maybe my example is not
general enought, maybe you are right...
>
> If you bypass xdef and directly extract S1(sx). Why can't you do one
> step further bypass S1() as well, and say main depend on "struct sx {
> E1 int d1;}?
>
> This is even more complicated than I original though.
> How about this case:
>
> #define S1(a) struct a { E1 int d1; }; E3 struct
> #define S2(a) a { E2 int d2; };
>
> The rest is the same. Now xdef will expand to the same text.
> What should main() depend on? S1, E1 and E3?
> Notice that without S2, macro expand by S1 can't compile at all.
>
>> Do you mean http://cfw.sourceforge.net/htmltag/init_32.c.pinfo.html ? This
>> is a gcc-based patch even there you need to trace empty expansion positions.
>
> Yes. Did that patch submit to gcc? I can see trace empty expansion one level.
Kind-of:-) http://gcc.gnu.org/ml/gcc/2012-03/msg00208.html
It disapears in the gcc list noise however...
> You track empty macro pass that one multiple level macro expand as well?
I dump everything, however I use a perl script to reconstruct...
>
> Chris
>
next prev parent reply other threads:[~2012-05-15 13:00 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-24 9:54 dependency tee from c parser entities downto token Konrad Eisele
2012-04-25 20:10 ` [PATCH] depend.c: build up a dependency tree from c entities downto tokens: entries in the tree are: macro-depend: tree of #if nesting macro-expansions: possible macro expansion source of a token tok->macro-expansions->macro tok->macro-depend->macro c entities are linked in via [stmt|expr|sym]->start-end-token Konrad Eisele
2012-04-30 22:58 ` dependency tee from c parser entities downto token Christopher Li
2012-05-02 7:27 ` Konrad Eisele
2012-05-03 23:52 ` Christopher Li
2012-05-04 7:33 ` Konrad Eisele
2012-05-04 9:25 ` Christopher Li
2012-05-04 10:36 ` Konrad Eisele
2012-05-04 12:36 ` Konrad Eisele
2012-05-04 15:30 ` Josh Triplett
2012-05-04 20:53 ` Konrad Eisele
2012-05-04 22:30 ` Christopher Li
2012-05-05 0:32 ` Josh Triplett
2012-05-05 8:59 ` Konrad Eisele
2012-05-05 8:56 ` Konrad Eisele
2012-05-04 18:02 ` Christopher Li
2012-05-04 21:46 ` Konrad Eisele
2012-05-04 21:56 ` Konrad Eisele
2012-05-04 23:05 ` Christopher Li
2012-05-05 8:54 ` Konrad Eisele
2012-05-05 11:12 ` Christopher Li
2012-05-05 16:59 ` Konrad Eisele
[not found] ` <CANeU7Qn7vUzLQAF6JGRECro_pPDnL7MCswkrNACe1wohLHZu7g@mail.gmail.com>
2012-05-05 19:56 ` Fwd: " Christopher Li
2012-05-05 23:38 ` Konrad Eisele
2012-05-06 18:34 ` Christopher Li
2012-05-07 6:12 ` Konrad Eisele
2012-05-07 22:06 ` Christopher Li
2012-05-08 6:38 ` Konrad Eisele
2012-05-09 9:18 ` Christopher Li
2012-05-09 9:48 ` Konrad Eisele
2012-05-09 22:50 ` Christopher Li
2012-05-10 6:19 ` Konrad Eisele
2012-05-10 6:38 ` Konrad Eisele
2012-05-10 9:37 ` Christopher Li
2012-05-10 9:51 ` Konrad Eisele
2012-05-10 11:25 ` Christopher Li
2012-05-10 12:14 ` Konrad Eisele
2012-05-10 12:28 ` Konrad Eisele
2012-05-11 19:40 ` Christopher Li
2012-05-11 21:48 ` Konrad Eisele
2012-05-12 11:02 ` Christopher Li
2012-05-12 17:46 ` Konrad Eisele
2012-05-12 17:57 ` Konrad Eisele
2012-05-13 8:52 ` Konrad Eisele
2012-05-15 6:30 ` Christopher Li
2012-05-15 7:52 ` Konrad Eisele
2012-05-15 9:44 ` Christopher Li
2012-05-15 13:03 ` Konrad Eisele [this message]
2012-05-14 10:53 ` Christopher Li
2012-05-10 9:03 ` Christopher Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FB25435.1030604@gmail.com \
--to=eiselekd@gmail.com \
--cc=konrad@gaisler.com \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).