[Lldb-commits] [lldb] r248359 - Add {TypeSystem|CompilerType}::GetTypeForFormatters()

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 22 18:39:47 PDT 2015


Author: enrico
Date: Tue Sep 22 20:39:46 2015
New Revision: 248359

URL: http://llvm.org/viewvc/llvm-project?rev=248359&view=rev
Log:
Add {TypeSystem|CompilerType}::GetTypeForFormatters()

Different type system may have different notions of attributes of a type that do not matter for data formatters matching purposes
For instance, in the case of clang types, we remove some qualifiers (e.g. "volatile") as it doesn't make much sense to differentiate volatile T from T in the data formatters

This new API allows each type system to generate, if needed, a type that does not have those unwanted attributes that the data formatters can then consume to generate matches


Modified:
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h
    lldb/trunk/include/lldb/Symbol/CompilerType.h
    lldb/trunk/include/lldb/Symbol/TypeSystem.h
    lldb/trunk/source/DataFormatters/FormatManager.cpp
    lldb/trunk/source/Symbol/ClangASTContext.cpp
    lldb/trunk/source/Symbol/CompilerType.cpp
    lldb/trunk/source/Symbol/TypeSystem.cpp

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=248359&r1=248358&r2=248359&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Sep 22 20:39:46 2015
@@ -904,6 +904,9 @@ public:
                          size_t idx,
                          lldb::TemplateArgumentKind &kind) override;
     
+    CompilerType
+    GetTypeForFormatters (void* type) override;
+    
     //----------------------------------------------------------------------
     // Modifying RecordType
     //----------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Symbol/CompilerType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompilerType.h?rev=248359&r1=248358&r2=248359&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/CompilerType.h (original)
+++ lldb/trunk/include/lldb/Symbol/CompilerType.h Tue Sep 22 20:39:46 2015
@@ -456,6 +456,9 @@ public:
     GetTemplateArgument (size_t idx,
                          lldb::TemplateArgumentKind &kind) const;
     
+    CompilerType
+    GetTypeForFormatters () const;
+    
     //------------------------------------------------------------------
     // Pointers & References
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=248359&r1=248358&r2=248359&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Tue Sep 22 20:39:46 2015
@@ -504,6 +504,9 @@ public:
         return nullptr;
     }
     
+    virtual CompilerType
+    GetTypeForFormatters (void* type);
+    
 protected:
     const LLVMCastKind m_kind; // Support for llvm casting
     SymbolFile *m_sym_file;

Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=248359&r1=248358&r2=248359&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Tue Sep 22 20:39:46 2015
@@ -199,7 +199,7 @@ FormatManager::GetPossibleMatches (Value
                                    bool did_strip_typedef,
                                    bool root_level)
 {
-    compiler_type = ClangASTContext::RemoveFastQualifiers(compiler_type);
+    compiler_type = compiler_type.GetTypeForFormatters();
     ConstString type_name(compiler_type.GetConstTypeName());
     if (valobj.GetBitfieldBitSize() > 0)
     {

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=248359&r1=248358&r2=248359&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Sep 22 20:39:46 2015
@@ -6801,6 +6801,14 @@ ClangASTContext::GetTemplateArgument (ll
     return CompilerType ();
 }
 
+CompilerType
+ClangASTContext::GetTypeForFormatters (void* type)
+{
+    if (type)
+        return RemoveFastQualifiers(CompilerType(this, type));
+    return CompilerType();
+}
+
 static bool
 IsOperator (const char *name, clang::OverloadedOperatorKind &op_kind)
 {

Modified: lldb/trunk/source/Symbol/CompilerType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompilerType.cpp?rev=248359&r1=248358&r2=248359&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/CompilerType.cpp (original)
+++ lldb/trunk/source/Symbol/CompilerType.cpp Tue Sep 22 20:39:46 2015
@@ -851,6 +851,13 @@ CompilerType::GetTemplateArgument (size_
     return CompilerType();
 }
 
+CompilerType
+CompilerType::GetTypeForFormatters () const
+{
+    if (IsValid())
+        return m_type_system->GetTypeForFormatters(m_type);
+    return CompilerType();
+}
 
 // Get the index of the child of "clang_type" whose name matches. This function
 // doesn't descend into the children, but only looks one level deep and name

Modified: lldb/trunk/source/Symbol/TypeSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeSystem.cpp?rev=248359&r1=248358&r2=248359&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/TypeSystem.cpp (original)
+++ lldb/trunk/source/Symbol/TypeSystem.cpp Tue Sep 22 20:39:46 2015
@@ -80,3 +80,8 @@ TypeSystem::GetBuiltinTypeByName (const
     return CompilerType();
 }
 
+CompilerType
+TypeSystem::GetTypeForFormatters (void* type)
+{
+    return CompilerType(this, type);
+}




More information about the lldb-commits mailing list