From cd2139a527f2d829bdde7877c992215f598e927b Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Mon, 17 Aug 2020 12:47:12 +0200 Subject: [PATCH] [lldb][NFC] Use the proper type for the 'storage' parameter of CreateFunctionDeclaration All the callers pass an enum and we cast the int anyway back to the actual type, so we might as well just use the type for the parameter. --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 6 +++--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h | 2 +- lldb/unittests/Symbol/TestTypeSystemClang.cpp | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 69c829d..23e0527 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -1996,8 +1996,8 @@ TypeSystemClang::GetDeclarationName(const char *name, FunctionDecl *TypeSystemClang::CreateFunctionDeclaration( clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, - const char *name, const CompilerType &function_clang_type, int storage, - bool is_inline) { + const char *name, const CompilerType &function_clang_type, + clang::StorageClass storage, bool is_inline) { FunctionDecl *func_decl = nullptr; ASTContext &ast = getASTContext(); if (!decl_ctx) @@ -2012,7 +2012,7 @@ FunctionDecl *TypeSystemClang::CreateFunctionDeclaration( func_decl->setDeclContext(decl_ctx); func_decl->setDeclName(declarationName); func_decl->setType(ClangUtil::GetQualType(function_clang_type)); - func_decl->setStorageClass(static_cast(storage)); + func_decl->setStorageClass(storage); func_decl->setInlineSpecified(is_inline); func_decl->setHasWrittenPrototype(hasWrittenPrototype); func_decl->setConstexprKind(isConstexprSpecified ? CSK_constexpr diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 399743a..32736ee 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -414,7 +414,7 @@ public: CreateFunctionDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *name, const CompilerType &function_Type, - int storage, bool is_inline); + clang::StorageClass storage, bool is_inline); CompilerType CreateFunctionType(const CompilerType &result_type, const CompilerType *args, unsigned num_args, diff --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp b/lldb/unittests/Symbol/TestTypeSystemClang.cpp index bd7eb14..f43b4f5 100644 --- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp +++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp @@ -559,7 +559,8 @@ TEST_F(TestTypeSystemClang, TestFunctionTemplateConstruction) { CompilerType clang_type = m_ast->CreateFunctionType(int_type, nullptr, 0U, false, 0U); FunctionDecl *func = m_ast->CreateFunctionDeclaration( - TU, OptionalClangModuleID(), "foo", clang_type, 0, false); + TU, OptionalClangModuleID(), "foo", clang_type, StorageClass::SC_None, + false); TypeSystemClang::TemplateParameterInfos empty_params; // Create the actual function template. @@ -590,7 +591,8 @@ TEST_F(TestTypeSystemClang, TestFunctionTemplateInRecordConstruction) { // 1. FunctionDecls can't be in a Record (only CXXMethodDecls can). // 2. It is mirroring the behavior of DWARFASTParserClang::ParseSubroutine. FunctionDecl *func = m_ast->CreateFunctionDeclaration( - TU, OptionalClangModuleID(), "foo", clang_type, 0, false); + TU, OptionalClangModuleID(), "foo", clang_type, StorageClass::SC_None, + false); TypeSystemClang::TemplateParameterInfos empty_params; // Create the actual function template. -- 2.7.4