Enter-tainer / cxx2flow

将 C/C++ 代码转换成流程图 / Turn your C/C++ code into flowchart
MIT License
737 stars 61 forks source link

dummy ast node error #46

Closed eHammarstrom closed 10 months ago

eHammarstrom commented 10 months ago

The following code,

#include <stdio.h>

static void a(void)
{
    printf("a\n");
}

static void b(void)
{
    printf("b\n");
}

static void x(int y)
{
    if (y > 0) {
        return a();
    } else {
        return b();
    }
}

int main(void)
{
    int y;
    scanf("%d", &y);

    x(y);
}

With the following parameters,

cxx2flow test.c x | dot -Tpng -o test.png

Results in this output,

Error: cxx2flow::unexpected_dummy_ast

  × unexpected dummy ast node
    ╭─[test.c:15:1]
 15 │             return a();
 16 │ ╭─▶     } else {
 17 │ │           return b();
 18 │ ├─▶     }
    · ╰──── dummy ast node here
 19 │     }
    ╰────
  help: dummy node found in the ast
        this might be a bug, please report it to the author
Enter-tainer commented 10 months ago

it runs on my machine...

image
Enter-tainer commented 10 months ago

there are also people reporting this in #42. Which version are you using? can you update the source file here? Can you also try compile it from source and see if it is working?

eHammarstrom commented 10 months ago

This is my version output,

cxx2flow
Build Timestamp:     2024-01-27T16:43:10.723665879Z
Build Version:       0.6.1
Commit SHA:          Some("00c7aec26e7babc1a9de50c53a5b48e6620871b3")
Commit Date:         Some("2023-12-18T19:56:54Z")
Commit Branch:       Some("main")
Cargo Target Triple: x86_64-unknown-linux-gnu
Cargo Profile:       release

I built it from cargo install just a couple of days ago.

Are there perhaps any requirements on any external dependencies at build time?

Enter-tainer commented 10 months ago

maybe try cargo install --locked ? cargo install doesn't respect lock file and it might use a different version of tree-sitter

eHammarstrom commented 10 months ago

That works. I didn't know about it not respecting the lock file, thanks for sharing.