Skip to content

Missing return types from C functions inside M3 model #69

@matteasu

Description

@matteasu

Setup:

  • Rascal 0.34.1
  • Clair 0.10.1
  • Ubuntu 22.10 aarch64
  • OpenJDK 17.0.7

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"
                        }
                    }
                ]
            }
        ]
    ],

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions