Features/CoroutineFnCleanup: Difference between revisions
(Created page with "== Hand-written bdrv_co_* functions == # bdrv_pread/bdrv_pwrite have different calling convention than bdrv_co_pread/bdrv_co_pwrite #* Fix using Coccinelle? # Missing bdrv_co_...") |
No edit summary |
||
Line 36: | Line 36: | ||
;<tt>match functionDecl(isExpansionInMainFile(), forEachDescendant(callExpr(callee(unless(functionDecl()))).bind("call"))).bind("root")'</tt> | ;<tt>match functionDecl(isExpansionInMainFile(), forEachDescendant(callExpr(callee(unless(functionDecl()))).bind("call"))).bind("root")'</tt> | ||
:indirect call | :indirect call | ||
== Clang references == | |||
https://devblogs.microsoft.com/cppblog/exploring-clang-tooling-part-1-extending-clang-tidy/ | |||
https://devblogs.microsoft.com/cppblog/exploring-clang-tooling-part-2-examining-the-clang-ast-with-clang-query/ | |||
https://devblogs.microsoft.com/cppblog/exploring-clang-tooling-part-3-rewriting-code-with-clang-tidy/ |
Revision as of 08:57, 9 May 2022
Hand-written bdrv_co_* functions
- bdrv_pread/bdrv_pwrite have different calling convention than bdrv_co_pread/bdrv_co_pwrite
- Fix using Coccinelle?
- Missing bdrv_co_pwrite_sync, bdrv_co_pwrite_zeroes
- Adjust code in block/io.c and introduce generated_co_wrapper
Annotations
- Add coroutine_mixed_fn annotation; superset of generated_co_wrapper, also includes:
- bdrv_create
- bdrv_can_store_new_dirty_bitmap, bdrv_remove_persistent_dirty_bitmap
- bdrv_drain_all_begin, bdrv_do_drained_begin, bdrv_do_drained_end
- qio_channel_readv_full_all_eof, qio_channel_writev_full
- qcow2_open, qcow2_has_zero_init
- bdrv_qed_open
- qmp_dispatch
- nvme_get_free_req
- schedule_next_request
- Detect call from non-coroutine_fn to coroutine_mixed_fn
- Add coroutine_mixed_fn to caller
- Possibly add fixit to rewrite
- Detect call from coroutine_fn to coroutine_mixed_fn (libclang/clang-tidy)
- Possibly add fixit to rewrite
- See also
Clang-query examples
Invoking clang-query:
- Change definition of coroutine_fn to #define coroutine_fn=__attribute__((annotate("coroutine")))
- Invoke clang-query -p build-path block/io.c
Example of clang-query uses:
- match functionDecl(allOf(unless(hasAttr("attr::Annotate")),hasDescendant(callExpr(callee(hasAttr("attr::Annotate"))).bind("callee"))))
- call from non-coroutine_fn to coroutine_fn
- match varDecl(hasType(namedDecl(hasName("BlockDriver"))), hasInitializer(anything()))
- declaration of BlockDriver struct, with initializer
- match functionDecl(isExpansionInMainFile(), forEachDescendant(callExpr(callee(unless(functionDecl()))).bind("call"))).bind("root")'
- indirect call
Clang references
https://devblogs.microsoft.com/cppblog/exploring-clang-tooling-part-1-extending-clang-tidy/