[clang] 90a2fbd - Switch to TypeSystemClang over to CreateDeserialized() (NFC)

Adrian Prantl via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 16 18:19:03 PDT 2020


Author: Adrian Prantl
Date: 2020-03-16T18:11:36-07:00
New Revision: 90a2fbdb044bcf285646e79f3b096ccb196f6d02

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

LOG: Switch to TypeSystemClang over to CreateDeserialized() (NFC)

which is the more appropriate API for its use-case.

Differential Revision: https://reviews.llvm.org/D75715

Added: 
    

Modified: 
    clang/include/clang/AST/DeclCXX.h
    clang/include/clang/AST/DeclTemplate.h
    lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h
index 987738f73676..60d99f1a487f 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -2415,17 +2415,6 @@ class CXXConstructorDecl final
                      : ExplicitSpecKind::ResolvedFalse);
   }
 
-  void setExplicitSpecifier(ExplicitSpecifier ES) {
-    assert((!ES.getExpr() ||
-            CXXConstructorDeclBits.HasTrailingExplicitSpecifier) &&
-           "cannot set this explicit specifier. no trail-allocated space for "
-           "explicit");
-    if (ES.getExpr())
-      *getCanonicalDecl()->getTrailingObjects<ExplicitSpecifier>() = ES;
-    else
-      CXXConstructorDeclBits.IsSimpleExplicit = ES.isExplicit();
-  }
-
   enum TraillingAllocKind {
     TAKInheritsConstructor = 1,
     TAKHasTailExplicit = 1 << 1,
@@ -2451,6 +2440,17 @@ class CXXConstructorDecl final
          InheritedConstructor Inherited = InheritedConstructor(),
          Expr *TrailingRequiresClause = nullptr);
 
+  void setExplicitSpecifier(ExplicitSpecifier ES) {
+    assert((!ES.getExpr() ||
+            CXXConstructorDeclBits.HasTrailingExplicitSpecifier) &&
+           "cannot set this explicit specifier. no trail-allocated space for "
+           "explicit");
+    if (ES.getExpr())
+      *getCanonicalDecl()->getTrailingObjects<ExplicitSpecifier>() = ES;
+    else
+      CXXConstructorDeclBits.IsSimpleExplicit = ES.isExplicit();
+  }
+
   ExplicitSpecifier getExplicitSpecifier() {
     return getCanonicalDecl()->getExplicitSpecifierInternal();
   }

diff  --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h
index def1ab18706c..e9c4879b41e8 100755
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -1927,6 +1927,10 @@ class ClassTemplateSpecializationDecl
         getTemplateSpecializationKind());
   }
 
+  void setSpecializedTemplate(ClassTemplateDecl *Specialized) {
+    SpecializedTemplate = Specialized;
+  }
+
   void setSpecializationKind(TemplateSpecializationKind TSK) {
     SpecializationKind = TSK;
   }

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 42655ad6cc24..c278aef8949e 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1207,10 +1207,11 @@ CompilerType TypeSystemClang::CreateRecordType(DeclContext *decl_ctx,
   // complete definition just in case.
 
   bool has_name = !name.empty();
-
-  CXXRecordDecl *decl = CXXRecordDecl::Create(
-      ast, (TagDecl::TagKind)kind, decl_ctx, SourceLocation(), SourceLocation(),
-      has_name ? &ast.Idents.get(name) : nullptr);
+  CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, 0);
+  decl->setTagKind(static_cast<TagDecl::TagKind>(kind));
+  decl->setDeclContext(decl_ctx);
+  if (has_name)
+    decl->setDeclName(&ast.Idents.get(name));
 
   if (!has_name) {
     // In C++ a lambda is also represented as an unnamed class. This is
@@ -1331,9 +1332,12 @@ clang::FunctionTemplateDecl *TypeSystemClang::CreateFunctionTemplateDecl(
 
   TemplateParameterList *template_param_list = CreateTemplateParameterList(
       ast, template_param_infos, template_param_decls);
-  FunctionTemplateDecl *func_tmpl_decl = FunctionTemplateDecl::Create(
-      ast, decl_ctx, func_decl->getLocation(), func_decl->getDeclName(),
-      template_param_list, func_decl);
+  FunctionTemplateDecl *func_tmpl_decl =
+      FunctionTemplateDecl::CreateDeserialized(ast, 0);
+  func_tmpl_decl->setDeclContext(decl_ctx);
+  func_tmpl_decl->setLocation(func_decl->getLocation());
+  func_tmpl_decl->setDeclName(func_decl->getDeclName());
+  func_tmpl_decl->init(func_decl, template_param_list);
 
   for (size_t i = 0, template_param_decl_count = template_param_decls.size();
        i < template_param_decl_count; ++i) {
@@ -1384,11 +1388,11 @@ ClassTemplateDecl *TypeSystemClang::CreateClassTemplateDecl(
   TemplateParameterList *template_param_list = CreateTemplateParameterList(
       ast, template_param_infos, template_param_decls);
 
-  CXXRecordDecl *template_cxx_decl = CXXRecordDecl::Create(
-      ast, (TagDecl::TagKind)kind,
-      decl_ctx, // What decl context do we use here? TU? The actual decl
-                // context?
-      SourceLocation(), SourceLocation(), &identifier_info);
+  CXXRecordDecl *template_cxx_decl = CXXRecordDecl::CreateDeserialized(ast, 0);
+  template_cxx_decl->setTagKind(static_cast<TagDecl::TagKind>(kind));
+  // What decl context do we use here? TU? The actual decl context?
+  template_cxx_decl->setDeclContext(decl_ctx);
+  template_cxx_decl->setDeclName(decl_name);
 
   for (size_t i = 0, template_param_decl_count = template_param_decls.size();
        i < template_param_decl_count; ++i) {
@@ -1400,11 +1404,11 @@ ClassTemplateDecl *TypeSystemClang::CreateClassTemplateDecl(
   // template_cxx_decl->startDefinition();
   // template_cxx_decl->completeDefinition();
 
-  class_template_decl = ClassTemplateDecl::Create(
-      ast,
-      decl_ctx, // What decl context do we use here? TU? The actual decl
-                // context?
-      SourceLocation(), decl_name, template_param_list, template_cxx_decl);
+  class_template_decl = ClassTemplateDecl::CreateDeserialized(ast, 0);
+  // What decl context do we use here? TU? The actual decl context?
+  class_template_decl->setDeclContext(decl_ctx);
+  class_template_decl->setDeclName(decl_name);
+  class_template_decl->init(template_cxx_decl, template_param_list);
   template_cxx_decl->setDescribedClassTemplate(class_template_decl);
 
   if (class_template_decl) {
@@ -1458,9 +1462,16 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl(
         ast, template_param_infos.packed_args->args);
   }
   ClassTemplateSpecializationDecl *class_template_specialization_decl =
-      ClassTemplateSpecializationDecl::Create(
-          ast, (TagDecl::TagKind)kind, decl_ctx, SourceLocation(),
-          SourceLocation(), class_template_decl, args, nullptr);
+      ClassTemplateSpecializationDecl::CreateDeserialized(ast, 0);
+  class_template_specialization_decl->setTagKind(
+      static_cast<TagDecl::TagKind>(kind));
+  class_template_specialization_decl->setDeclContext(decl_ctx);
+  class_template_specialization_decl->setInstantiationOf(class_template_decl);
+  class_template_specialization_decl->setTemplateArgs(
+      TemplateArgumentList::CreateCopy(ast, args));
+  ast.getTypeDeclType(class_template_specialization_decl, nullptr);
+  class_template_specialization_decl->setDeclName(
+      class_template_decl->getDeclName());
 
   class_template_specialization_decl->setSpecializationKind(
       TSK_ExplicitSpecialization);
@@ -1589,11 +1600,11 @@ CompilerType TypeSystemClang::CreateObjCClass(llvm::StringRef name,
   if (decl_ctx == nullptr)
     decl_ctx = ast.getTranslationUnitDecl();
 
-  ObjCInterfaceDecl *decl = ObjCInterfaceDecl::Create(
-      ast, decl_ctx, SourceLocation(), &ast.Idents.get(name), nullptr, nullptr,
-      SourceLocation(),
-      /*isForwardDecl,*/
-      isInternal);
+  ObjCInterfaceDecl *decl = ObjCInterfaceDecl::CreateDeserialized(ast, 0);
+  decl->setDeclContext(decl_ctx);
+  decl->setDeclName(&ast.Idents.get(name));
+  /*isForwardDecl,*/
+  decl->setImplicit(isInternal);
 
   if (decl && metadata)
     SetMetadata(decl, *metadata);
@@ -1631,7 +1642,7 @@ TypeSystemClang::GetNumBaseClasses(const CXXRecordDecl *cxx_record_decl,
 #pragma mark Namespace Declarations
 
 NamespaceDecl *TypeSystemClang::GetUniqueNamespaceDeclaration(
-    const char *name, DeclContext *decl_ctx, bool is_inline) {
+    const char *name, clang::DeclContext *decl_ctx, bool is_inline) {
   NamespaceDecl *namespace_decl = nullptr;
   ASTContext &ast = getASTContext();
   TranslationUnitDecl *translation_unit_decl = ast.getTranslationUnitDecl();
@@ -1690,9 +1701,10 @@ NamespaceDecl *TypeSystemClang::GetUniqueNamespaceDeclaration(
 
 clang::BlockDecl *
 TypeSystemClang::CreateBlockDeclaration(clang::DeclContext *ctx) {
-  if (ctx != nullptr) {
+  if (ctx) {
     clang::BlockDecl *decl =
-        clang::BlockDecl::Create(getASTContext(), ctx, clang::SourceLocation());
+        clang::BlockDecl::CreateDeserialized(getASTContext(), 0);
+    decl->setDeclContext(ctx);
     ctx->addDecl(decl);
     return decl;
   }
@@ -1718,15 +1730,16 @@ clang::DeclContext *FindLCABetweenDecls(clang::DeclContext *left,
 
 clang::UsingDirectiveDecl *TypeSystemClang::CreateUsingDirectiveDeclaration(
     clang::DeclContext *decl_ctx, clang::NamespaceDecl *ns_decl) {
-  if (decl_ctx != nullptr && ns_decl != nullptr) {
+  if (decl_ctx && ns_decl) {
     auto *translation_unit = getASTContext().getTranslationUnitDecl();
     clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
-        getASTContext(), decl_ctx, clang::SourceLocation(),
-        clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
-        clang::SourceLocation(), ns_decl,
-        FindLCABetweenDecls(decl_ctx, ns_decl, translation_unit));
-    decl_ctx->addDecl(using_decl);
-    return using_decl;
+          getASTContext(), decl_ctx, clang::SourceLocation(),
+          clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
+          clang::SourceLocation(), ns_decl,
+          FindLCABetweenDecls(decl_ctx, ns_decl,
+                              translation_unit));
+      decl_ctx->addDecl(using_decl);
+      return using_decl;
   }
   return nullptr;
 }
@@ -1750,12 +1763,13 @@ TypeSystemClang::CreateUsingDeclaration(clang::DeclContext *current_decl_ctx,
 
 clang::VarDecl *TypeSystemClang::CreateVariableDeclaration(
     clang::DeclContext *decl_context, const char *name, clang::QualType type) {
-  if (decl_context != nullptr) {
-    clang::VarDecl *var_decl = clang::VarDecl::Create(
-        getASTContext(), decl_context, clang::SourceLocation(),
-        clang::SourceLocation(),
-        name && name[0] ? &getASTContext().Idents.getOwn(name) : nullptr, type,
-        nullptr, clang::SC_None);
+  if (decl_context) {
+    clang::VarDecl *var_decl =
+        clang::VarDecl::CreateDeserialized(getASTContext(), 0);
+    var_decl->setDeclContext(decl_context);
+    if (name && name[0])
+      var_decl->setDeclName(&getASTContext().Idents.getOwn(name));
+    var_decl->setType(type);
     var_decl->setAccess(clang::AS_public);
     decl_context->addDecl(var_decl);
     return var_decl;
@@ -1879,11 +1893,15 @@ FunctionDecl *TypeSystemClang::CreateFunctionDeclaration(
 
   clang::DeclarationName declarationName =
       GetDeclarationName(name, function_clang_type);
-  func_decl = FunctionDecl::Create(
-      ast, decl_ctx, SourceLocation(), SourceLocation(), declarationName,
-      ClangUtil::GetQualType(function_clang_type), nullptr,
-      (clang::StorageClass)storage, is_inline, hasWrittenPrototype,
-      isConstexprSpecified ? CSK_constexpr : CSK_unspecified);
+  func_decl = FunctionDecl::CreateDeserialized(ast, 0);
+  func_decl->setDeclContext(decl_ctx);
+  func_decl->setDeclName(declarationName);
+  func_decl->setType(ClangUtil::GetQualType(function_clang_type));
+  func_decl->setStorageClass(static_cast<clang::StorageClass>(storage));
+  func_decl->setInlineSpecified(is_inline);
+  func_decl->setHasWrittenPrototype(hasWrittenPrototype);
+  func_decl->setConstexprKind(isConstexprSpecified ? CSK_constexpr
+                                                   : CSK_unspecified);
   if (func_decl)
     decl_ctx->addDecl(func_decl);
 
@@ -1935,11 +1953,12 @@ ParmVarDecl *TypeSystemClang::CreateParameterDeclaration(
     clang::DeclContext *decl_ctx, const char *name,
     const CompilerType &param_type, int storage, bool add_decl) {
   ASTContext &ast = getASTContext();
-  auto *decl =
-      ParmVarDecl::Create(ast, decl_ctx, SourceLocation(), SourceLocation(),
-                          name && name[0] ? &ast.Idents.get(name) : nullptr,
-                          ClangUtil::GetQualType(param_type), nullptr,
-                          (clang::StorageClass)storage, nullptr);
+  auto *decl = ParmVarDecl::CreateDeserialized(ast, 0);
+  decl->setDeclContext(decl_ctx);
+  if (name && name[0])
+    decl->setDeclName(&ast.Idents.get(name));
+  decl->setType(ClangUtil::GetQualType(param_type));
+  decl->setStorageClass(static_cast<clang::StorageClass>(storage));
   if (add_decl)
     decl_ctx->addDecl(decl);
 
@@ -2036,13 +2055,15 @@ TypeSystemClang::CreateEnumerationType(const char *name, DeclContext *decl_ctx,
   // like maybe filling in the SourceLocation with it...
   ASTContext &ast = getASTContext();
 
-  EnumDecl *enum_decl = EnumDecl::Create(
-      ast, decl_ctx, SourceLocation(), SourceLocation(),
-      name && name[0] ? &ast.Idents.get(name) : nullptr, nullptr,
-      is_scoped, // IsScoped
-      is_scoped, // IsScopedUsingClassTag
-      false);    // TODO: IsFixed
-
+  // TODO: ask about these...
+  //    const bool IsFixed = false;
+  EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, 0);
+  enum_decl->setDeclContext(decl_ctx);
+  if (name && name[0])
+    enum_decl->setDeclName(&ast.Idents.get(name));
+  enum_decl->setScoped(is_scoped);
+  enum_decl->setScopedUsingClassTag(is_scoped);
+  enum_decl->setFixed(false);
   if (enum_decl) {
     if (decl_ctx)
       decl_ctx->addDecl(enum_decl);
@@ -4243,10 +4264,11 @@ CompilerType TypeSystemClang::CreateTypedefType(
     if (decl_ctx == nullptr)
       decl_ctx = ast->getASTContext().getTranslationUnitDecl();
 
-    clang::TypedefDecl *decl = clang::TypedefDecl::Create(
-        clang_ast, decl_ctx, clang::SourceLocation(), clang::SourceLocation(),
-        &clang_ast.Idents.get(typedef_name),
-        clang_ast.getTrivialTypeSourceInfo(qual_type));
+    clang::TypedefDecl *decl =
+        clang::TypedefDecl::CreateDeserialized(clang_ast, 0);
+    decl->setDeclContext(decl_ctx);
+    decl->setDeclName(&clang_ast.Idents.get(typedef_name));
+    decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
 
     decl->setAccess(clang::AS_public); // TODO respect proper access specifier
 
@@ -4349,10 +4371,11 @@ TypeSystemClang::CreateTypedef(lldb::opaque_compiler_type_t type,
     if (decl_ctx == nullptr)
       decl_ctx = getASTContext().getTranslationUnitDecl();
 
-    clang::TypedefDecl *decl = clang::TypedefDecl::Create(
-        clang_ast, decl_ctx, clang::SourceLocation(), clang::SourceLocation(),
-        &clang_ast.Idents.get(typedef_name),
-        clang_ast.getTrivialTypeSourceInfo(qual_type));
+    clang::TypedefDecl *decl =
+        clang::TypedefDecl::CreateDeserialized(clang_ast, 0);
+    decl->setDeclContext(decl_ctx);
+    decl->setDeclName(&clang_ast.Idents.get(typedef_name));
+    decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
 
     clang::TagDecl *tdecl = nullptr;
     if (!qual_type.isNull()) {
@@ -6888,15 +6911,12 @@ clang::FieldDecl *TypeSystemClang::AddFieldToRecordType(
 
   clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
   if (record_decl) {
-    field = clang::FieldDecl::Create(
-        clang_ast, record_decl, clang::SourceLocation(),
-        clang::SourceLocation(),
-        ident,                                    // Identifier
-        ClangUtil::GetQualType(field_clang_type), // Field type
-        nullptr,                                  // TInfo *
-        bit_width,                                // BitWidth
-        false,                                    // Mutable
-        clang::ICIS_NoInit);                      // HasInit
+    field = clang::FieldDecl::CreateDeserialized(clang_ast, 0);
+    field->setDeclContext(record_decl);
+    field->setDeclName(ident);
+    field->setType(ClangUtil::GetQualType(field_clang_type));
+    if (bit_width)
+      field->setBitWidth(bit_width);
 
     if (name.empty()) {
       // Determine whether this field corresponds to an anonymous struct or
@@ -6929,14 +6949,15 @@ clang::FieldDecl *TypeSystemClang::AddFieldToRecordType(
 
       field_clang_type.GetCompleteType();
 
-      field = clang::ObjCIvarDecl::Create(
-          clang_ast, class_interface_decl, clang::SourceLocation(),
-          clang::SourceLocation(),
-          ident,                                    // Identifier
-          ClangUtil::GetQualType(field_clang_type), // Field type
-          nullptr,                                  // TypeSourceInfo *
-          ConvertAccessTypeToObjCIvarAccessControl(access), bit_width,
-          is_synthesized);
+      auto ivar = clang::ObjCIvarDecl::CreateDeserialized(clang_ast, 0);
+      ivar->setDeclContext(class_interface_decl);
+      ivar->setDeclName(ident);
+      ivar->setType(ClangUtil::GetQualType(field_clang_type));
+      ivar->setAccessControl(ConvertAccessTypeToObjCIvarAccessControl(access));
+      if (bit_width)
+        ivar->setBitWidth(bit_width);
+      ivar->setSynthesize(is_synthesized);
+      field = ivar;
 
       if (field) {
         class_interface_decl->addDecl(field);
@@ -7089,15 +7110,11 @@ clang::VarDecl *TypeSystemClang::AddVariableToRecordType(
   if (!name.empty())
     ident = &ast->getASTContext().Idents.get(name);
 
-  var_decl = clang::VarDecl::Create(
-      ast->getASTContext(),             // ASTContext &
-      record_decl,                      // DeclContext *
-      clang::SourceLocation(),          // clang::SourceLocation StartLoc
-      clang::SourceLocation(),          // clang::SourceLocation IdLoc
-      ident,                            // clang::IdentifierInfo *
-      ClangUtil::GetQualType(var_type), // Variable clang::QualType
-      nullptr,                          // TypeSourceInfo *
-      clang::SC_Static);                // StorageClass
+  var_decl = clang::VarDecl::CreateDeserialized(ast->getASTContext(), 0);
+  var_decl->setDeclContext(record_decl);
+  var_decl->setDeclName(ident);
+  var_decl->setType(ClangUtil::GetQualType(var_type));
+  var_decl->setStorageClass(clang::SC_Static);
   if (!var_decl)
     return nullptr;
 
@@ -7153,29 +7170,34 @@ clang::CXXMethodDecl *TypeSystemClang::AddMethodToCXXRecordType(
     return nullptr; // skip everything artificial
 
   const clang::ExplicitSpecifier explicit_spec(
-      nullptr /*expr*/, is_explicit
-                            ? clang::ExplicitSpecKind::ResolvedTrue
-                            : clang::ExplicitSpecKind::ResolvedFalse);
+      nullptr /*expr*/, is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
+                                    : clang::ExplicitSpecKind::ResolvedFalse);
+
   if (name.startswith("~")) {
-    cxx_dtor_decl = clang::CXXDestructorDecl::Create(
-        getASTContext(), cxx_record_decl, clang::SourceLocation(),
-        clang::DeclarationNameInfo(
-            getASTContext().DeclarationNames.getCXXDestructorName(
-                getASTContext().getCanonicalType(record_qual_type)),
-            clang::SourceLocation()),
-        method_qual_type, nullptr, is_inline, is_artificial,
-        ConstexprSpecKind::CSK_unspecified);
+    cxx_dtor_decl =
+        clang::CXXDestructorDecl::CreateDeserialized(getASTContext(), 0);
+    cxx_dtor_decl->setDeclContext(cxx_record_decl);
+    cxx_dtor_decl->setDeclName(
+        getASTContext().DeclarationNames.getCXXDestructorName(
+            getASTContext().getCanonicalType(record_qual_type)));
+    cxx_dtor_decl->setType(method_qual_type);
+    cxx_dtor_decl->setImplicit(is_artificial);
+    cxx_dtor_decl->setInlineSpecified(is_inline);
+    cxx_dtor_decl->setConstexprKind(CSK_unspecified);
     cxx_method_decl = cxx_dtor_decl;
   } else if (decl_name == cxx_record_decl->getDeclName()) {
-    cxx_ctor_decl = clang::CXXConstructorDecl::Create(
-        getASTContext(), cxx_record_decl, clang::SourceLocation(),
-        clang::DeclarationNameInfo(
-            getASTContext().DeclarationNames.getCXXConstructorName(
-                getASTContext().getCanonicalType(record_qual_type)),
-            clang::SourceLocation()),
-        method_qual_type,
-        nullptr, // TypeSourceInfo *
-        explicit_spec, is_inline, is_artificial, CSK_unspecified);
+    cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
+        getASTContext(), 0, 0);
+    cxx_ctor_decl->setDeclContext(cxx_record_decl);
+    cxx_ctor_decl->setDeclName(
+        getASTContext().DeclarationNames.getCXXConstructorName(
+            getASTContext().getCanonicalType(record_qual_type)));
+    cxx_ctor_decl->setType(method_qual_type);
+    cxx_ctor_decl->setImplicit(is_artificial);
+    cxx_ctor_decl->setInlineSpecified(is_inline);
+    cxx_ctor_decl->setConstexprKind(CSK_unspecified);
+    cxx_ctor_decl->setNumCtorInitializers(0);
+    cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
     cxx_method_decl = cxx_ctor_decl;
   } else {
     clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
@@ -7191,36 +7213,41 @@ clang::CXXMethodDecl *TypeSystemClang::AddMethodToCXXRecordType(
         if (!TypeSystemClang::CheckOverloadedOperatorKindParameterCount(
                 is_method, op_kind, num_params))
           return nullptr;
-        cxx_method_decl = clang::CXXMethodDecl::Create(
-            getASTContext(), cxx_record_decl, clang::SourceLocation(),
-            clang::DeclarationNameInfo(
-                getASTContext().DeclarationNames.getCXXOperatorName(op_kind),
-                clang::SourceLocation()),
-            method_qual_type,
-            nullptr, // TypeSourceInfo *
-            SC, is_inline, CSK_unspecified, clang::SourceLocation());
+        cxx_method_decl =
+            clang::CXXMethodDecl::CreateDeserialized(getASTContext(), 0);
+        cxx_method_decl->setDeclContext(cxx_record_decl);
+        cxx_method_decl->setDeclName(
+            getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
+        cxx_method_decl->setType(method_qual_type);
+        cxx_method_decl->setStorageClass(SC);
+        cxx_method_decl->setInlineSpecified(is_inline);
+        cxx_method_decl->setConstexprKind(CSK_unspecified);
       } else if (num_params == 0) {
         // Conversion operators don't take params...
-        cxx_method_decl = clang::CXXConversionDecl::Create(
-            getASTContext(), cxx_record_decl, clang::SourceLocation(),
-            clang::DeclarationNameInfo(
-                getASTContext().DeclarationNames.getCXXConversionFunctionName(
-                    getASTContext().getCanonicalType(
-                        function_type->getReturnType())),
-                clang::SourceLocation()),
-            method_qual_type,
-            nullptr, // TypeSourceInfo *
-            is_inline, explicit_spec, CSK_unspecified, clang::SourceLocation());
+        auto *cxx_conversion_decl =
+            clang::CXXConversionDecl::CreateDeserialized(getASTContext(), 0);
+        cxx_conversion_decl->setDeclContext(cxx_record_decl);
+        cxx_conversion_decl->setDeclName(
+            getASTContext().DeclarationNames.getCXXConversionFunctionName(
+                getASTContext().getCanonicalType(
+                    function_type->getReturnType())));
+        cxx_conversion_decl->setType(method_qual_type);
+        cxx_conversion_decl->setInlineSpecified(is_inline);
+        cxx_conversion_decl->setExplicitSpecifier(explicit_spec);        
+        cxx_conversion_decl->setConstexprKind(CSK_unspecified);
+        cxx_method_decl = cxx_conversion_decl;
       }
     }
 
     if (cxx_method_decl == nullptr) {
-      cxx_method_decl = clang::CXXMethodDecl::Create(
-          getASTContext(), cxx_record_decl, clang::SourceLocation(),
-          clang::DeclarationNameInfo(decl_name, clang::SourceLocation()),
-          method_qual_type,
-          nullptr, // TypeSourceInfo *
-          SC, is_inline, CSK_unspecified, clang::SourceLocation());
+      cxx_method_decl =
+          clang::CXXMethodDecl::CreateDeserialized(getASTContext(), 0);
+      cxx_method_decl->setDeclContext(cxx_record_decl);
+      cxx_method_decl->setDeclName(decl_name);
+      cxx_method_decl->setType(method_qual_type);
+      cxx_method_decl->setInlineSpecified(is_inline);
+      cxx_method_decl->setStorageClass(SC);
+      cxx_method_decl->setConstexprKind(CSK_unspecified);
     }
   }
 
@@ -7389,15 +7416,14 @@ bool TypeSystemClang::AddObjCClassProperty(
     prop_type_source = clang_ast.getTrivialTypeSourceInfo(
         ClangUtil::GetQualType(property_clang_type));
 
-  clang::ObjCPropertyDecl *property_decl = clang::ObjCPropertyDecl::Create(
-      clang_ast, class_interface_decl,
-      clang::SourceLocation(), // Source Location
-      &clang_ast.Idents.get(property_name),
-      clang::SourceLocation(), // Source Location for AT
-      clang::SourceLocation(), // Source location for (
-      ivar_decl ? ivar_decl->getType()
-                : ClangUtil::GetQualType(property_clang_type),
-      prop_type_source);
+  clang::ObjCPropertyDecl *property_decl =
+      clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, 0);
+  property_decl->setDeclContext(class_interface_decl);
+  property_decl->setDeclName(&clang_ast.Idents.get(property_name));
+  property_decl->setType(ivar_decl
+                             ? ivar_decl->getType()
+                             : ClangUtil::GetQualType(property_clang_type),
+                         prop_type_source);
 
   if (!property_decl)
     return false;
@@ -7477,12 +7503,18 @@ bool TypeSystemClang::AddObjCClassProperty(
         clang::ObjCMethodDecl::None;
     const bool HasRelatedResultType = false;
 
-    getter = clang::ObjCMethodDecl::Create(
-        clang_ast, clang::SourceLocation(), clang::SourceLocation(), getter_sel,
-        ClangUtil::GetQualType(property_clang_type_to_access), nullptr,
-        class_interface_decl, isInstance, isVariadic, isPropertyAccessor,
-        isSynthesizedAccessorStub, isImplicitlyDeclared, isDefined, impControl,
-        HasRelatedResultType);
+    getter = clang::ObjCMethodDecl::CreateDeserialized(clang_ast, 0);
+    getter->setDeclName(getter_sel);
+    getter->setReturnType(ClangUtil::GetQualType(property_clang_type_to_access));
+    getter->setDeclContext(class_interface_decl);
+    getter->setInstanceMethod(isInstance);
+    getter->setVariadic(isVariadic);
+    getter->setPropertyAccessor(isPropertyAccessor);
+    getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
+    getter->setImplicit(isImplicitlyDeclared);
+    getter->setDefined(isDefined);
+    getter->setDeclImplementation(impControl);
+    getter->setRelatedResultType(HasRelatedResultType);
 
     if (getter) {
       if (metadata)
@@ -7512,11 +7544,18 @@ bool TypeSystemClang::AddObjCClassProperty(
         clang::ObjCMethodDecl::None;
     const bool HasRelatedResultType = false;
 
-    setter = clang::ObjCMethodDecl::Create(
-        clang_ast, clang::SourceLocation(), clang::SourceLocation(), setter_sel,
-        result_type, nullptr, class_interface_decl, isInstance, isVariadic,
-        isPropertyAccessor, isSynthesizedAccessorStub, isImplicitlyDeclared,
-        isDefined, impControl, HasRelatedResultType);
+    setter = clang::ObjCMethodDecl::CreateDeserialized(clang_ast, 0);
+    setter->setDeclName(setter_sel);
+    setter->setReturnType(result_type);
+    setter->setDeclContext(class_interface_decl);
+    setter->setInstanceMethod(isInstance);
+    setter->setVariadic(isVariadic);
+    setter->setPropertyAccessor(isPropertyAccessor);
+    setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
+    setter->setImplicit(isImplicitlyDeclared);
+    setter->setDefined(isDefined);
+    setter->setDeclImplementation(impControl);
+    setter->setRelatedResultType(HasRelatedResultType);
 
     if (setter) {
       if (metadata)
@@ -7632,15 +7671,19 @@ clang::ObjCMethodDecl *TypeSystemClang::AddMethodToObjCObjectType(
     return nullptr; // some debug information is corrupt.  We are not going to
                     // deal with it.
 
-  clang::ObjCMethodDecl *objc_method_decl = clang::ObjCMethodDecl::Create(
-      ast,
-      clang::SourceLocation(), // beginLoc,
-      clang::SourceLocation(), // endLoc,
-      method_selector, method_function_prototype->getReturnType(),
-      nullptr, // TypeSourceInfo *ResultTInfo,
-      lldb_ast->GetDeclContextForType(ClangUtil::GetQualType(type)), isInstance,
-      isVariadic, isPropertyAccessor, isSynthesizedAccessorStub,
-      isImplicitlyDeclared, isDefined, impControl, HasRelatedResultType);
+  auto *objc_method_decl = clang::ObjCMethodDecl::CreateDeserialized(ast, 0);
+  objc_method_decl->setDeclName(method_selector);
+  objc_method_decl->setReturnType(method_function_prototype->getReturnType());
+  objc_method_decl->setDeclContext(
+      lldb_ast->GetDeclContextForType(ClangUtil::GetQualType(type)));
+  objc_method_decl->setInstanceMethod(isInstance);
+  objc_method_decl->setVariadic(isVariadic);
+  objc_method_decl->setPropertyAccessor(isPropertyAccessor);
+  objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
+  objc_method_decl->setImplicit(isImplicitlyDeclared);
+  objc_method_decl->setDefined(isDefined);
+  objc_method_decl->setDeclImplementation(impControl);
+  objc_method_decl->setRelatedResultType(HasRelatedResultType);
 
   if (objc_method_decl == nullptr)
     return nullptr;
@@ -7864,10 +7907,13 @@ clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType(
   if (!enutype)
     return nullptr;
 
-  clang::EnumConstantDecl *enumerator_decl = clang::EnumConstantDecl::Create(
-      getASTContext(), enutype->getDecl(), clang::SourceLocation(),
-      name ? &getASTContext().Idents.get(name) : nullptr, // Identifier
-      clang::QualType(enutype, 0), nullptr, value);
+  clang::EnumConstantDecl *enumerator_decl =
+      clang::EnumConstantDecl::CreateDeserialized(getASTContext(), 0);
+  enumerator_decl->setDeclContext(enutype->getDecl());
+  if (name && name[0])
+    enumerator_decl->setDeclName(&getASTContext().Idents.get(name));
+  enumerator_decl->setType(clang::QualType(enutype, 0));
+  enumerator_decl->setInitVal(value);
 
   if (!enumerator_decl)
     return nullptr;


        


More information about the cfe-commits mailing list