Search code examples
parsingclangclang-ast-matchers

Clang matcher that hasGlobalStorage but is non-static


I was trying to compose a matcher that finds global variables that does not have static storage

This is what I have so far

varDecl(hasGlobalStorage(), isDefinition())

Accoring to Clang AST Matcher Reference

hasGlobalStorage will also match static variables inside function bodies

enter image description here

I don't want to match 'y' variable

How do I do that?


Solution

  • You can use isLocalVarDecl method.