[lldb][NFC] Use the proper type for the 'storage' parameter of CreateFunctionDeclaration
authorRaphael Isemann <teemperor@gmail.com>
Mon, 17 Aug 2020 10:47:12 +0000 (12:47 +0200)
committerRaphael Isemann <teemperor@gmail.com>
Mon, 17 Aug 2020 10:53:58 +0000 (12:53 +0200)
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
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/unittests/Symbol/TestTypeSystemClang.cpp

index 69c829d..23e0527 100644 (file)
@@ -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<clang::StorageClass>(storage));
+  func_decl->setStorageClass(storage);
   func_decl->setInlineSpecified(is_inline);
   func_decl->setHasWrittenPrototype(hasWrittenPrototype);
   func_decl->setConstexprKind(isConstexprSpecified ? CSK_constexpr
index 399743a..32736ee 100644 (file)
@@ -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,
index bd7eb14..f43b4f5 100644 (file)
@@ -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.