finding in which function/method/scope a Decl is in, the parent so to say

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

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 to get the function scope.