Skip to content

python libclang parser incorrect handling of ::iterator #63277

Open
@d-e-e-p

Description

@d-e-e-p

Parsing the following code with Python libclang:

#include <vector>
int main() {
  const std::vector<int> i_is_ok;
  const std::vector<int>::const_iterator i_iter_becomes_const_iterator;
  return 0;
}

incorrectly produces AST that looks like:

TRANSLATION_UNIT s: class_iter.cpp 
    FUNCTION_DECL s: main t: int () 
        COMPOUND_STMT 
            DECL_STMT 
                VAR_DECL s: i_is_ok t: const int 
            DECL_STMT 
                VAR_DECL s: const_iterator t: const int 
            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-constiterator#class_iter.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