Skip to content

Initial C/C++ support #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Initial C/C++ support #77

wants to merge 2 commits into from

Conversation

rahlk
Copy link
Collaborator

@rahlk rahlk commented Jan 29, 2025

Added richer support for analyzing C projects with Clang parser as requested in Issue #79

This initial version is able to create a symbol table for C projects with the following attributes:

  1. CApplication

    class CApplication(BaseModel):
     """Represents a complete C application.
    
     Attributes:
         translation_units (Dict[str, CTranslationUnit]): All source files
         call_graph (List[CCallGraphEdge]): Function call relationships
     """
    
     translation_units: Dict[str, CTranslationUnit]
     call_graph: List[CCallGraphEdge] = []
    class CTranslationUnit(BaseModel):
     """Represents a C source file.
    
     Attributes:
         file_path (str): Path to the source file
         includes (List[str]): Header files included
         macros (List[CMacro]): Macro definitions
         typedefs (List[CTypedef]): Typedef declarations
         structs (List[CStruct]): Struct/union declarations
         enums (List[CEnum]): Enum declarations
         globals (List[CVariable]): Global variable declarations
         functions (Dict[str, CFunction]): Function declarations/definitions
         is_header (bool): Whether this is a header file
     """
    
     file_path: str
     includes: List[CInclude] = []
     macros: List[CMacro] = []
     typedefs: List[CTypedef] = []
     structs: List[CStruct] = []
     enums: List[CEnum] = []
     globals: List[CVariable] = []
     functions: Dict[str, CFunction] = {} # <-----[ Initial version has been implemented ]-----
     is_header: bool = False
     is_modified: bool = False

Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
@rahlk rahlk requested a review from sinha108 January 29, 2025 01:01
@rahlk rahlk changed the title Initialize C/C++ support feature branch. Initial C/C++ support Jan 29, 2025
Downstream changes from main to c-cpp branch
@rahlk rahlk marked this pull request as draft January 29, 2025 17:38
@rahlk rahlk closed this Jan 29, 2025
@rahlk rahlk deleted the support-c-cpp branch January 29, 2025 17:40
@rahlk rahlk added the kind/feature New feature(s) label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant