Skip to content

[C/C++] Get a function from __attribute__((__cleanup__(foo))) as a Function class instance #7312

Answered by mrc0mmand
mrc0mmand asked this question in Q&A
Discussion options

You must be logged in to vote

sigh, of course it was something obvious, I just had to step back from the computer for a bit:

// vi: syntax=ql:
import cpp

predicate functionHasAccess(string fun) {
    exists(Function f | f.getName() = fun and f.getAnAttribute().hasName("access") | f.getAnAttribute().getAnArgument().getValueText() = "write_only")
}

from LocalVariable v, string fun
where
    v.getAnAttribute().hasName("cleanup") and
    fun = v.getAnAttribute().getAnArgument().getValueText() and
    functionHasAccess(fun)
select v, fun

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mrc0mmand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant