[lldb][TypeSystem][NFC] CreateFunctionType to take parameters by llvm::ArrayRef (#142620)
This commit is contained in:
@@ -1978,10 +1978,10 @@ void ClangExpressionDeclMap::AddContextClassType(NameSearchContext &context,
|
||||
copied_clang_type.GetCompleteType()) {
|
||||
CompilerType void_clang_type =
|
||||
m_clang_ast_context->GetBasicType(eBasicTypeVoid);
|
||||
CompilerType void_ptr_clang_type = void_clang_type.GetPointerType();
|
||||
std::array<CompilerType, 1> args{void_clang_type.GetPointerType()};
|
||||
|
||||
CompilerType method_type = m_clang_ast_context->CreateFunctionType(
|
||||
void_clang_type, &void_ptr_clang_type, 1, false, 0);
|
||||
void_clang_type, args, false, 0);
|
||||
|
||||
const bool is_virtual = false;
|
||||
const bool is_static = false;
|
||||
|
||||
@@ -150,8 +150,9 @@ lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::Update() {
|
||||
lldb::ProcessSP process_sp = target_sp->GetProcessSP();
|
||||
auto ptr_size = process_sp->GetAddressByteSize();
|
||||
CompilerType void_type = ast_ctx->GetBasicType(lldb::eBasicTypeVoid);
|
||||
std::array<CompilerType, 1> args{void_type};
|
||||
CompilerType coro_func_type = ast_ctx->CreateFunctionType(
|
||||
/*result_type=*/void_type, /*args=*/&void_type, /*num_args=*/1,
|
||||
/*result_type=*/void_type, args,
|
||||
/*is_variadic=*/false, /*qualifiers=*/0);
|
||||
CompilerType coro_func_ptr_type = coro_func_type.GetPointerType();
|
||||
m_resume_ptr_sp = CreateValueObjectFromAddress(
|
||||
|
||||
@@ -489,8 +489,8 @@ SymbolFileCTF::CreateFunction(const CTFFunction &ctf_function) {
|
||||
llvm::inconvertibleErrorCode());
|
||||
|
||||
CompilerType func_type = m_ast->CreateFunctionType(
|
||||
ret_type->GetFullCompilerType(), arg_types.data(), arg_types.size(),
|
||||
ctf_function.variadic, 0, clang::CallingConv::CC_C);
|
||||
ret_type->GetFullCompilerType(), arg_types, ctf_function.variadic, 0,
|
||||
clang::CallingConv::CC_C);
|
||||
|
||||
Declaration decl;
|
||||
return MakeType(ctf_function.uid, ConstString(ctf_function.name), 0, nullptr,
|
||||
@@ -814,8 +814,7 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
|
||||
// Create function type.
|
||||
CompilerType func_type = m_ast->CreateFunctionType(
|
||||
ret_type ? ret_type->GetFullCompilerType() : CompilerType(),
|
||||
arg_types.data(), arg_types.size(), is_variadic, 0,
|
||||
clang::CallingConv::CC_C);
|
||||
arg_types, is_variadic, 0, clang::CallingConv::CC_C);
|
||||
lldb::user_id_t function_type_uid = m_types.size() + 1;
|
||||
TypeSP type_sp =
|
||||
MakeType(function_type_uid, symbol->GetName(), 0, nullptr,
|
||||
|
||||
@@ -1309,11 +1309,10 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
|
||||
|
||||
// clang_type will get the function prototype clang type after this
|
||||
// call
|
||||
CompilerType clang_type =
|
||||
m_ast.CreateFunctionType(return_clang_type, function_param_types.data(),
|
||||
function_param_types.size(), is_variadic,
|
||||
GetCXXMethodCVQuals(die, object_parameter),
|
||||
calling_convention, attrs.ref_qual);
|
||||
CompilerType clang_type = m_ast.CreateFunctionType(
|
||||
return_clang_type, function_param_types, is_variadic,
|
||||
GetCXXMethodCVQuals(die, object_parameter), calling_convention,
|
||||
attrs.ref_qual);
|
||||
|
||||
if (attrs.name) {
|
||||
bool type_handled = false;
|
||||
|
||||
@@ -1216,8 +1216,8 @@ clang::QualType PdbAstBuilder::CreateFunctionType(
|
||||
return {};
|
||||
|
||||
CompilerType return_ct = ToCompilerType(return_type);
|
||||
CompilerType func_sig_ast_type = m_clang.CreateFunctionType(
|
||||
return_ct, arg_types.data(), arg_types.size(), is_variadic, 0, *cc);
|
||||
CompilerType func_sig_ast_type =
|
||||
m_clang.CreateFunctionType(return_ct, arg_types, is_variadic, 0, *cc);
|
||||
|
||||
return clang::QualType::getFromOpaquePtr(
|
||||
func_sig_ast_type.GetOpaqueQualType());
|
||||
|
||||
@@ -653,9 +653,8 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
|
||||
if (func_sig->isVolatileType())
|
||||
type_quals |= clang::Qualifiers::Volatile;
|
||||
auto cc = TranslateCallingConvention(func_sig->getCallingConvention());
|
||||
CompilerType func_sig_ast_type =
|
||||
m_ast.CreateFunctionType(return_ast_type, arg_list.data(),
|
||||
arg_list.size(), is_variadic, type_quals, cc);
|
||||
CompilerType func_sig_ast_type = m_ast.CreateFunctionType(
|
||||
return_ast_type, arg_list, is_variadic, type_quals, cc);
|
||||
|
||||
AddSourceInfoToDecl(type, decl);
|
||||
return m_ast.GetSymbolFile()->MakeType(
|
||||
|
||||
@@ -2181,25 +2181,22 @@ FunctionDecl *TypeSystemClang::CreateFunctionDeclaration(
|
||||
}
|
||||
|
||||
CompilerType TypeSystemClang::CreateFunctionType(
|
||||
const CompilerType &result_type, const CompilerType *args,
|
||||
unsigned num_args, bool is_variadic, unsigned type_quals,
|
||||
clang::CallingConv cc, clang::RefQualifierKind ref_qual) {
|
||||
const CompilerType &result_type, llvm::ArrayRef<CompilerType> args,
|
||||
bool is_variadic, unsigned type_quals, clang::CallingConv cc,
|
||||
clang::RefQualifierKind ref_qual) {
|
||||
if (!result_type || !ClangUtil::IsClangType(result_type))
|
||||
return CompilerType(); // invalid return type
|
||||
|
||||
std::vector<QualType> qual_type_args;
|
||||
if (num_args > 0 && args == nullptr)
|
||||
return CompilerType(); // invalid argument array passed in
|
||||
|
||||
// Verify that all arguments are valid and the right type
|
||||
for (unsigned i = 0; i < num_args; ++i) {
|
||||
if (args[i]) {
|
||||
for (const auto &arg : args) {
|
||||
if (arg) {
|
||||
// Make sure we have a clang type in args[i] and not a type from another
|
||||
// language whose name might match
|
||||
const bool is_clang_type = ClangUtil::IsClangType(args[i]);
|
||||
const bool is_clang_type = ClangUtil::IsClangType(arg);
|
||||
lldbassert(is_clang_type);
|
||||
if (is_clang_type)
|
||||
qual_type_args.push_back(ClangUtil::GetQualType(args[i]));
|
||||
qual_type_args.push_back(ClangUtil::GetQualType(arg));
|
||||
else
|
||||
return CompilerType(); // invalid argument type (must be a clang type)
|
||||
} else
|
||||
|
||||
@@ -480,9 +480,9 @@ public:
|
||||
clang::StorageClass storage, bool is_inline);
|
||||
|
||||
CompilerType
|
||||
CreateFunctionType(const CompilerType &result_type, const CompilerType *args,
|
||||
unsigned num_args, bool is_variadic, unsigned type_quals,
|
||||
clang::CallingConv cc = clang::CC_C,
|
||||
CreateFunctionType(const CompilerType &result_type,
|
||||
llvm::ArrayRef<CompilerType> args, bool is_variadic,
|
||||
unsigned type_quals, clang::CallingConv cc = clang::CC_C,
|
||||
clang::RefQualifierKind ref_qual = clang::RQ_None);
|
||||
|
||||
clang::ParmVarDecl *
|
||||
|
||||
@@ -866,8 +866,7 @@ TEST_F(TestTypeSystemClang, TestFunctionTemplateConstruction) {
|
||||
clang::TranslationUnitDecl *TU = m_ast->GetTranslationUnitDecl();
|
||||
|
||||
// Prepare the declarations/types we need for the template.
|
||||
CompilerType clang_type =
|
||||
m_ast->CreateFunctionType(int_type, nullptr, 0U, false, 0U);
|
||||
CompilerType clang_type = m_ast->CreateFunctionType(int_type, {}, false, 0U);
|
||||
FunctionDecl *func = m_ast->CreateFunctionDeclaration(
|
||||
TU, OptionalClangModuleID(), "foo", clang_type, StorageClass::SC_None,
|
||||
false);
|
||||
@@ -895,8 +894,7 @@ TEST_F(TestTypeSystemClang, TestFunctionTemplateInRecordConstruction) {
|
||||
clang::TagDecl *record = ClangUtil::GetAsTagDecl(record_type);
|
||||
|
||||
// Prepare the declarations/types we need for the template.
|
||||
CompilerType clang_type =
|
||||
m_ast->CreateFunctionType(int_type, nullptr, 0U, false, 0U);
|
||||
CompilerType clang_type = m_ast->CreateFunctionType(int_type, {}, false, 0U);
|
||||
// We create the FunctionDecl for the template in the TU DeclContext because:
|
||||
// 1. FunctionDecls can't be in a Record (only CXXMethodDecls can).
|
||||
// 2. It is mirroring the behavior of DWARFASTParserClang::ParseSubroutine.
|
||||
@@ -930,10 +928,9 @@ TEST_F(TestTypeSystemClang, TestDeletingImplicitCopyCstrDueToMoveCStr) {
|
||||
|
||||
// Create a move constructor that will delete the implicit copy constructor.
|
||||
CompilerType return_type = m_ast->GetBasicType(lldb::eBasicTypeVoid);
|
||||
CompilerType param_type = t.GetRValueReferenceType();
|
||||
CompilerType function_type =
|
||||
m_ast->CreateFunctionType(return_type, ¶m_type, /*num_params*/ 1,
|
||||
/*variadic=*/false, /*quals*/ 0U);
|
||||
std::array<CompilerType, 1> args{t.GetRValueReferenceType()};
|
||||
CompilerType function_type = m_ast->CreateFunctionType(
|
||||
return_type, args, /*variadic=*/false, /*quals*/ 0U);
|
||||
bool is_virtual = false;
|
||||
bool is_static = false;
|
||||
bool is_inline = false;
|
||||
@@ -974,10 +971,9 @@ TEST_F(TestTypeSystemClang, TestNotDeletingUserCopyCstrDueToMoveCStr) {
|
||||
bool is_artificial = false;
|
||||
// Create a move constructor.
|
||||
{
|
||||
CompilerType param_type = t.GetRValueReferenceType();
|
||||
CompilerType function_type =
|
||||
m_ast->CreateFunctionType(return_type, ¶m_type, /*num_params*/ 1,
|
||||
/*variadic=*/false, /*quals*/ 0U);
|
||||
std::array<CompilerType, 1> args{t.GetRValueReferenceType()};
|
||||
CompilerType function_type = m_ast->CreateFunctionType(
|
||||
return_type, args, /*variadic=*/false, /*quals*/ 0U);
|
||||
m_ast->AddMethodToCXXRecordType(
|
||||
t.GetOpaqueQualType(), class_name, nullptr, function_type,
|
||||
lldb::AccessType::eAccessPublic, is_virtual, is_static, is_inline,
|
||||
@@ -985,9 +981,10 @@ TEST_F(TestTypeSystemClang, TestNotDeletingUserCopyCstrDueToMoveCStr) {
|
||||
}
|
||||
// Create a copy constructor.
|
||||
{
|
||||
CompilerType param_type = t.GetLValueReferenceType().AddConstModifier();
|
||||
std::array<CompilerType, 1> args{
|
||||
t.GetLValueReferenceType().AddConstModifier()};
|
||||
CompilerType function_type =
|
||||
m_ast->CreateFunctionType(return_type, ¶m_type, /*num_params*/ 1,
|
||||
m_ast->CreateFunctionType(return_type, args,
|
||||
/*variadic=*/false, /*quals*/ 0U);
|
||||
m_ast->AddMethodToCXXRecordType(
|
||||
t.GetOpaqueQualType(), class_name, nullptr, function_type,
|
||||
@@ -1012,10 +1009,9 @@ TEST_F(TestTypeSystemClang, AddMethodToObjCObjectType) {
|
||||
|
||||
// Add a method to the interface.
|
||||
std::vector<CompilerType> args;
|
||||
CompilerType func_type =
|
||||
m_ast->CreateFunctionType(m_ast->GetBasicType(lldb::eBasicTypeInt),
|
||||
args.data(), args.size(), /*variadic*/ false,
|
||||
/*quals*/ 0, clang::CallingConv::CC_C);
|
||||
CompilerType func_type = m_ast->CreateFunctionType(
|
||||
m_ast->GetBasicType(lldb::eBasicTypeInt), args, /*variadic*/ false,
|
||||
/*quals*/ 0, clang::CallingConv::CC_C);
|
||||
bool variadic = false;
|
||||
bool artificial = false;
|
||||
bool objc_direct = false;
|
||||
@@ -1098,9 +1094,9 @@ TEST_F(TestTypeSystemClang, AddMethodToCXXRecordType_ParmVarDecls) {
|
||||
llvm::SmallVector<CompilerType> param_types{
|
||||
m_ast->GetBasicType(lldb::eBasicTypeInt),
|
||||
m_ast->GetBasicType(lldb::eBasicTypeShort)};
|
||||
CompilerType function_type = m_ast->CreateFunctionType(
|
||||
return_type, param_types.data(), /*num_params*/ param_types.size(),
|
||||
/*variadic=*/false, /*quals*/ 0U);
|
||||
CompilerType function_type =
|
||||
m_ast->CreateFunctionType(return_type, param_types,
|
||||
/*variadic=*/false, /*quals*/ 0U);
|
||||
m_ast->AddMethodToCXXRecordType(
|
||||
t.GetOpaqueQualType(), "myFunc", nullptr, function_type,
|
||||
lldb::AccessType::eAccessPublic, is_virtual, is_static, is_inline,
|
||||
|
||||
Reference in New Issue
Block a user