Added correct C++ method declarations for destructors and for conversion
operators.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@115290 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 6a03514..10b123e 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -853,13 +853,36 @@
CXXMethodDecl *cxx_method_decl = NULL;
DeclarationName decl_name (&identifier_table->get(name));
+
+ DeclarationNameInfo decl_name_info (decl_name, SourceLocation());
+ const bool is_implicitly_declared = false;
- if (name[0] == '~' || decl_name == record_decl->getDeclName())
+ clang::Type *method_type(method_qual_type.getTypePtr());
+
+ if (method_type == NULL)
+ return NULL;
+
+ FunctionProtoType *method_function_prototype (dyn_cast<FunctionProtoType>(method_type));
+
+ if (!method_function_prototype)
+ return NULL;
+
+ unsigned int num_params = method_function_prototype->getNumArgs();
+
+ if (name[0] == '~')
{
- bool is_implicitly_declared = false;
+ cxx_method_decl = CXXDestructorDecl::Create (*ast_context,
+ cxx_record_decl,
+ decl_name_info,
+ method_qual_type,
+ is_inline,
+ is_implicitly_declared);
+ }
+ else if (decl_name == record_decl->getDeclName())
+ {
cxx_method_decl = CXXConstructorDecl::Create (*ast_context,
cxx_record_decl,
- DeclarationNameInfo (decl_name, SourceLocation()),
+ decl_name_info,
method_qual_type,
NULL, // TypeSourceInfo *
is_explicit,
@@ -867,15 +890,33 @@
is_implicitly_declared);
}
else
- {
- cxx_method_decl = CXXMethodDecl::Create (*ast_context,
- cxx_record_decl,
- DeclarationNameInfo (decl_name, SourceLocation()),
- method_qual_type,
- NULL, // TypeSourceInfo *
- is_static,
- SC_None,
- is_inline);
+ {
+ // TODO: verify this is an ok way to see if this is a C++ conversion
+ // operator. I am currently checking for "operator " following by a valid
+ // first character of a type name (A-Z, a-z, or _)...
+ if ((num_params == 0) &&
+ (::strstr(name, "operator ") == name) &&
+ (::isalpha(name[9]) || name[9] == '_'))
+ {
+ cxx_method_decl = CXXConversionDecl::Create (*ast_context,
+ cxx_record_decl,
+ decl_name_info,
+ method_qual_type,
+ NULL, // TypeSourceInfo *
+ is_inline,
+ is_explicit);
+ }
+ else
+ {
+ cxx_method_decl = CXXMethodDecl::Create (*ast_context,
+ cxx_record_decl,
+ decl_name_info,
+ method_qual_type,
+ NULL, // TypeSourceInfo *
+ is_static,
+ SC_None,
+ is_inline);
+ }
}
@@ -885,17 +926,6 @@
cxx_method_decl->setVirtualAsWritten (is_virtual);
// Populate the method decl with parameter decls
- clang::Type *method_type(method_qual_type.getTypePtr());
-
- if (method_type == NULL)
- return NULL;
-
- FunctionProtoType *method_function_prototype (dyn_cast<FunctionProtoType>(method_type));
-
- if (!method_function_prototype)
- return NULL;
-
- unsigned int num_params = method_function_prototype->getNumArgs();
ParmVarDecl *params[num_params];