[PATCH] D59599: [clangd] Fix a crash while printing Template Arguments

Eugene Zelenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 20 10:47:34 PDT 2019


Eugene.Zelenko added inline comments.


================
Comment at: clangd/AST.cpp:86
   else if (auto *Cls = llvm::dyn_cast<ClassTemplateSpecializationDecl>(&ND)) {
-    if (auto STL = Cls->getTypeAsWritten()
-                       ->getTypeLoc()
-                       .getAs<TemplateSpecializationTypeLoc>()) {
-      llvm::SmallVector<TemplateArgumentLoc, 8> ArgLocs;
-      ArgLocs.reserve(STL.getNumArgs());
-      for (unsigned I = 0; I < STL.getNumArgs(); ++I)
-        ArgLocs.push_back(STL.getArgLoc(I));
-      printTemplateArgumentList(OS, ArgLocs, Policy);
+    if (auto *TSI = Cls->getTypeAsWritten()) {
+      if (auto STL = TSI->getTypeLoc().getAs<TemplateSpecializationTypeLoc>()) {
----------------
Return type is not obvious, so auto should not be used.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59599/new/

https://reviews.llvm.org/D59599





More information about the cfe-commits mailing list