Getting the SourceLocation of the qualifier of a parameter

Hi all,

I'm trying to find the start of a parameter declaration, but only have
limited success. The function I'm looking at is defined similar to

void foo(const int* p)
{
}

and I'm using ASTConsumer::HandleTranslationUnit to trawl though the
AST looking for function definitions. When I find one I'm interested
in, I do

FunctionDecl* function=static_cast<FunctionDecl*>(decl);
VarDecl* parm=function->getParamDecl(0);
SourceLocation pos;
pos=parm->getSourceRange().getBegin(); // Nope, didn't work
cout << "Parameter declaration starts at column " <<
source_manager->getSpellingColumnNumber(pos) << endl;
pos=parm->getTypeSpecStartLoc(); // Nope, didn't work wither
cout << "Parameter declaration starts at column " <<
source_manager->getSpellingColumnNumber(pos) << endl;
pos=parm->getTypeSourceInfo()->getTypeLoc().getFullSourceRange().getBegin();
// What about this one?
cout << "Parameter declaration starts at column " <<
source_manager->getSpellingColumnNumber(pos) << endl;

In all cases I've tried, I get the position of the "int", not the
position of the "const". Is there a way of doing it that I have
missed, or is this an omission?

A simple test case showing this problem is attached.

Best Regards
Magnus Reftel

const_pos-1.zip (1.77 KB)

It's a Clang bug. getTypeSpecStartLoc() should return the location of the "const". Want to take a shot at fixing it?

  - Doug