find the scope of local variable

Is there a way to find if a local variable has static scope?
typedef stream InternalStream;
void comp (float *A, float *B, float *E, int M)
{

static InternalStream X(“str_X”);
static InternalStream Y(“str_Y”);

}

My requirement is to error out if “InternalStream X” is not declared with static scope.
I tried parsing CXXRecordDecl with DeclContext::decl_iterator but it didn’t work.
Any help would be appreciated.

I think you’re looking for VarDecl::hasLocalStorage().

https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html#ab7c54da372d71f7a83cc5a8834cb70f7

Returns true if a variable with function scope is a non-static local variable.

Thanks for replies.
VarDecl::hasLocalStorage() should solve my problem.
But how can I write a condition to get the originalType of InternalStream.
if (VarDecl *vd = dyn_cast(d)) {
QualType qt = vd->getType();
}
With the above code getType is returning InternalStream, but I need to get the orginalType “typedef stream InternalStream”

See “Clang” CFE Internals Manual — Clang 16.0.0git documentation