Skip to content

parser::parse: Inconsistency in documentation or unwanted behavior when file already in index #170

@rafzi

Description

@rafzi
  • cppast version: main branch
  • parser: libclang_parser
  • clang version: 16.0.4

simple_file_parser::parse states: \returns The parsed file or an empty optional, if a fatal error occurred.

https://github.com/foonathan/cppast/blob/main/include/cppast/parser.hpp#L110

It does internally call parser::parse, which states: \returns The [cppast::cpp_file]() object describing it. It can be 'nullptr', if there was an error or the specified file already registered in the index.

Therefore, simple_file_parser::parse actually also returns nullptr if the file is already in the index. A user of it will then expect that the parsing failed, when it actually succeeded.

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