[cfe-dev] Getting information from MemRegion

Rui Paulo rpaulo at apple.com
Mon Jun 6 21:56:44 PDT 2011


Hi,

I was using this code to get the variable name from the MemRegion, but it fails when we mix complicated pre-processor macros:

    const VarRegion *lockVR = dyn_cast_or_null<VarRegion>(lockR);
    const VarDecl *lockVD;
    if (lockVR)
      lockVD = lockVR->getDecl();
    else
      lockVD = NULL;

Then I would use lockVD->getName(), but for complicated macros, lockVR is null.

What I want to accomplish here is to just print the variable name as it is in the code (not how the macro expands the variable), so we could have:

#define lock(_mtx) pthread_mutex_lock((_mtx))

lock(foo);

At this point, I want to print 'foo'. Seems like I'm missing something because this doesn't work on all cases.

Any ideas?

Thanks,
--
Rui Paulo




More information about the cfe-dev mailing list