<html><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:12pt"><div>Hello everybody,</div><div style="margin-left: 40px;">I want to be able to spot file-level variables(either with static or extern) used inside each function. I've already hooked an AST matcher(from for functions with definitions found during parsing.<br></div><div style="margin-left: 40px;"><br></div><div style="margin-left: 40px; color: rgb(0, 0, 0); font-size: 16px; font-family: Courier New,courier,monaco,monospace,sans-serif; background-color: transparent; font-style: normal;">Since I couldn't find a matcher that would allow me to match top-level declarations, I thought I could similarly define another matcher for variable declarations along with a custom MatchCallback class to filter only on variables with file-scope declarations(using VarDecl::<span class=""></span><span class="">isFileVarDecl</span>
method). Is this the easy way to go or may there be a better way through AST matchers that would get me directly file-scope variable declarations(without having to check its cope myself), like with chaining/nesting some matchers together? The closest thing I could find was <a href="" name="hasDeclContext0Anchor">hasDeclContext</a> but couldn't find a matcher to match a translation unit scope.</div><div style="margin-left: 40px; color: rgb(0, 0, 0); font-size: 16px; font-family: Courier New,courier,monaco,monospace,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="margin-left: 40px; color: rgb(0, 0, 0); font-size: 16px; font-family: Courier New,courier,monaco,monospace,sans-serif; background-color: transparent; font-style: normal;">Appreciating your advice.<br class=""></div></div></body></html>