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

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to