[cfe-dev] Name lookup in ObjC methods
Ted Kremenek
kremenek at apple.com
Wed Apr 2 08:55:34 PDT 2008
Argiris,
I've been very impressed with the work you have been doing on all of
this. It's quite impressive, and will make a great contribution to
clang. Comments inline.
On Apr 2, 2008, at 8:30 AM, Argiris Kirtzidis wrote:
> Chris Lattner wrote:
>>> -Decl class has a ContextDecl member
>>
>> Should this be in Decl, or in ScopedDecl? It doesn't make much sense
>> for struct fields (for example) to have this context pointer.
Chris: Why is that the case? For example, I can imagine cases in the
static analyzer where knowing the RecordDecl for a given structure
field could potentially be very useful, and clean some things up
nicely. Is it the cost of the extra pointer that you are worried about?
>>
>>
>>> -All Decl subclasses receive a ContextDecl at their constructors
>>
>> Sounds good, but only scopedecl if possible.
> Isn't this a bit restricting ? When NamespaceDecl is added,
> non-ScopedDecls could be under TranslationUnitDecl or a
> specific NamespaceDecl. NamespaceDecl itself makes little sense to
> be a
> ScopedDecl, but it makes sense to give it
> a context pointer to its enclosing namespace.
> Most of the non-ScopedDecls are ObjC specific but for Objective C++
> they
> will be able to use NamespaceDecl
> context pointers to, for example, get their fully qualified name.
All of this makes a lot of sense to me. I like the unifying concept
of context here, from the TranslationUnit level and down, and I like
having NamespaceDecls having an enclosing context, etc., so that one
can easily traverse the namespace hierarchy. I'm curious, how would
the following be handled:
namespace foo {
class F { public: void foo(); };
}
using namespace foo;
void F::foo() {}
What would the "ContextDecl" be for the decl representing the
definition of foo? Would it be a NamespaceDecl, or a
TranslationUnitDecl? If it is a NamespaceDecl, is it the same
NamespaceDecl as the one enclosing the class definition? I'm sorry if
this has already been discussed; I'm trying to wrap my mind around
what exactly a ContextDecl is, as it seems to represents both a
syntactic construct and a language concept.
> And if RecordDecl is made a ContextDecl (mostly useful for C++), a
> context pointer for FieldDecl would point at
> the struct/class that defined it.
This makes sense to me, and I think it would be very useful.
More information about the cfe-dev
mailing list