[Lldb-commits] [lldb] c214c92 - [lldb][NFC] Remove ClangASTContext::GetBuiltinTypeForEncodingAndBitSize overload

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 29 04:58:03 PST 2019


Author: Raphael Isemann
Date: 2019-11-29T13:57:02+01:00
New Revision: c214c92f3be7c15abc458f23c7be05a5790e6aed

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

LOG: [lldb][NFC] Remove ClangASTContext::GetBuiltinTypeForEncodingAndBitSize overload

Added: 
    

Modified: 
    lldb/include/lldb/Symbol/ClangASTContext.h
    lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
    lldb/source/Symbol/ClangASTContext.cpp
    lldb/unittests/Symbol/TestClangASTContext.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index 7018f3b71b4f..a55307ef632d 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -150,9 +150,6 @@ class ClangASTContext : public TypeSystem {
   CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
                                                    size_t bit_size) override;
 
-  static CompilerType GetBuiltinTypeForEncodingAndBitSize(
-      clang::ASTContext *ast, lldb::Encoding encoding, uint32_t bit_size);
-
   CompilerType GetBasicType(lldb::BasicType type);
 
   CompilerType GetBasicType(ConstString name);

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index b33547529deb..22966e8023d6 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1762,8 +1762,8 @@ void ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
   CompilerType clang_type =
-      ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(
-          m_ast_context, reg_info->encoding, reg_info->byte_size * 8);
+      m_clang_ast_context->GetBuiltinTypeForEncodingAndBitSize(
+          reg_info->encoding, reg_info->byte_size * 8);
 
   if (!clang_type) {
     LLDB_LOGF(log, "  Tried to add a type for %s, but couldn't get one",

diff  --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 9988f0615651..8428dfe8c4fa 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -843,77 +843,62 @@ static inline bool QualTypeMatchesBitSize(const uint64_t bit_size,
 CompilerType
 ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
                                                      size_t bit_size) {
-  return ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(
-      getASTContext(), encoding, bit_size);
-}
-
-CompilerType ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(
-    ASTContext *ast, Encoding encoding, uint32_t bit_size) {
-  auto *clang_ast_context = ClangASTContext::GetASTContext(ast);
+  ASTContext *ast = this->getASTContext();
   if (!ast)
     return CompilerType();
   switch (encoding) {
   case eEncodingInvalid:
     if (QualTypeMatchesBitSize(bit_size, ast, ast->VoidPtrTy))
-      return CompilerType(clang_ast_context, ast->VoidPtrTy.getAsOpaquePtr());
+      return CompilerType(this, ast->VoidPtrTy.getAsOpaquePtr());
     break;
 
   case eEncodingUint:
     if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedCharTy))
-      return CompilerType(clang_ast_context,
-                          ast->UnsignedCharTy.getAsOpaquePtr());
+      return CompilerType(this, ast->UnsignedCharTy.getAsOpaquePtr());
     if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedShortTy))
-      return CompilerType(clang_ast_context,
-                          ast->UnsignedShortTy.getAsOpaquePtr());
+      return CompilerType(this, ast->UnsignedShortTy.getAsOpaquePtr());
     if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedIntTy))
-      return CompilerType(clang_ast_context,
-                          ast->UnsignedIntTy.getAsOpaquePtr());
+      return CompilerType(this, ast->UnsignedIntTy.getAsOpaquePtr());
     if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongTy))
-      return CompilerType(clang_ast_context,
-                          ast->UnsignedLongTy.getAsOpaquePtr());
+      return CompilerType(this, ast->UnsignedLongTy.getAsOpaquePtr());
     if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongLongTy))
-      return CompilerType(clang_ast_context,
-                          ast->UnsignedLongLongTy.getAsOpaquePtr());
+      return CompilerType(this, ast->UnsignedLongLongTy.getAsOpaquePtr());
     if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedInt128Ty))
-      return CompilerType(clang_ast_context,
-                          ast->UnsignedInt128Ty.getAsOpaquePtr());
+      return CompilerType(this, ast->UnsignedInt128Ty.getAsOpaquePtr());
     break;
 
   case eEncodingSint:
     if (QualTypeMatchesBitSize(bit_size, ast, ast->SignedCharTy))
-      return CompilerType(clang_ast_context,
-                          ast->SignedCharTy.getAsOpaquePtr());
+      return CompilerType(this, ast->SignedCharTy.getAsOpaquePtr());
     if (QualTypeMatchesBitSize(bit_size, ast, ast->ShortTy))
-      return CompilerType(clang_ast_context, ast->ShortTy.getAsOpaquePtr());
+      return CompilerType(this, ast->ShortTy.getAsOpaquePtr());
     if (QualTypeMatchesBitSize(bit_size, ast, ast->IntTy))
-      return CompilerType(clang_ast_context, ast->IntTy.getAsOpaquePtr());
+      return CompilerType(this, ast->IntTy.getAsOpaquePtr());
     if (QualTypeMatchesBitSize(bit_size, ast, ast->LongTy))
-      return CompilerType(clang_ast_context, ast->LongTy.getAsOpaquePtr());
+      return CompilerType(this, ast->LongTy.getAsOpaquePtr());
     if (QualTypeMatchesBitSize(bit_size, ast, ast->LongLongTy))
-      return CompilerType(clang_ast_context, ast->LongLongTy.getAsOpaquePtr());
+      return CompilerType(this, ast->LongLongTy.getAsOpaquePtr());
     if (QualTypeMatchesBitSize(bit_size, ast, ast->Int128Ty))
-      return CompilerType(clang_ast_context, ast->Int128Ty.getAsOpaquePtr());
+      return CompilerType(this, ast->Int128Ty.getAsOpaquePtr());
     break;
 
   case eEncodingIEEE754:
     if (QualTypeMatchesBitSize(bit_size, ast, ast->FloatTy))
-      return CompilerType(clang_ast_context, ast->FloatTy.getAsOpaquePtr());
+      return CompilerType(this, ast->FloatTy.getAsOpaquePtr());
     if (QualTypeMatchesBitSize(bit_size, ast, ast->DoubleTy))
-      return CompilerType(clang_ast_context, ast->DoubleTy.getAsOpaquePtr());
+      return CompilerType(this, ast->DoubleTy.getAsOpaquePtr());
     if (QualTypeMatchesBitSize(bit_size, ast, ast->LongDoubleTy))
-      return CompilerType(clang_ast_context,
-                          ast->LongDoubleTy.getAsOpaquePtr());
+      return CompilerType(this, ast->LongDoubleTy.getAsOpaquePtr());
     if (QualTypeMatchesBitSize(bit_size, ast, ast->HalfTy))
-      return CompilerType(clang_ast_context, ast->HalfTy.getAsOpaquePtr());
+      return CompilerType(this, ast->HalfTy.getAsOpaquePtr());
     break;
 
   case eEncodingVector:
     // Sanity check that bit_size is a multiple of 8's.
     if (bit_size && !(bit_size & 0x7u))
       return CompilerType(
-          clang_ast_context,
-          ast->getExtVectorType(ast->UnsignedCharTy, bit_size / 8)
-              .getAsOpaquePtr());
+          this, ast->getExtVectorType(ast->UnsignedCharTy, bit_size / 8)
+                    .getAsOpaquePtr());
     break;
   }
 

diff  --git a/lldb/unittests/Symbol/TestClangASTContext.cpp b/lldb/unittests/Symbol/TestClangASTContext.cpp
index 44a824636cf7..8fb24acc7a6a 100644
--- a/lldb/unittests/Symbol/TestClangASTContext.cpp
+++ b/lldb/unittests/Symbol/TestClangASTContext.cpp
@@ -169,10 +169,12 @@ TEST_F(TestClangASTContext, TestGetBasicTypeFromName) {
   EXPECT_EQ(GetBasicQualType(eBasicTypeNullPtr), GetBasicQualType("nullptr"));
 }
 
-void VerifyEncodingAndBitSize(clang::ASTContext *context,
+void VerifyEncodingAndBitSize(ClangASTContext &clang_context,
                               lldb::Encoding encoding, unsigned int bit_size) {
-  CompilerType type = ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(
-      context, encoding, bit_size);
+  clang::ASTContext *context = clang_context.getASTContext();
+
+  CompilerType type =
+      clang_context.GetBuiltinTypeForEncodingAndBitSize(encoding, bit_size);
   EXPECT_TRUE(type.IsValid());
 
   QualType qtype = ClangUtil::GetQualType(type);
@@ -206,8 +208,6 @@ void VerifyEncodingAndBitSize(clang::ASTContext *context,
 }
 
 TEST_F(TestClangASTContext, TestBuiltinTypeForEncodingAndBitSize) {
-  clang::ASTContext *context = m_ast->getASTContext();
-
   // Make sure we can get types of every possible size in every possible
   // encoding.
   // We can't make any guarantee about which specific type we get, because the
@@ -215,20 +215,20 @@ TEST_F(TestClangASTContext, TestBuiltinTypeForEncodingAndBitSize) {
   // isn't that specific.  We only need to make sure the compiler hands us some
   // type that
   // is both a builtin type and matches the requested bit size.
-  VerifyEncodingAndBitSize(context, eEncodingSint, 8);
-  VerifyEncodingAndBitSize(context, eEncodingSint, 16);
-  VerifyEncodingAndBitSize(context, eEncodingSint, 32);
-  VerifyEncodingAndBitSize(context, eEncodingSint, 64);
-  VerifyEncodingAndBitSize(context, eEncodingSint, 128);
-
-  VerifyEncodingAndBitSize(context, eEncodingUint, 8);
-  VerifyEncodingAndBitSize(context, eEncodingUint, 16);
-  VerifyEncodingAndBitSize(context, eEncodingUint, 32);
-  VerifyEncodingAndBitSize(context, eEncodingUint, 64);
-  VerifyEncodingAndBitSize(context, eEncodingUint, 128);
-
-  VerifyEncodingAndBitSize(context, eEncodingIEEE754, 32);
-  VerifyEncodingAndBitSize(context, eEncodingIEEE754, 64);
+  VerifyEncodingAndBitSize(*m_ast, eEncodingSint, 8);
+  VerifyEncodingAndBitSize(*m_ast, eEncodingSint, 16);
+  VerifyEncodingAndBitSize(*m_ast, eEncodingSint, 32);
+  VerifyEncodingAndBitSize(*m_ast, eEncodingSint, 64);
+  VerifyEncodingAndBitSize(*m_ast, eEncodingSint, 128);
+
+  VerifyEncodingAndBitSize(*m_ast, eEncodingUint, 8);
+  VerifyEncodingAndBitSize(*m_ast, eEncodingUint, 16);
+  VerifyEncodingAndBitSize(*m_ast, eEncodingUint, 32);
+  VerifyEncodingAndBitSize(*m_ast, eEncodingUint, 64);
+  VerifyEncodingAndBitSize(*m_ast, eEncodingUint, 128);
+
+  VerifyEncodingAndBitSize(*m_ast, eEncodingIEEE754, 32);
+  VerifyEncodingAndBitSize(*m_ast, eEncodingIEEE754, 64);
 }
 
 TEST_F(TestClangASTContext, TestIsClangType) {


        


More information about the lldb-commits mailing list