SUSE / clang-extract

Other
7 stars 3 forks source link

Fix SymbolExternalizer skipping symbols in typeof() #30

Closed giulianobelinassi closed 1 month ago

giulianobelinassi commented 1 month ago

Previously, the SymbolExternalizer did not run on TypeOfTypeExpr, causing constructions such as

typeof(symbol_to_externalize) x;

to fail compilation because symbol_to_externalize was renamed to something else. Fix this by hacking a RecursiveASTVisitor that parses all types in the function and update the reference.

Fixes #24

marcosps commented 1 month ago

Now it's able to finish the closure, but it generates code similar to klp-ccp (it expands the KLP_TRACE macro that it huge), but the code it at least indented. But it still generates code that fails to compile:

In file included from /home/mpdesouza/kgr/data/x86_64/usr/src/linux-5.3.18-150300.59.158/include/linux/compiler_types.h:68,
                 from <command-line>:
In function ‘arch_static_branch’,
    inlined from ‘static_key_false’ at /home/mpdesouza/kgr/data/x86_64/usr/src/linux-5.3.18-150300.59.158/include/linux/jump_label.h:172:9,
    inlined from ‘trace_tls_device_rx_resync_nh_delay’ at /home/mpdesouza/kgr/livepatches/bsc1222402/ce/15.3u43/work_net_tls_tls_device.c/livepatch.c:852:9,
    inlined from ‘klpp_tls_device_rx_resync_new_rec’ at /home/mpdesouza/kgr/livepatches/bsc1222402/ce/15.3u43/work_net_tls_tls_device.c/livepatch.c:1249:4:
/home/mpdesouza/kgr/data/x86_64/usr/src/linux-5.3.18-150300.59.158/include/linux/compiler-gcc.h:120:38: warning: ‘asm’ operand 0 probably does not match constraints
  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
      |                                      ^~~
/home/mpdesouza/kgr/data/x86_64/usr/src/linux-5.3.18-150300.59.158/arch/x86/include/asm/jump_label.h:25:9: note: in expansion of macro ‘asm_volatile_goto’
   25 |         asm_volatile_goto("1:"
      |         ^~~~~~~~~~~~~~~~~
/home/mpdesouza/kgr/data/x86_64/usr/src/linux-5.3.18-150300.59.158/include/linux/compiler-gcc.h:120:38: error: impossible constraint in ‘asm’
  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
      |                                      ^~~
/home/mpdesouza/kgr/data/x86_64/usr/src/linux-5.3.18-150300.59.158/arch/x86/include/asm/jump_label.h:25:9: note: in expansion of macro ‘asm_volatile_goto’
   25 |         asm_volatile_goto("1:"

But at least clang-extract is able to finish!