[cfe-dev] CLANG Function Def... How to get Entire SourceRange

Manuel Klimek klimek at google.com
Mon Apr 9 11:04:45 PDT 2012


$ cat t.cc
extern "C" void f();

$ clang++ -cc1 -ast-dump-xml t.cc
[...]
 <LinkageSpec ptr="0x38577f0" lang="C">
  <Function ptr="0x38872f0" name="f" prototype="true" storage="extern">
   <FunctionProtoType ptr="0x3857840" canonical="0x3857840">
    <BuiltinType ptr="0x3856c30" canonical="0x3856c30"/>
    <parameters/>
   </FunctionProtoType>
  </Function>
 </LinkageSpec>

searching for LinkageSpec in the code base leads to LinkageSpecDecl,
which is a DeclContext, so without having verified it I'd expect
FD->getDeclContext() to give the LinkageSpecDecl in that case (but I'm
not sure).

Cheers,
/Manuel

On Mon, Apr 9, 2012 at 11:58 AM, Suhas <suhaslimaye at gmail.com> wrote:
> I have 2 function prototypes
>
> extern  void  myTestFunc(double a, int c);
> extern "C" void  myFunc2(int a, int c);
>
> When i tried to get entire sourceRange for both,  with FunctionDecl object ,
> as
> FunctionDecl *FD;
> sourceLocation sBegin = FD->getLocStart();
> sourceLocation sEnd = FD->getLocEnd();
> sourceRange.setBegin(sBegin);
> sourceRange.setEnd(sEnd);
>
> The sourceRange for 1st is getting as :
> extern  void  myTestFunc(double a, int c)
>
> where as for second
> void  myFunc2(int a, int c)
>
> Issue, is I want to get entire sourceRange for second. i.e
> extern "C" void  myFunc2(int a, int c)
>
>
> So, how to get entire SourceRange?
>
>
> Suhas Limaye.
> Pune.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>




More information about the cfe-dev mailing list