diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc index 94bab5c41f5a..206ec0098dd6 100644 --- a/src/cc/frontends/clang/b_frontend_action.cc +++ b/src/cc/frontends/clang/b_frontend_action.cc @@ -200,7 +200,7 @@ bool ProbeVisitor::VisitBinaryOperator(BinaryOperator *E) { return true; } bool ProbeVisitor::VisitUnaryOperator(UnaryOperator *E) { - if (E->getOpcode() == UO_AddrOf) + if (E->getOpcode() != UO_Deref) return true; if (memb_visited_.find(E) != memb_visited_.end()) return true; diff --git a/tests/python/test_clang.py b/tests/python/test_clang.py index 93d8742510cf..691083d92b2e 100755 --- a/tests/python/test_clang.py +++ b/tests/python/test_clang.py @@ -408,6 +408,17 @@ def test_bpf_dins_pkt_rewrite(self): """ b = BPF(text=text) + def test_unary_operator(self): + text = """ +#include +#include +int trace_read_entry(struct pt_regs *ctx, struct file *file) { + return !file->f_op->read_iter; +} + """ + b = BPF(text=text) + b.attach_kprobe(event="__vfs_read", fn_name="trace_read_entry") + if __name__ == "__main__": main()