tree-sitter-cpp
tree-sitter-cpp copied to clipboard
bug: Tree sitter does not recognize Clang's Nullability Attributes
Did you check existing issues?
- [x] I have read all the tree-sitter docs if it relates to using the parser
- [X] I have searched the existing issues of tree-sitter-cpp
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)
No response
Describe the bug
Clang supports nullability attributes in the form of _Nullable or _Nonnull: https://clang.llvm.org/docs/AttributeReference.html#nullability-attributes. These attributes are not supported by tree-sitter-cpp.
The codebase I'm working with has a lots of these and it breaks tree-sitter based tooling since ASTs are parsed incorrectly/with errors
Steps To Reproduce/Bad Parse Tree
Tried this on the playground:
// Code: C++
int _Nonnull n;
Generated AST:
translation_unit [0, 0] - [1, 0]
declaration [0, 0] - [0, 15]
type: primitive_type [0, 0] - [0, 3]
declarator: identifier [0, 4] - [0, 12]
ERROR [0, 13] - [0, 14]
identifier [0, 13] - [0, 14]
It considers _Nonnull as an identified and 'n' as an error node.
Expected Behavior/Parse Tree
- No AST errors
- '_Nonnull' is considered an attribute
Repro
void foo() {
int _Nonnull n;
}