Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] empty AST macro expansions

I just tried an alternate solution using a combination of getParent and getChildren to find the previous node in the list. The idea being that I could look for the target macro at the start of my target node or the end of the previous one. I did this in the debugger to be certain that I was getting the node that I thought I was.

However, I found that it is not there either. Thinking about that a bit more, I realized that this was confirmed by the test case that I've attached to the patch:

	#define X
	#define Y void
	Y X func1();
	X Y func2();

Regardless of whether the second X expands at the end of func1 or the start of func2, there should be a total of 4 expansions. However, the test case finds only 3.

It makes sense to me that we can't tell where to associate the empty expansion, but it seems that it should go somewhere. I'm not really sure where that place would be, maybe as its own node between func1 and func2?

-Andrew

On 13-02-26 07:41 AM, Schorn, Markus wrote:
Hi Andrew,
I guess the example should read:
	#define X
	#define Y void
	Y X func1() {}
	X Y func2() {}

I do not consider this to be a bug. The first empty macro expansion clearly belongs to the function definition of 'func1'. However the second one occurs between two function definitions. Associating it with either the first or the second function-definition would be a random choice.
Markus.

-----Original Message-----
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Andrew Eidsness
Sent: Tue, 26. 02. 2013 13:07
To: cdt-dev@xxxxxxxxxxx
Subject: Re: [cdt-dev] empty AST macro expansions

I've found another problem which I think is similar to this one.  I've raised 401696 to track, but would appreciate it if someone could tell me if it actually isn't a bug.  If not then I'll find a different way to do what I'm trying to accomplish.

In this case the empty expansion is lost when it is at the start of the declarator, e.g. in,

	#define X
	#define Y void
	Y X void func1() {}
	X Y void func2() {}

Calling IASTNode.getNodeLocations on the node for func1 will return two macro expansions, but calling it for func2 will return only one.

Stepping through the code for the problem case, it looks like the expansion for X is not being associated with the node at all.  I guess that is because there isn't a way to distinguish from this case:

	Y X void func1() {} X
	  Y void func2() {}

?

-Andrew


Back to the top