[PATCH] D125224: [CodeComplete] prototype of contextual postfix completions
SR_team via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 23 09:01:00 PDT 2023
SR_team added a comment.
Iterator checks may crash in current state. Also, `pointeeType` may return invalid type of iterator store (`T*` instead of `T`)
================
Comment at: clang/lib/Sema/SemaCodeComplete.cpp:5589
+ const auto &Args =
+ static_cast<ClassTemplateSpecializationDecl *>(RD->getDeclContext())
+ ->getTemplateArgs();
----------------
RD is nullptr here - use `RT->getDecl()->getDeclContext()` instead
================
Comment at: clang/lib/Sema/SemaCodeComplete.cpp:5646
+ if (!Element.isNull()) {
+ if (Element->isPointerType())
+ return "const auto*";
----------------
GNU STL use pointer to type in iterators, so need check is `Element` pointer-to-pointer:
```
if (Element->isPointerType()) {
if (const auto *PT = dyn_cast<PointerType>(Element)) {
Element = PT->getPointeeType();
if (Element->isPointerType())
return "const auto*";
}
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125224/new/
https://reviews.llvm.org/D125224
More information about the cfe-commits
mailing list