[Lldb-commits] [lldb] 14ecbd7 - [lldb][NFC] Refactor TypeSystemClang::GetTypeName

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 10 23:44:20 PST 2020


Author: Raphael Isemann
Date: 2020-02-11T08:43:57+01:00
New Revision: 14ecbd7b8ded18af6c95f6a9957da541d1ec0e80

URL: https://github.com/llvm/llvm-project/commit/14ecbd7b8ded18af6c95f6a9957da541d1ec0e80
DIFF: https://github.com/llvm/llvm-project/commit/14ecbd7b8ded18af6c95f6a9957da541d1ec0e80.diff

LOG: [lldb][NFC] Refactor TypeSystemClang::GetTypeName

Added: 
    

Modified: 
    lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index b1704e625634..3d9a80dd3f73 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3495,21 +3495,20 @@ bool TypeSystemClang::GetCompleteType(lldb::opaque_compiler_type_t type) {
 }
 
 ConstString TypeSystemClang::GetTypeName(lldb::opaque_compiler_type_t type) {
-  std::string type_name;
-  if (type) {
-    clang::PrintingPolicy printing_policy(getASTContext().getPrintingPolicy());
-    clang::QualType qual_type(GetQualType(type));
-    printing_policy.SuppressTagKeyword = true;
-    const clang::TypedefType *typedef_type =
-        qual_type->getAs<clang::TypedefType>();
-    if (typedef_type) {
-      const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
-      type_name = typedef_decl->getQualifiedNameAsString();
-    } else {
-      type_name = qual_type.getAsString(printing_policy);
-    }
+  if (!type)
+    return ConstString();
+
+  clang::QualType qual_type(GetQualType(type));
+
+  // For a typedef just return the qualified name.
+  if (const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
+    const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
+    return ConstString(typedef_decl->getQualifiedNameAsString());
   }
-  return ConstString(type_name);
+
+  clang::PrintingPolicy printing_policy(getASTContext().getPrintingPolicy());
+  printing_policy.SuppressTagKeyword = true;
+  return ConstString(qual_type.getAsString(printing_policy));
 }
 
 uint32_t


        


More information about the lldb-commits mailing list