Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] How to find the declaring parent of an IVariable ?

On Thu, May 21, 2009 at 9:45 PM, manivannan_pk <manivannanp_k@xxxxxxxxxxx> wrote:

Suppose I have an IBinding which is an instance of IVariable. How do I find
which entity declares it ?

IVariable.getOwner() returns the binding containing the variable. 


- For a local variable or a formal parameter, the declaring parent is an
- For a global variable, the declaring parent is an IASTTranslationUnit
- For an IField, the declaring parent is an IASTCompositeTypeSpecifier

The most important thing to understand is relationship between IName and IBinding. IName represents a particular occurrence of a symbol. IBinding represents the underlying entity behind the symbol. For example:
class A {
  void m();  // m is an IName

void A::m() {  // m is another IName

Both, declaration and definition of method m belong to a single binding. The owner of m is the binding that represents class A.



View this message in context:
Sent from the Eclipse CDT - Development mailing list archive at

cdt-dev mailing list

Back to the top