awpandey updated this revision to Diff 233289.
awpandey added a comment.

@dblaikie . I have removed the redundant test case. What else should I do in 
this patch?


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

https://reviews.llvm.org/D70524

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGenCXX/debug-info-auto-return.cpp

Index: clang/test/CodeGenCXX/debug-info-auto-return.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-auto-return.cpp
@@ -0,0 +1,18 @@
+//  Test for debug info for C++11 auto return member functions
+// RUN: %clang_cc1 -dwarf-version=5  -emit-llvm -triple x86_64-linux-gnu %s -o - \
+// RUN:   -O0 -disable-llvm-passes \
+// RUN:   -debug-info-kind=standalone \
+// RUN: | FileCheck %s
+
+// CHECK: !DISubprogram(name: "findMax",{{.*}}, type: ![[t:[0-9]+]],{{.*}}
+
+// CHECK: ![[t:[0-9]+]] = !DISubroutineType(types: ![[t1:[0-9]+]])
+// CHECK-NEXT: ![[t1:[0-9]+]] = !{![[t2:[0-9]+]], {{.*}}
+// CHECK-NEXT: ![[t2:[0-9]+]] = !DIBasicType(tag: DW_TAG_unspecified_type, name: "auto")
+
+struct myClass {
+  auto findMax();
+};
+
+auto myClass::findMax() {
+}
Index: clang/lib/CodeGen/CGDebugInfo.h
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -165,6 +165,7 @@
   /// ivars and property accessors.
   llvm::DIType *CreateType(const BuiltinType *Ty);
   llvm::DIType *CreateType(const ComplexType *Ty);
+  llvm::DIType *CreateType(const AutoType *Ty);
   llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg);
   llvm::DIType *CreateType(const TypedefType *Ty, llvm::DIFile *Fg);
   llvm::DIType *CreateType(const TemplateSpecializationType *Ty,
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -810,6 +810,10 @@
   return DBuilder.createBasicType(BTName, Size, Encoding);
 }
 
+llvm::DIType *CGDebugInfo::CreateType(const AutoType *Ty) {
+  return DBuilder.createUnspecifiedType("auto");
+}
+
 llvm::DIType *CGDebugInfo::CreateType(const ComplexType *Ty) {
   // Bit size and offset of the type.
   llvm::dwarf::TypeKind Encoding = llvm::dwarf::DW_ATE_complex_float;
@@ -2860,7 +2864,8 @@
   return DBuilder.createTempMacroFile(Parent, Line, FName);
 }
 
-static QualType UnwrapTypeForDebugInfo(QualType T, const ASTContext &C) {
+static QualType UnwrapTypeForDebugInfo(QualType T, const ASTContext &C,
+                                       int dwarfVersion) {
   Qualifiers Quals;
   do {
     Qualifiers InnerQuals = T.getLocalQualifiers();
@@ -2907,6 +2912,10 @@
       T = cast<SubstTemplateTypeParmType>(T)->getReplacementType();
       break;
     case Type::Auto:
+      if (dwarfVersion >= 5) {
+        return C.getQualifiedType(T.getTypePtr(), Quals);
+      }
+      LLVM_FALLTHROUGH;
     case Type::DeducedTemplateSpecialization: {
       QualType DT = cast<DeducedType>(T)->getDeducedType();
       assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
@@ -2928,7 +2937,8 @@
 llvm::DIType *CGDebugInfo::getTypeOrNull(QualType Ty) {
 
   // Unwrap the type as needed for debug information.
-  Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext());
+  Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext(),
+                              CGM.getCodeGenOpts().DwarfVersion);
 
   auto It = TypeCache.find(Ty.getAsOpaquePtr());
   if (It != TypeCache.end()) {
@@ -2969,7 +2979,8 @@
   });
 
   // Unwrap the type as needed for debug information.
-  Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext());
+  Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext(),
+                              CGM.getCodeGenOpts().DwarfVersion);
 
   if (auto *T = getTypeOrNull(Ty))
     return T;
@@ -3083,6 +3094,9 @@
     return CreateType(cast<TemplateSpecializationType>(Ty), Unit);
 
   case Type::Auto:
+    if (CGM.getCodeGenOpts().DwarfVersion >= 5)
+      return CreateType(cast<AutoType>(Ty));
+
   case Type::Attributed:
   case Type::Adjusted:
   case Type::Decayed:
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to