Commit b1fb07dd authored by Raphael Isemann's avatar Raphael Isemann
Browse files

[lldb][NFC] Simplify ClangASTContext::GetTypeForDecl

Also removes the GetASTContext call from this code.
parent 6991d572
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -164,11 +164,11 @@ public:
  static bool AreTypesSame(CompilerType type1, CompilerType type2,
                           bool ignore_qualifiers = false);

  static CompilerType GetTypeForDecl(clang::NamedDecl *decl);
  CompilerType GetTypeForDecl(clang::NamedDecl *decl);

  static CompilerType GetTypeForDecl(clang::TagDecl *decl);
  CompilerType GetTypeForDecl(clang::TagDecl *decl);

  static CompilerType GetTypeForDecl(clang::ObjCInterfaceDecl *objc_decl);
  CompilerType GetTypeForDecl(clang::ObjCInterfaceDecl *objc_decl);

  template <typename RecordDeclType>
  CompilerType
+4 −3
Original line number Diff line number Diff line
@@ -255,7 +255,8 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
  return type_sp;
}

static void CompleteExternalTagDeclType(ClangASTImporter &ast_importer,
static void CompleteExternalTagDeclType(ClangASTContext &ast,
                                        ClangASTImporter &ast_importer,
                                        clang::DeclContext *decl_ctx,
                                        DWARFDIE die,
                                        const char *type_name_cstr) {
@@ -264,7 +265,7 @@ static void CompleteExternalTagDeclType(ClangASTImporter &ast_importer,
    return;

  // If this type was not imported from an external AST, there's nothing to do.
  CompilerType type = ClangASTContext::GetTypeForDecl(tag_decl_ctx);
  CompilerType type = ast.GetTypeForDecl(tag_decl_ctx);
  if (!type || !ast_importer.CanImport(type))
    return;

@@ -1594,7 +1595,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
    // backing the Decl is complete before adding children to it. This is
    // not an issue in the non-gmodules case because the debug info will
    // always contain a full definition of parent types in that case.
    CompleteExternalTagDeclType(GetClangASTImporter(), decl_ctx, die,
    CompleteExternalTagDeclType(m_ast, GetClangASTImporter(), decl_ctx, die,
                                attrs.name.GetCString());

    if (attrs.accessibility == eAccessNone && decl_ctx) {
+5 −17
Original line number Diff line number Diff line
@@ -1179,25 +1179,13 @@ CompilerType ClangASTContext::GetTypeForDecl(clang::NamedDecl *decl) {
}

CompilerType ClangASTContext::GetTypeForDecl(TagDecl *decl) {
  // No need to call the getASTContext() accessor (which can create the AST if
  // it isn't created yet, because we can't have created a decl in this
  // AST if our AST didn't already exist...
  ASTContext *ast = &decl->getASTContext();
  if (ast)
    return CompilerType(ClangASTContext::GetASTContext(ast),
                        ast->getTagDeclType(decl).getAsOpaquePtr());
  return CompilerType();
  return CompilerType(this,
                      getASTContext().getTagDeclType(decl).getAsOpaquePtr());
}

CompilerType ClangASTContext::GetTypeForDecl(ObjCInterfaceDecl *decl) {
  // No need to call the getASTContext() accessor (which can create the AST if
  // it isn't created yet, because we can't have created a decl in this
  // AST if our AST didn't already exist...
  ASTContext *ast = &decl->getASTContext();
  if (ast)
    return CompilerType(ClangASTContext::GetASTContext(ast),
                        ast->getObjCInterfaceType(decl).getAsOpaquePtr());
  return CompilerType();
  return CompilerType(
      this, getASTContext().getObjCInterfaceType(decl).getAsOpaquePtr());
}

#pragma mark Structure, Unions, Classes
@@ -9183,7 +9171,7 @@ uint32_t ClangASTContext::CountDeclLevels(clang::DeclContext *frame_decl_ctx,
                  continue;
                // Check types, if one was provided.
                if (child_type) {
                  CompilerType clang_type = ClangASTContext::GetTypeForDecl(nd);
                  CompilerType clang_type = GetTypeForDecl(nd);
                  if (!AreTypesSame(clang_type, *child_type,
                                    /*ignore_qualifiers=*/true))
                    continue;