Skip to content

python libclang incorrect parsing of vector in class #63372

Open
@d-e-e-p

Description

@d-e-e-p

Parsing the following code with Python libclang:

#include <map>
#include <vector>

struct Map {
  // m_visible shows up in python libclang AST
  std::map<int, int> m_visible;
  // m_invisible is missing in python libclang AST
  std::map<int, std::vector<int>> m_invisible;
}; 

main(){
  Map m;
  return 0;
}

m_visible shows up but m_invisible doesn't show up in AST.

TRANSLATION_UNIT s: missing_vector.cpp 
    STRUCT_DECL s: Map t: Map 
        FIELD_DECL s: m_visible t: int 
    FUNCTION_DECL s: main t: int () 
        COMPOUND_STMT 
            DECL_STMT 
                VAR_DECL s: m t: Map 
                    TYPE_REF s: struct Map t: Map 
                        STRUCT_DECL s: Map t: Map 
                            FIELD_DECL s: m_visible t: int 
                    CALL_EXPR s: Map t: Map 
                        CONSTRUCTOR s: Map t: void () noexcept 
                            COMPOUND_STMT 
            RETURN_STMT 
                INTEGER_LITERAL 

this AST dump was produced using script from:
https://gist.githubusercontent.com/scturtle/a7b5349028c249f2e9eeb5688d3e0c5e/raw/fb16f021d2ddcaba9122ad8867aa955c1be4f988/ast_dump.py

see demo at repl:
https://replit.com/@binterboo/python-libclang-bug-with-vector#missing_vector.cpp

LLVM_VER: 16.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions