Local variables: How to use F.getValueSymbolTable()

I wanna get all the local variables in a function. But an error happens.

void getLocalVariables(Function &F) {
  ValueSymbolTable *vst = F.getValueSymbolTable();
  for (auto vs : vst) {  // here it says: This scope-based "for" statement required the appropriate "begin" function, but was not found
    auto s = vs.getKey();
    auto v = vs.getValue();
  }
}

The error is that: This scope-based "for" statement required the appropriate "begin" function, but was not found . So how can I correct my code ? Tks.

You probably want something like for (auto vs : *vst) {, you can’t iterate over a pointer, though I don’t know where that error message came from, I guess it’s translated from localised MSVC error messages?

So… How can I use F.getValueSymbolTable() to get variables?

Did you try what I said?

Yes, I tried this. But it still says This scope-based "for" statement required the appropriate "begin" function, but was not found. I don’t know how to iterate it.