Issue 89395
Summary [clang][Index] potential unchecked `nullptr`s in `TypeIndexer` and `CursorVisitor` for broken code
Labels question, clang, clangd
Assignees
Reporter 5chmidti
    The issues clangd/clangd/2016 and #89389 show that there may be some unchecked `nullptr` accesses in invalid code, and there are some more unchecked accesses to the result of `getDecl` and `getPtr` (hidden behind a `get*Decl`). Should these be checked preemptively?

E.g. 
https://github.com/llvm/llvm-project/blob/3a4bc11b675c0511319c2843221133e986825b3b/clang/lib/Index/IndexTypeSourceInfo.cpp#L164-L167 checks the result of `getTypePtr`, while https://github.com/llvm/llvm-project/blob/3a4bc11b675c0511319c2843221133e986825b3b/clang/lib/Index/IndexTypeSourceInfo.cpp#L174-L178 does not, and all other `get[...]Decl` calls look like `return getTypePtr()->getDecl();`
https://github.com/llvm/llvm-project/blob/3a4bc11b675c0511319c2843221133e986825b3b/clang/lib/Index/IndexTypeSourceInfo.cpp#L61
https://github.com/llvm/llvm-project/blob/3a4bc11b675c0511319c2843221133e986825b3b/clang/include/clang/AST/TypeLoc.h#L695-L697

(I'm also adding a `clangd` label, because clangd looks at a lot of broken code, which is how the linked issue was raised)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to