[Lldb-commits] [lldb] 6991d57 - [lldb][NFC] Make integer types functions in ClangASTContext not static

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Sun Dec 29 12:54:36 PST 2019


Author: Raphael Isemann
Date: 2019-12-29T21:54:07+01:00
New Revision: 6991d5728f12594cabfd8d8d570361efb07f1d5a

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

LOG: [lldb][NFC] Make integer types functions in ClangASTContext not static

These functions need a ClangASTContext instance that we would otherwise
recalculate by calling GetASTContext (which is no longer necessary with
this patch).

Added: 
    

Modified: 
    lldb/include/lldb/Symbol/ClangASTContext.h
    lldb/source/Symbol/ClangASTContext.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index 7bc5c5912aaa..9307825675cf 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -352,15 +352,9 @@ class ClangASTContext : public TypeSystem {
 
   // Integer type functions
 
-  static CompilerType GetIntTypeFromBitSize(clang::ASTContext *ast,
-                                            size_t bit_size, bool is_signed);
+  CompilerType GetIntTypeFromBitSize(size_t bit_size, bool is_signed);
 
-  CompilerType GetPointerSizedIntType(bool is_signed) {
-    return GetPointerSizedIntType(&getASTContext(), is_signed);
-  }
-
-  static CompilerType GetPointerSizedIntType(clang::ASTContext *ast,
-                                             bool is_signed);
+  CompilerType GetPointerSizedIntType(bool is_signed);
 
   // Floating point functions
 

diff  --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 0664db37a04c..e9727399d7ec 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -2094,66 +2094,53 @@ ClangASTContext::CreateEnumerationType(const char *name, DeclContext *decl_ctx,
   return CompilerType();
 }
 
-CompilerType ClangASTContext::GetIntTypeFromBitSize(clang::ASTContext *ast,
-                                                    size_t bit_size,
+CompilerType ClangASTContext::GetIntTypeFromBitSize(size_t bit_size,
                                                     bool is_signed) {
-  if (ast) {
-    auto *clang_ast_context = ClangASTContext::GetASTContext(ast);
-    if (is_signed) {
-      if (bit_size == ast->getTypeSize(ast->SignedCharTy))
-        return CompilerType(clang_ast_context,
-                            ast->SignedCharTy.getAsOpaquePtr());
+  clang::ASTContext &ast = getASTContext();
 
-      if (bit_size == ast->getTypeSize(ast->ShortTy))
-        return CompilerType(clang_ast_context, ast->ShortTy.getAsOpaquePtr());
+  if (is_signed) {
+    if (bit_size == ast.getTypeSize(ast.SignedCharTy))
+      return CompilerType(this, ast.SignedCharTy.getAsOpaquePtr());
 
-      if (bit_size == ast->getTypeSize(ast->IntTy))
-        return CompilerType(clang_ast_context, ast->IntTy.getAsOpaquePtr());
+    if (bit_size == ast.getTypeSize(ast.ShortTy))
+      return CompilerType(this, ast.ShortTy.getAsOpaquePtr());
 
-      if (bit_size == ast->getTypeSize(ast->LongTy))
-        return CompilerType(clang_ast_context, ast->LongTy.getAsOpaquePtr());
+    if (bit_size == ast.getTypeSize(ast.IntTy))
+      return CompilerType(this, ast.IntTy.getAsOpaquePtr());
 
-      if (bit_size == ast->getTypeSize(ast->LongLongTy))
-        return CompilerType(clang_ast_context,
-                            ast->LongLongTy.getAsOpaquePtr());
+    if (bit_size == ast.getTypeSize(ast.LongTy))
+      return CompilerType(this, ast.LongTy.getAsOpaquePtr());
 
-      if (bit_size == ast->getTypeSize(ast->Int128Ty))
-        return CompilerType(clang_ast_context, ast->Int128Ty.getAsOpaquePtr());
-    } else {
-      if (bit_size == ast->getTypeSize(ast->UnsignedCharTy))
-        return CompilerType(clang_ast_context,
-                            ast->UnsignedCharTy.getAsOpaquePtr());
+    if (bit_size == ast.getTypeSize(ast.LongLongTy))
+      return CompilerType(this, ast.LongLongTy.getAsOpaquePtr());
 
-      if (bit_size == ast->getTypeSize(ast->UnsignedShortTy))
-        return CompilerType(clang_ast_context,
-                            ast->UnsignedShortTy.getAsOpaquePtr());
+    if (bit_size == ast.getTypeSize(ast.Int128Ty))
+      return CompilerType(this, ast.Int128Ty.getAsOpaquePtr());
+  } else {
+    if (bit_size == ast.getTypeSize(ast.UnsignedCharTy))
+      return CompilerType(this, ast.UnsignedCharTy.getAsOpaquePtr());
 
-      if (bit_size == ast->getTypeSize(ast->UnsignedIntTy))
-        return CompilerType(clang_ast_context,
-                            ast->UnsignedIntTy.getAsOpaquePtr());
+    if (bit_size == ast.getTypeSize(ast.UnsignedShortTy))
+      return CompilerType(this, ast.UnsignedShortTy.getAsOpaquePtr());
 
-      if (bit_size == ast->getTypeSize(ast->UnsignedLongTy))
-        return CompilerType(clang_ast_context,
-                            ast->UnsignedLongTy.getAsOpaquePtr());
+    if (bit_size == ast.getTypeSize(ast.UnsignedIntTy))
+      return CompilerType(this, ast.UnsignedIntTy.getAsOpaquePtr());
 
-      if (bit_size == ast->getTypeSize(ast->UnsignedLongLongTy))
-        return CompilerType(clang_ast_context,
-                            ast->UnsignedLongLongTy.getAsOpaquePtr());
+    if (bit_size == ast.getTypeSize(ast.UnsignedLongTy))
+      return CompilerType(this, ast.UnsignedLongTy.getAsOpaquePtr());
 
-      if (bit_size == ast->getTypeSize(ast->UnsignedInt128Ty))
-        return CompilerType(clang_ast_context,
-                            ast->UnsignedInt128Ty.getAsOpaquePtr());
-    }
+    if (bit_size == ast.getTypeSize(ast.UnsignedLongLongTy))
+      return CompilerType(this, ast.UnsignedLongLongTy.getAsOpaquePtr());
+
+    if (bit_size == ast.getTypeSize(ast.UnsignedInt128Ty))
+      return CompilerType(this, ast.UnsignedInt128Ty.getAsOpaquePtr());
   }
   return CompilerType();
 }
 
-CompilerType ClangASTContext::GetPointerSizedIntType(clang::ASTContext *ast,
-                                                     bool is_signed) {
-  if (ast)
-    return GetIntTypeFromBitSize(ast, ast->getTypeSize(ast->VoidPtrTy),
-                                 is_signed);
-  return CompilerType();
+CompilerType ClangASTContext::GetPointerSizedIntType(bool is_signed) {
+  return GetIntTypeFromBitSize(
+      getASTContext().getTypeSize(getASTContext().VoidPtrTy), is_signed);
 }
 
 void ClangASTContext::DumpDeclContextHiearchy(clang::DeclContext *decl_ctx) {


        


More information about the lldb-commits mailing list