usethesource / clair

C Language Analysis in Rascal
BSD 2-Clause "Simplified" License
25 stars 12 forks source link

Missing return types from C functions inside M3 model #69

Closed matteasu closed 10 months ago

matteasu commented 11 months ago

Setup:

Given a simple C program, such as:

#include <stdio.h>

int main(int argc, char argv[]){
    printf("Hello world!");
    return 0;
}

If I try to generate an M3 model using the proper createM3ModelFromCFile function, I can see no trace of the function return type or parameters type inside the declaredType field of the M3 model. However, these are present if the program is parsed using the createM3ModelFromCppFile function.

    "declaredType": [
        [
            "c+function:///home/matteoasuni/test.c/main(int,char.*)",
            "any"
        ]
    ],
"declaredType": [
        [
            "cpp+function:///home/matteoasuni/test.c/main(int,char.*)",
            {
                "returnType": {
                    "modifiers": [],
                    "baseType": "int"
                },
                "parameterTypes": [
                    {
                        "modifiers": [],
                        "baseType": "int"
                    },
                    {
                        "modifiers": [],
                        "type": {
                            "modifiers": [],
                            "baseType": "char"
                        }
                    }
                ]
            }
        ]
    ],
jurgenvinju commented 10 months ago

Thanks @matteasu for reporting this.

jurgenvinju commented 10 months ago

Have not come around to fixing, but it should not be hard..

jurgenvinju commented 10 months ago

Release 0.12.0 is underway with this fix @matteasu