================
@@ -86,10 +86,80 @@ mlir::Type 
CIRGenTypes::convertFunctionTypeInternal(QualType qft) {
   return cir::FuncType::get(SmallVector<mlir::Type, 1>{}, cgm.VoidTy);
 }
 
+// This is CIR's version of CodeGenTypes::addRecordTypeName. It isn't shareable
+// because CIR has different uniquing requirements.
+std::string CIRGenTypes::getRecordTypeName(const clang::RecordDecl *recordDecl,
+                                           StringRef suffix) {
+  llvm::SmallString<256> typeName;
+  llvm::raw_svector_ostream outStream(typeName);
+
+  PrintingPolicy policy = recordDecl->getASTContext().getPrintingPolicy();
+  policy.SuppressInlineNamespace = false;
+
+  if (recordDecl->getIdentifier()) {
+    if (recordDecl->getDeclContext())
+      recordDecl->printQualifiedName(outStream, policy);
+    else
+      recordDecl->printName(outStream, policy);
+
+    // Ensure each template specialization has a unique name.
+    if (auto *templateSpecialization =
+            llvm::dyn_cast<ClassTemplateSpecializationDecl>(recordDecl)) {
----------------
erichkeane wrote:

The template-args can print... awkwardly sometimes and not consistently 
depending on placeholder syntax and sugaring.  The code we already have to do 
such printing is already pretty onerous.   See `ConvertTypeToDiagnosticString` 
for what we typically use for diagnostics (which is a little more convoluted, 
but interesting all the same).

Clang `TypePrinter(LangOptions()).print` also does similar work and does a 
pretty solid job of it, and has some options to make it easier to not be weird. 
 So we might try that?


https://github.com/llvm/llvm-project/pull/135105
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to