[cfe-dev] ifStmt::getThen() returns ifStmt again?
Bruno Ricci via cfe-dev
cfe-dev at lists.llvm.org
Wed Mar 27 12:53:32 PDT 2019
On 27/03/2019 19:10, Ulrich Thomas Gabor via cfe-dev wrote:
> Hi
>
> I recently started to test the current master
> https://github.com/llvm/llvm-project/commit/e04483ee35ba28c089cbbcec97a96b67ce0a035e
>
> and found that ifStmt::getThen() now returns the ifStmt itself like in the
> following code where both dump calls give the same output:
>
> stmt.dump(dbgs());
> const IfStmt ifS = cast<IfStmt>(stmt);
> auto x = ifS.getThen();
> x->dump(dbgs());
>
> The AST was generated for a simple program:
>
> int main(int argc, char ** argv) {
> int a = 0;
> if (true) {
> a = 10;
> }
> return a;
> }
>
>
> This was not the case for LLVM 8, previously the a=10 stmt was returned.
> Should it be that way or am I doing something wrong?
>
> Best
> Ulrich
>
I cannot reproduce this with a recent clang (and if IfStmt::getThen returned the
IfStmt itself, clang would be hopelessly broken). If you look at the implementation of
IfStmt::getThen in AST/Stmt.h you can see that it returns the then statement, which
is stored as a trailing object.
Best,
Bruno
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
More information about the cfe-dev
mailing list