diff options
| author | Greg Clayton <gclayton@apple.com> | 2011-10-14 22:47:18 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2011-10-14 22:47:18 +0000 |
| commit | 147e1fa298a34c7bac24e153f4a07030145d6a7e (patch) | |
| tree | 1a9923a22f020376ab93d3dea7bc12e7ced10db5 | |
| parent | ea166d44e7dde9f197e8ec0d73342a22a77aec04 (diff) | |
| download | bcm5719-llvm-147e1fa298a34c7bac24e153f4a07030145d6a7e.tar.gz bcm5719-llvm-147e1fa298a34c7bac24e153f4a07030145d6a7e.zip | |
Add function decls to their parent decl context.
llvm-svn: 142011
| -rw-r--r-- | lldb/include/lldb/Symbol/ClangASTContext.h | 3 | ||||
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Symbol/ClangASTContext.cpp | 75 |
3 files changed, 43 insertions, 38 deletions
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 27bccbb4083..c18cb4e9aec 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -547,7 +547,8 @@ public: //------------------------------------------------------------------ clang::FunctionDecl * - CreateFunctionDeclaration (const char *name, + CreateFunctionDeclaration (clang::DeclContext *decl_ctx, + const char *name, lldb::clang_type_t function_Type, int storage, bool is_inline); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index d2f0311d843..881192761bc 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -4368,7 +4368,8 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, if (!type_handled) { // We just have a function that isn't part of a class - clang::FunctionDecl *function_decl = ast.CreateFunctionDeclaration (type_name_cstr, + clang::FunctionDecl *function_decl = ast.CreateFunctionDeclaration (containing_decl_ctx, + type_name_cstr, clang_type, storage, is_inline); diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 3fc15a36fd4..8ee022937c4 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -4145,41 +4145,42 @@ ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *d #pragma mark Function Types FunctionDecl * -ClangASTContext::CreateFunctionDeclaration (const char *name, clang_type_t function_clang_type, int storage, bool is_inline) +ClangASTContext::CreateFunctionDeclaration (DeclContext *decl_ctx, const char *name, clang_type_t function_clang_type, int storage, bool is_inline) { - if (name) - { - ASTContext *ast = getASTContext(); - assert (ast != NULL); + FunctionDecl *func_decl = NULL; + ASTContext *ast = getASTContext(); + if (decl_ctx == NULL) + decl_ctx = ast->getTranslationUnitDecl(); - if (name && name[0]) - { - return FunctionDecl::Create(*ast, - ast->getTranslationUnitDecl(), - SourceLocation(), - SourceLocation(), - DeclarationName (&ast->Idents.get(name)), - QualType::getFromOpaquePtr(function_clang_type), - NULL, - (FunctionDecl::StorageClass)storage, - (FunctionDecl::StorageClass)storage, - is_inline); - } - else - { - return FunctionDecl::Create(*ast, - ast->getTranslationUnitDecl(), - SourceLocation(), - SourceLocation(), - DeclarationName (), - QualType::getFromOpaquePtr(function_clang_type), - NULL, - (FunctionDecl::StorageClass)storage, - (FunctionDecl::StorageClass)storage, - is_inline); - } + if (name && name[0]) + { + func_decl = FunctionDecl::Create (*ast, + decl_ctx, + SourceLocation(), + SourceLocation(), + DeclarationName (&ast->Idents.get(name)), + QualType::getFromOpaquePtr(function_clang_type), + NULL, + (FunctionDecl::StorageClass)storage, + (FunctionDecl::StorageClass)storage, + is_inline); } - return NULL; + else + { + func_decl = FunctionDecl::Create (*ast, + decl_ctx, + SourceLocation(), + SourceLocation(), + DeclarationName (), + QualType::getFromOpaquePtr(function_clang_type), + NULL, + (FunctionDecl::StorageClass)storage, + (FunctionDecl::StorageClass)storage, + is_inline); + } + if (func_decl) + decl_ctx->addDecl (func_decl); + return func_decl; } clang_type_t @@ -4204,10 +4205,10 @@ ClangASTContext::CreateFunctionType (ASTContext *ast, proto_info.NumExceptions = 0; proto_info.Exceptions = NULL; - return ast->getFunctionType(QualType::getFromOpaquePtr(result_type), - qual_type_args.empty() ? NULL : &qual_type_args.front(), - qual_type_args.size(), - proto_info).getAsOpaquePtr(); // NoReturn); + return ast->getFunctionType (QualType::getFromOpaquePtr(result_type), + qual_type_args.empty() ? NULL : &qual_type_args.front(), + qual_type_args.size(), + proto_info).getAsOpaquePtr(); // NoReturn); } ParmVarDecl * @@ -5218,6 +5219,8 @@ ClangASTContext::CreateTypedefType (const char *name, clang_type_t clang_type, D name ? &identifier_table->get(name) : NULL, // Identifier ast->CreateTypeSourceInfo(qual_type)); + //decl_ctx->addDecl (decl); + decl->setAccess(AS_public); // TODO respect proper access specifier // Get a uniqued QualType for the typedef decl type |

