GumTreeDiff / cgum

The C parser for GumTree
12 stars 5 forks source link

Missing type differences in C files #12

Open xiaotili0123 opened 5 years ago

xiaotili0123 commented 5 years ago

I use gumTree to diff two C files and show the results in the web server. However, I am confused that why it didn't catch the type difference of variables in the two files. The link of the screenshot of the result is showed below:

https://drive.google.com/open?id=1a30eSvuYkCHNnt_IIMVkFS9eS8TwgzLG

JuliaLawall commented 5 years ago

On Sun, 22 Sep 2019, Crystal_Lee wrote:

I use gumTree to diff two C files and show the results in the web server. However, I am confused that why it didn't catch the type difference of variables in the two files. The link of the screenshot of the result is showed below:

https://drive.google.com/open?id=1a30eSvuYkCHNnt_IIMVkFS9eS8TwgzLG

Could you send the actual files? It is not possible to copy paste them from the screenshot.

julia

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute thethread.[AAD2ZGSYFUNFFKBWHULCYALQLATUTA5CNFSM4IZFXZJ2YY3PNVWWK3TUL52HS4DFUVE XG43VMWVGG33NNVSW45C7NFSM4HM5UJUA.gif]

xiaotili0123 commented 5 years ago

Sure, please find the txt file in the link: https://drive.google.com/open?id=1aMpgnI_9ie8Egmv0qyBZyVZBFNuqUESb

jrfaller commented 5 years ago

I can confirm the problem! By trying directly to parse the C code using cgum (cgum 2.c) on the right file (the one with long long int typed functions), I have the impression that this return type is not present in the AST

jrfaller commented 3 years ago

Hi @JuliaLawall !

I have looked into this simple example :

int main() {
    return 0;
}

cgum outputs

<tree type = "Program" pos = "0" length = "35" line_before = "1" col_before = "0" line_after = "4" col_after = "0">
 <tree type = "Definition" pos = "0" length = "34" line_before = "1" col_before = "0" line_after = "4" col_after = "1">
  <tree type = "Definition" pos = "0" length = "34" line_before = "1" col_before = "0" line_after = "4" col_after = "1">
    <tree type = "ParamList" pos = "9" length = "2" line_before = "1" col_before = "9" line_after = "1" col_after = "11">
    </tree>
   <tree type = "GenericString" label = "main" pos = "5" length = "4" line_before = "1" col_before = "5" line_after = "1" col_after = "9"/>
   <tree type = "Compound" pos = "12" length = "22" line_before = "1" col_before = "12" line_after = "4" col_after = "1">
    <tree type = "DeclList" pos = "15" length = "6" line_before = "2" col_before = "1" line_after = "2" col_after = "7">
     <tree type = "GenericString" label = "i" pos = "19" length = "1" line_before = "2" col_before = "5" line_after = "2" col_after = "6"/>
    </tree>
    <tree type = "ReturnExpr" pos = "23" length = "9" line_before = "3" col_before = "1" line_after = "3" col_after = "10">
     <tree type = "Constant" label = "0" pos = "30" length = "1" line_before = "3" col_before = "8" line_after = "3" col_after = "9"/>
    </tree>
   </tree>
  </tree>
 </tree>
 <tree type = "FinalDef" label = "" pos = "35" length = "0" line_before = "4" col_before = "0" line_after = "4" col_after = "0"/>
</tree>

I have three remarks/questions :

Do you think it would be hard to fix these behaviors ?

Cheers!

jrfaller commented 3 years ago

Bonus question ;) what is the <tree type = "FinalDef" label = "" pos = "35" length = "0" line_before = "4" col_before = "0" line_after = "4" col_after = "0"/>? It corresponds to the }?

Cheers.