It sounds like you want the DeclContext.  Use the function
Decl::getDeclContext() to get a DeclContext pointer.  See
http://clang.llvm.org/doxygen/classclang_1_1DeclContext.html for details
about DeclContext.  DeclContext::isTranslationUnit() for globals and
DeclContext::isFunctionOrMethod() for function/method scope.  DeclContext
can also be cast to other Decl types, so for example you could use
dyn_cast<FunctionDecl> to get the function scope.

On Fri, Nov 11, 2016 at 4:06 AM, folkert via cfe-users <
cfe-users@lists.llvm.org> wrote:

> Hi,
>
> How can I find the parent of a VarDecl? The scope it is in. E.g.
> function/method or a global.
>
>
> Folkert van Heusden
> _______________________________________________
> cfe-users mailing list
> cfe-users@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to