[cfe-dev] Help getting source locations for type qualifiers

Kirill Bobyrev via cfe-dev cfe-dev at lists.llvm.org
Thu Jul 28 14:42:17 PDT 2016


Hi,

You can try getting previous token and checking whether it’s a part of the qualtype (and if so, extending SourceRange). I don’t know how to do this in a clean way (tm), but at least it should work.

—
Kirill

> On 28 Jul 2016, at 22:06, scott constable via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> Hi all,
> 
> Consider the following declaration:
> 
> const char *const ptr = 0;
> 
> With an ordinary TypeLoc, I can get the SourceRange corresponding to the "char *" part of the type by calling getSourceRange(), but I would like to get the SourceRange of the whole qualtype, i.e. "const char *const". The documentation seems to suggest that this should be possible via the TypeLoc::findExplicitQualifierLoc() function, which "Find[s] a type with the location of an explicit type qualifier." The implementation casts the TypeLoc to a QualifiedTypeLoc and returns the result. However, the documentation for QualifiedTypeLoc states that "Currently, we intentionally do not provide source location for type qualifiers."
> 
> Does this mean that what I want to do is not possible?
> 
> Thanks in advance,
> 
> Scott Constable
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list