[PATCH] D137064: [clangd] Fix a semantic-highlighting crash.
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 31 02:49:34 PDT 2022
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.
thanks!
================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:664
bool VisitCXXMemberCallExpr(CXXMemberCallExpr *CE) {
- if (isa<CXXDestructorDecl>(CE->getMethodDecl())) {
+ if (isa_and_nonnull<CXXDestructorDecl>(CE->getMethodDecl())) {
if (auto *ME = dyn_cast<MemberExpr>(CE->getCallee())) {
----------------
can you add a comment here saying `getMethodDecl can return nullptr with member pointers`.
(it's also quite surprising that this is the only place we're calling getMethodDecl in clangd, afaict).
================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:664
bool VisitCXXMemberCallExpr(CXXMemberCallExpr *CE) {
- if (isa<CXXDestructorDecl>(CE->getMethodDecl())) {
+ if (isa_and_nonnull<CXXDestructorDecl>(CE->getMethodDecl())) {
if (auto *ME = dyn_cast<MemberExpr>(CE->getCallee())) {
----------------
kadircet wrote:
> can you add a comment here saying `getMethodDecl can return nullptr with member pointers`.
>
> (it's also quite surprising that this is the only place we're calling getMethodDecl in clangd, afaict).
nit: `isa_and_present` is the new alternative
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137064/new/
https://reviews.llvm.org/D137064
More information about the cfe-commits
mailing list