Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] How to figure out which function is using macro withindex only

Dmitry,
a function never uses a macro, however a macro may be used to define 
(part of) a function or mutliple functions, see my examples below. 
In general you cannot map macro expansions to function definitions. 

To figure out the relationship between a macro expansion and function
definitions you'd need to know the file-offsets of the function
definition.
This information is currently not part of the index.

Markus.

Why macro expansions don't map to function definitions:
#define TINT int
#define CALL printf
#define ENTIRE_DEF void func() {}
#define OVERLAP static int sVar; int getBla(){return sVar;} void
setBla(int x){sVar=x;}

void f1() {
   CALL("bla");  // ok, CALL is used within f1().
}
TINT f2() {}     // is TINT used within f2()??
ENTIRE_DEF       // ENTIRE_DEF is used to define func().
OVERLAP          // OVERLAP is used to define getBla(), setBla(int) and
more.



> -----Original Message-----
> From: cdt-dev-bounces@xxxxxxxxxxx 
> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Dmitry Smirnov
> Sent: Friday, October 10, 2008 9:58 AM
> To: CDT General developers list.
> Subject: [cdt-dev] How to figure out which function is using 
> macro withindex only
> Importance: Low
> 
> Hi,
> 
> Here is the problem I'm trying to resolve:
> Let's assume there is a function that uses a macro.
> I need to find out which function is using a macro with index only.
> I can get the list of all the names of particular file with 
> IIndedFile.findNames(int offset, int length).
> This list will contain the macros (PDOMMacroDefinition and
> PDOMMacroReference) at the end of the list (after all other names).
> The problem is that I cannot figure out which function uses a macro:
> - PDOMCFunction.getFunctionScope() returns null, so I cannot 
> get offset and length of the function body. I.e. I cannot use 
> IIndedFile.findNames(int offset, int length).
> - PDOMName.getEclosedNames for a function does not return any macro
> - IIndex.findReferncies() for PDOMMacro or PDOMMacroContainer 
> returns the PDOMMacroReferenceName which in turn returns 
> PDOMMacroContainer as its binding.
> 
> Is there any way to deal with this function-to-macro usage?
> 
> Dmitry
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
> 


Back to the top