[PATCH] D27384: [libclang] Restore clang_getNumTemplateArguments/clang_getTemplateArgumentAsType functionality

Saleem Abdulrasool via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 3 18:13:59 PST 2016


compnerd added inline comments.


================
Comment at: tools/libclang/CXType.cpp:151-153
+  if (A.getKind() != TemplateArgument::Type)
+    return MakeCXType(QualType(), TU);
+  return MakeCXType(A.getAsType(), TU);
----------------
Isn't this more compact as:

    return MakeCXType(A.getKind() == TemplateArgument::Type ? A.getAsType() : QualType(), TU);


================
Comment at: tools/libclang/CXType.cpp:961
+    return GetTemplateArgumentType(TA, i, GetTU(CT));
+  }
+  const CXXRecordDecl *RecordDecl = T->getAsCXXRecordDecl();
----------------
Why not inline the template arguments?


================
Comment at: tools/libclang/CXType.cpp:965
     return MakeCXType(QualType(), GetTU(CT));
-  const TemplateArgument &A = TA[i];
-  if (A.getKind() != TemplateArgument::Type)
+  const ClassTemplateSpecializationDecl *TemplateDecl =
+    dyn_cast<ClassTemplateSpecializationDecl>(RecordDecl);
----------------
Use `auto`, the type is obvious.


================
Comment at: tools/libclang/CXType.cpp:970
+  const TemplateArgumentList &TA = TemplateDecl->getTemplateArgs();
+  return GetTemplateArgumentType(TA, i, GetTU(CT));
 }
----------------
Similar.


https://reviews.llvm.org/D27384





More information about the cfe-commits mailing list