[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC v2 00/10] Introduce an extensible static analyzer
From: |
Christian Schoenebeck |
Subject: |
Re: [RFC v2 00/10] Introduce an extensible static analyzer |
Date: |
Sat, 15 Oct 2022 15:14:20 +0200 |
On Freitag, 14. Oktober 2022 00:00:58 CEST Paolo Bonzini wrote:
[...]
> However, it seems like a lost battle. :( Some of the optimizations are
> stuff that you should just not have to do, for example only invoking
> "x.kind" once (because it's a property not a field). Another issue is
> that the bindings are incomplete, for example if you have a ForStmt
> you just get a Cursor and you are not able to access individual
> expressions. As a result, this for example is wrong in the
> return-value-never-used test:
>
> static int f(void) { return 42; }
> static void g(void) {
> for (f(); ; ) { } /* should warn, it doesn't */
> }
>
> and I couldn't fix it without breaking "for (; f(); )" because AFAICT
> the two are indistinguishable.
You mean accessing the `for` loop's init expression, condition expression,
increment statement? AFAICS those are accessible already by calling
get_children() on the `for` statement cursor:
https://github.com/llvm/llvm-project/blob/main/clang/bindings/python/clang/cindex.py#L1833
I just made a quick test with a short .c file and their demo script:
https://github.com/llvm/llvm-project/blob/main/clang/bindings/python/examples/cindex/cindex-dump.py
And I got all those components of the `for` loop as children of the `for`
cursor.
Best regards,
Christian Schoenebeck