List Info

Thread: Re: Re: cp-name-parser.y




Re: Re: cp-name-parser.y
user name
2008-03-03 11:01:52
Daniel Jacobowitz wrote:
> On Fri, Feb 29, 2008 at 02:49:25PM -0500, Aleksandar
Ristovski wrote:
>> Daniel Jacobowitz wrote:
>>> On Fri, Feb 29, 2008 at 02:09:13PM -0500,
Aleksandar Ristovski wrote:
>>>> I am looking at that since right now
something like this:
>>>>
>>>> -var-create - * "(anonymous
namespace)::foobar"
>>>>
> 
> Yes, we could take the unique string from the mangled
name and call it
> (anonymous namespace _MESS_OF_GARBAGE)::foobar, and
then recognize
> that syntax when we parse expressions.
I think _MESS_OF_GARBAGE is already sufficient, without
combining it with 
'(anonymous namespace)'. _MESS_OF_GARBAGE is used only if
print demangle is off. 
For MI interface, it should (almost always?) be the case.

When '(anonymous namespace)' is used, since it could be any
anonymous namespace, 
it is not sufficient to uniquely identify a symbol and
therefore we can only use 
this form if there is a valid frame that will give it a
context.

In either case, I see nothing wrong with the way it is
printed out, I see the 
problem with parsing either of the forms: _MESS_OF_GARBAGE
and '(anonymous 
namespace)'. The first can not be parsed due to '.' in it
and the latter due to 
'(anonymous namespace)'.

> 
> I don't know how the existing anonymous namespace code
works.  It was
> David Carlton's work and I wasn't following it at the
time.  We need
> them internally, to get bare lookup right, but maybe we
should not
> display them to the user - just call the type
"foobar".
I think it's ok the way it works now - makes it clear where
it comes from.
> 
> If we do that, though, what if there are multiple types
named foobar?
> Completely legal C++.  Well, no worse than the problem
we have in C
> anyway - so maybe that's the change we should make.
> 

> 
> We could recognize
> that things with (anonymous namespace) in them are the
names of C++
> symbols in c-exp.y.
> 
Or we could write new cp-exp.y for parsing mangled and
demangled names (but this 
probably overlaps with cp-name-parser)?


Re: Re: cp-name-parser.y
country flaguser name
United States
2008-03-03 11:22:17
On Mon, Mar 03, 2008 at 12:01:52PM -0500, Aleksandar
Ristovski wrote:
> Daniel Jacobowitz wrote:
>> Yes, we could take the unique string from the
mangled name and call it
>> (anonymous namespace _MESS_OF_GARBAGE)::foobar, and
then recognize
>> that syntax when we parse expressions.
> I think _MESS_OF_GARBAGE is already sufficient, without
combining it with  
> '(anonymous namespace)'. _MESS_OF_GARBAGE is used only
if print demangle 
> is off. For MI interface, it should (almost always?) be
the case.
>
> When '(anonymous namespace)' is used, since it could be
any anonymous 
> namespace, it is not sufficient to uniquely identify a
symbol and 
> therefore we can only use this form if there is a valid
frame that will 
> give it a context.
>
> In either case, I see nothing wrong with the way it is
printed out, I see 
> the problem with parsing either of the forms:
_MESS_OF_GARBAGE and 
> '(anonymous namespace)'. The first can not be parsed
due to '.' in it and 
> the latter due to '(anonymous namespace)'.

Sorry, that's not what I meant.  Any symbol is in one
particular
anonymous namespace when we print it out.  So we could print
out
which anonymous namespace it's in.

Given this:

namespace A
{
  int x;
  namespace
  {
    int y;
  }
}

using namespace A;
int foo()
{
  return x + y;
}

We get these:

drowcaradoc:~% c++filt _ZN1A1xE
A:
drowcaradoc:~% c++filt _ZN1A19_GLOBAL__N__ZN1A1xE1yE
A::(anonymous namespace)::y

That mangling is actually
"A::_GLOBAL__N__ZN1A1xE::y" according to the
ABI.  We could print out "A::(anonymous namespace
A:)::y&
quot;.

But I see that this will not work with the latest GCC which
just uses
_GLOBAL__N_1 on many platforms.

So the easiest solution may be to ignore "(anonymous
namespace)::"
during symbol lookup.

A workaround you could try would be to use quoted symbol
names.
Does this work?

-var-create - * "'(anonymous namespace)::foobar'"

-- 
Daniel Jacobowitz
CodeSourcery

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )