[cfe-dev] Clang-tidy check for preprocessor marked functions

Marc-André Lureau via cfe-dev cfe-dev at lists.llvm.org
Thu Jun 22 07:40:21 PDT 2017


Hi,

I have started to investigate using clang-tidy for some QEMU checks and
modernization, with some success. I started sending patches to the QEMU ML (
https://lists.nongnu.org/archive/html/qemu-devel/2017-06/msg05034.html).
The QEMU maintainer, Peter, challenged me to see if we could write a check
for coroutine usage: check if there are calls to a coroutine-marked
function from a non-coroutine (which would be a bug, as coroutine may
yield). Coroutine function are marked with a "coroutine_fn" macro, this a
simple example:

#define coroutine_fn

void coroutine_fn qemu_coroutine_yield(void);

int main(int argc, char *argv[])
{
    qemu_coroutine_yield();
    return 0;
}


Here, qemu_coroutine_yield() should be an error, because main() is not a
coroutine_fn.

Is there a way to write a clang-tidy check, perhaps at PP level, that would
mark the function declaration with coroutine type?

What would you suggest instead?

PS: forgive me if this is not the clang-tidy list.
PS2: I opened 2 little bugs on bugzilla, no reply so far
https://bugs.llvm.org/show_bug.cgi?id=33440,
https://bugs.llvm.org/show_bug.cgi?id=33441

-- 
Marc-André Lureau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170622/d7043b02/attachment.html>


More information about the cfe-dev mailing list