2010-06-09 00:52:24 +08:00
|
|
|
//===-- ClangASTContext.cpp -------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-06-14 03:06:42 +08:00
|
|
|
#include "lldb/Symbol/ClangASTContext.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
// Other libraries and framework includes
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
|
|
|
|
// Clang headers like to use NDEBUG inside of them to enable/disable debug
|
|
|
|
// releated features using "#ifndef NDEBUG" preprocessor blocks to do one thing
|
|
|
|
// or another. This is bad because it means that if clang was built in release
|
|
|
|
// mode, it assumes that you are building in release mode which is not always
|
|
|
|
// the case. You can end up with functions that are defined as empty in header
|
|
|
|
// files when NDEBUG is not defined, and this can cause link errors with the
|
|
|
|
// clang .a files that you have since you might be missing functions in the .a
|
|
|
|
// file. So we have to define NDEBUG when including clang headers to avoid any
|
|
|
|
// mismatches. This is covered by rdar://problem/8691220
|
|
|
|
|
2011-10-27 01:46:51 +08:00
|
|
|
#if !defined(NDEBUG) && !defined(LLVM_NDEBUG_OFF)
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
#define LLDB_DEFINED_NDEBUG_FOR_CLANG
|
2010-07-09 02:16:16 +08:00
|
|
|
#define NDEBUG
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
// Need to include assert.h so it is as clang would expect it to be (disabled)
|
|
|
|
#include <assert.h>
|
|
|
|
#endif
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "clang/AST/ASTContext.h"
|
|
|
|
#include "clang/AST/ASTImporter.h"
|
|
|
|
#include "clang/AST/CXXInheritance.h"
|
2010-07-23 02:30:50 +08:00
|
|
|
#include "clang/AST/DeclObjC.h"
|
2011-10-22 11:33:13 +08:00
|
|
|
#include "clang/AST/DeclTemplate.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "clang/AST/RecordLayout.h"
|
|
|
|
#include "clang/AST/Type.h"
|
|
|
|
#include "clang/Basic/Builtins.h"
|
|
|
|
#include "clang/Basic/FileManager.h"
|
2010-11-18 10:56:27 +08:00
|
|
|
#include "clang/Basic/FileSystemOptions.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "clang/Basic/SourceManager.h"
|
|
|
|
#include "clang/Basic/TargetInfo.h"
|
|
|
|
#include "clang/Basic/TargetOptions.h"
|
|
|
|
#include "clang/Frontend/FrontendOptions.h"
|
|
|
|
#include "clang/Frontend/LangStandard.h"
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
|
|
|
|
#ifdef LLDB_DEFINED_NDEBUG_FOR_CLANG
|
2010-07-09 02:16:16 +08:00
|
|
|
#undef NDEBUG
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
#undef LLDB_DEFINED_NDEBUG_FOR_CLANG
|
|
|
|
// Need to re-include assert.h so it is as _we_ would expect it to be (enabled)
|
|
|
|
#include <assert.h>
|
|
|
|
#endif
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-02-16 05:59:32 +08:00
|
|
|
#include "lldb/Core/ArchSpec.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/dwarf.h"
|
2010-10-27 11:32:59 +08:00
|
|
|
#include "lldb/Core/Flags.h"
|
2010-10-29 02:19:36 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2011-10-22 11:33:13 +08:00
|
|
|
#include "lldb/Core/RegularExpression.h"
|
|
|
|
#include "lldb/Expression/ASTDumper.h"
|
2011-10-26 09:06:27 +08:00
|
|
|
#include "lldb/Symbol/VerifyDecl.h"
|
2011-06-25 06:03:24 +08:00
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/ObjCLanguageRuntime.h"
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-06-14 03:06:42 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2010-08-05 09:57:25 +08:00
|
|
|
using namespace lldb;
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb_private;
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace clang;
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
|
|
|
|
static bool
|
|
|
|
GetCompleteQualType (clang::ASTContext *ast, clang::QualType qual_type)
|
|
|
|
{
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::Record:
|
|
|
|
case clang::Type::Enum:
|
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const clang::TagType *tag_type = dyn_cast<clang::TagType>(qual_type.getTypePtr());
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (tag_type)
|
|
|
|
{
|
|
|
|
clang::TagDecl *tag_decl = tag_type->getDecl();
|
|
|
|
if (tag_decl)
|
|
|
|
{
|
|
|
|
if (tag_decl->getDefinition())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (tag_decl->hasExternalLexicalStorage())
|
|
|
|
{
|
2011-05-30 08:49:24 +08:00
|
|
|
if (ast)
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
{
|
2011-05-30 08:49:24 +08:00
|
|
|
ExternalASTSource *external_ast_source = ast->getExternalSource();
|
|
|
|
if (external_ast_source)
|
|
|
|
{
|
|
|
|
external_ast_source->CompleteType(tag_decl);
|
|
|
|
return !tag_type->isIncompleteType();
|
|
|
|
}
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::ObjCObject:
|
|
|
|
case clang::Type::ObjCInterface:
|
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const clang::ObjCObjectType *objc_class_type = dyn_cast<clang::ObjCObjectType>(qual_type);
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (objc_class_type)
|
|
|
|
{
|
|
|
|
clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
|
|
|
|
// We currently can't complete objective C types through the newly added ASTContext
|
|
|
|
// because it only supports TagDecl objects right now...
|
2011-07-16 07:30:15 +08:00
|
|
|
if (class_interface_decl)
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
{
|
2011-07-02 08:25:22 +08:00
|
|
|
bool is_forward_decl = class_interface_decl->isForwardDecl();
|
|
|
|
if (is_forward_decl && class_interface_decl->hasExternalLexicalStorage())
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
{
|
2011-07-02 08:25:22 +08:00
|
|
|
if (ast)
|
2011-05-30 08:49:24 +08:00
|
|
|
{
|
2011-07-02 08:25:22 +08:00
|
|
|
ExternalASTSource *external_ast_source = ast->getExternalSource();
|
|
|
|
if (external_ast_source)
|
|
|
|
{
|
|
|
|
external_ast_source->CompleteType (class_interface_decl);
|
|
|
|
is_forward_decl = class_interface_decl->isForwardDecl();
|
|
|
|
}
|
2011-05-30 08:49:24 +08:00
|
|
|
}
|
2011-07-02 08:25:22 +08:00
|
|
|
return is_forward_decl == false;
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
}
|
2011-07-02 08:25:22 +08:00
|
|
|
return true;
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
}
|
2011-07-02 08:25:22 +08:00
|
|
|
else
|
|
|
|
return false;
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::Typedef:
|
|
|
|
return GetCompleteQualType (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType());
|
2011-08-12 07:56:13 +08:00
|
|
|
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return GetCompleteQualType (ast, cast<ElaboratedType>(qual_type)->getNamedType());
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-23 02:30:50 +08:00
|
|
|
static AccessSpecifier
|
2010-08-05 09:57:25 +08:00
|
|
|
ConvertAccessTypeToAccessSpecifier (AccessType access)
|
2010-07-23 02:30:50 +08:00
|
|
|
{
|
|
|
|
switch (access)
|
|
|
|
{
|
2010-08-05 09:57:25 +08:00
|
|
|
default: break;
|
|
|
|
case eAccessNone: return AS_none;
|
|
|
|
case eAccessPublic: return AS_public;
|
|
|
|
case eAccessPrivate: return AS_private;
|
|
|
|
case eAccessProtected: return AS_protected;
|
2010-07-23 02:30:50 +08:00
|
|
|
}
|
|
|
|
return AS_none;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ObjCIvarDecl::AccessControl
|
2010-08-05 09:57:25 +08:00
|
|
|
ConvertAccessTypeToObjCIvarAccessControl (AccessType access)
|
2010-07-23 02:30:50 +08:00
|
|
|
{
|
|
|
|
switch (access)
|
|
|
|
{
|
2010-08-05 09:57:25 +08:00
|
|
|
default: break;
|
|
|
|
case eAccessNone: return ObjCIvarDecl::None;
|
|
|
|
case eAccessPublic: return ObjCIvarDecl::Public;
|
|
|
|
case eAccessPrivate: return ObjCIvarDecl::Private;
|
|
|
|
case eAccessProtected: return ObjCIvarDecl::Protected;
|
|
|
|
case eAccessPackage: return ObjCIvarDecl::Package;
|
2010-07-23 02:30:50 +08:00
|
|
|
}
|
|
|
|
return ObjCIvarDecl::None;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
static void
|
|
|
|
ParseLangArgs
|
|
|
|
(
|
|
|
|
LangOptions &Opts,
|
2010-06-14 01:34:29 +08:00
|
|
|
InputKind IK
|
2010-06-09 00:52:24 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
// FIXME: Cleanup per-file based stuff.
|
|
|
|
|
|
|
|
// Set some properties which depend soley on the input kind; it would be nice
|
|
|
|
// to move these to the language standard, and have the driver resolve the
|
|
|
|
// input kind + language standard.
|
2010-06-14 01:34:29 +08:00
|
|
|
if (IK == IK_Asm) {
|
2010-06-09 00:52:24 +08:00
|
|
|
Opts.AsmPreprocessor = 1;
|
2010-06-14 01:34:29 +08:00
|
|
|
} else if (IK == IK_ObjC ||
|
|
|
|
IK == IK_ObjCXX ||
|
|
|
|
IK == IK_PreprocessedObjC ||
|
|
|
|
IK == IK_PreprocessedObjCXX) {
|
2010-06-09 00:52:24 +08:00
|
|
|
Opts.ObjC1 = Opts.ObjC2 = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
LangStandard::Kind LangStd = LangStandard::lang_unspecified;
|
|
|
|
|
|
|
|
if (LangStd == LangStandard::lang_unspecified) {
|
|
|
|
// Based on the base language, pick one.
|
|
|
|
switch (IK) {
|
2010-06-14 01:34:29 +08:00
|
|
|
case IK_None:
|
|
|
|
case IK_AST:
|
2011-03-15 08:17:19 +08:00
|
|
|
case IK_LLVM_IR:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
assert (!"Invalid input kind!");
|
2010-06-14 01:34:29 +08:00
|
|
|
case IK_OpenCL:
|
2010-06-09 00:52:24 +08:00
|
|
|
LangStd = LangStandard::lang_opencl;
|
|
|
|
break;
|
2011-03-15 08:17:19 +08:00
|
|
|
case IK_CUDA:
|
|
|
|
LangStd = LangStandard::lang_cuda;
|
|
|
|
break;
|
2010-06-14 01:34:29 +08:00
|
|
|
case IK_Asm:
|
|
|
|
case IK_C:
|
|
|
|
case IK_PreprocessedC:
|
|
|
|
case IK_ObjC:
|
|
|
|
case IK_PreprocessedObjC:
|
2010-06-09 00:52:24 +08:00
|
|
|
LangStd = LangStandard::lang_gnu99;
|
|
|
|
break;
|
2010-06-14 01:34:29 +08:00
|
|
|
case IK_CXX:
|
|
|
|
case IK_PreprocessedCXX:
|
|
|
|
case IK_ObjCXX:
|
|
|
|
case IK_PreprocessedObjCXX:
|
2010-06-09 00:52:24 +08:00
|
|
|
LangStd = LangStandard::lang_gnucxx98;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const LangStandard &Std = LangStandard::getLangStandardForKind(LangStd);
|
|
|
|
Opts.BCPLComment = Std.hasBCPLComments();
|
|
|
|
Opts.C99 = Std.isC99();
|
|
|
|
Opts.CPlusPlus = Std.isCPlusPlus();
|
|
|
|
Opts.CPlusPlus0x = Std.isCPlusPlus0x();
|
|
|
|
Opts.Digraphs = Std.hasDigraphs();
|
|
|
|
Opts.GNUMode = Std.isGNUMode();
|
|
|
|
Opts.GNUInline = !Std.isC99();
|
|
|
|
Opts.HexFloats = Std.hasHexFloats();
|
|
|
|
Opts.ImplicitInt = Std.hasImplicitInt();
|
|
|
|
|
|
|
|
// OpenCL has some additional defaults.
|
|
|
|
if (LangStd == LangStandard::lang_opencl) {
|
|
|
|
Opts.OpenCL = 1;
|
|
|
|
Opts.AltiVec = 1;
|
|
|
|
Opts.CXXOperatorNames = 1;
|
|
|
|
Opts.LaxVectorConversions = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OpenCL and C++ both have bool, true, false keywords.
|
|
|
|
Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
|
|
|
|
|
|
|
|
// if (Opts.CPlusPlus)
|
|
|
|
// Opts.CXXOperatorNames = !Args.hasArg(OPT_fno_operator_names);
|
|
|
|
//
|
|
|
|
// if (Args.hasArg(OPT_fobjc_gc_only))
|
|
|
|
// Opts.setGCMode(LangOptions::GCOnly);
|
|
|
|
// else if (Args.hasArg(OPT_fobjc_gc))
|
|
|
|
// Opts.setGCMode(LangOptions::HybridGC);
|
|
|
|
//
|
|
|
|
// if (Args.hasArg(OPT_print_ivar_layout))
|
|
|
|
// Opts.ObjCGCBitmapPrint = 1;
|
|
|
|
//
|
|
|
|
// if (Args.hasArg(OPT_faltivec))
|
|
|
|
// Opts.AltiVec = 1;
|
|
|
|
//
|
|
|
|
// if (Args.hasArg(OPT_pthread))
|
|
|
|
// Opts.POSIXThreads = 1;
|
|
|
|
//
|
|
|
|
// llvm::StringRef Vis = getLastArgValue(Args, OPT_fvisibility,
|
|
|
|
// "default");
|
|
|
|
// if (Vis == "default")
|
2010-10-30 02:38:40 +08:00
|
|
|
Opts.setVisibilityMode(DefaultVisibility);
|
2010-06-09 00:52:24 +08:00
|
|
|
// else if (Vis == "hidden")
|
|
|
|
// Opts.setVisibilityMode(LangOptions::Hidden);
|
|
|
|
// else if (Vis == "protected")
|
|
|
|
// Opts.setVisibilityMode(LangOptions::Protected);
|
|
|
|
// else
|
|
|
|
// Diags.Report(diag::err_drv_invalid_value)
|
|
|
|
// << Args.getLastArg(OPT_fvisibility)->getAsString(Args) << Vis;
|
|
|
|
|
|
|
|
// Opts.OverflowChecking = Args.hasArg(OPT_ftrapv);
|
|
|
|
|
|
|
|
// Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs
|
|
|
|
// is specified, or -std is set to a conforming mode.
|
|
|
|
Opts.Trigraphs = !Opts.GNUMode;
|
|
|
|
// if (Args.hasArg(OPT_trigraphs))
|
|
|
|
// Opts.Trigraphs = 1;
|
|
|
|
//
|
|
|
|
// Opts.DollarIdents = Args.hasFlag(OPT_fdollars_in_identifiers,
|
|
|
|
// OPT_fno_dollars_in_identifiers,
|
|
|
|
// !Opts.AsmPreprocessor);
|
|
|
|
// Opts.PascalStrings = Args.hasArg(OPT_fpascal_strings);
|
|
|
|
// Opts.Microsoft = Args.hasArg(OPT_fms_extensions);
|
|
|
|
// Opts.WritableStrings = Args.hasArg(OPT_fwritable_strings);
|
|
|
|
// if (Args.hasArg(OPT_fno_lax_vector_conversions))
|
|
|
|
// Opts.LaxVectorConversions = 0;
|
|
|
|
// Opts.Exceptions = Args.hasArg(OPT_fexceptions);
|
|
|
|
// Opts.RTTI = !Args.hasArg(OPT_fno_rtti);
|
|
|
|
// Opts.Blocks = Args.hasArg(OPT_fblocks);
|
|
|
|
// Opts.CharIsSigned = !Args.hasArg(OPT_fno_signed_char);
|
|
|
|
// Opts.ShortWChar = Args.hasArg(OPT_fshort_wchar);
|
|
|
|
// Opts.Freestanding = Args.hasArg(OPT_ffreestanding);
|
|
|
|
// Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding;
|
|
|
|
// Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);
|
|
|
|
// Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
|
|
|
|
// Opts.AccessControl = Args.hasArg(OPT_faccess_control);
|
|
|
|
// Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
|
|
|
|
// Opts.MathErrno = !Args.hasArg(OPT_fno_math_errno);
|
|
|
|
// Opts.InstantiationDepth = getLastArgIntValue(Args, OPT_ftemplate_depth, 99,
|
|
|
|
// Diags);
|
|
|
|
// Opts.NeXTRuntime = !Args.hasArg(OPT_fgnu_runtime);
|
|
|
|
// Opts.ObjCConstantStringClass = getLastArgValue(Args,
|
|
|
|
// OPT_fconstant_string_class);
|
|
|
|
// Opts.ObjCNonFragileABI = Args.hasArg(OPT_fobjc_nonfragile_abi);
|
|
|
|
// Opts.CatchUndefined = Args.hasArg(OPT_fcatch_undefined_behavior);
|
|
|
|
// Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
|
|
|
|
// Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
|
|
|
|
// Opts.Static = Args.hasArg(OPT_static_define);
|
|
|
|
Opts.OptimizeSize = 0;
|
|
|
|
|
|
|
|
// FIXME: Eliminate this dependency.
|
|
|
|
// unsigned Opt =
|
|
|
|
// Args.hasArg(OPT_Os) ? 2 : getLastArgIntValue(Args, OPT_O, 0, Diags);
|
|
|
|
// Opts.Optimize = Opt != 0;
|
|
|
|
unsigned Opt = 0;
|
|
|
|
|
|
|
|
// This is the __NO_INLINE__ define, which just depends on things like the
|
|
|
|
// optimization level and -fno-inline, not actually whether the backend has
|
|
|
|
// inlining enabled.
|
|
|
|
//
|
|
|
|
// FIXME: This is affected by other options (-fno-inline).
|
|
|
|
Opts.NoInline = !Opt;
|
|
|
|
|
|
|
|
// unsigned SSP = getLastArgIntValue(Args, OPT_stack_protector, 0, Diags);
|
|
|
|
// switch (SSP) {
|
|
|
|
// default:
|
|
|
|
// Diags.Report(diag::err_drv_invalid_value)
|
|
|
|
// << Args.getLastArg(OPT_stack_protector)->getAsString(Args) << SSP;
|
|
|
|
// break;
|
|
|
|
// case 0: Opts.setStackProtectorMode(LangOptions::SSPOff); break;
|
|
|
|
// case 1: Opts.setStackProtectorMode(LangOptions::SSPOn); break;
|
|
|
|
// case 2: Opts.setStackProtectorMode(LangOptions::SSPReq); break;
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
2010-07-02 09:29:13 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ClangASTContext::ClangASTContext (const char *target_triple) :
|
2010-06-09 00:52:24 +08:00
|
|
|
m_target_triple(),
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
m_ast_ap(),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_language_options_ap(),
|
|
|
|
m_source_manager_ap(),
|
2011-10-08 07:18:13 +08:00
|
|
|
m_diagnostics_engine_ap(),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_target_options_ap(),
|
|
|
|
m_target_info_ap(),
|
|
|
|
m_identifier_table_ap(),
|
|
|
|
m_selector_table_ap(),
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
m_builtins_ap(),
|
|
|
|
m_callback_tag_decl (NULL),
|
|
|
|
m_callback_objc_decl (NULL),
|
|
|
|
m_callback_baton (NULL)
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (target_triple && target_triple[0])
|
2011-07-30 09:26:02 +08:00
|
|
|
SetTargetTriple (target_triple);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
ClangASTContext::~ClangASTContext()
|
|
|
|
{
|
|
|
|
m_builtins_ap.reset();
|
|
|
|
m_selector_table_ap.reset();
|
|
|
|
m_identifier_table_ap.reset();
|
|
|
|
m_target_info_ap.reset();
|
|
|
|
m_target_options_ap.reset();
|
2011-10-08 07:18:13 +08:00
|
|
|
m_diagnostics_engine_ap.reset();
|
2010-06-09 00:52:24 +08:00
|
|
|
m_source_manager_ap.reset();
|
|
|
|
m_language_options_ap.reset();
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
m_ast_ap.reset();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ClangASTContext::Clear()
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
m_ast_ap.reset();
|
2010-06-09 00:52:24 +08:00
|
|
|
m_language_options_ap.reset();
|
|
|
|
m_source_manager_ap.reset();
|
2011-10-08 07:18:13 +08:00
|
|
|
m_diagnostics_engine_ap.reset();
|
2010-06-09 00:52:24 +08:00
|
|
|
m_target_options_ap.reset();
|
|
|
|
m_target_info_ap.reset();
|
|
|
|
m_identifier_table_ap.reset();
|
|
|
|
m_selector_table_ap.reset();
|
|
|
|
m_builtins_ap.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
ClangASTContext::GetTargetTriple ()
|
|
|
|
{
|
|
|
|
return m_target_triple.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ClangASTContext::SetTargetTriple (const char *target_triple)
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
m_target_triple.assign(target_triple);
|
|
|
|
}
|
|
|
|
|
2011-02-16 05:59:32 +08:00
|
|
|
void
|
|
|
|
ClangASTContext::SetArchitecture (const ArchSpec &arch)
|
|
|
|
{
|
2011-07-30 09:26:02 +08:00
|
|
|
SetTargetTriple(arch.GetTriple().str().c_str());
|
2011-02-16 05:59:32 +08:00
|
|
|
}
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
bool
|
|
|
|
ClangASTContext::HasExternalSource ()
|
|
|
|
{
|
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
if (ast)
|
|
|
|
return ast->getExternalSource () != NULL;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ClangASTContext::SetExternalSource (llvm::OwningPtr<ExternalASTSource> &ast_source_ap)
|
|
|
|
{
|
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
if (ast)
|
|
|
|
{
|
|
|
|
ast->setExternalSource (ast_source_ap);
|
|
|
|
ast->getTranslationUnitDecl()->setHasExternalLexicalStorage(true);
|
|
|
|
//ast->getTranslationUnitDecl()->setHasExternalVisibleStorage(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ClangASTContext::RemoveExternalSource ()
|
|
|
|
{
|
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
|
|
|
|
if (ast)
|
|
|
|
{
|
|
|
|
llvm::OwningPtr<ExternalASTSource> empty_ast_source_ap;
|
|
|
|
ast->setExternalSource (empty_ast_source_ap);
|
|
|
|
ast->getTranslationUnitDecl()->setHasExternalLexicalStorage(false);
|
|
|
|
//ast->getTranslationUnitDecl()->setHasExternalVisibleStorage(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
ASTContext *
|
|
|
|
ClangASTContext::getASTContext()
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (m_ast_ap.get() == NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
m_ast_ap.reset(new ASTContext (*getLanguageOptions(),
|
|
|
|
*getSourceManager(),
|
2011-10-08 07:18:13 +08:00
|
|
|
getTargetInfo(),
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
*getIdentifierTable(),
|
|
|
|
*getSelectorTable(),
|
|
|
|
*getBuiltinContext(),
|
|
|
|
0));
|
2010-12-11 08:08:56 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if ((m_callback_tag_decl || m_callback_objc_decl) && m_callback_baton)
|
|
|
|
{
|
|
|
|
m_ast_ap->getTranslationUnitDecl()->setHasExternalLexicalStorage();
|
|
|
|
//m_ast_ap->getTranslationUnitDecl()->setHasExternalVisibleStorage();
|
|
|
|
}
|
|
|
|
|
2011-10-08 07:18:13 +08:00
|
|
|
m_ast_ap->getDiagnostics().setClient(getDiagnosticConsumer(), false);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return m_ast_ap.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Builtin::Context *
|
|
|
|
ClangASTContext::getBuiltinContext()
|
|
|
|
{
|
|
|
|
if (m_builtins_ap.get() == NULL)
|
2011-10-08 07:18:13 +08:00
|
|
|
m_builtins_ap.reset (new Builtin::Context());
|
2010-06-09 00:52:24 +08:00
|
|
|
return m_builtins_ap.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
IdentifierTable *
|
|
|
|
ClangASTContext::getIdentifierTable()
|
|
|
|
{
|
|
|
|
if (m_identifier_table_ap.get() == NULL)
|
|
|
|
m_identifier_table_ap.reset(new IdentifierTable (*ClangASTContext::getLanguageOptions(), NULL));
|
|
|
|
return m_identifier_table_ap.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
LangOptions *
|
|
|
|
ClangASTContext::getLanguageOptions()
|
|
|
|
{
|
|
|
|
if (m_language_options_ap.get() == NULL)
|
|
|
|
{
|
|
|
|
m_language_options_ap.reset(new LangOptions());
|
2010-06-14 01:34:29 +08:00
|
|
|
ParseLangArgs(*m_language_options_ap, IK_ObjCXX);
|
|
|
|
// InitializeLangOptions(*m_language_options_ap, IK_ObjCXX);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return m_language_options_ap.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
SelectorTable *
|
|
|
|
ClangASTContext::getSelectorTable()
|
|
|
|
{
|
|
|
|
if (m_selector_table_ap.get() == NULL)
|
|
|
|
m_selector_table_ap.reset (new SelectorTable());
|
|
|
|
return m_selector_table_ap.get();
|
|
|
|
}
|
|
|
|
|
2010-11-18 10:56:27 +08:00
|
|
|
clang::FileManager *
|
|
|
|
ClangASTContext::getFileManager()
|
|
|
|
{
|
|
|
|
if (m_file_manager_ap.get() == NULL)
|
2010-12-03 07:20:03 +08:00
|
|
|
{
|
|
|
|
clang::FileSystemOptions file_system_options;
|
|
|
|
m_file_manager_ap.reset(new clang::FileManager(file_system_options));
|
|
|
|
}
|
2010-11-18 10:56:27 +08:00
|
|
|
return m_file_manager_ap.get();
|
|
|
|
}
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
clang::SourceManager *
|
2010-06-09 00:52:24 +08:00
|
|
|
ClangASTContext::getSourceManager()
|
|
|
|
{
|
|
|
|
if (m_source_manager_ap.get() == NULL)
|
2011-10-08 07:18:13 +08:00
|
|
|
m_source_manager_ap.reset(new clang::SourceManager(*getDiagnosticsEngine(), *getFileManager()));
|
2010-06-09 00:52:24 +08:00
|
|
|
return m_source_manager_ap.get();
|
|
|
|
}
|
|
|
|
|
2011-10-08 07:18:13 +08:00
|
|
|
clang::DiagnosticsEngine *
|
|
|
|
ClangASTContext::getDiagnosticsEngine()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-10-08 07:18:13 +08:00
|
|
|
if (m_diagnostics_engine_ap.get() == NULL)
|
2010-11-20 05:46:54 +08:00
|
|
|
{
|
|
|
|
llvm::IntrusiveRefCntPtr<DiagnosticIDs> diag_id_sp(new DiagnosticIDs());
|
2011-10-08 07:18:13 +08:00
|
|
|
m_diagnostics_engine_ap.reset(new DiagnosticsEngine(diag_id_sp));
|
2010-11-20 05:46:54 +08:00
|
|
|
}
|
2011-10-08 07:18:13 +08:00
|
|
|
return m_diagnostics_engine_ap.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-10-08 07:18:13 +08:00
|
|
|
class NullDiagnosticConsumer : public DiagnosticConsumer
|
2010-12-11 08:08:56 +08:00
|
|
|
{
|
|
|
|
public:
|
2011-10-08 07:18:13 +08:00
|
|
|
NullDiagnosticConsumer ()
|
2010-12-11 08:08:56 +08:00
|
|
|
{
|
|
|
|
m_log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
|
|
|
|
}
|
|
|
|
|
2011-10-08 07:18:13 +08:00
|
|
|
void HandleDiagnostic (DiagnosticsEngine::Level DiagLevel, const Diagnostic &info)
|
2010-12-11 08:08:56 +08:00
|
|
|
{
|
|
|
|
if (m_log)
|
|
|
|
{
|
|
|
|
llvm::SmallVectorImpl<char> diag_str(10);
|
|
|
|
info.FormatDiagnostic(diag_str);
|
|
|
|
diag_str.push_back('\0');
|
|
|
|
m_log->Printf("Compiler diagnostic: %s\n", diag_str.data());
|
|
|
|
}
|
|
|
|
}
|
2011-10-08 07:18:13 +08:00
|
|
|
|
|
|
|
DiagnosticConsumer *clone (DiagnosticsEngine &Diags) const
|
|
|
|
{
|
|
|
|
return new NullDiagnosticConsumer ();
|
|
|
|
}
|
2010-12-11 08:08:56 +08:00
|
|
|
private:
|
|
|
|
LogSP m_log;
|
|
|
|
};
|
|
|
|
|
2011-10-08 07:18:13 +08:00
|
|
|
DiagnosticConsumer *
|
|
|
|
ClangASTContext::getDiagnosticConsumer()
|
2010-12-11 08:08:56 +08:00
|
|
|
{
|
2011-10-08 07:18:13 +08:00
|
|
|
if (m_diagnostic_consumer_ap.get() == NULL)
|
|
|
|
m_diagnostic_consumer_ap.reset(new NullDiagnosticConsumer);
|
2010-12-11 08:08:56 +08:00
|
|
|
|
2011-10-08 07:18:13 +08:00
|
|
|
return m_diagnostic_consumer_ap.get();
|
2010-12-11 08:08:56 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
TargetOptions *
|
|
|
|
ClangASTContext::getTargetOptions()
|
|
|
|
{
|
|
|
|
if (m_target_options_ap.get() == NULL && !m_target_triple.empty())
|
|
|
|
{
|
|
|
|
m_target_options_ap.reset (new TargetOptions());
|
|
|
|
if (m_target_options_ap.get())
|
|
|
|
m_target_options_ap->Triple = m_target_triple;
|
|
|
|
}
|
|
|
|
return m_target_options_ap.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TargetInfo *
|
|
|
|
ClangASTContext::getTargetInfo()
|
|
|
|
{
|
|
|
|
// target_triple should be something like "x86_64-apple-darwin10"
|
|
|
|
if (m_target_info_ap.get() == NULL && !m_target_triple.empty())
|
2011-10-08 07:18:13 +08:00
|
|
|
m_target_info_ap.reset (TargetInfo::CreateTargetInfo(*getDiagnosticsEngine(), *getTargetOptions()));
|
2010-06-09 00:52:24 +08:00
|
|
|
return m_target_info_ap.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark Basic Types
|
|
|
|
|
|
|
|
static inline bool
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
QualTypeMatchesBitSize(const uint64_t bit_size, ASTContext *ast, QualType qual_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
uint64_t qual_type_bit_size = ast->getTypeSize(qual_type);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (qual_type_bit_size == bit_size)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2010-08-05 09:57:25 +08:00
|
|
|
ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (Encoding encoding, uint32_t bit_size)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast = getASTContext();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
assert (ast != NULL);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return GetBuiltinTypeForEncodingAndBitSize (ast, encoding, bit_size);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (ASTContext *ast, Encoding encoding, uint32_t bit_size)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (!ast)
|
2010-06-09 00:52:24 +08:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
switch (encoding)
|
|
|
|
{
|
2010-08-05 09:57:25 +08:00
|
|
|
case eEncodingInvalid:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->VoidPtrTy))
|
|
|
|
return ast->VoidPtrTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-05 09:57:25 +08:00
|
|
|
case eEncodingUint:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
|
|
|
|
return ast->UnsignedCharTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
|
|
|
|
return ast->UnsignedShortTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedIntTy))
|
|
|
|
return ast->UnsignedIntTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongTy))
|
|
|
|
return ast->UnsignedLongTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongLongTy))
|
|
|
|
return ast->UnsignedLongLongTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedInt128Ty))
|
|
|
|
return ast->UnsignedInt128Ty.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-05 09:57:25 +08:00
|
|
|
case eEncodingSint:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy))
|
|
|
|
return ast->CharTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->ShortTy))
|
|
|
|
return ast->ShortTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->IntTy))
|
|
|
|
return ast->IntTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongTy))
|
|
|
|
return ast->LongTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongLongTy))
|
|
|
|
return ast->LongLongTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->Int128Ty))
|
|
|
|
return ast->Int128Ty.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-05 09:57:25 +08:00
|
|
|
case eEncodingIEEE754:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->FloatTy))
|
|
|
|
return ast->FloatTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->DoubleTy))
|
|
|
|
return ast->DoubleTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongDoubleTy))
|
|
|
|
return ast->LongDoubleTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-05 09:57:25 +08:00
|
|
|
case eEncodingVector:
|
2010-06-09 00:52:24 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2010-06-09 00:52:24 +08:00
|
|
|
ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name, uint32_t dw_ate, uint32_t bit_size)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast = getASTContext();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
#define streq(a,b) strcmp(a,b) == 0
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
assert (ast != NULL);
|
|
|
|
if (ast)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
switch (dw_ate)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DW_ATE_address:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->VoidPtrTy))
|
|
|
|
return ast->VoidPtrTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DW_ATE_boolean:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->BoolTy))
|
|
|
|
return ast->BoolTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
|
|
|
|
return ast->UnsignedCharTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
|
|
|
|
return ast->UnsignedShortTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedIntTy))
|
|
|
|
return ast->UnsignedIntTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
2011-01-15 10:52:14 +08:00
|
|
|
case DW_ATE_lo_user:
|
|
|
|
// This has been seen to mean DW_AT_complex_integer
|
2011-10-29 07:06:08 +08:00
|
|
|
if (type_name)
|
2011-01-15 10:52:14 +08:00
|
|
|
{
|
2011-10-29 07:06:08 +08:00
|
|
|
if (::strstr(type_name, "complex"))
|
|
|
|
{
|
|
|
|
clang_type_t complex_int_clang_type = GetBuiltinTypeForDWARFEncodingAndBitSize ("int", DW_ATE_signed, bit_size/2);
|
|
|
|
return ast->getComplexType (QualType::getFromOpaquePtr(complex_int_clang_type)).getAsOpaquePtr();
|
|
|
|
}
|
2011-01-15 10:52:14 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
case DW_ATE_complex_float:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->FloatComplexTy))
|
|
|
|
return ast->FloatComplexTy.getAsOpaquePtr();
|
|
|
|
else if (QualTypeMatchesBitSize (bit_size, ast, ast->DoubleComplexTy))
|
|
|
|
return ast->DoubleComplexTy.getAsOpaquePtr();
|
|
|
|
else if (QualTypeMatchesBitSize (bit_size, ast, ast->LongDoubleComplexTy))
|
|
|
|
return ast->LongDoubleComplexTy.getAsOpaquePtr();
|
2011-01-15 10:52:14 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
clang_type_t complex_float_clang_type = GetBuiltinTypeForDWARFEncodingAndBitSize ("float", DW_ATE_float, bit_size/2);
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return ast->getComplexType (QualType::getFromOpaquePtr(complex_float_clang_type)).getAsOpaquePtr();
|
2011-01-15 10:52:14 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DW_ATE_float:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->FloatTy))
|
|
|
|
return ast->FloatTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->DoubleTy))
|
|
|
|
return ast->DoubleTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongDoubleTy))
|
|
|
|
return ast->LongDoubleTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DW_ATE_signed:
|
|
|
|
if (type_name)
|
|
|
|
{
|
2010-11-02 11:48:39 +08:00
|
|
|
if (strstr(type_name, "long long"))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongLongTy))
|
|
|
|
return ast->LongLongTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-11-02 11:48:39 +08:00
|
|
|
else if (strstr(type_name, "long"))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongTy))
|
|
|
|
return ast->LongTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-11-02 11:48:39 +08:00
|
|
|
else if (strstr(type_name, "short"))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->ShortTy))
|
|
|
|
return ast->ShortTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-11-02 11:48:39 +08:00
|
|
|
else if (strstr(type_name, "char"))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy))
|
|
|
|
return ast->CharTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->SignedCharTy))
|
|
|
|
return ast->SignedCharTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-11-02 11:48:39 +08:00
|
|
|
else if (strstr(type_name, "int"))
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->IntTy))
|
|
|
|
return ast->IntTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->Int128Ty))
|
|
|
|
return ast->Int128Ty.getAsOpaquePtr();
|
2010-11-02 11:48:39 +08:00
|
|
|
}
|
|
|
|
else if (streq(type_name, "wchar_t"))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->WCharTy))
|
|
|
|
return ast->WCharTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-02-10 07:39:34 +08:00
|
|
|
else if (streq(type_name, "void"))
|
|
|
|
{
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->VoidTy))
|
|
|
|
return ast->VoidTy.getAsOpaquePtr();
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
// We weren't able to match up a type name, just search by size
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy))
|
|
|
|
return ast->CharTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->ShortTy))
|
|
|
|
return ast->ShortTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->IntTy))
|
|
|
|
return ast->IntTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongTy))
|
|
|
|
return ast->LongTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->LongLongTy))
|
|
|
|
return ast->LongLongTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->Int128Ty))
|
|
|
|
return ast->Int128Ty.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DW_ATE_signed_char:
|
|
|
|
if (type_name)
|
|
|
|
{
|
|
|
|
if (streq(type_name, "signed char"))
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->SignedCharTy))
|
|
|
|
return ast->SignedCharTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->CharTy))
|
|
|
|
return ast->CharTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->SignedCharTy))
|
|
|
|
return ast->SignedCharTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DW_ATE_unsigned:
|
|
|
|
if (type_name)
|
|
|
|
{
|
2010-11-02 11:48:39 +08:00
|
|
|
if (strstr(type_name, "long long"))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongLongTy))
|
|
|
|
return ast->UnsignedLongLongTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-11-02 11:48:39 +08:00
|
|
|
else if (strstr(type_name, "long"))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongTy))
|
|
|
|
return ast->UnsignedLongTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-11-02 11:48:39 +08:00
|
|
|
else if (strstr(type_name, "short"))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
|
|
|
|
return ast->UnsignedShortTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-11-02 11:48:39 +08:00
|
|
|
else if (strstr(type_name, "char"))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
|
|
|
|
return ast->UnsignedCharTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-11-02 11:48:39 +08:00
|
|
|
else if (strstr(type_name, "int"))
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedIntTy))
|
|
|
|
return ast->UnsignedIntTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedInt128Ty))
|
|
|
|
return ast->UnsignedInt128Ty.getAsOpaquePtr();
|
2010-11-02 11:48:39 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
// We weren't able to match up a type name, just search by size
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
|
|
|
|
return ast->UnsignedCharTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
|
|
|
|
return ast->UnsignedShortTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedIntTy))
|
|
|
|
return ast->UnsignedIntTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongTy))
|
|
|
|
return ast->UnsignedLongTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedLongLongTy))
|
|
|
|
return ast->UnsignedLongLongTy.getAsOpaquePtr();
|
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedInt128Ty))
|
|
|
|
return ast->UnsignedInt128Ty.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DW_ATE_unsigned_char:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedCharTy))
|
|
|
|
return ast->UnsignedCharTy.getAsOpaquePtr();
|
2011-02-10 07:39:34 +08:00
|
|
|
if (QualTypeMatchesBitSize (bit_size, ast, ast->UnsignedShortTy))
|
|
|
|
return ast->UnsignedShortTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DW_ATE_imaginary_float:
|
|
|
|
break;
|
2011-10-29 07:06:08 +08:00
|
|
|
|
|
|
|
case DW_ATE_UTF:
|
|
|
|
if (type_name)
|
|
|
|
{
|
|
|
|
if (streq(type_name, "char16_t"))
|
|
|
|
{
|
|
|
|
return ast->Char16Ty.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
else if (streq(type_name, "char32_t"))
|
|
|
|
{
|
|
|
|
return ast->Char32Ty.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// This assert should fire for anything that we don't catch above so we know
|
|
|
|
// to fix any issues we run into.
|
2011-05-18 02:15:05 +08:00
|
|
|
if (type_name)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "error: need to add support for DW_TAG_base_type '%s' encoded with DW_ATE = 0x%x, bit_size = %u\n", type_name, dw_ate, bit_size);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf (stderr, "error: need to add support for DW_TAG_base_type encoded with DW_ATE = 0x%x, bit_size = %u\n", dw_ate, bit_size);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ClangASTContext::GetBuiltInType_void(ASTContext *ast)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return ast->VoidTy.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-11-19 10:52:21 +08:00
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::GetBuiltInType_bool()
|
|
|
|
{
|
|
|
|
return getASTContext()->BoolTy.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2010-08-03 08:35:52 +08:00
|
|
|
ClangASTContext::GetBuiltInType_objc_id()
|
|
|
|
{
|
2010-12-07 07:53:20 +08:00
|
|
|
return getASTContext()->getPointerType(getASTContext()->ObjCBuiltinIdTy).getAsOpaquePtr();
|
2010-08-03 08:35:52 +08:00
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2010-08-03 08:35:52 +08:00
|
|
|
ClangASTContext::GetBuiltInType_objc_Class()
|
|
|
|
{
|
2010-10-25 08:29:48 +08:00
|
|
|
return getASTContext()->ObjCBuiltinClassTy.getAsOpaquePtr();
|
2010-08-03 08:35:52 +08:00
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2010-08-03 08:35:52 +08:00
|
|
|
ClangASTContext::GetBuiltInType_objc_selector()
|
|
|
|
{
|
2010-12-07 07:53:20 +08:00
|
|
|
return getASTContext()->getPointerType(getASTContext()->ObjCBuiltinSelTy).getAsOpaquePtr();
|
2010-08-03 08:35:52 +08:00
|
|
|
}
|
|
|
|
|
2011-05-13 07:54:16 +08:00
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::GetUnknownAnyType(clang::ASTContext *ast)
|
|
|
|
{
|
|
|
|
return ast->UnknownAnyTy.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2010-06-09 00:52:24 +08:00
|
|
|
ClangASTContext::GetCStringType (bool is_const)
|
|
|
|
{
|
|
|
|
QualType char_type(getASTContext()->CharTy);
|
|
|
|
|
|
|
|
if (is_const)
|
|
|
|
char_type.addConst();
|
|
|
|
|
|
|
|
return getASTContext()->getPointerType(char_type).getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2010-06-09 00:52:24 +08:00
|
|
|
ClangASTContext::GetVoidPtrType (bool is_const)
|
|
|
|
{
|
|
|
|
return GetVoidPtrType(getASTContext(), is_const);
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ClangASTContext::GetVoidPtrType (ASTContext *ast, bool is_const)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
QualType void_ptr_type(ast->VoidPtrTy);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (is_const)
|
|
|
|
void_ptr_type.addConst();
|
|
|
|
|
|
|
|
return void_ptr_type.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2010-12-03 07:20:03 +08:00
|
|
|
ClangASTContext::CopyType (ASTContext *dst_ast,
|
|
|
|
ASTContext *src_ast,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t clang_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-11-18 10:56:27 +08:00
|
|
|
FileSystemOptions file_system_options;
|
2010-12-03 07:20:03 +08:00
|
|
|
FileManager file_manager (file_system_options);
|
|
|
|
ASTImporter importer(*dst_ast, file_manager,
|
2011-01-19 07:32:05 +08:00
|
|
|
*src_ast, file_manager,
|
|
|
|
false);
|
2010-11-10 06:37:10 +08:00
|
|
|
|
2010-12-03 07:20:03 +08:00
|
|
|
QualType src (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
QualType dst (importer.Import(src));
|
2010-11-10 06:37:10 +08:00
|
|
|
|
|
|
|
return dst.getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-11-13 11:52:47 +08:00
|
|
|
|
|
|
|
clang::Decl *
|
2010-12-03 07:20:03 +08:00
|
|
|
ClangASTContext::CopyDecl (ASTContext *dst_ast,
|
|
|
|
ASTContext *src_ast,
|
2010-11-13 11:52:47 +08:00
|
|
|
clang::Decl *source_decl)
|
2010-12-11 08:08:56 +08:00
|
|
|
{
|
2010-11-18 10:56:27 +08:00
|
|
|
FileSystemOptions file_system_options;
|
2010-12-03 07:20:03 +08:00
|
|
|
FileManager file_manager (file_system_options);
|
|
|
|
ASTImporter importer(*dst_ast, file_manager,
|
2011-01-19 07:32:05 +08:00
|
|
|
*src_ast, file_manager,
|
|
|
|
false);
|
2010-11-13 11:52:47 +08:00
|
|
|
|
|
|
|
return importer.Import(source_decl);
|
|
|
|
}
|
|
|
|
|
2010-07-16 08:00:27 +08:00
|
|
|
bool
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ClangASTContext::AreTypesSame(ASTContext *ast,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t type1,
|
|
|
|
clang_type_t type2)
|
2010-07-16 06:30:52 +08:00
|
|
|
{
|
2011-02-17 07:00:21 +08:00
|
|
|
return ast->hasSameType (QualType::getFromOpaquePtr(type1),
|
|
|
|
QualType::getFromOpaquePtr(type2));
|
2010-07-16 06:30:52 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#pragma mark CVR modifiers
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::AddConstModifier (clang_type_t clang_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType result(QualType::getFromOpaquePtr(clang_type));
|
|
|
|
result.addConst();
|
|
|
|
return result.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::AddRestrictModifier (clang_type_t clang_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType result(QualType::getFromOpaquePtr(clang_type));
|
|
|
|
result.getQualifiers().setRestrict (true);
|
|
|
|
return result.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::AddVolatileModifier (clang_type_t clang_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType result(QualType::getFromOpaquePtr(clang_type));
|
|
|
|
result.getQualifiers().setVolatile (true);
|
|
|
|
return result.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
|
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::GetTypeForDecl (TagDecl *decl)
|
|
|
|
{
|
|
|
|
// No need to call the getASTContext() accessor (which can create the AST
|
|
|
|
// if it isn't created yet, because we can't have created a decl in this
|
|
|
|
// AST if our AST didn't already exist...
|
|
|
|
if (m_ast_ap.get())
|
|
|
|
return m_ast_ap->getTagDeclType(decl).getAsOpaquePtr();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::GetTypeForDecl (ObjCInterfaceDecl *decl)
|
|
|
|
{
|
|
|
|
// No need to call the getASTContext() accessor (which can create the AST
|
|
|
|
// if it isn't created yet, because we can't have created a decl in this
|
|
|
|
// AST if our AST didn't already exist...
|
|
|
|
if (m_ast_ap.get())
|
|
|
|
return m_ast_ap->getObjCInterfaceType(decl).getAsOpaquePtr();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#pragma mark Structure, Unions, Classes
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2011-10-26 11:31:36 +08:00
|
|
|
ClangASTContext::CreateRecordType (DeclContext *decl_ctx, AccessType access_type, const char *name, int kind, LanguageType language)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
assert (ast != NULL);
|
2010-10-25 08:29:48 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (decl_ctx == NULL)
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
decl_ctx = ast->getTranslationUnitDecl();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-07-28 10:04:09 +08:00
|
|
|
|
2011-08-25 07:50:00 +08:00
|
|
|
if (language == eLanguageTypeObjC || language == eLanguageTypeObjC_plus_plus)
|
2010-07-28 10:04:09 +08:00
|
|
|
{
|
2010-10-11 10:25:34 +08:00
|
|
|
bool isForwardDecl = true;
|
2010-07-28 10:04:09 +08:00
|
|
|
bool isInternal = false;
|
|
|
|
return CreateObjCClass (name, decl_ctx, isForwardDecl, isInternal);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// NOTE: Eventually CXXRecordDecl will be merged back into RecordDecl and
|
|
|
|
// we will need to update this code. I was told to currently always use
|
|
|
|
// the CXXRecordDecl class since we often don't know from debug information
|
|
|
|
// if something is struct or a class, so we default to always use the more
|
|
|
|
// complete definition just in case.
|
2011-10-22 11:33:13 +08:00
|
|
|
CXXRecordDecl *decl = CXXRecordDecl::Create (*ast,
|
|
|
|
(TagDecl::TagKind)kind,
|
|
|
|
decl_ctx,
|
|
|
|
SourceLocation(),
|
|
|
|
SourceLocation(),
|
|
|
|
name && name[0] ? &ast->Idents.get(name) : NULL);
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
|
2011-10-26 11:31:36 +08:00
|
|
|
if (decl_ctx)
|
|
|
|
{
|
|
|
|
if (access_type != eAccessNone)
|
|
|
|
decl->setAccess (ConvertAccessTypeToAccessSpecifier (access_type));
|
|
|
|
decl_ctx->addDecl (decl);
|
|
|
|
}
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return ast->getTagDeclType(decl).getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
|
2011-10-22 11:33:13 +08:00
|
|
|
ClassTemplateDecl *
|
|
|
|
ClangASTContext::CreateClassTemplateDecl (DeclContext *decl_ctx,
|
2011-10-26 11:31:36 +08:00
|
|
|
lldb::AccessType access_type,
|
2011-10-22 11:33:13 +08:00
|
|
|
const char *class_name,
|
|
|
|
int kind,
|
|
|
|
const TemplateParameterInfos &template_param_infos)
|
|
|
|
{
|
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
|
|
|
|
ClassTemplateDecl *class_template_decl = NULL;
|
|
|
|
if (decl_ctx == NULL)
|
|
|
|
decl_ctx = ast->getTranslationUnitDecl();
|
|
|
|
|
|
|
|
IdentifierInfo &identifier_info = ast->Idents.get(class_name);
|
|
|
|
DeclarationName decl_name (&identifier_info);
|
|
|
|
|
|
|
|
clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
|
|
|
|
for (clang::DeclContext::lookup_iterator pos = result.first, end = result.second; pos != end; ++pos)
|
|
|
|
{
|
|
|
|
class_template_decl = dyn_cast<clang::ClassTemplateDecl>(*pos);
|
|
|
|
if (class_template_decl)
|
|
|
|
return class_template_decl;
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::SmallVector<NamedDecl *, 8> template_param_decls;
|
|
|
|
const bool parameter_pack = false;
|
|
|
|
const bool is_typename = false;
|
|
|
|
const unsigned depth = 0;
|
|
|
|
const size_t num_template_params = template_param_infos.GetSize();
|
|
|
|
for (size_t i=0; i<num_template_params; ++i)
|
|
|
|
{
|
|
|
|
const char *name = template_param_infos.names[i];
|
|
|
|
if (template_param_infos.args[i].getAsIntegral())
|
|
|
|
{
|
|
|
|
template_param_decls.push_back (NonTypeTemplateParmDecl::Create (*ast,
|
|
|
|
ast->getTranslationUnitDecl(), // Is this the right decl context?, SourceLocation StartLoc,
|
|
|
|
SourceLocation(),
|
|
|
|
SourceLocation(),
|
|
|
|
depth,
|
|
|
|
i,
|
|
|
|
&ast->Idents.get(name),
|
|
|
|
template_param_infos.args[i].getAsType(),
|
|
|
|
parameter_pack,
|
|
|
|
NULL));
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
template_param_decls.push_back (TemplateTypeParmDecl::Create (*ast,
|
|
|
|
ast->getTranslationUnitDecl(), // Is this the right decl context?
|
|
|
|
SourceLocation(),
|
|
|
|
SourceLocation(),
|
|
|
|
depth,
|
|
|
|
i,
|
|
|
|
&ast->Idents.get(name),
|
|
|
|
is_typename,
|
|
|
|
parameter_pack));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TemplateParameterList *template_param_list = TemplateParameterList::Create (*ast,
|
|
|
|
SourceLocation(),
|
|
|
|
SourceLocation(),
|
|
|
|
&template_param_decls.front(),
|
|
|
|
template_param_decls.size(),
|
|
|
|
SourceLocation());
|
|
|
|
|
|
|
|
|
|
|
|
CXXRecordDecl *template_cxx_decl = CXXRecordDecl::Create (*ast,
|
|
|
|
(TagDecl::TagKind)kind,
|
|
|
|
decl_ctx, // What decl context do we use here? TU? The actual decl context?
|
|
|
|
SourceLocation(),
|
|
|
|
SourceLocation(),
|
|
|
|
&identifier_info);
|
|
|
|
|
|
|
|
|
|
|
|
class_template_decl = ClassTemplateDecl::Create (*ast,
|
|
|
|
decl_ctx, // What decl context do we use here? TU? The actual decl context?
|
|
|
|
SourceLocation(),
|
|
|
|
decl_name,
|
|
|
|
template_param_list,
|
|
|
|
template_cxx_decl,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (class_template_decl)
|
2011-10-26 09:06:27 +08:00
|
|
|
{
|
2011-10-26 11:31:36 +08:00
|
|
|
if (access_type != eAccessNone)
|
|
|
|
class_template_decl->setAccess (ConvertAccessTypeToAccessSpecifier (access_type));
|
2011-10-22 11:33:13 +08:00
|
|
|
decl_ctx->addDecl (class_template_decl);
|
2011-10-26 09:06:27 +08:00
|
|
|
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
|
|
|
VerifyDecl(class_template_decl);
|
|
|
|
#endif
|
|
|
|
}
|
2011-10-22 11:33:13 +08:00
|
|
|
|
|
|
|
return class_template_decl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ClassTemplateSpecializationDecl *
|
|
|
|
ClangASTContext::CreateClassTemplateSpecializationDecl (DeclContext *decl_ctx,
|
|
|
|
ClassTemplateDecl *class_template_decl,
|
|
|
|
int kind,
|
|
|
|
const TemplateParameterInfos &template_param_infos)
|
|
|
|
{
|
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
ClassTemplateSpecializationDecl *class_template_specialization_decl = ClassTemplateSpecializationDecl::Create (*ast,
|
|
|
|
(TagDecl::TagKind)kind,
|
|
|
|
decl_ctx,
|
|
|
|
SourceLocation(),
|
|
|
|
SourceLocation(),
|
|
|
|
class_template_decl,
|
|
|
|
&template_param_infos.args.front(),
|
|
|
|
template_param_infos.args.size(),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return class_template_specialization_decl;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::clang_type_t
|
|
|
|
ClangASTContext::CreateClassTemplateSpecializationType (ClassTemplateSpecializationDecl *class_template_specialization_decl)
|
|
|
|
{
|
|
|
|
if (class_template_specialization_decl)
|
|
|
|
{
|
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
if (ast)
|
|
|
|
return ast->getTagDeclType(class_template_specialization_decl).getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
bool
|
|
|
|
ClangASTContext::SetHasExternalStorage (clang_type_t clang_type, bool has_extern)
|
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::Record:
|
|
|
|
{
|
|
|
|
CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
|
|
|
|
if (cxx_record_decl)
|
|
|
|
{
|
|
|
|
cxx_record_decl->setHasExternalLexicalStorage (has_extern);
|
2011-01-20 12:18:48 +08:00
|
|
|
cxx_record_decl->setHasExternalVisibleStorage (has_extern);
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::Enum:
|
|
|
|
{
|
|
|
|
EnumDecl *enum_decl = cast<EnumType>(qual_type)->getDecl();
|
|
|
|
if (enum_decl)
|
|
|
|
{
|
|
|
|
enum_decl->setHasExternalLexicalStorage (has_extern);
|
2011-01-20 12:18:48 +08:00
|
|
|
enum_decl->setHasExternalVisibleStorage (has_extern);
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::ObjCObject:
|
|
|
|
case clang::Type::ObjCInterface:
|
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr());
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
assert (objc_class_type);
|
|
|
|
if (objc_class_type)
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
|
|
|
|
|
|
|
|
if (class_interface_decl)
|
|
|
|
{
|
|
|
|
class_interface_decl->setHasExternalLexicalStorage (has_extern);
|
2011-01-20 12:18:48 +08:00
|
|
|
class_interface_decl->setHasExternalVisibleStorage (has_extern);
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
case clang::Type::Typedef:
|
|
|
|
return ClangASTContext::SetHasExternalStorage (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), has_extern);
|
2011-08-12 07:56:13 +08:00
|
|
|
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::SetHasExternalStorage (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), has_extern);
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-10-02 07:13:49 +08:00
|
|
|
static bool
|
|
|
|
IsOperator (const char *name, OverloadedOperatorKind &op_kind)
|
|
|
|
{
|
|
|
|
if (name == NULL || name[0] == '\0')
|
|
|
|
return false;
|
|
|
|
|
2010-12-11 03:51:54 +08:00
|
|
|
#define OPERATOR_PREFIX "operator"
|
2010-12-14 10:59:59 +08:00
|
|
|
#define OPERATOR_PREFIX_LENGTH (sizeof (OPERATOR_PREFIX) - 1)
|
2010-12-10 10:15:55 +08:00
|
|
|
|
|
|
|
const char *post_op_name = NULL;
|
|
|
|
|
2010-12-11 03:51:54 +08:00
|
|
|
bool no_space = true;
|
2010-12-10 10:15:55 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (::strncmp(name, OPERATOR_PREFIX, OPERATOR_PREFIX_LENGTH))
|
2010-12-11 03:51:54 +08:00
|
|
|
return false;
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
post_op_name = name + OPERATOR_PREFIX_LENGTH;
|
|
|
|
|
2010-12-11 03:51:54 +08:00
|
|
|
if (post_op_name[0] == ' ')
|
2010-12-10 10:15:55 +08:00
|
|
|
{
|
2010-12-11 03:51:54 +08:00
|
|
|
post_op_name++;
|
|
|
|
no_space = false;
|
2010-12-10 10:15:55 +08:00
|
|
|
}
|
|
|
|
|
2010-12-11 03:51:54 +08:00
|
|
|
#undef OPERATOR_PREFIX
|
2010-12-14 10:59:59 +08:00
|
|
|
#undef OPERATOR_PREFIX_LENGTH
|
2010-10-02 07:13:49 +08:00
|
|
|
|
|
|
|
// This is an operator, set the overloaded operator kind to invalid
|
|
|
|
// in case this is a conversion operator...
|
|
|
|
op_kind = NUM_OVERLOADED_OPERATORS;
|
|
|
|
|
|
|
|
switch (post_op_name[0])
|
|
|
|
{
|
2010-12-10 10:15:55 +08:00
|
|
|
default:
|
|
|
|
if (no_space)
|
|
|
|
return false;
|
|
|
|
break;
|
2010-10-02 07:13:49 +08:00
|
|
|
case 'n':
|
2010-12-10 10:15:55 +08:00
|
|
|
if (no_space)
|
|
|
|
return false;
|
2010-10-02 07:13:49 +08:00
|
|
|
if (strcmp (post_op_name, "new") == 0)
|
|
|
|
op_kind = OO_New;
|
|
|
|
else if (strcmp (post_op_name, "new[]") == 0)
|
|
|
|
op_kind = OO_Array_New;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'd':
|
2010-12-10 10:15:55 +08:00
|
|
|
if (no_space)
|
|
|
|
return false;
|
2010-10-02 07:13:49 +08:00
|
|
|
if (strcmp (post_op_name, "delete") == 0)
|
|
|
|
op_kind = OO_Delete;
|
|
|
|
else if (strcmp (post_op_name, "delete[]") == 0)
|
|
|
|
op_kind = OO_Array_Delete;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '+':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Plus;
|
|
|
|
else if (post_op_name[2] == '\0')
|
|
|
|
{
|
|
|
|
if (post_op_name[1] == '=')
|
|
|
|
op_kind = OO_PlusEqual;
|
|
|
|
else if (post_op_name[1] == '+')
|
|
|
|
op_kind = OO_PlusPlus;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '-':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Minus;
|
|
|
|
else if (post_op_name[2] == '\0')
|
|
|
|
{
|
|
|
|
switch (post_op_name[1])
|
|
|
|
{
|
|
|
|
case '=': op_kind = OO_MinusEqual; break;
|
|
|
|
case '-': op_kind = OO_MinusMinus; break;
|
|
|
|
case '>': op_kind = OO_Arrow; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (post_op_name[3] == '\0')
|
|
|
|
{
|
|
|
|
if (post_op_name[2] == '*')
|
|
|
|
op_kind = OO_ArrowStar; break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '*':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Star;
|
|
|
|
else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
|
|
|
|
op_kind = OO_StarEqual;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '/':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Slash;
|
|
|
|
else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
|
|
|
|
op_kind = OO_SlashEqual;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '%':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Percent;
|
|
|
|
else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
|
|
|
|
op_kind = OO_PercentEqual;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case '^':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Caret;
|
|
|
|
else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
|
|
|
|
op_kind = OO_CaretEqual;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '&':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Amp;
|
|
|
|
else if (post_op_name[2] == '\0')
|
|
|
|
{
|
|
|
|
switch (post_op_name[1])
|
|
|
|
{
|
|
|
|
case '=': op_kind = OO_AmpEqual; break;
|
|
|
|
case '&': op_kind = OO_AmpAmp; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '|':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Pipe;
|
|
|
|
else if (post_op_name[2] == '\0')
|
|
|
|
{
|
|
|
|
switch (post_op_name[1])
|
|
|
|
{
|
|
|
|
case '=': op_kind = OO_PipeEqual; break;
|
|
|
|
case '|': op_kind = OO_PipePipe; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '~':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Tilde;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '!':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Exclaim;
|
|
|
|
else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
|
|
|
|
op_kind = OO_ExclaimEqual;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '=':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Equal;
|
|
|
|
else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
|
|
|
|
op_kind = OO_EqualEqual;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '<':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Less;
|
|
|
|
else if (post_op_name[2] == '\0')
|
|
|
|
{
|
|
|
|
switch (post_op_name[1])
|
|
|
|
{
|
|
|
|
case '<': op_kind = OO_LessLess; break;
|
|
|
|
case '=': op_kind = OO_LessEqual; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (post_op_name[3] == '\0')
|
|
|
|
{
|
|
|
|
if (post_op_name[2] == '=')
|
|
|
|
op_kind = OO_LessLessEqual;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '>':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Greater;
|
|
|
|
else if (post_op_name[2] == '\0')
|
|
|
|
{
|
|
|
|
switch (post_op_name[1])
|
|
|
|
{
|
|
|
|
case '>': op_kind = OO_GreaterGreater; break;
|
|
|
|
case '=': op_kind = OO_GreaterEqual; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (post_op_name[1] == '>' &&
|
|
|
|
post_op_name[2] == '=' &&
|
|
|
|
post_op_name[3] == '\0')
|
|
|
|
{
|
|
|
|
op_kind = OO_GreaterGreaterEqual;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ',':
|
|
|
|
if (post_op_name[1] == '\0')
|
|
|
|
op_kind = OO_Comma;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '(':
|
|
|
|
if (post_op_name[1] == ')' && post_op_name[2] == '\0')
|
|
|
|
op_kind = OO_Call;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '[':
|
|
|
|
if (post_op_name[1] == ']' && post_op_name[2] == '\0')
|
|
|
|
op_kind = OO_Subscript;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
|
2011-06-19 11:43:27 +08:00
|
|
|
static inline bool
|
2011-10-15 09:15:07 +08:00
|
|
|
check_op_param (uint32_t op_kind, bool unary, bool binary, uint32_t num_params)
|
2011-06-19 11:43:27 +08:00
|
|
|
{
|
2011-10-15 09:15:07 +08:00
|
|
|
// Special-case call since it can take any number of operands
|
|
|
|
if(op_kind == OO_Call)
|
|
|
|
return true;
|
|
|
|
|
2011-06-19 11:43:27 +08:00
|
|
|
// The parameter count doens't include "this"
|
|
|
|
if (num_params == 0)
|
|
|
|
return unary;
|
|
|
|
if (num_params == 1)
|
|
|
|
return binary;
|
2011-10-15 09:15:07 +08:00
|
|
|
else
|
2011-06-19 11:43:27 +08:00
|
|
|
return false;
|
|
|
|
}
|
2011-11-01 06:50:57 +08:00
|
|
|
|
2011-06-19 11:43:27 +08:00
|
|
|
bool
|
|
|
|
ClangASTContext::CheckOverloadedOperatorKindParameterCount (uint32_t op_kind, uint32_t num_params)
|
|
|
|
{
|
2011-10-15 09:15:07 +08:00
|
|
|
#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) case OO_##Name: return check_op_param (op_kind, Unary, Binary, num_params);
|
2011-06-19 11:43:27 +08:00
|
|
|
switch (op_kind)
|
|
|
|
{
|
|
|
|
#include "clang/Basic/OperatorKinds.def"
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-09-23 09:09:21 +08:00
|
|
|
CXXMethodDecl *
|
2010-09-17 10:58:26 +08:00
|
|
|
ClangASTContext::AddMethodToCXXRecordType
|
|
|
|
(
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t record_opaque_type,
|
2010-09-23 09:09:21 +08:00
|
|
|
const char *name,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t method_opaque_type,
|
2010-09-23 09:09:21 +08:00
|
|
|
lldb::AccessType access,
|
2010-09-24 13:15:53 +08:00
|
|
|
bool is_virtual,
|
|
|
|
bool is_static,
|
2010-10-01 10:31:07 +08:00
|
|
|
bool is_inline,
|
2011-11-02 02:07:13 +08:00
|
|
|
bool is_explicit,
|
2011-11-02 09:38:59 +08:00
|
|
|
bool is_attr_used,
|
|
|
|
bool is_artificial
|
2010-09-23 09:09:21 +08:00
|
|
|
)
|
2010-09-17 10:58:26 +08:00
|
|
|
{
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
if (!record_opaque_type || !method_opaque_type || !name)
|
2010-09-29 00:10:54 +08:00
|
|
|
return NULL;
|
2010-09-17 10:58:26 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
assert(ast);
|
2010-09-17 10:58:26 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
IdentifierTable *identifier_table = &ast->Idents;
|
2010-09-17 10:58:26 +08:00
|
|
|
|
|
|
|
assert(identifier_table);
|
|
|
|
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
QualType record_qual_type(QualType::getFromOpaquePtr(record_opaque_type));
|
2010-09-24 13:15:53 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
CXXRecordDecl *cxx_record_decl = record_qual_type->getAsCXXRecordDecl();
|
2010-09-17 10:58:26 +08:00
|
|
|
|
2010-09-24 13:15:53 +08:00
|
|
|
if (cxx_record_decl == NULL)
|
2010-09-23 09:09:21 +08:00
|
|
|
return NULL;
|
2010-09-17 10:58:26 +08:00
|
|
|
|
2010-09-24 13:15:53 +08:00
|
|
|
QualType method_qual_type (QualType::getFromOpaquePtr (method_opaque_type));
|
|
|
|
|
2010-10-01 10:31:07 +08:00
|
|
|
CXXMethodDecl *cxx_method_decl = NULL;
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
|
2010-10-01 10:31:07 +08:00
|
|
|
DeclarationName decl_name (&identifier_table->get(name));
|
2010-10-01 11:45:20 +08:00
|
|
|
|
2011-01-27 12:42:51 +08:00
|
|
|
const clang::FunctionType *function_Type = dyn_cast<FunctionType>(method_qual_type.getTypePtr());
|
2010-10-01 11:45:20 +08:00
|
|
|
|
2010-10-02 09:40:05 +08:00
|
|
|
if (function_Type == NULL)
|
2010-10-01 11:45:20 +08:00
|
|
|
return NULL;
|
|
|
|
|
2011-01-27 12:42:51 +08:00
|
|
|
const FunctionProtoType *method_function_prototype (dyn_cast<FunctionProtoType>(function_Type));
|
2010-10-01 10:31:07 +08:00
|
|
|
|
2010-10-01 11:45:20 +08:00
|
|
|
if (!method_function_prototype)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
unsigned int num_params = method_function_prototype->getNumArgs();
|
|
|
|
|
2011-11-02 09:38:59 +08:00
|
|
|
CXXDestructorDecl *cxx_dtor_decl(NULL);
|
|
|
|
CXXConstructorDecl *cxx_ctor_decl(NULL);
|
|
|
|
|
2010-10-01 11:45:20 +08:00
|
|
|
if (name[0] == '~')
|
|
|
|
{
|
2011-11-02 09:38:59 +08:00
|
|
|
cxx_dtor_decl = CXXDestructorDecl::Create (*ast,
|
|
|
|
cxx_record_decl,
|
|
|
|
SourceLocation(),
|
|
|
|
DeclarationNameInfo (ast->DeclarationNames.getCXXDestructorName (ast->getCanonicalType (record_qual_type)), SourceLocation()),
|
|
|
|
method_qual_type,
|
|
|
|
NULL,
|
|
|
|
is_inline,
|
|
|
|
is_artificial);
|
|
|
|
cxx_method_decl = cxx_dtor_decl;
|
2010-10-01 11:45:20 +08:00
|
|
|
}
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
else if (decl_name == cxx_record_decl->getDeclName())
|
2010-10-01 10:31:07 +08:00
|
|
|
{
|
2011-11-02 09:38:59 +08:00
|
|
|
cxx_ctor_decl = CXXConstructorDecl::Create (*ast,
|
|
|
|
cxx_record_decl,
|
|
|
|
SourceLocation(),
|
|
|
|
DeclarationNameInfo (ast->DeclarationNames.getCXXConstructorName (ast->getCanonicalType (record_qual_type)), SourceLocation()),
|
|
|
|
method_qual_type,
|
|
|
|
NULL, // TypeSourceInfo *
|
|
|
|
is_explicit,
|
|
|
|
is_inline,
|
|
|
|
is_artificial,
|
|
|
|
false /*is_constexpr*/);
|
|
|
|
cxx_method_decl = cxx_ctor_decl;
|
2010-10-01 10:31:07 +08:00
|
|
|
}
|
|
|
|
else
|
2010-10-01 11:45:20 +08:00
|
|
|
{
|
2010-10-02 07:13:49 +08:00
|
|
|
|
|
|
|
OverloadedOperatorKind op_kind = NUM_OVERLOADED_OPERATORS;
|
|
|
|
if (IsOperator (name, op_kind))
|
2010-10-01 11:45:20 +08:00
|
|
|
{
|
2010-10-02 07:13:49 +08:00
|
|
|
if (op_kind != NUM_OVERLOADED_OPERATORS)
|
|
|
|
{
|
2011-06-19 11:43:27 +08:00
|
|
|
// Check the number of operator parameters. Sometimes we have
|
|
|
|
// seen bad DWARF that doesn't correctly describe operators and
|
|
|
|
// if we try to create a methed and add it to the class, clang
|
|
|
|
// will assert and crash, so we need to make sure things are
|
|
|
|
// acceptable.
|
|
|
|
if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount (op_kind, num_params))
|
|
|
|
return NULL;
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
cxx_method_decl = CXXMethodDecl::Create (*ast,
|
2010-10-01 11:45:20 +08:00
|
|
|
cxx_record_decl,
|
2011-03-15 08:17:19 +08:00
|
|
|
SourceLocation(),
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
DeclarationNameInfo (ast->DeclarationNames.getCXXOperatorName (op_kind), SourceLocation()),
|
2010-10-01 11:45:20 +08:00
|
|
|
method_qual_type,
|
|
|
|
NULL, // TypeSourceInfo *
|
2010-10-02 07:13:49 +08:00
|
|
|
is_static,
|
|
|
|
SC_None,
|
2011-03-15 08:17:19 +08:00
|
|
|
is_inline,
|
2011-10-08 07:18:13 +08:00
|
|
|
false /*is_constexpr*/,
|
2011-03-15 08:17:19 +08:00
|
|
|
SourceLocation());
|
2010-10-02 07:13:49 +08:00
|
|
|
}
|
|
|
|
else if (num_params == 0)
|
|
|
|
{
|
|
|
|
// Conversion operators don't take params...
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
cxx_method_decl = CXXConversionDecl::Create (*ast,
|
2010-10-02 07:13:49 +08:00
|
|
|
cxx_record_decl,
|
2011-03-15 08:17:19 +08:00
|
|
|
SourceLocation(),
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
DeclarationNameInfo (ast->DeclarationNames.getCXXConversionFunctionName (ast->getCanonicalType (function_Type->getResultType())), SourceLocation()),
|
2010-10-02 07:13:49 +08:00
|
|
|
method_qual_type,
|
|
|
|
NULL, // TypeSourceInfo *
|
|
|
|
is_inline,
|
2011-03-15 08:17:19 +08:00
|
|
|
is_explicit,
|
2011-10-08 07:18:13 +08:00
|
|
|
false /*is_constexpr*/,
|
2011-03-15 08:17:19 +08:00
|
|
|
SourceLocation());
|
2010-10-02 07:13:49 +08:00
|
|
|
}
|
2010-10-01 11:45:20 +08:00
|
|
|
}
|
2010-10-02 07:13:49 +08:00
|
|
|
|
|
|
|
if (cxx_method_decl == NULL)
|
2010-10-01 11:45:20 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
cxx_method_decl = CXXMethodDecl::Create (*ast,
|
2010-10-01 11:45:20 +08:00
|
|
|
cxx_record_decl,
|
2011-03-15 08:17:19 +08:00
|
|
|
SourceLocation(),
|
2010-10-02 07:13:49 +08:00
|
|
|
DeclarationNameInfo (decl_name, SourceLocation()),
|
2010-10-01 11:45:20 +08:00
|
|
|
method_qual_type,
|
|
|
|
NULL, // TypeSourceInfo *
|
|
|
|
is_static,
|
|
|
|
SC_None,
|
2011-03-15 08:17:19 +08:00
|
|
|
is_inline,
|
2011-10-08 07:18:13 +08:00
|
|
|
false /*is_constexpr*/,
|
2011-03-15 08:17:19 +08:00
|
|
|
SourceLocation());
|
2010-10-01 11:45:20 +08:00
|
|
|
}
|
2010-10-01 10:31:07 +08:00
|
|
|
}
|
2010-10-02 07:13:49 +08:00
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
AccessSpecifier access_specifier = ConvertAccessTypeToAccessSpecifier (access);
|
2010-09-23 11:01:22 +08:00
|
|
|
|
2010-09-24 13:15:53 +08:00
|
|
|
cxx_method_decl->setAccess (access_specifier);
|
|
|
|
cxx_method_decl->setVirtualAsWritten (is_virtual);
|
2010-09-23 11:01:22 +08:00
|
|
|
|
2011-11-02 02:07:13 +08:00
|
|
|
if (is_attr_used)
|
|
|
|
cxx_method_decl->addAttr(::new (*ast) UsedAttr(SourceRange(), *ast));
|
|
|
|
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
// Populate the method decl with parameter decls
|
|
|
|
|
2011-05-20 07:33:46 +08:00
|
|
|
llvm::SmallVector<ParmVarDecl *, 12> params;
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
|
|
|
|
for (int param_index = 0;
|
|
|
|
param_index < num_params;
|
|
|
|
++param_index)
|
|
|
|
{
|
2011-05-20 07:33:46 +08:00
|
|
|
params.push_back (ParmVarDecl::Create (*ast,
|
|
|
|
cxx_method_decl,
|
|
|
|
SourceLocation(),
|
|
|
|
SourceLocation(),
|
|
|
|
NULL, // anonymous
|
|
|
|
method_function_prototype->getArgType(param_index),
|
|
|
|
NULL,
|
|
|
|
SC_None,
|
|
|
|
SC_None,
|
|
|
|
NULL));
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
}
|
|
|
|
|
2011-10-08 07:18:13 +08:00
|
|
|
cxx_method_decl->setParams (ArrayRef<ParmVarDecl*>(params));
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
|
2010-09-24 13:15:53 +08:00
|
|
|
cxx_record_decl->addDecl (cxx_method_decl);
|
2011-10-26 09:06:27 +08:00
|
|
|
|
2011-11-02 10:06:20 +08:00
|
|
|
// Sometimes the debug info will mention a constructor (default/copy/move),
|
|
|
|
// destructor, or assignment operator (copy/move) but there won't be any
|
|
|
|
// version of this in the code. So we check if the function was artificially
|
|
|
|
// generated and if it is trivial and this lets the compiler/backend know
|
|
|
|
// that it can inline the IR for these when it needs to and we can avoid a
|
|
|
|
// "missing function" error when running expressions.
|
|
|
|
|
2011-11-02 09:38:59 +08:00
|
|
|
if (is_artificial)
|
|
|
|
{
|
2011-11-02 10:06:20 +08:00
|
|
|
if (cxx_ctor_decl &&
|
|
|
|
((cxx_ctor_decl->isDefaultConstructor() && cxx_record_decl->hasTrivialDefaultConstructor ()) ||
|
|
|
|
(cxx_ctor_decl->isCopyConstructor() && cxx_record_decl->hasTrivialCopyConstructor ()) ||
|
|
|
|
(cxx_ctor_decl->isMoveConstructor() && cxx_record_decl->hasTrivialMoveConstructor ()) ))
|
2011-11-02 09:38:59 +08:00
|
|
|
{
|
|
|
|
cxx_ctor_decl->setDefaulted();
|
|
|
|
cxx_ctor_decl->setTrivial(true);
|
|
|
|
}
|
2011-11-02 10:06:20 +08:00
|
|
|
else if (cxx_dtor_decl)
|
|
|
|
{
|
|
|
|
if (cxx_record_decl->hasTrivialDestructor())
|
|
|
|
{
|
|
|
|
cxx_dtor_decl->setDefaulted();
|
|
|
|
cxx_dtor_decl->setTrivial(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((cxx_method_decl->isCopyAssignmentOperator() && cxx_record_decl->hasTrivialCopyAssignment()) ||
|
|
|
|
(cxx_method_decl->isMoveAssignmentOperator() && cxx_record_decl->hasTrivialMoveAssignment()))
|
2011-11-02 09:38:59 +08:00
|
|
|
{
|
2011-11-02 10:06:20 +08:00
|
|
|
cxx_method_decl->setDefaulted();
|
|
|
|
cxx_method_decl->setTrivial(true);
|
2011-11-02 09:38:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-26 09:06:27 +08:00
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
|
|
|
VerifyDecl(cxx_method_decl);
|
|
|
|
#endif
|
2011-01-20 12:18:48 +08:00
|
|
|
|
|
|
|
// printf ("decl->isPolymorphic() = %i\n", cxx_record_decl->isPolymorphic());
|
|
|
|
// printf ("decl->isAggregate() = %i\n", cxx_record_decl->isAggregate());
|
|
|
|
// printf ("decl->isPOD() = %i\n", cxx_record_decl->isPOD());
|
|
|
|
// printf ("decl->isEmpty() = %i\n", cxx_record_decl->isEmpty());
|
|
|
|
// printf ("decl->isAbstract() = %i\n", cxx_record_decl->isAbstract());
|
|
|
|
// printf ("decl->hasTrivialConstructor() = %i\n", cxx_record_decl->hasTrivialConstructor());
|
|
|
|
// printf ("decl->hasTrivialCopyConstructor() = %i\n", cxx_record_decl->hasTrivialCopyConstructor());
|
|
|
|
// printf ("decl->hasTrivialCopyAssignment() = %i\n", cxx_record_decl->hasTrivialCopyAssignment());
|
|
|
|
// printf ("decl->hasTrivialDestructor() = %i\n", cxx_record_decl->hasTrivialDestructor());
|
2010-09-23 09:09:21 +08:00
|
|
|
return cxx_method_decl;
|
2010-09-17 10:58:26 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
2010-07-23 02:30:50 +08:00
|
|
|
ClangASTContext::AddFieldToRecordType
|
|
|
|
(
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t record_clang_type,
|
2010-07-23 02:30:50 +08:00
|
|
|
const char *name,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t field_type,
|
2010-07-23 02:30:50 +08:00
|
|
|
AccessType access,
|
|
|
|
uint32_t bitfield_bit_size
|
|
|
|
)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (record_clang_type == NULL || field_type == NULL)
|
|
|
|
return false;
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
IdentifierTable *identifier_table = &ast->Idents;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
assert (ast != NULL);
|
2010-06-09 00:52:24 +08:00
|
|
|
assert (identifier_table != NULL);
|
|
|
|
|
|
|
|
QualType record_qual_type(QualType::getFromOpaquePtr(record_clang_type));
|
|
|
|
|
2011-01-27 12:42:51 +08:00
|
|
|
const clang::Type *clang_type = record_qual_type.getTypePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
const RecordType *record_type = dyn_cast<RecordType>(clang_type);
|
|
|
|
|
|
|
|
if (record_type)
|
|
|
|
{
|
|
|
|
RecordDecl *record_decl = record_type->getDecl();
|
|
|
|
|
|
|
|
clang::Expr *bit_width = NULL;
|
|
|
|
if (bitfield_bit_size != 0)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
APInt bitfield_bit_size_apint(ast->getTypeSize(ast->IntTy), bitfield_bit_size);
|
|
|
|
bit_width = new (*ast)IntegerLiteral (*ast, bitfield_bit_size_apint, ast->IntTy, SourceLocation());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
FieldDecl *field = FieldDecl::Create (*ast,
|
2010-07-23 02:30:50 +08:00
|
|
|
record_decl,
|
|
|
|
SourceLocation(),
|
2011-03-15 08:17:19 +08:00
|
|
|
SourceLocation(),
|
2010-07-23 02:30:50 +08:00
|
|
|
name ? &identifier_table->get(name) : NULL, // Identifier
|
|
|
|
QualType::getFromOpaquePtr(field_type), // Field type
|
2011-07-30 10:42:06 +08:00
|
|
|
NULL, // TInfo *
|
2010-07-23 02:30:50 +08:00
|
|
|
bit_width, // BitWidth
|
2011-07-30 10:42:06 +08:00
|
|
|
false, // Mutable
|
|
|
|
false); // HasInit
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-07-23 02:30:50 +08:00
|
|
|
field->setAccess (ConvertAccessTypeToAccessSpecifier (access));
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (field)
|
|
|
|
{
|
|
|
|
record_decl->addDecl(field);
|
2011-10-26 09:06:27 +08:00
|
|
|
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
|
|
|
VerifyDecl(field);
|
|
|
|
#endif
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
2010-07-28 10:04:09 +08:00
|
|
|
else
|
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(clang_type);
|
2010-07-28 10:04:09 +08:00
|
|
|
if (objc_class_type)
|
|
|
|
{
|
2010-09-24 13:15:53 +08:00
|
|
|
bool is_synthesized = false;
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ClangASTContext::AddObjCClassIVar (ast,
|
2010-09-17 04:01:08 +08:00
|
|
|
record_clang_type,
|
2010-07-28 10:04:09 +08:00
|
|
|
name,
|
|
|
|
field_type,
|
|
|
|
access,
|
|
|
|
bitfield_bit_size,
|
2010-09-24 13:15:53 +08:00
|
|
|
is_synthesized);
|
2010-07-28 10:04:09 +08:00
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ClangASTContext::FieldIsBitfield (FieldDecl* field, uint32_t& bitfield_bit_size)
|
|
|
|
{
|
|
|
|
return FieldIsBitfield(getASTContext(), field, bitfield_bit_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ClangASTContext::FieldIsBitfield
|
|
|
|
(
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast,
|
2010-06-09 00:52:24 +08:00
|
|
|
FieldDecl* field,
|
|
|
|
uint32_t& bitfield_bit_size
|
|
|
|
)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (ast == NULL || field == NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (field->isBitField())
|
|
|
|
{
|
|
|
|
Expr* bit_width_expr = field->getBitWidth();
|
|
|
|
if (bit_width_expr)
|
|
|
|
{
|
|
|
|
llvm::APSInt bit_width_apsint;
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (bit_width_expr->isIntegerConstantExpr(bit_width_apsint, *ast))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
bitfield_bit_size = bit_width_apsint.getLimitedValue(UINT32_MAX);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ClangASTContext::RecordHasFields (const RecordDecl *record_decl)
|
|
|
|
{
|
|
|
|
if (record_decl == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!record_decl->field_empty())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// No fields, lets check this is a CXX record and check the base classes
|
|
|
|
const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
|
|
|
|
if (cxx_record_decl)
|
|
|
|
{
|
|
|
|
CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
|
|
|
|
for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
|
|
|
|
base_class != base_class_end;
|
|
|
|
++base_class)
|
|
|
|
{
|
|
|
|
const CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl());
|
|
|
|
if (RecordHasFields(base_class_decl))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ClangASTContext::SetDefaultAccessForRecordFields (clang_type_t clang_type, int default_accessibility, int *assigned_accessibilities, size_t num_assigned_accessibilities)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (clang_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
|
|
|
|
|
2011-01-27 12:42:51 +08:00
|
|
|
const RecordType *record_type = dyn_cast<RecordType>(qual_type.getTypePtr());
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (record_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
RecordDecl *record_decl = record_type->getDecl();
|
|
|
|
if (record_decl)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
uint32_t field_idx;
|
|
|
|
RecordDecl::field_iterator field, field_end;
|
|
|
|
for (field = record_decl->field_begin(), field_end = record_decl->field_end(), field_idx = 0;
|
|
|
|
field != field_end;
|
|
|
|
++field, ++field_idx)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
// If no accessibility was assigned, assign the correct one
|
|
|
|
if (field_idx < num_assigned_accessibilities && assigned_accessibilities[field_idx] == clang::AS_none)
|
|
|
|
field->setAccess ((AccessSpecifier)default_accessibility);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark C++ Base Classes
|
|
|
|
|
|
|
|
CXXBaseSpecifier *
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::CreateBaseClassSpecifier (clang_type_t base_class_type, AccessType access, bool is_virtual, bool base_of_class)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (base_class_type)
|
2010-07-31 04:30:44 +08:00
|
|
|
return new CXXBaseSpecifier (SourceRange(),
|
|
|
|
is_virtual,
|
|
|
|
base_of_class,
|
|
|
|
ConvertAccessTypeToAccessSpecifier (access),
|
2011-01-19 07:32:05 +08:00
|
|
|
getASTContext()->CreateTypeSourceInfo (QualType::getFromOpaquePtr(base_class_type)),
|
|
|
|
SourceLocation());
|
2010-06-09 00:52:24 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-07-02 09:29:13 +08:00
|
|
|
void
|
|
|
|
ClangASTContext::DeleteBaseClassSpecifiers (CXXBaseSpecifier **base_classes, unsigned num_base_classes)
|
|
|
|
{
|
|
|
|
for (unsigned i=0; i<num_base_classes; ++i)
|
|
|
|
{
|
|
|
|
delete base_classes[i];
|
|
|
|
base_classes[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::SetBaseClassesForClassType (clang_type_t class_clang_type, CXXBaseSpecifier const * const *base_classes, unsigned num_base_classes)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (class_clang_type)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
CXXRecordDecl *cxx_record_decl = QualType::getFromOpaquePtr(class_clang_type)->getAsCXXRecordDecl();
|
|
|
|
if (cxx_record_decl)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
cxx_record_decl->setBases(base_classes, num_base_classes);
|
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2010-07-23 02:30:50 +08:00
|
|
|
#pragma mark Objective C Classes
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2010-07-23 02:30:50 +08:00
|
|
|
ClangASTContext::CreateObjCClass
|
|
|
|
(
|
|
|
|
const char *name,
|
|
|
|
DeclContext *decl_ctx,
|
|
|
|
bool isForwardDecl,
|
|
|
|
bool isInternal
|
|
|
|
)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
assert (ast != NULL);
|
2010-07-23 02:30:50 +08:00
|
|
|
assert (name && name[0]);
|
|
|
|
if (decl_ctx == NULL)
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
decl_ctx = ast->getTranslationUnitDecl();
|
2010-07-23 02:30:50 +08:00
|
|
|
|
|
|
|
// NOTE: Eventually CXXRecordDecl will be merged back into RecordDecl and
|
|
|
|
// we will need to update this code. I was told to currently always use
|
|
|
|
// the CXXRecordDecl class since we often don't know from debug information
|
|
|
|
// if something is struct or a class, so we default to always use the more
|
|
|
|
// complete definition just in case.
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ObjCInterfaceDecl *decl = ObjCInterfaceDecl::Create (*ast,
|
2010-07-23 02:30:50 +08:00
|
|
|
decl_ctx,
|
|
|
|
SourceLocation(),
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
&ast->Idents.get(name),
|
2010-07-23 02:30:50 +08:00
|
|
|
SourceLocation(),
|
|
|
|
isForwardDecl,
|
|
|
|
isInternal);
|
2010-07-28 10:04:09 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return ast->getObjCInterfaceType(decl).getAsOpaquePtr();
|
2010-07-23 02:30:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-07-23 02:30:50 +08:00
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::SetObjCSuperClass (clang_type_t class_opaque_type, clang_type_t super_opaque_type)
|
2010-07-23 02:30:50 +08:00
|
|
|
{
|
|
|
|
if (class_opaque_type && super_opaque_type)
|
|
|
|
{
|
|
|
|
QualType class_qual_type(QualType::getFromOpaquePtr(class_opaque_type));
|
|
|
|
QualType super_qual_type(QualType::getFromOpaquePtr(super_opaque_type));
|
2011-01-27 12:42:51 +08:00
|
|
|
const clang::Type *class_type = class_qual_type.getTypePtr();
|
|
|
|
const clang::Type *super_type = super_qual_type.getTypePtr();
|
2010-07-23 02:30:50 +08:00
|
|
|
if (class_type && super_type)
|
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(class_type);
|
|
|
|
const ObjCObjectType *objc_super_type = dyn_cast<ObjCObjectType>(super_type);
|
2010-07-23 02:30:50 +08:00
|
|
|
if (objc_class_type && objc_super_type)
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
|
|
|
|
ObjCInterfaceDecl *super_interface_decl = objc_super_type->getInterface();
|
|
|
|
if (class_interface_decl && super_interface_decl)
|
|
|
|
{
|
|
|
|
class_interface_decl->setSuperClass(super_interface_decl);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
ClangASTContext::AddObjCClassIVar
|
|
|
|
(
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t class_opaque_type,
|
2010-07-23 02:30:50 +08:00
|
|
|
const char *name,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t ivar_opaque_type,
|
2010-07-23 02:30:50 +08:00
|
|
|
AccessType access,
|
|
|
|
uint32_t bitfield_bit_size,
|
2010-09-24 13:15:53 +08:00
|
|
|
bool is_synthesized
|
2010-07-23 02:30:50 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
if (class_opaque_type == NULL || ivar_opaque_type == NULL)
|
|
|
|
return false;
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
IdentifierTable *identifier_table = &ast->Idents;
|
2010-07-23 02:30:50 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
assert (ast != NULL);
|
2010-07-23 02:30:50 +08:00
|
|
|
assert (identifier_table != NULL);
|
|
|
|
|
|
|
|
QualType class_qual_type(QualType::getFromOpaquePtr(class_opaque_type));
|
|
|
|
|
2011-01-27 12:42:51 +08:00
|
|
|
const clang::Type *class_type = class_qual_type.getTypePtr();
|
2010-07-23 02:30:50 +08:00
|
|
|
if (class_type)
|
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(class_type);
|
2010-07-23 02:30:50 +08:00
|
|
|
|
|
|
|
if (objc_class_type)
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
|
|
|
|
|
|
|
|
if (class_interface_decl)
|
|
|
|
{
|
|
|
|
clang::Expr *bit_width = NULL;
|
|
|
|
if (bitfield_bit_size != 0)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
APInt bitfield_bit_size_apint(ast->getTypeSize(ast->IntTy), bitfield_bit_size);
|
|
|
|
bit_width = new (*ast)IntegerLiteral (*ast, bitfield_bit_size_apint, ast->IntTy, SourceLocation());
|
2010-07-23 02:30:50 +08:00
|
|
|
}
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ObjCIvarDecl *field = ObjCIvarDecl::Create (*ast,
|
2010-07-28 10:04:09 +08:00
|
|
|
class_interface_decl,
|
|
|
|
SourceLocation(),
|
2011-03-15 08:17:19 +08:00
|
|
|
SourceLocation(),
|
2010-07-28 10:04:09 +08:00
|
|
|
&identifier_table->get(name), // Identifier
|
|
|
|
QualType::getFromOpaquePtr(ivar_opaque_type), // Field type
|
|
|
|
NULL, // TypeSourceInfo *
|
|
|
|
ConvertAccessTypeToObjCIvarAccessControl (access),
|
|
|
|
bit_width,
|
2010-09-24 13:15:53 +08:00
|
|
|
is_synthesized);
|
2010-07-28 10:04:09 +08:00
|
|
|
|
|
|
|
if (field)
|
|
|
|
{
|
|
|
|
class_interface_decl->addDecl(field);
|
2011-10-26 09:06:27 +08:00
|
|
|
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
|
|
|
VerifyDecl(field);
|
|
|
|
#endif
|
|
|
|
|
2010-07-28 10:04:09 +08:00
|
|
|
return true;
|
|
|
|
}
|
2010-07-23 02:30:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-07-28 10:04:09 +08:00
|
|
|
|
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::ObjCTypeHasIVars (clang_type_t class_opaque_type, bool check_superclass)
|
2010-07-28 10:04:09 +08:00
|
|
|
{
|
|
|
|
QualType class_qual_type(QualType::getFromOpaquePtr(class_opaque_type));
|
|
|
|
|
2011-01-27 12:42:51 +08:00
|
|
|
const clang::Type *class_type = class_qual_type.getTypePtr();
|
2010-07-28 10:04:09 +08:00
|
|
|
if (class_type)
|
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(class_type);
|
2010-07-28 10:04:09 +08:00
|
|
|
|
|
|
|
if (objc_class_type)
|
|
|
|
return ObjCDeclHasIVars (objc_class_type->getInterface(), check_superclass);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ClangASTContext::ObjCDeclHasIVars (ObjCInterfaceDecl *class_interface_decl, bool check_superclass)
|
|
|
|
{
|
|
|
|
while (class_interface_decl)
|
|
|
|
{
|
|
|
|
if (class_interface_decl->ivar_size() > 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (check_superclass)
|
|
|
|
class_interface_decl = class_interface_decl->getSuperClass();
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2010-09-24 13:15:53 +08:00
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
ObjCMethodDecl *
|
2010-09-24 13:15:53 +08:00
|
|
|
ClangASTContext::AddMethodToObjCObjectType
|
|
|
|
(
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t class_opaque_type,
|
2010-09-24 13:15:53 +08:00
|
|
|
const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]")
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t method_opaque_type,
|
2010-09-24 13:15:53 +08:00
|
|
|
lldb::AccessType access
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (class_opaque_type == NULL || method_opaque_type == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
IdentifierTable *identifier_table = &ast->Idents;
|
2010-09-24 13:15:53 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
assert (ast != NULL);
|
2010-09-24 13:15:53 +08:00
|
|
|
assert (identifier_table != NULL);
|
|
|
|
|
|
|
|
QualType class_qual_type(QualType::getFromOpaquePtr(class_opaque_type));
|
|
|
|
|
2011-01-27 12:42:51 +08:00
|
|
|
const clang::Type *class_type = class_qual_type.getTypePtr();
|
2010-09-24 13:15:53 +08:00
|
|
|
if (class_type == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2011-01-27 12:42:51 +08:00
|
|
|
const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(class_type);
|
2010-09-24 13:15:53 +08:00
|
|
|
|
|
|
|
if (objc_class_type == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
|
|
|
|
|
|
|
|
if (class_interface_decl == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
const char *selector_start = ::strchr (name, ' ');
|
|
|
|
if (selector_start == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
selector_start++;
|
|
|
|
if (!(::isalpha (selector_start[0]) || selector_start[0] == '_'))
|
|
|
|
return NULL;
|
|
|
|
llvm::SmallVector<IdentifierInfo *, 12> selector_idents;
|
|
|
|
|
2010-10-12 10:24:53 +08:00
|
|
|
size_t len = 0;
|
2010-09-24 13:15:53 +08:00
|
|
|
const char *start;
|
2010-10-12 10:24:53 +08:00
|
|
|
//printf ("name = '%s'\n", name);
|
|
|
|
|
|
|
|
unsigned num_selectors_with_args = 0;
|
|
|
|
for (start = selector_start;
|
2010-09-24 13:15:53 +08:00
|
|
|
start && *start != '\0' && *start != ']';
|
2010-10-12 10:24:53 +08:00
|
|
|
start += len)
|
2010-09-24 13:15:53 +08:00
|
|
|
{
|
2010-10-12 10:24:53 +08:00
|
|
|
len = ::strcspn(start, ":]");
|
2010-10-27 12:01:14 +08:00
|
|
|
bool has_arg = (start[len] == ':');
|
|
|
|
if (has_arg)
|
2010-10-12 10:24:53 +08:00
|
|
|
++num_selectors_with_args;
|
2010-09-24 13:15:53 +08:00
|
|
|
selector_idents.push_back (&identifier_table->get (StringRef (start, len)));
|
2010-10-27 12:01:14 +08:00
|
|
|
if (has_arg)
|
|
|
|
len += 1;
|
2010-09-24 13:15:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (selector_idents.size() == 0)
|
|
|
|
return 0;
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
clang::Selector method_selector = ast->Selectors.getSelector (num_selectors_with_args ? selector_idents.size() : 0,
|
2010-09-24 13:15:53 +08:00
|
|
|
selector_idents.data());
|
|
|
|
|
|
|
|
QualType method_qual_type (QualType::getFromOpaquePtr (method_opaque_type));
|
|
|
|
|
|
|
|
// Populate the method decl with parameter decls
|
2011-01-27 12:42:51 +08:00
|
|
|
const clang::Type *method_type(method_qual_type.getTypePtr());
|
2010-09-24 13:15:53 +08:00
|
|
|
|
|
|
|
if (method_type == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2011-01-27 12:42:51 +08:00
|
|
|
const FunctionProtoType *method_function_prototype (dyn_cast<FunctionProtoType>(method_type));
|
2010-09-24 13:15:53 +08:00
|
|
|
|
|
|
|
if (!method_function_prototype)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
bool is_variadic = false;
|
|
|
|
bool is_synthesized = false;
|
|
|
|
bool is_defined = false;
|
|
|
|
ObjCMethodDecl::ImplementationControl imp_control = ObjCMethodDecl::None;
|
|
|
|
|
|
|
|
const unsigned num_args = method_function_prototype->getNumArgs();
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ObjCMethodDecl *objc_method_decl = ObjCMethodDecl::Create (*ast,
|
2010-09-24 13:15:53 +08:00
|
|
|
SourceLocation(), // beginLoc,
|
|
|
|
SourceLocation(), // endLoc,
|
|
|
|
method_selector,
|
|
|
|
method_function_prototype->getResultType(),
|
|
|
|
NULL, // TypeSourceInfo *ResultTInfo,
|
|
|
|
GetDeclContextForType (class_opaque_type),
|
|
|
|
name[0] == '-',
|
|
|
|
is_variadic,
|
|
|
|
is_synthesized,
|
2011-10-08 07:18:13 +08:00
|
|
|
true, // is_implicitly_declared
|
2010-09-24 13:15:53 +08:00
|
|
|
is_defined,
|
|
|
|
imp_control,
|
2011-10-08 07:18:13 +08:00
|
|
|
false /*has_related_result_type*/);
|
2010-09-24 13:15:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
if (objc_method_decl == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (num_args > 0)
|
|
|
|
{
|
|
|
|
llvm::SmallVector<ParmVarDecl *, 12> params;
|
|
|
|
|
|
|
|
for (int param_index = 0; param_index < num_args; ++param_index)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
params.push_back (ParmVarDecl::Create (*ast,
|
2010-09-24 13:15:53 +08:00
|
|
|
objc_method_decl,
|
|
|
|
SourceLocation(),
|
2011-03-15 08:17:19 +08:00
|
|
|
SourceLocation(),
|
2010-09-24 13:15:53 +08:00
|
|
|
NULL, // anonymous
|
|
|
|
method_function_prototype->getArgType(param_index),
|
|
|
|
NULL,
|
|
|
|
SC_Auto,
|
|
|
|
SC_Auto,
|
|
|
|
NULL));
|
|
|
|
}
|
|
|
|
|
2011-10-08 07:18:13 +08:00
|
|
|
objc_method_decl->setMethodParams(*ast, ArrayRef<ParmVarDecl*>(params), ArrayRef<SourceLocation>());
|
2010-09-24 13:15:53 +08:00
|
|
|
}
|
2010-07-28 10:04:09 +08:00
|
|
|
|
2010-09-24 13:15:53 +08:00
|
|
|
class_interface_decl->addDecl (objc_method_decl);
|
|
|
|
|
2011-10-26 09:06:27 +08:00
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
|
|
|
VerifyDecl(objc_method_decl);
|
|
|
|
#endif
|
2010-09-24 13:15:53 +08:00
|
|
|
|
|
|
|
return objc_method_decl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-15 06:52:14 +08:00
|
|
|
uint32_t
|
2010-10-27 11:32:59 +08:00
|
|
|
ClangASTContext::GetTypeInfo
|
|
|
|
(
|
|
|
|
clang_type_t clang_type,
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
clang::ASTContext *ast,
|
2010-10-27 11:32:59 +08:00
|
|
|
clang_type_t *pointee_or_element_clang_type
|
|
|
|
)
|
2010-10-15 06:52:14 +08:00
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
2010-10-27 11:32:59 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (pointee_or_element_clang_type)
|
|
|
|
*pointee_or_element_clang_type = NULL;
|
2010-10-15 06:52:14 +08:00
|
|
|
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
|
|
|
{
|
2010-10-25 08:29:48 +08:00
|
|
|
case clang::Type::Builtin:
|
|
|
|
switch (cast<clang::BuiltinType>(qual_type)->getKind())
|
|
|
|
{
|
|
|
|
case clang::BuiltinType::ObjCId:
|
|
|
|
case clang::BuiltinType::ObjCClass:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (ast && pointee_or_element_clang_type)
|
|
|
|
*pointee_or_element_clang_type = ast->ObjCBuiltinClassTy.getAsOpaquePtr();
|
2010-10-25 08:29:48 +08:00
|
|
|
return eTypeIsBuiltIn | eTypeIsPointer | eTypeHasValue;
|
2011-07-12 08:18:11 +08:00
|
|
|
break;
|
|
|
|
case clang::BuiltinType::Bool:
|
|
|
|
case clang::BuiltinType::Char_U:
|
|
|
|
case clang::BuiltinType::UChar:
|
|
|
|
case clang::BuiltinType::WChar_U:
|
|
|
|
case clang::BuiltinType::Char16:
|
|
|
|
case clang::BuiltinType::Char32:
|
|
|
|
case clang::BuiltinType::UShort:
|
|
|
|
case clang::BuiltinType::UInt:
|
|
|
|
case clang::BuiltinType::ULong:
|
|
|
|
case clang::BuiltinType::ULongLong:
|
|
|
|
case clang::BuiltinType::UInt128:
|
|
|
|
case clang::BuiltinType::Char_S:
|
|
|
|
case clang::BuiltinType::SChar:
|
|
|
|
case clang::BuiltinType::WChar_S:
|
|
|
|
case clang::BuiltinType::Short:
|
|
|
|
case clang::BuiltinType::Int:
|
|
|
|
case clang::BuiltinType::Long:
|
|
|
|
case clang::BuiltinType::LongLong:
|
|
|
|
case clang::BuiltinType::Int128:
|
|
|
|
case clang::BuiltinType::Float:
|
|
|
|
case clang::BuiltinType::Double:
|
|
|
|
case clang::BuiltinType::LongDouble:
|
|
|
|
return eTypeIsBuiltIn | eTypeHasValue | eTypeIsScalar;
|
2010-10-27 11:32:59 +08:00
|
|
|
default:
|
|
|
|
break;
|
2010-10-25 08:29:48 +08:00
|
|
|
}
|
|
|
|
return eTypeIsBuiltIn | eTypeHasValue;
|
2010-10-27 11:32:59 +08:00
|
|
|
|
|
|
|
case clang::Type::BlockPointer:
|
|
|
|
if (pointee_or_element_clang_type)
|
|
|
|
*pointee_or_element_clang_type = qual_type->getPointeeType().getAsOpaquePtr();
|
|
|
|
return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
|
|
|
|
|
2011-01-15 10:52:14 +08:00
|
|
|
case clang::Type::Complex: return eTypeIsBuiltIn | eTypeHasValue;
|
2010-10-27 11:32:59 +08:00
|
|
|
|
|
|
|
case clang::Type::ConstantArray:
|
|
|
|
case clang::Type::DependentSizedArray:
|
|
|
|
case clang::Type::IncompleteArray:
|
|
|
|
case clang::Type::VariableArray:
|
|
|
|
if (pointee_or_element_clang_type)
|
|
|
|
*pointee_or_element_clang_type = cast<ArrayType>(qual_type.getTypePtr())->getElementType().getAsOpaquePtr();
|
|
|
|
return eTypeHasChildren | eTypeIsArray;
|
|
|
|
|
2010-10-15 06:52:14 +08:00
|
|
|
case clang::Type::DependentName: return 0;
|
|
|
|
case clang::Type::DependentSizedExtVector: return eTypeHasChildren | eTypeIsVector;
|
|
|
|
case clang::Type::DependentTemplateSpecialization: return eTypeIsTemplate;
|
|
|
|
case clang::Type::Decltype: return 0;
|
2010-10-27 11:32:59 +08:00
|
|
|
|
|
|
|
case clang::Type::Enum:
|
|
|
|
if (pointee_or_element_clang_type)
|
|
|
|
*pointee_or_element_clang_type = cast<EnumType>(qual_type)->getDecl()->getIntegerType().getAsOpaquePtr();
|
|
|
|
return eTypeIsEnumeration | eTypeHasValue;
|
|
|
|
|
2011-08-12 07:56:13 +08:00
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::GetTypeInfo (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(),
|
|
|
|
ast,
|
|
|
|
pointee_or_element_clang_type);
|
2010-10-15 06:52:14 +08:00
|
|
|
case clang::Type::ExtVector: return eTypeHasChildren | eTypeIsVector;
|
|
|
|
case clang::Type::FunctionProto: return eTypeIsFuncPrototype | eTypeHasValue;
|
|
|
|
case clang::Type::FunctionNoProto: return eTypeIsFuncPrototype | eTypeHasValue;
|
|
|
|
case clang::Type::InjectedClassName: return 0;
|
2010-10-27 11:32:59 +08:00
|
|
|
|
|
|
|
case clang::Type::LValueReference:
|
|
|
|
case clang::Type::RValueReference:
|
|
|
|
if (pointee_or_element_clang_type)
|
|
|
|
*pointee_or_element_clang_type = cast<ReferenceType>(qual_type.getTypePtr())->getPointeeType().getAsOpaquePtr();
|
|
|
|
return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
|
|
|
|
|
2010-10-15 06:52:14 +08:00
|
|
|
case clang::Type::MemberPointer: return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
|
2010-10-27 11:32:59 +08:00
|
|
|
|
|
|
|
case clang::Type::ObjCObjectPointer:
|
|
|
|
if (pointee_or_element_clang_type)
|
|
|
|
*pointee_or_element_clang_type = qual_type->getPointeeType().getAsOpaquePtr();
|
|
|
|
return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer | eTypeHasValue;
|
|
|
|
|
2010-10-15 06:52:14 +08:00
|
|
|
case clang::Type::ObjCObject: return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
|
|
|
|
case clang::Type::ObjCInterface: return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
|
2010-10-27 11:32:59 +08:00
|
|
|
|
|
|
|
case clang::Type::Pointer:
|
|
|
|
if (pointee_or_element_clang_type)
|
|
|
|
*pointee_or_element_clang_type = qual_type->getPointeeType().getAsOpaquePtr();
|
|
|
|
return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
|
|
|
|
|
2010-10-15 06:52:14 +08:00
|
|
|
case clang::Type::Record:
|
|
|
|
if (qual_type->getAsCXXRecordDecl())
|
|
|
|
return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
|
|
|
|
else
|
|
|
|
return eTypeHasChildren | eTypeIsStructUnion;
|
|
|
|
break;
|
|
|
|
case clang::Type::SubstTemplateTypeParm: return eTypeIsTemplate;
|
|
|
|
case clang::Type::TemplateTypeParm: return eTypeIsTemplate;
|
|
|
|
case clang::Type::TemplateSpecialization: return eTypeIsTemplate;
|
2010-10-27 11:32:59 +08:00
|
|
|
|
|
|
|
case clang::Type::Typedef:
|
2010-12-13 09:26:27 +08:00
|
|
|
return eTypeIsTypedef | ClangASTContext::GetTypeInfo (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ast,
|
2010-10-27 11:32:59 +08:00
|
|
|
pointee_or_element_clang_type);
|
|
|
|
|
2010-10-15 06:52:14 +08:00
|
|
|
case clang::Type::TypeOfExpr: return 0;
|
|
|
|
case clang::Type::TypeOf: return 0;
|
|
|
|
case clang::Type::UnresolvedUsing: return 0;
|
|
|
|
case clang::Type::Vector: return eTypeHasChildren | eTypeIsVector;
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-28 10:04:09 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#pragma mark Aggregate Types
|
|
|
|
|
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::IsAggregateType (clang_type_t clang_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
|
2010-09-13 11:32:57 +08:00
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::IncompleteArray:
|
|
|
|
case clang::Type::VariableArray:
|
|
|
|
case clang::Type::ConstantArray:
|
|
|
|
case clang::Type::ExtVector:
|
|
|
|
case clang::Type::Vector:
|
|
|
|
case clang::Type::Record:
|
2010-07-28 10:04:09 +08:00
|
|
|
case clang::Type::ObjCObject:
|
|
|
|
case clang::Type::ObjCInterface:
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
2011-08-12 07:56:13 +08:00
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::IsAggregateType (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Typedef:
|
2010-12-13 09:26:27 +08:00
|
|
|
return ClangASTContext::IsAggregateType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// The clang type does have a value
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ClangASTContext::GetNumChildren (clang::ASTContext *ast, clang_type_t clang_type, bool omit_empty_base_classes)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (clang_type == NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
uint32_t num_children = 0;
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
|
2010-07-28 10:04:09 +08:00
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-08-03 08:35:52 +08:00
|
|
|
case clang::Type::Builtin:
|
|
|
|
switch (cast<clang::BuiltinType>(qual_type)->getKind())
|
|
|
|
{
|
2010-10-27 11:32:59 +08:00
|
|
|
case clang::BuiltinType::ObjCId: // child is Class
|
2010-08-03 08:35:52 +08:00
|
|
|
case clang::BuiltinType::ObjCClass: // child is Class
|
|
|
|
num_children = 1;
|
2010-10-27 11:32:59 +08:00
|
|
|
break;
|
2010-08-03 08:35:52 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2010-12-15 13:08:08 +08:00
|
|
|
|
2011-01-15 10:52:14 +08:00
|
|
|
case clang::Type::Complex: return 0;
|
2010-12-15 13:08:08 +08:00
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Record:
|
2011-01-20 12:18:48 +08:00
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr());
|
|
|
|
const RecordDecl *record_decl = record_type->getDecl();
|
|
|
|
assert(record_decl);
|
|
|
|
const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
|
|
|
|
if (cxx_record_decl)
|
|
|
|
{
|
|
|
|
if (omit_empty_base_classes)
|
|
|
|
{
|
|
|
|
// Check each base classes to see if it or any of its
|
|
|
|
// base classes contain any fields. This can help
|
|
|
|
// limit the noise in variable views by not having to
|
|
|
|
// show base classes that contain no members.
|
|
|
|
CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
|
|
|
|
for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
|
|
|
|
base_class != base_class_end;
|
|
|
|
++base_class)
|
|
|
|
{
|
|
|
|
const CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl());
|
|
|
|
|
|
|
|
// Skip empty base classes
|
|
|
|
if (RecordHasFields(base_class_decl) == false)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
num_children++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Include all base classes
|
|
|
|
num_children += cxx_record_decl->getNumBases();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
RecordDecl::field_iterator field, field_end;
|
|
|
|
for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field)
|
|
|
|
++num_children;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-28 10:04:09 +08:00
|
|
|
case clang::Type::ObjCObject:
|
|
|
|
case clang::Type::ObjCInterface:
|
2011-01-20 12:18:48 +08:00
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
2010-07-28 10:04:09 +08:00
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr());
|
2010-07-28 10:04:09 +08:00
|
|
|
assert (objc_class_type);
|
|
|
|
if (objc_class_type)
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
|
|
|
|
|
|
|
|
if (class_interface_decl)
|
|
|
|
{
|
|
|
|
|
|
|
|
ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
|
|
|
|
if (superclass_interface_decl)
|
|
|
|
{
|
|
|
|
if (omit_empty_base_classes)
|
|
|
|
{
|
|
|
|
if (ClangASTContext::ObjCDeclHasIVars (superclass_interface_decl, true))
|
|
|
|
++num_children;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
++num_children;
|
|
|
|
}
|
|
|
|
|
|
|
|
num_children += class_interface_decl->ivar_size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::ObjCObjectPointer:
|
2010-08-03 08:35:52 +08:00
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ObjCObjectPointerType *pointer_type = cast<ObjCObjectPointerType>(qual_type.getTypePtr());
|
2010-08-03 08:35:52 +08:00
|
|
|
QualType pointee_type = pointer_type->getPointeeType();
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
uint32_t num_pointee_children = ClangASTContext::GetNumChildren (ast,
|
|
|
|
pointee_type.getAsOpaquePtr(),
|
2010-08-03 08:35:52 +08:00
|
|
|
omit_empty_base_classes);
|
|
|
|
// If this type points to a simple type, then it has 1 child
|
|
|
|
if (num_pointee_children == 0)
|
|
|
|
num_children = 1;
|
|
|
|
else
|
|
|
|
num_children = num_pointee_children;
|
|
|
|
}
|
|
|
|
break;
|
2010-07-28 10:04:09 +08:00
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::ConstantArray:
|
2010-06-09 00:52:24 +08:00
|
|
|
num_children = cast<ConstantArrayType>(qual_type.getTypePtr())->getSize().getLimitedValue();
|
|
|
|
break;
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Pointer:
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const PointerType *pointer_type = cast<PointerType>(qual_type.getTypePtr());
|
2010-12-15 13:08:08 +08:00
|
|
|
QualType pointee_type (pointer_type->getPointeeType());
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
uint32_t num_pointee_children = ClangASTContext::GetNumChildren (ast,
|
|
|
|
pointee_type.getAsOpaquePtr(),
|
2010-07-28 10:04:09 +08:00
|
|
|
omit_empty_base_classes);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (num_pointee_children == 0)
|
2010-12-15 13:08:08 +08:00
|
|
|
{
|
|
|
|
// We have a pointer to a pointee type that claims it has no children.
|
|
|
|
// We will want to look at
|
|
|
|
num_children = ClangASTContext::GetNumPointeeChildren (pointee_type.getAsOpaquePtr());
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
num_children = num_pointee_children;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-10-27 11:32:59 +08:00
|
|
|
case clang::Type::LValueReference:
|
|
|
|
case clang::Type::RValueReference:
|
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ReferenceType *reference_type = cast<ReferenceType>(qual_type.getTypePtr());
|
2010-10-27 11:32:59 +08:00
|
|
|
QualType pointee_type = reference_type->getPointeeType();
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
uint32_t num_pointee_children = ClangASTContext::GetNumChildren (ast,
|
|
|
|
pointee_type.getAsOpaquePtr(),
|
2010-10-27 11:32:59 +08:00
|
|
|
omit_empty_base_classes);
|
|
|
|
// If this type points to a simple type, then it has 1 child
|
|
|
|
if (num_pointee_children == 0)
|
|
|
|
num_children = 1;
|
|
|
|
else
|
|
|
|
num_children = num_pointee_children;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Typedef:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
num_children = ClangASTContext::GetNumChildren (ast,
|
|
|
|
cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
|
|
|
|
omit_empty_base_classes);
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
2011-08-12 07:56:13 +08:00
|
|
|
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
num_children = ClangASTContext::GetNumChildren (ast,
|
|
|
|
cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(),
|
|
|
|
omit_empty_base_classes);
|
|
|
|
break;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return num_children;
|
|
|
|
}
|
|
|
|
|
2011-09-10 07:04:00 +08:00
|
|
|
uint32_t
|
|
|
|
ClangASTContext::GetNumDirectBaseClasses (clang::ASTContext *ast, clang_type_t clang_type)
|
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
uint32_t count = 0;
|
|
|
|
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::Record:
|
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
|
|
|
{
|
|
|
|
const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
|
|
|
|
if (cxx_record_decl)
|
|
|
|
count = cxx_record_decl->getNumBases();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::ObjCObject:
|
|
|
|
case clang::Type::ObjCInterface:
|
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
|
|
|
{
|
|
|
|
const ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType();
|
|
|
|
if (objc_class_type)
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
|
|
|
|
|
|
|
|
if (class_interface_decl && class_interface_decl->getSuperClass())
|
|
|
|
count = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case clang::Type::Typedef:
|
|
|
|
count = ClangASTContext::GetNumDirectBaseClasses (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
count = ClangASTContext::GetNumDirectBaseClasses (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
ClangASTContext::GetNumVirtualBaseClasses (clang::ASTContext *ast,
|
|
|
|
clang_type_t clang_type)
|
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
uint32_t count = 0;
|
|
|
|
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::Record:
|
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
|
|
|
{
|
|
|
|
const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
|
|
|
|
if (cxx_record_decl)
|
|
|
|
count = cxx_record_decl->getNumVBases();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::Typedef:
|
|
|
|
count = ClangASTContext::GetNumVirtualBaseClasses (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
count = ClangASTContext::GetNumVirtualBaseClasses (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
ClangASTContext::GetNumFields (clang::ASTContext *ast, clang_type_t clang_type)
|
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
uint32_t count = 0;
|
|
|
|
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::Record:
|
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
|
|
|
{
|
|
|
|
const RecordType *record_type = dyn_cast<RecordType>(qual_type.getTypePtr());
|
|
|
|
if (record_type)
|
|
|
|
{
|
|
|
|
RecordDecl *record_decl = record_type->getDecl();
|
|
|
|
if (record_decl)
|
|
|
|
{
|
|
|
|
uint32_t field_idx = 0;
|
|
|
|
RecordDecl::field_iterator field, field_end;
|
|
|
|
for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field)
|
|
|
|
++field_idx;
|
|
|
|
count = field_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::Typedef:
|
|
|
|
count = ClangASTContext::GetNumFields (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
count = ClangASTContext::GetNumFields (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::GetDirectBaseClassAtIndex (clang::ASTContext *ast,
|
|
|
|
clang_type_t clang_type,
|
|
|
|
uint32_t idx,
|
|
|
|
uint32_t *byte_offset_ptr)
|
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::Record:
|
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
|
|
|
{
|
|
|
|
const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
|
|
|
|
if (cxx_record_decl)
|
|
|
|
{
|
|
|
|
uint32_t curr_idx = 0;
|
|
|
|
CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
|
|
|
|
for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
|
|
|
|
base_class != base_class_end;
|
|
|
|
++base_class, ++curr_idx)
|
|
|
|
{
|
|
|
|
if (curr_idx == idx)
|
|
|
|
{
|
|
|
|
if (byte_offset_ptr)
|
|
|
|
{
|
|
|
|
const ASTRecordLayout &record_layout = ast->getASTRecordLayout(cxx_record_decl);
|
|
|
|
const CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl());
|
|
|
|
// if (base_class->isVirtual())
|
|
|
|
// *byte_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
|
|
|
|
// else
|
|
|
|
*byte_offset_ptr = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8;
|
|
|
|
}
|
|
|
|
return base_class->getType().getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::ObjCObject:
|
|
|
|
case clang::Type::ObjCInterface:
|
|
|
|
if (idx == 0 && GetCompleteQualType (ast, qual_type))
|
|
|
|
{
|
|
|
|
const ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType();
|
|
|
|
if (objc_class_type)
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
|
|
|
|
|
|
|
|
if (class_interface_decl)
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
|
|
|
|
if (superclass_interface_decl)
|
|
|
|
{
|
|
|
|
if (byte_offset_ptr)
|
|
|
|
*byte_offset_ptr = 0;
|
|
|
|
return ast->getObjCInterfaceType(superclass_interface_decl).getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case clang::Type::Typedef:
|
|
|
|
return ClangASTContext::GetDirectBaseClassAtIndex (ast,
|
|
|
|
cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
|
|
|
|
idx,
|
|
|
|
byte_offset_ptr);
|
|
|
|
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::GetDirectBaseClassAtIndex (ast,
|
|
|
|
cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(),
|
|
|
|
idx,
|
|
|
|
byte_offset_ptr);
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::GetVirtualBaseClassAtIndex (clang::ASTContext *ast,
|
|
|
|
clang_type_t clang_type,
|
|
|
|
uint32_t idx,
|
|
|
|
uint32_t *byte_offset_ptr)
|
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::Record:
|
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
|
|
|
{
|
|
|
|
const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
|
|
|
|
if (cxx_record_decl)
|
|
|
|
{
|
|
|
|
uint32_t curr_idx = 0;
|
|
|
|
CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
|
|
|
|
for (base_class = cxx_record_decl->vbases_begin(), base_class_end = cxx_record_decl->vbases_end();
|
|
|
|
base_class != base_class_end;
|
|
|
|
++base_class, ++curr_idx)
|
|
|
|
{
|
|
|
|
if (curr_idx == idx)
|
|
|
|
{
|
|
|
|
if (byte_offset_ptr)
|
|
|
|
{
|
|
|
|
const ASTRecordLayout &record_layout = ast->getASTRecordLayout(cxx_record_decl);
|
|
|
|
const CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl());
|
|
|
|
*byte_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
|
|
|
|
|
|
|
|
}
|
|
|
|
return base_class->getType().getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::Typedef:
|
|
|
|
return ClangASTContext::GetVirtualBaseClassAtIndex (ast,
|
|
|
|
cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
|
|
|
|
idx,
|
|
|
|
byte_offset_ptr);
|
|
|
|
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::GetVirtualBaseClassAtIndex (ast,
|
|
|
|
cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(),
|
|
|
|
idx,
|
|
|
|
byte_offset_ptr);
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::GetFieldAtIndex (clang::ASTContext *ast,
|
|
|
|
clang_type_t clang_type,
|
|
|
|
uint32_t idx,
|
|
|
|
std::string& name,
|
|
|
|
uint32_t *byte_offset_ptr)
|
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::Record:
|
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
|
|
|
{
|
|
|
|
const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr());
|
|
|
|
const RecordDecl *record_decl = record_type->getDecl();
|
|
|
|
uint32_t field_idx = 0;
|
|
|
|
RecordDecl::field_iterator field, field_end;
|
|
|
|
for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx)
|
|
|
|
{
|
|
|
|
if (idx == field_idx)
|
|
|
|
{
|
|
|
|
// Print the member type if requested
|
|
|
|
// Print the member name and equal sign
|
|
|
|
name.assign(field->getNameAsString());
|
|
|
|
|
|
|
|
// Figure out the type byte size (field_type_info.first) and
|
|
|
|
// alignment (field_type_info.second) from the AST context.
|
|
|
|
if (byte_offset_ptr)
|
|
|
|
{
|
|
|
|
const ASTRecordLayout &record_layout = ast->getASTRecordLayout(record_decl);
|
|
|
|
*byte_offset_ptr = (record_layout.getFieldOffset (field_idx) + 7) / 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
return field->getType().getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::ObjCObject:
|
|
|
|
case clang::Type::ObjCInterface:
|
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
|
|
|
{
|
|
|
|
const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr());
|
|
|
|
assert (objc_class_type);
|
|
|
|
if (objc_class_type)
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
|
|
|
|
|
|
|
|
if (class_interface_decl)
|
|
|
|
{
|
|
|
|
if (idx < (class_interface_decl->ivar_size()))
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end();
|
|
|
|
uint32_t ivar_idx = 0;
|
|
|
|
|
|
|
|
for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos, ++ivar_idx)
|
|
|
|
{
|
|
|
|
if (ivar_idx == idx)
|
|
|
|
{
|
|
|
|
const ObjCIvarDecl* ivar_decl = *ivar_pos;
|
|
|
|
|
|
|
|
QualType ivar_qual_type(ivar_decl->getType());
|
|
|
|
|
|
|
|
name.assign(ivar_decl->getNameAsString());
|
|
|
|
|
|
|
|
if (byte_offset_ptr)
|
|
|
|
{
|
|
|
|
const ASTRecordLayout &interface_layout = ast->getASTObjCInterfaceLayout(class_interface_decl);
|
|
|
|
*byte_offset_ptr = (interface_layout.getFieldOffset (ivar_idx) + 7)/8;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ivar_qual_type.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case clang::Type::Typedef:
|
|
|
|
return ClangASTContext::GetFieldAtIndex (ast,
|
|
|
|
cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
|
|
|
|
idx,
|
|
|
|
name,
|
|
|
|
byte_offset_ptr);
|
|
|
|
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::GetFieldAtIndex (ast,
|
|
|
|
cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(),
|
|
|
|
idx,
|
|
|
|
name,
|
|
|
|
byte_offset_ptr);
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-15 13:08:08 +08:00
|
|
|
// If a pointer to a pointee type (the clang_type arg) says that it has no
|
|
|
|
// children, then we either need to trust it, or override it and return a
|
|
|
|
// different result. For example, an "int *" has one child that is an integer,
|
|
|
|
// but a function pointer doesn't have any children. Likewise if a Record type
|
|
|
|
// claims it has no children, then there really is nothing to show.
|
|
|
|
uint32_t
|
|
|
|
ClangASTContext::GetNumPointeeChildren (clang_type_t clang_type)
|
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
|
|
|
{
|
2011-01-09 06:26:47 +08:00
|
|
|
case clang::Type::Builtin:
|
|
|
|
switch (cast<clang::BuiltinType>(qual_type)->getKind())
|
|
|
|
{
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
case clang::BuiltinType::UnknownAny:
|
2011-01-09 06:26:47 +08:00
|
|
|
case clang::BuiltinType::Void:
|
|
|
|
case clang::BuiltinType::NullPtr:
|
|
|
|
return 0;
|
|
|
|
case clang::BuiltinType::Bool:
|
|
|
|
case clang::BuiltinType::Char_U:
|
|
|
|
case clang::BuiltinType::UChar:
|
2011-01-19 07:32:05 +08:00
|
|
|
case clang::BuiltinType::WChar_U:
|
2011-01-09 06:26:47 +08:00
|
|
|
case clang::BuiltinType::Char16:
|
|
|
|
case clang::BuiltinType::Char32:
|
|
|
|
case clang::BuiltinType::UShort:
|
|
|
|
case clang::BuiltinType::UInt:
|
|
|
|
case clang::BuiltinType::ULong:
|
|
|
|
case clang::BuiltinType::ULongLong:
|
|
|
|
case clang::BuiltinType::UInt128:
|
|
|
|
case clang::BuiltinType::Char_S:
|
|
|
|
case clang::BuiltinType::SChar:
|
2011-01-19 07:32:05 +08:00
|
|
|
case clang::BuiltinType::WChar_S:
|
2011-01-09 06:26:47 +08:00
|
|
|
case clang::BuiltinType::Short:
|
|
|
|
case clang::BuiltinType::Int:
|
|
|
|
case clang::BuiltinType::Long:
|
|
|
|
case clang::BuiltinType::LongLong:
|
|
|
|
case clang::BuiltinType::Int128:
|
|
|
|
case clang::BuiltinType::Float:
|
|
|
|
case clang::BuiltinType::Double:
|
|
|
|
case clang::BuiltinType::LongDouble:
|
|
|
|
case clang::BuiltinType::Dependent:
|
|
|
|
case clang::BuiltinType::Overload:
|
|
|
|
case clang::BuiltinType::ObjCId:
|
|
|
|
case clang::BuiltinType::ObjCClass:
|
|
|
|
case clang::BuiltinType::ObjCSel:
|
2011-05-16 06:34:38 +08:00
|
|
|
case clang::BuiltinType::BoundMember:
|
2011-10-22 11:33:13 +08:00
|
|
|
case clang::BuiltinType::Half:
|
|
|
|
case clang::BuiltinType::ARCUnbridgedCast:
|
2011-11-04 11:34:56 +08:00
|
|
|
//case clang::BuiltinType::PseudoObject:
|
2011-01-09 06:26:47 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-01-15 10:52:14 +08:00
|
|
|
case clang::Type::Complex: return 1;
|
2010-12-15 13:08:08 +08:00
|
|
|
case clang::Type::Pointer: return 1;
|
|
|
|
case clang::Type::BlockPointer: return 0; // If block pointers don't have debug info, then no children for them
|
|
|
|
case clang::Type::LValueReference: return 1;
|
|
|
|
case clang::Type::RValueReference: return 1;
|
|
|
|
case clang::Type::MemberPointer: return 0;
|
|
|
|
case clang::Type::ConstantArray: return 0;
|
|
|
|
case clang::Type::IncompleteArray: return 0;
|
|
|
|
case clang::Type::VariableArray: return 0;
|
|
|
|
case clang::Type::DependentSizedArray: return 0;
|
|
|
|
case clang::Type::DependentSizedExtVector: return 0;
|
|
|
|
case clang::Type::Vector: return 0;
|
|
|
|
case clang::Type::ExtVector: return 0;
|
|
|
|
case clang::Type::FunctionProto: return 0; // When we function pointers, they have no children...
|
|
|
|
case clang::Type::FunctionNoProto: return 0; // When we function pointers, they have no children...
|
|
|
|
case clang::Type::UnresolvedUsing: return 0;
|
|
|
|
case clang::Type::Paren: return 0;
|
|
|
|
case clang::Type::Typedef: return ClangASTContext::GetNumPointeeChildren (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
|
2011-08-12 07:56:13 +08:00
|
|
|
case clang::Type::Elaborated: return ClangASTContext::GetNumPointeeChildren (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
|
2010-12-15 13:08:08 +08:00
|
|
|
case clang::Type::TypeOfExpr: return 0;
|
|
|
|
case clang::Type::TypeOf: return 0;
|
|
|
|
case clang::Type::Decltype: return 0;
|
|
|
|
case clang::Type::Record: return 0;
|
|
|
|
case clang::Type::Enum: return 1;
|
|
|
|
case clang::Type::TemplateTypeParm: return 1;
|
|
|
|
case clang::Type::SubstTemplateTypeParm: return 1;
|
|
|
|
case clang::Type::TemplateSpecialization: return 1;
|
|
|
|
case clang::Type::InjectedClassName: return 0;
|
|
|
|
case clang::Type::DependentName: return 1;
|
|
|
|
case clang::Type::DependentTemplateSpecialization: return 1;
|
|
|
|
case clang::Type::ObjCObject: return 0;
|
|
|
|
case clang::Type::ObjCInterface: return 0;
|
|
|
|
case clang::Type::ObjCObjectPointer: return 1;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2010-06-09 00:52:24 +08:00
|
|
|
ClangASTContext::GetChildClangTypeAtIndex
|
|
|
|
(
|
2011-06-25 06:03:24 +08:00
|
|
|
ExecutionContext *exe_ctx,
|
2010-06-09 00:52:24 +08:00
|
|
|
const char *parent_name,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t parent_clang_type,
|
2010-06-09 00:52:24 +08:00
|
|
|
uint32_t idx,
|
|
|
|
bool transparent_pointers,
|
|
|
|
bool omit_empty_base_classes,
|
2011-07-10 04:12:33 +08:00
|
|
|
bool ignore_array_bounds,
|
2010-06-09 00:52:24 +08:00
|
|
|
std::string& child_name,
|
|
|
|
uint32_t &child_byte_size,
|
|
|
|
int32_t &child_byte_offset,
|
|
|
|
uint32_t &child_bitfield_bit_size,
|
2010-10-15 06:52:14 +08:00
|
|
|
uint32_t &child_bitfield_bit_offset,
|
2011-01-21 09:59:00 +08:00
|
|
|
bool &child_is_base_class,
|
|
|
|
bool &child_is_deref_of_parent
|
2010-06-09 00:52:24 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
if (parent_clang_type)
|
|
|
|
|
2011-06-25 06:03:24 +08:00
|
|
|
return GetChildClangTypeAtIndex (exe_ctx,
|
|
|
|
getASTContext(),
|
2010-06-09 00:52:24 +08:00
|
|
|
parent_name,
|
|
|
|
parent_clang_type,
|
|
|
|
idx,
|
|
|
|
transparent_pointers,
|
|
|
|
omit_empty_base_classes,
|
2011-07-10 04:12:33 +08:00
|
|
|
ignore_array_bounds,
|
2010-06-09 00:52:24 +08:00
|
|
|
child_name,
|
|
|
|
child_byte_size,
|
|
|
|
child_byte_offset,
|
|
|
|
child_bitfield_bit_size,
|
2010-10-15 06:52:14 +08:00
|
|
|
child_bitfield_bit_offset,
|
2011-01-21 09:59:00 +08:00
|
|
|
child_is_base_class,
|
|
|
|
child_is_deref_of_parent);
|
2010-06-09 00:52:24 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2010-06-09 00:52:24 +08:00
|
|
|
ClangASTContext::GetChildClangTypeAtIndex
|
|
|
|
(
|
2011-06-25 06:03:24 +08:00
|
|
|
ExecutionContext *exe_ctx,
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast,
|
2010-06-09 00:52:24 +08:00
|
|
|
const char *parent_name,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t parent_clang_type,
|
2010-06-09 00:52:24 +08:00
|
|
|
uint32_t idx,
|
|
|
|
bool transparent_pointers,
|
|
|
|
bool omit_empty_base_classes,
|
2011-07-10 04:12:33 +08:00
|
|
|
bool ignore_array_bounds,
|
2010-06-09 00:52:24 +08:00
|
|
|
std::string& child_name,
|
|
|
|
uint32_t &child_byte_size,
|
|
|
|
int32_t &child_byte_offset,
|
|
|
|
uint32_t &child_bitfield_bit_size,
|
2010-10-15 06:52:14 +08:00
|
|
|
uint32_t &child_bitfield_bit_offset,
|
2011-01-21 09:59:00 +08:00
|
|
|
bool &child_is_base_class,
|
|
|
|
bool &child_is_deref_of_parent
|
2010-06-09 00:52:24 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
if (parent_clang_type == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (idx < ClangASTContext::GetNumChildren (ast, parent_clang_type, omit_empty_base_classes))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
uint32_t bit_offset;
|
|
|
|
child_bitfield_bit_size = 0;
|
|
|
|
child_bitfield_bit_offset = 0;
|
2010-10-15 06:52:14 +08:00
|
|
|
child_is_base_class = false;
|
2010-06-09 00:52:24 +08:00
|
|
|
QualType parent_qual_type(QualType::getFromOpaquePtr(parent_clang_type));
|
2010-09-13 11:32:57 +08:00
|
|
|
const clang::Type::TypeClass parent_type_class = parent_qual_type->getTypeClass();
|
|
|
|
switch (parent_type_class)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-08-03 08:35:52 +08:00
|
|
|
case clang::Type::Builtin:
|
|
|
|
switch (cast<clang::BuiltinType>(parent_qual_type)->getKind())
|
|
|
|
{
|
|
|
|
case clang::BuiltinType::ObjCId:
|
|
|
|
case clang::BuiltinType::ObjCClass:
|
2010-10-25 08:29:48 +08:00
|
|
|
child_name = "isa";
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
child_byte_size = ast->getTypeSize(ast->ObjCBuiltinClassTy) / CHAR_BIT;
|
|
|
|
return ast->ObjCBuiltinClassTy.getAsOpaquePtr();
|
2010-08-03 08:35:52 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Record:
|
2011-01-20 12:18:48 +08:00
|
|
|
if (GetCompleteQualType (ast, parent_qual_type))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
const RecordType *record_type = cast<RecordType>(parent_qual_type.getTypePtr());
|
|
|
|
const RecordDecl *record_decl = record_type->getDecl();
|
|
|
|
assert(record_decl);
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
const ASTRecordLayout &record_layout = ast->getASTRecordLayout(record_decl);
|
2010-06-09 00:52:24 +08:00
|
|
|
uint32_t child_idx = 0;
|
|
|
|
|
|
|
|
const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
|
|
|
|
if (cxx_record_decl)
|
|
|
|
{
|
|
|
|
// We might have base classes to print out first
|
|
|
|
CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
|
|
|
|
for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
|
|
|
|
base_class != base_class_end;
|
|
|
|
++base_class)
|
|
|
|
{
|
|
|
|
const CXXRecordDecl *base_class_decl = NULL;
|
|
|
|
|
|
|
|
// Skip empty base classes
|
|
|
|
if (omit_empty_base_classes)
|
|
|
|
{
|
|
|
|
base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl());
|
|
|
|
if (RecordHasFields(base_class_decl) == false)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (idx == child_idx)
|
|
|
|
{
|
|
|
|
if (base_class_decl == NULL)
|
|
|
|
base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl());
|
|
|
|
|
|
|
|
|
|
|
|
if (base_class->isVirtual())
|
2011-01-22 15:12:45 +08:00
|
|
|
bit_offset = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
2011-01-22 15:12:45 +08:00
|
|
|
bit_offset = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// Base classes should be a multiple of 8 bits in size
|
|
|
|
child_byte_offset = bit_offset/8;
|
2011-06-30 10:28:26 +08:00
|
|
|
|
|
|
|
child_name = ClangASTType::GetTypeNameForQualType(base_class->getType());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
uint64_t clang_type_info_bit_size = ast->getTypeSize(base_class->getType());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-04-16 07:42:06 +08:00
|
|
|
// Base classes bit sizes should be a multiple of 8 bits in size
|
2010-06-09 00:52:24 +08:00
|
|
|
assert (clang_type_info_bit_size % 8 == 0);
|
|
|
|
child_byte_size = clang_type_info_bit_size / 8;
|
2010-10-15 06:52:14 +08:00
|
|
|
child_is_base_class = true;
|
2010-06-09 00:52:24 +08:00
|
|
|
return base_class->getType().getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
// We don't increment the child index in the for loop since we might
|
|
|
|
// be skipping empty base classes
|
|
|
|
++child_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Make sure index is in range...
|
|
|
|
uint32_t field_idx = 0;
|
|
|
|
RecordDecl::field_iterator field, field_end;
|
|
|
|
for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx, ++child_idx)
|
|
|
|
{
|
|
|
|
if (idx == child_idx)
|
|
|
|
{
|
|
|
|
// Print the member type if requested
|
|
|
|
// Print the member name and equal sign
|
|
|
|
child_name.assign(field->getNameAsString().c_str());
|
|
|
|
|
|
|
|
// Figure out the type byte size (field_type_info.first) and
|
|
|
|
// alignment (field_type_info.second) from the AST context.
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
std::pair<uint64_t, unsigned> field_type_info = ast->getTypeInfo(field->getType());
|
2010-07-10 04:39:50 +08:00
|
|
|
assert(field_idx < record_layout.getFieldCount());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
child_byte_size = field_type_info.first / 8;
|
|
|
|
|
|
|
|
// Figure out the field offset within the current struct/union/class type
|
|
|
|
bit_offset = record_layout.getFieldOffset (field_idx);
|
|
|
|
child_byte_offset = bit_offset / 8;
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (ClangASTContext::FieldIsBitfield (ast, *field, child_bitfield_bit_size))
|
2010-06-09 00:52:24 +08:00
|
|
|
child_bitfield_bit_offset = bit_offset % 8;
|
|
|
|
|
|
|
|
return field->getType().getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-28 10:04:09 +08:00
|
|
|
case clang::Type::ObjCObject:
|
|
|
|
case clang::Type::ObjCInterface:
|
2011-01-20 12:18:48 +08:00
|
|
|
if (GetCompleteQualType (ast, parent_qual_type))
|
2010-07-28 10:04:09 +08:00
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(parent_qual_type.getTypePtr());
|
2010-07-28 10:04:09 +08:00
|
|
|
assert (objc_class_type);
|
|
|
|
if (objc_class_type)
|
|
|
|
{
|
|
|
|
uint32_t child_idx = 0;
|
|
|
|
ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
|
|
|
|
|
|
|
|
if (class_interface_decl)
|
|
|
|
{
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
const ASTRecordLayout &interface_layout = ast->getASTObjCInterfaceLayout(class_interface_decl);
|
2010-07-28 10:04:09 +08:00
|
|
|
ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
|
|
|
|
if (superclass_interface_decl)
|
|
|
|
{
|
|
|
|
if (omit_empty_base_classes)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (ClangASTContext::GetNumChildren(ast, ast->getObjCInterfaceType(superclass_interface_decl).getAsOpaquePtr(), omit_empty_base_classes) > 0)
|
2010-07-28 10:04:09 +08:00
|
|
|
{
|
|
|
|
if (idx == 0)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
QualType ivar_qual_type(ast->getObjCInterfaceType(superclass_interface_decl));
|
2010-07-28 10:04:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
child_name.assign(superclass_interface_decl->getNameAsString().c_str());
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
std::pair<uint64_t, unsigned> ivar_type_info = ast->getTypeInfo(ivar_qual_type.getTypePtr());
|
2010-07-28 10:04:09 +08:00
|
|
|
|
|
|
|
child_byte_size = ivar_type_info.first / 8;
|
2010-08-03 08:35:52 +08:00
|
|
|
child_byte_offset = 0;
|
2010-10-15 06:52:14 +08:00
|
|
|
child_is_base_class = true;
|
2010-07-28 10:04:09 +08:00
|
|
|
|
|
|
|
return ivar_qual_type.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
|
|
|
|
++child_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
++child_idx;
|
|
|
|
}
|
2010-08-03 08:35:52 +08:00
|
|
|
|
|
|
|
const uint32_t superclass_idx = child_idx;
|
2010-07-28 10:04:09 +08:00
|
|
|
|
|
|
|
if (idx < (child_idx + class_interface_decl->ivar_size()))
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end();
|
|
|
|
|
|
|
|
for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos)
|
|
|
|
{
|
|
|
|
if (child_idx == idx)
|
|
|
|
{
|
|
|
|
const ObjCIvarDecl* ivar_decl = *ivar_pos;
|
|
|
|
|
|
|
|
QualType ivar_qual_type(ivar_decl->getType());
|
|
|
|
|
|
|
|
child_name.assign(ivar_decl->getNameAsString().c_str());
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
std::pair<uint64_t, unsigned> ivar_type_info = ast->getTypeInfo(ivar_qual_type.getTypePtr());
|
2010-07-28 10:04:09 +08:00
|
|
|
|
|
|
|
child_byte_size = ivar_type_info.first / 8;
|
|
|
|
|
|
|
|
// Figure out the field offset within the current struct/union/class type
|
2011-06-25 06:03:24 +08:00
|
|
|
// For ObjC objects, we can't trust the bit offset we get from the Clang AST, since
|
|
|
|
// that doesn't account for the space taken up by unbacked properties, or from
|
|
|
|
// the changing size of base classes that are newer than this class.
|
|
|
|
// So if we have a process around that we can ask about this object, do so.
|
|
|
|
child_byte_offset = LLDB_INVALID_IVAR_OFFSET;
|
2011-09-22 12:58:26 +08:00
|
|
|
Process *process = NULL;
|
|
|
|
if (exe_ctx)
|
|
|
|
process = exe_ctx->GetProcessPtr();
|
|
|
|
if (process)
|
2011-06-25 06:03:24 +08:00
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
|
2011-06-25 06:03:24 +08:00
|
|
|
if (objc_runtime != NULL)
|
|
|
|
{
|
2011-07-30 03:53:35 +08:00
|
|
|
ClangASTType parent_ast_type (ast, parent_qual_type.getAsOpaquePtr());
|
2011-06-25 06:03:24 +08:00
|
|
|
child_byte_offset = objc_runtime->GetByteOffsetForIvar (parent_ast_type, ivar_decl->getNameAsString().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (child_byte_offset == LLDB_INVALID_IVAR_OFFSET)
|
|
|
|
{
|
|
|
|
bit_offset = interface_layout.getFieldOffset (child_idx - superclass_idx);
|
|
|
|
child_byte_offset = bit_offset / 8;
|
|
|
|
}
|
2010-07-28 10:04:09 +08:00
|
|
|
|
|
|
|
return ivar_qual_type.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
++child_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::ObjCObjectPointer:
|
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ObjCObjectPointerType *pointer_type = cast<ObjCObjectPointerType>(parent_qual_type.getTypePtr());
|
2010-08-03 08:35:52 +08:00
|
|
|
QualType pointee_type = pointer_type->getPointeeType();
|
|
|
|
|
|
|
|
if (transparent_pointers && ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
|
|
|
|
{
|
2011-01-21 09:59:00 +08:00
|
|
|
child_is_deref_of_parent = false;
|
|
|
|
bool tmp_child_is_deref_of_parent = false;
|
2011-06-25 06:03:24 +08:00
|
|
|
return GetChildClangTypeAtIndex (exe_ctx,
|
|
|
|
ast,
|
2010-08-03 08:35:52 +08:00
|
|
|
parent_name,
|
|
|
|
pointer_type->getPointeeType().getAsOpaquePtr(),
|
|
|
|
idx,
|
|
|
|
transparent_pointers,
|
|
|
|
omit_empty_base_classes,
|
2011-07-10 04:12:33 +08:00
|
|
|
ignore_array_bounds,
|
2010-08-03 08:35:52 +08:00
|
|
|
child_name,
|
|
|
|
child_byte_size,
|
|
|
|
child_byte_offset,
|
|
|
|
child_bitfield_bit_size,
|
2010-10-15 06:52:14 +08:00
|
|
|
child_bitfield_bit_offset,
|
2011-01-21 09:59:00 +08:00
|
|
|
child_is_base_class,
|
|
|
|
tmp_child_is_deref_of_parent);
|
2010-08-03 08:35:52 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-21 09:59:00 +08:00
|
|
|
child_is_deref_of_parent = true;
|
2010-08-03 08:35:52 +08:00
|
|
|
if (parent_name)
|
|
|
|
{
|
|
|
|
child_name.assign(1, '*');
|
|
|
|
child_name += parent_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We have a pointer to an simple type
|
|
|
|
if (idx == 0)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
std::pair<uint64_t, unsigned> clang_type_info = ast->getTypeInfo(pointee_type);
|
2010-08-03 08:35:52 +08:00
|
|
|
assert(clang_type_info.first % 8 == 0);
|
|
|
|
child_byte_size = clang_type_info.first / 8;
|
|
|
|
child_byte_offset = 0;
|
|
|
|
return pointee_type.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
}
|
2010-07-28 10:04:09 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::ConstantArray:
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
const ConstantArrayType *array = cast<ConstantArrayType>(parent_qual_type.getTypePtr());
|
|
|
|
const uint64_t element_count = array->getSize().getLimitedValue();
|
|
|
|
|
2011-07-10 04:12:33 +08:00
|
|
|
if (ignore_array_bounds || idx < element_count)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (GetCompleteQualType (ast, array->getElementType()))
|
|
|
|
{
|
|
|
|
std::pair<uint64_t, unsigned> field_type_info = ast->getTypeInfo(array->getElementType());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
char element_name[64];
|
|
|
|
::snprintf (element_name, sizeof (element_name), "[%u]", idx);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
child_name.assign(element_name);
|
|
|
|
assert(field_type_info.first % 8 == 0);
|
|
|
|
child_byte_size = field_type_info.first / 8;
|
2011-07-10 04:12:33 +08:00
|
|
|
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return array->getElementType().getAsOpaquePtr();
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Pointer:
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const PointerType *pointer_type = cast<PointerType>(parent_qual_type.getTypePtr());
|
2010-06-09 00:52:24 +08:00
|
|
|
QualType pointee_type = pointer_type->getPointeeType();
|
2011-01-09 06:26:47 +08:00
|
|
|
|
|
|
|
// Don't dereference "void *" pointers
|
|
|
|
if (pointee_type->isVoidType())
|
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (transparent_pointers && ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
|
|
|
|
{
|
2011-01-21 09:59:00 +08:00
|
|
|
child_is_deref_of_parent = false;
|
|
|
|
bool tmp_child_is_deref_of_parent = false;
|
2011-06-25 06:03:24 +08:00
|
|
|
return GetChildClangTypeAtIndex (exe_ctx,
|
|
|
|
ast,
|
2010-06-09 00:52:24 +08:00
|
|
|
parent_name,
|
|
|
|
pointer_type->getPointeeType().getAsOpaquePtr(),
|
|
|
|
idx,
|
|
|
|
transparent_pointers,
|
|
|
|
omit_empty_base_classes,
|
2011-07-10 04:12:33 +08:00
|
|
|
ignore_array_bounds,
|
2010-06-09 00:52:24 +08:00
|
|
|
child_name,
|
|
|
|
child_byte_size,
|
|
|
|
child_byte_offset,
|
|
|
|
child_bitfield_bit_size,
|
2010-10-15 06:52:14 +08:00
|
|
|
child_bitfield_bit_offset,
|
2011-01-21 09:59:00 +08:00
|
|
|
child_is_base_class,
|
|
|
|
tmp_child_is_deref_of_parent);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-21 09:59:00 +08:00
|
|
|
child_is_deref_of_parent = true;
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (parent_name)
|
|
|
|
{
|
|
|
|
child_name.assign(1, '*');
|
|
|
|
child_name += parent_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We have a pointer to an simple type
|
|
|
|
if (idx == 0)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
std::pair<uint64_t, unsigned> clang_type_info = ast->getTypeInfo(pointee_type);
|
2010-06-09 00:52:24 +08:00
|
|
|
assert(clang_type_info.first % 8 == 0);
|
|
|
|
child_byte_size = clang_type_info.first / 8;
|
|
|
|
child_byte_offset = 0;
|
|
|
|
return pointee_type.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-10-27 11:32:59 +08:00
|
|
|
case clang::Type::LValueReference:
|
|
|
|
case clang::Type::RValueReference:
|
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ReferenceType *reference_type = cast<ReferenceType>(parent_qual_type.getTypePtr());
|
2010-10-27 11:32:59 +08:00
|
|
|
QualType pointee_type(reference_type->getPointeeType());
|
|
|
|
clang_type_t pointee_clang_type = pointee_type.getAsOpaquePtr();
|
|
|
|
if (transparent_pointers && ClangASTContext::IsAggregateType (pointee_clang_type))
|
|
|
|
{
|
2011-01-21 09:59:00 +08:00
|
|
|
child_is_deref_of_parent = false;
|
|
|
|
bool tmp_child_is_deref_of_parent = false;
|
2011-06-25 06:03:24 +08:00
|
|
|
return GetChildClangTypeAtIndex (exe_ctx,
|
|
|
|
ast,
|
2010-10-27 11:32:59 +08:00
|
|
|
parent_name,
|
|
|
|
pointee_clang_type,
|
|
|
|
idx,
|
|
|
|
transparent_pointers,
|
|
|
|
omit_empty_base_classes,
|
2011-07-10 04:12:33 +08:00
|
|
|
ignore_array_bounds,
|
2010-10-27 11:32:59 +08:00
|
|
|
child_name,
|
|
|
|
child_byte_size,
|
|
|
|
child_byte_offset,
|
|
|
|
child_bitfield_bit_size,
|
|
|
|
child_bitfield_bit_offset,
|
2011-01-21 09:59:00 +08:00
|
|
|
child_is_base_class,
|
|
|
|
tmp_child_is_deref_of_parent);
|
2010-10-27 11:32:59 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (parent_name)
|
|
|
|
{
|
|
|
|
child_name.assign(1, '&');
|
|
|
|
child_name += parent_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We have a pointer to an simple type
|
|
|
|
if (idx == 0)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
std::pair<uint64_t, unsigned> clang_type_info = ast->getTypeInfo(pointee_type);
|
2010-10-27 11:32:59 +08:00
|
|
|
assert(clang_type_info.first % 8 == 0);
|
|
|
|
child_byte_size = clang_type_info.first / 8;
|
|
|
|
child_byte_offset = 0;
|
|
|
|
return pointee_type.getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Typedef:
|
2011-06-25 06:03:24 +08:00
|
|
|
return GetChildClangTypeAtIndex (exe_ctx,
|
|
|
|
ast,
|
2010-06-09 00:52:24 +08:00
|
|
|
parent_name,
|
2010-12-13 09:26:27 +08:00
|
|
|
cast<TypedefType>(parent_qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
|
2010-06-09 00:52:24 +08:00
|
|
|
idx,
|
|
|
|
transparent_pointers,
|
|
|
|
omit_empty_base_classes,
|
2011-07-10 04:12:33 +08:00
|
|
|
ignore_array_bounds,
|
2010-06-09 00:52:24 +08:00
|
|
|
child_name,
|
|
|
|
child_byte_size,
|
|
|
|
child_byte_offset,
|
|
|
|
child_bitfield_bit_size,
|
2010-10-15 06:52:14 +08:00
|
|
|
child_bitfield_bit_offset,
|
2011-01-21 09:59:00 +08:00
|
|
|
child_is_base_class,
|
|
|
|
child_is_deref_of_parent);
|
2010-06-09 00:52:24 +08:00
|
|
|
break;
|
2011-08-12 07:56:13 +08:00
|
|
|
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return GetChildClangTypeAtIndex (exe_ctx,
|
|
|
|
ast,
|
|
|
|
parent_name,
|
|
|
|
cast<ElaboratedType>(parent_qual_type)->getNamedType().getAsOpaquePtr(),
|
|
|
|
idx,
|
|
|
|
transparent_pointers,
|
|
|
|
omit_empty_base_classes,
|
|
|
|
ignore_array_bounds,
|
|
|
|
child_name,
|
|
|
|
child_byte_size,
|
|
|
|
child_byte_offset,
|
|
|
|
child_bitfield_bit_size,
|
|
|
|
child_bitfield_bit_offset,
|
|
|
|
child_is_base_class,
|
|
|
|
child_is_deref_of_parent);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-07-23 23:37:46 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
BaseSpecifierIsEmpty (const CXXBaseSpecifier *b)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return ClangASTContext::RecordHasFields(b->getType()->getAsCXXRecordDecl()) == false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
GetNumBaseClasses (const CXXRecordDecl *cxx_record_decl, bool omit_empty_base_classes)
|
|
|
|
{
|
|
|
|
uint32_t num_bases = 0;
|
|
|
|
if (cxx_record_decl)
|
|
|
|
{
|
|
|
|
if (omit_empty_base_classes)
|
|
|
|
{
|
|
|
|
CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
|
|
|
|
for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
|
|
|
|
base_class != base_class_end;
|
|
|
|
++base_class)
|
|
|
|
{
|
|
|
|
// Skip empty base classes
|
|
|
|
if (omit_empty_base_classes)
|
|
|
|
{
|
|
|
|
if (BaseSpecifierIsEmpty (base_class))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
++num_bases;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
num_bases = cxx_record_decl->getNumBases();
|
|
|
|
}
|
|
|
|
return num_bases;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
GetIndexForRecordBase
|
|
|
|
(
|
|
|
|
const RecordDecl *record_decl,
|
|
|
|
const CXXBaseSpecifier *base_spec,
|
|
|
|
bool omit_empty_base_classes
|
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t child_idx = 0;
|
|
|
|
|
|
|
|
const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
|
|
|
|
|
|
|
|
// const char *super_name = record_decl->getNameAsCString();
|
|
|
|
// const char *base_name = base_spec->getType()->getAs<RecordType>()->getDecl()->getNameAsCString();
|
|
|
|
// printf ("GetIndexForRecordChild (%s, %s)\n", super_name, base_name);
|
|
|
|
//
|
|
|
|
if (cxx_record_decl)
|
|
|
|
{
|
|
|
|
CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
|
|
|
|
for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
|
|
|
|
base_class != base_class_end;
|
|
|
|
++base_class)
|
|
|
|
{
|
|
|
|
if (omit_empty_base_classes)
|
|
|
|
{
|
|
|
|
if (BaseSpecifierIsEmpty (base_class))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// printf ("GetIndexForRecordChild (%s, %s) base[%u] = %s\n", super_name, base_name,
|
|
|
|
// child_idx,
|
|
|
|
// base_class->getType()->getAs<RecordType>()->getDecl()->getNameAsCString());
|
|
|
|
//
|
|
|
|
//
|
|
|
|
if (base_class == base_spec)
|
|
|
|
return child_idx;
|
|
|
|
++child_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return UINT32_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
GetIndexForRecordChild
|
|
|
|
(
|
|
|
|
const RecordDecl *record_decl,
|
|
|
|
NamedDecl *canonical_decl,
|
|
|
|
bool omit_empty_base_classes
|
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t child_idx = GetNumBaseClasses (dyn_cast<CXXRecordDecl>(record_decl), omit_empty_base_classes);
|
|
|
|
|
|
|
|
// const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
|
|
|
|
//
|
|
|
|
//// printf ("GetIndexForRecordChild (%s, %s)\n", record_decl->getNameAsCString(), canonical_decl->getNameAsCString());
|
|
|
|
// if (cxx_record_decl)
|
|
|
|
// {
|
|
|
|
// CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
|
|
|
|
// for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
|
|
|
|
// base_class != base_class_end;
|
|
|
|
// ++base_class)
|
|
|
|
// {
|
|
|
|
// if (omit_empty_base_classes)
|
|
|
|
// {
|
|
|
|
// if (BaseSpecifierIsEmpty (base_class))
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//// printf ("GetIndexForRecordChild (%s, %s) base[%u] = %s\n",
|
|
|
|
//// record_decl->getNameAsCString(),
|
|
|
|
//// canonical_decl->getNameAsCString(),
|
|
|
|
//// child_idx,
|
|
|
|
//// base_class->getType()->getAs<RecordType>()->getDecl()->getNameAsCString());
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// CXXRecordDecl *curr_base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl());
|
|
|
|
// if (curr_base_class_decl == canonical_decl)
|
|
|
|
// {
|
|
|
|
// return child_idx;
|
|
|
|
// }
|
|
|
|
// ++child_idx;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// const uint32_t num_bases = child_idx;
|
|
|
|
RecordDecl::field_iterator field, field_end;
|
|
|
|
for (field = record_decl->field_begin(), field_end = record_decl->field_end();
|
|
|
|
field != field_end;
|
|
|
|
++field, ++child_idx)
|
|
|
|
{
|
|
|
|
// printf ("GetIndexForRecordChild (%s, %s) field[%u] = %s\n",
|
|
|
|
// record_decl->getNameAsCString(),
|
|
|
|
// canonical_decl->getNameAsCString(),
|
|
|
|
// child_idx - num_bases,
|
|
|
|
// field->getNameAsCString());
|
|
|
|
|
|
|
|
if (field->getCanonicalDecl() == canonical_decl)
|
|
|
|
return child_idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
return UINT32_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Look for a child member (doesn't include base classes, but it does include
|
|
|
|
// their members) in the type hierarchy. Returns an index path into "clang_type"
|
|
|
|
// on how to reach the appropriate member.
|
|
|
|
//
|
|
|
|
// class A
|
|
|
|
// {
|
|
|
|
// public:
|
|
|
|
// int m_a;
|
|
|
|
// int m_b;
|
|
|
|
// };
|
|
|
|
//
|
|
|
|
// class B
|
|
|
|
// {
|
|
|
|
// };
|
|
|
|
//
|
|
|
|
// class C :
|
|
|
|
// public B,
|
|
|
|
// public A
|
|
|
|
// {
|
|
|
|
// };
|
|
|
|
//
|
|
|
|
// If we have a clang type that describes "class C", and we wanted to looked
|
|
|
|
// "m_b" in it:
|
|
|
|
//
|
|
|
|
// With omit_empty_base_classes == false we would get an integer array back with:
|
|
|
|
// { 1, 1 }
|
|
|
|
// The first index 1 is the child index for "class A" within class C
|
|
|
|
// The second index 1 is the child index for "m_b" within class A
|
|
|
|
//
|
|
|
|
// With omit_empty_base_classes == true we would get an integer array back with:
|
|
|
|
// { 0, 1 }
|
|
|
|
// The first index 0 is the child index for "class A" within class C (since class B doesn't have any members it doesn't count)
|
|
|
|
// The second index 1 is the child index for "m_b" within class A
|
|
|
|
|
|
|
|
size_t
|
|
|
|
ClangASTContext::GetIndexOfChildMemberWithName
|
|
|
|
(
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t clang_type,
|
2010-06-09 00:52:24 +08:00
|
|
|
const char *name,
|
|
|
|
bool omit_empty_base_classes,
|
|
|
|
std::vector<uint32_t>& child_indexes
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (clang_type && name && name[0])
|
|
|
|
{
|
|
|
|
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
|
2010-09-13 11:32:57 +08:00
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Record:
|
2011-01-20 12:18:48 +08:00
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr());
|
|
|
|
const RecordDecl *record_decl = record_type->getDecl();
|
|
|
|
|
|
|
|
assert(record_decl);
|
|
|
|
uint32_t child_idx = 0;
|
|
|
|
|
|
|
|
const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
|
|
|
|
|
|
|
|
// Try and find a field that matches NAME
|
|
|
|
RecordDecl::field_iterator field, field_end;
|
|
|
|
StringRef name_sref(name);
|
|
|
|
for (field = record_decl->field_begin(), field_end = record_decl->field_end();
|
|
|
|
field != field_end;
|
|
|
|
++field, ++child_idx)
|
|
|
|
{
|
|
|
|
if (field->getName().equals (name_sref))
|
|
|
|
{
|
|
|
|
// We have to add on the number of base classes to this index!
|
|
|
|
child_indexes.push_back (child_idx + GetNumBaseClasses (cxx_record_decl, omit_empty_base_classes));
|
|
|
|
return child_indexes.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cxx_record_decl)
|
|
|
|
{
|
|
|
|
const RecordDecl *parent_record_decl = cxx_record_decl;
|
|
|
|
|
|
|
|
//printf ("parent = %s\n", parent_record_decl->getNameAsCString());
|
|
|
|
|
|
|
|
//const Decl *root_cdecl = cxx_record_decl->getCanonicalDecl();
|
|
|
|
// Didn't find things easily, lets let clang do its thang...
|
2011-07-30 10:42:06 +08:00
|
|
|
IdentifierInfo & ident_ref = ast->Idents.get(name_sref);
|
2010-06-09 00:52:24 +08:00
|
|
|
DeclarationName decl_name(&ident_ref);
|
|
|
|
|
|
|
|
CXXBasePaths paths;
|
|
|
|
if (cxx_record_decl->lookupInBases(CXXRecordDecl::FindOrdinaryMember,
|
|
|
|
decl_name.getAsOpaquePtr(),
|
|
|
|
paths))
|
|
|
|
{
|
|
|
|
CXXBasePaths::const_paths_iterator path, path_end = paths.end();
|
|
|
|
for (path = paths.begin(); path != path_end; ++path)
|
|
|
|
{
|
|
|
|
const size_t num_path_elements = path->size();
|
|
|
|
for (size_t e=0; e<num_path_elements; ++e)
|
|
|
|
{
|
|
|
|
CXXBasePathElement elem = (*path)[e];
|
|
|
|
|
|
|
|
child_idx = GetIndexForRecordBase (parent_record_decl, elem.Base, omit_empty_base_classes);
|
|
|
|
if (child_idx == UINT32_MAX)
|
|
|
|
{
|
|
|
|
child_indexes.clear();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
child_indexes.push_back (child_idx);
|
|
|
|
parent_record_decl = cast<RecordDecl>(elem.Base->getType()->getAs<RecordType>()->getDecl());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DeclContext::lookup_iterator named_decl_pos;
|
|
|
|
for (named_decl_pos = path->Decls.first;
|
|
|
|
named_decl_pos != path->Decls.second && parent_record_decl;
|
|
|
|
++named_decl_pos)
|
|
|
|
{
|
|
|
|
//printf ("path[%zu] = %s\n", child_indexes.size(), (*named_decl_pos)->getNameAsCString());
|
|
|
|
|
|
|
|
child_idx = GetIndexForRecordChild (parent_record_decl, *named_decl_pos, omit_empty_base_classes);
|
|
|
|
if (child_idx == UINT32_MAX)
|
|
|
|
{
|
|
|
|
child_indexes.clear();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
child_indexes.push_back (child_idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return child_indexes.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-28 10:04:09 +08:00
|
|
|
case clang::Type::ObjCObject:
|
|
|
|
case clang::Type::ObjCInterface:
|
2011-01-20 12:18:48 +08:00
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
2010-07-28 10:04:09 +08:00
|
|
|
{
|
|
|
|
StringRef name_sref(name);
|
2011-01-27 12:42:51 +08:00
|
|
|
const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr());
|
2010-07-28 10:04:09 +08:00
|
|
|
assert (objc_class_type);
|
|
|
|
if (objc_class_type)
|
|
|
|
{
|
|
|
|
uint32_t child_idx = 0;
|
|
|
|
ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
|
|
|
|
|
|
|
|
if (class_interface_decl)
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end();
|
|
|
|
ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
|
|
|
|
|
2010-09-18 10:11:07 +08:00
|
|
|
for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos, ++child_idx)
|
2010-07-28 10:04:09 +08:00
|
|
|
{
|
|
|
|
const ObjCIvarDecl* ivar_decl = *ivar_pos;
|
|
|
|
|
|
|
|
if (ivar_decl->getName().equals (name_sref))
|
|
|
|
{
|
|
|
|
if ((!omit_empty_base_classes && superclass_interface_decl) ||
|
|
|
|
( omit_empty_base_classes && ObjCDeclHasIVars (superclass_interface_decl, true)))
|
|
|
|
++child_idx;
|
|
|
|
|
|
|
|
child_indexes.push_back (child_idx);
|
|
|
|
return child_indexes.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (superclass_interface_decl)
|
|
|
|
{
|
|
|
|
// The super class index is always zero for ObjC classes,
|
|
|
|
// so we push it onto the child indexes in case we find
|
|
|
|
// an ivar in our superclass...
|
|
|
|
child_indexes.push_back (0);
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (GetIndexOfChildMemberWithName (ast,
|
|
|
|
ast->getObjCInterfaceType(superclass_interface_decl).getAsOpaquePtr(),
|
2010-07-28 10:04:09 +08:00
|
|
|
name,
|
|
|
|
omit_empty_base_classes,
|
|
|
|
child_indexes))
|
|
|
|
{
|
|
|
|
// We did find an ivar in a superclass so just
|
|
|
|
// return the results!
|
|
|
|
return child_indexes.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
// We didn't find an ivar matching "name" in our
|
|
|
|
// superclass, pop the superclass zero index that
|
|
|
|
// we pushed on above.
|
|
|
|
child_indexes.pop_back();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::ObjCObjectPointer:
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return GetIndexOfChildMemberWithName (ast,
|
2010-07-28 10:04:09 +08:00
|
|
|
cast<ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType().getAsOpaquePtr(),
|
|
|
|
name,
|
|
|
|
omit_empty_base_classes,
|
|
|
|
child_indexes);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::ConstantArray:
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
// const ConstantArrayType *array = cast<ConstantArrayType>(parent_qual_type.getTypePtr());
|
|
|
|
// const uint64_t element_count = array->getSize().getLimitedValue();
|
|
|
|
//
|
|
|
|
// if (idx < element_count)
|
|
|
|
// {
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
// std::pair<uint64_t, unsigned> field_type_info = ast->getTypeInfo(array->getElementType());
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
// char element_name[32];
|
|
|
|
// ::snprintf (element_name, sizeof (element_name), "%s[%u]", parent_name ? parent_name : "", idx);
|
|
|
|
//
|
|
|
|
// child_name.assign(element_name);
|
|
|
|
// assert(field_type_info.first % 8 == 0);
|
|
|
|
// child_byte_size = field_type_info.first / 8;
|
|
|
|
// child_byte_offset = idx * child_byte_size;
|
|
|
|
// return array->getElementType().getAsOpaquePtr();
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
// case clang::Type::MemberPointerType:
|
2010-06-09 00:52:24 +08:00
|
|
|
// {
|
|
|
|
// MemberPointerType *mem_ptr_type = cast<MemberPointerType>(qual_type.getTypePtr());
|
|
|
|
// QualType pointee_type = mem_ptr_type->getPointeeType();
|
|
|
|
//
|
|
|
|
// if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
|
|
|
|
// {
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
// return GetIndexOfChildWithName (ast,
|
2010-06-09 00:52:24 +08:00
|
|
|
// mem_ptr_type->getPointeeType().getAsOpaquePtr(),
|
|
|
|
// name);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
//
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::LValueReference:
|
|
|
|
case clang::Type::RValueReference:
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ReferenceType *reference_type = cast<ReferenceType>(qual_type.getTypePtr());
|
2010-06-09 00:52:24 +08:00
|
|
|
QualType pointee_type = reference_type->getPointeeType();
|
|
|
|
|
|
|
|
if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return GetIndexOfChildMemberWithName (ast,
|
2010-06-09 00:52:24 +08:00
|
|
|
reference_type->getPointeeType().getAsOpaquePtr(),
|
|
|
|
name,
|
|
|
|
omit_empty_base_classes,
|
|
|
|
child_indexes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Pointer:
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const PointerType *pointer_type = cast<PointerType>(qual_type.getTypePtr());
|
2010-06-09 00:52:24 +08:00
|
|
|
QualType pointee_type = pointer_type->getPointeeType();
|
|
|
|
|
|
|
|
if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return GetIndexOfChildMemberWithName (ast,
|
2010-06-09 00:52:24 +08:00
|
|
|
pointer_type->getPointeeType().getAsOpaquePtr(),
|
|
|
|
name,
|
|
|
|
omit_empty_base_classes,
|
|
|
|
child_indexes);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if (parent_name)
|
|
|
|
// {
|
|
|
|
// child_name.assign(1, '*');
|
|
|
|
// child_name += parent_name;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // We have a pointer to an simple type
|
|
|
|
// if (idx == 0)
|
|
|
|
// {
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
// std::pair<uint64_t, unsigned> clang_type_info = ast->getTypeInfo(pointee_type);
|
2010-06-09 00:52:24 +08:00
|
|
|
// assert(clang_type_info.first % 8 == 0);
|
|
|
|
// child_byte_size = clang_type_info.first / 8;
|
|
|
|
// child_byte_offset = 0;
|
|
|
|
// return pointee_type.getAsOpaquePtr();
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Typedef:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return GetIndexOfChildMemberWithName (ast,
|
2010-12-13 09:26:27 +08:00
|
|
|
cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
|
2010-06-09 00:52:24 +08:00
|
|
|
name,
|
|
|
|
omit_empty_base_classes,
|
|
|
|
child_indexes);
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get the index of the child of "clang_type" whose name matches. This function
|
|
|
|
// doesn't descend into the children, but only looks one level deep and name
|
|
|
|
// matches can include base class names.
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
ClangASTContext::GetIndexOfChildWithName
|
|
|
|
(
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t clang_type,
|
2010-06-09 00:52:24 +08:00
|
|
|
const char *name,
|
|
|
|
bool omit_empty_base_classes
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (clang_type && name && name[0])
|
|
|
|
{
|
|
|
|
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
|
2010-07-28 10:04:09 +08:00
|
|
|
|
2010-09-13 11:32:57 +08:00
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
2010-07-28 10:04:09 +08:00
|
|
|
|
2010-09-13 11:32:57 +08:00
|
|
|
switch (type_class)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Record:
|
2011-01-20 12:18:48 +08:00
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr());
|
|
|
|
const RecordDecl *record_decl = record_type->getDecl();
|
|
|
|
|
|
|
|
assert(record_decl);
|
|
|
|
uint32_t child_idx = 0;
|
|
|
|
|
|
|
|
const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
|
|
|
|
|
|
|
|
if (cxx_record_decl)
|
|
|
|
{
|
|
|
|
CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
|
|
|
|
for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
|
|
|
|
base_class != base_class_end;
|
|
|
|
++base_class)
|
|
|
|
{
|
|
|
|
// Skip empty base classes
|
|
|
|
CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl());
|
|
|
|
if (omit_empty_base_classes && RecordHasFields(base_class_decl) == false)
|
|
|
|
continue;
|
|
|
|
|
2011-06-30 10:28:26 +08:00
|
|
|
std::string base_class_type_name (ClangASTType::GetTypeNameForQualType(base_class->getType()));
|
|
|
|
if (base_class_type_name.compare (name) == 0)
|
2010-06-09 00:52:24 +08:00
|
|
|
return child_idx;
|
|
|
|
++child_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try and find a field that matches NAME
|
|
|
|
RecordDecl::field_iterator field, field_end;
|
|
|
|
StringRef name_sref(name);
|
|
|
|
for (field = record_decl->field_begin(), field_end = record_decl->field_end();
|
|
|
|
field != field_end;
|
|
|
|
++field, ++child_idx)
|
|
|
|
{
|
|
|
|
if (field->getName().equals (name_sref))
|
|
|
|
return child_idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-28 10:04:09 +08:00
|
|
|
case clang::Type::ObjCObject:
|
|
|
|
case clang::Type::ObjCInterface:
|
2011-01-20 12:18:48 +08:00
|
|
|
if (GetCompleteQualType (ast, qual_type))
|
2010-07-28 10:04:09 +08:00
|
|
|
{
|
|
|
|
StringRef name_sref(name);
|
2011-01-27 12:42:51 +08:00
|
|
|
const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr());
|
2010-07-28 10:04:09 +08:00
|
|
|
assert (objc_class_type);
|
|
|
|
if (objc_class_type)
|
|
|
|
{
|
|
|
|
uint32_t child_idx = 0;
|
|
|
|
ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
|
|
|
|
|
|
|
|
if (class_interface_decl)
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end();
|
|
|
|
ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
|
|
|
|
|
|
|
|
for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos)
|
|
|
|
{
|
|
|
|
const ObjCIvarDecl* ivar_decl = *ivar_pos;
|
|
|
|
|
|
|
|
if (ivar_decl->getName().equals (name_sref))
|
|
|
|
{
|
|
|
|
if ((!omit_empty_base_classes && superclass_interface_decl) ||
|
|
|
|
( omit_empty_base_classes && ObjCDeclHasIVars (superclass_interface_decl, true)))
|
|
|
|
++child_idx;
|
|
|
|
|
|
|
|
return child_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (superclass_interface_decl)
|
|
|
|
{
|
|
|
|
if (superclass_interface_decl->getName().equals (name_sref))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::ObjCObjectPointer:
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return GetIndexOfChildWithName (ast,
|
2010-07-28 10:04:09 +08:00
|
|
|
cast<ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType().getAsOpaquePtr(),
|
|
|
|
name,
|
|
|
|
omit_empty_base_classes);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::ConstantArray:
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
// const ConstantArrayType *array = cast<ConstantArrayType>(parent_qual_type.getTypePtr());
|
|
|
|
// const uint64_t element_count = array->getSize().getLimitedValue();
|
|
|
|
//
|
|
|
|
// if (idx < element_count)
|
|
|
|
// {
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
// std::pair<uint64_t, unsigned> field_type_info = ast->getTypeInfo(array->getElementType());
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
// char element_name[32];
|
|
|
|
// ::snprintf (element_name, sizeof (element_name), "%s[%u]", parent_name ? parent_name : "", idx);
|
|
|
|
//
|
|
|
|
// child_name.assign(element_name);
|
|
|
|
// assert(field_type_info.first % 8 == 0);
|
|
|
|
// child_byte_size = field_type_info.first / 8;
|
|
|
|
// child_byte_offset = idx * child_byte_size;
|
|
|
|
// return array->getElementType().getAsOpaquePtr();
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
// case clang::Type::MemberPointerType:
|
2010-06-09 00:52:24 +08:00
|
|
|
// {
|
|
|
|
// MemberPointerType *mem_ptr_type = cast<MemberPointerType>(qual_type.getTypePtr());
|
|
|
|
// QualType pointee_type = mem_ptr_type->getPointeeType();
|
|
|
|
//
|
|
|
|
// if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
|
|
|
|
// {
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
// return GetIndexOfChildWithName (ast,
|
2010-06-09 00:52:24 +08:00
|
|
|
// mem_ptr_type->getPointeeType().getAsOpaquePtr(),
|
|
|
|
// name);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
//
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::LValueReference:
|
|
|
|
case clang::Type::RValueReference:
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ReferenceType *reference_type = cast<ReferenceType>(qual_type.getTypePtr());
|
2010-06-09 00:52:24 +08:00
|
|
|
QualType pointee_type = reference_type->getPointeeType();
|
|
|
|
|
|
|
|
if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return GetIndexOfChildWithName (ast,
|
2010-06-09 00:52:24 +08:00
|
|
|
reference_type->getPointeeType().getAsOpaquePtr(),
|
|
|
|
name,
|
|
|
|
omit_empty_base_classes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Pointer:
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const PointerType *pointer_type = cast<PointerType>(qual_type.getTypePtr());
|
2010-06-09 00:52:24 +08:00
|
|
|
QualType pointee_type = pointer_type->getPointeeType();
|
|
|
|
|
|
|
|
if (ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return GetIndexOfChildWithName (ast,
|
2010-06-09 00:52:24 +08:00
|
|
|
pointer_type->getPointeeType().getAsOpaquePtr(),
|
|
|
|
name,
|
|
|
|
omit_empty_base_classes);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if (parent_name)
|
|
|
|
// {
|
|
|
|
// child_name.assign(1, '*');
|
|
|
|
// child_name += parent_name;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // We have a pointer to an simple type
|
|
|
|
// if (idx == 0)
|
|
|
|
// {
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
// std::pair<uint64_t, unsigned> clang_type_info = ast->getTypeInfo(pointee_type);
|
2010-06-09 00:52:24 +08:00
|
|
|
// assert(clang_type_info.first % 8 == 0);
|
|
|
|
// child_byte_size = clang_type_info.first / 8;
|
|
|
|
// child_byte_offset = 0;
|
|
|
|
// return pointee_type.getAsOpaquePtr();
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Typedef:
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return GetIndexOfChildWithName (ast,
|
2010-12-13 09:26:27 +08:00
|
|
|
cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
|
2010-06-09 00:52:24 +08:00
|
|
|
name,
|
|
|
|
omit_empty_base_classes);
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return UINT32_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark TagType
|
|
|
|
|
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::SetTagTypeKind (clang_type_t tag_clang_type, int kind)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (tag_clang_type)
|
|
|
|
{
|
|
|
|
QualType tag_qual_type(QualType::getFromOpaquePtr(tag_clang_type));
|
2011-01-27 12:42:51 +08:00
|
|
|
const clang::Type *clang_type = tag_qual_type.getTypePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (clang_type)
|
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const TagType *tag_type = dyn_cast<TagType>(clang_type);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (tag_type)
|
|
|
|
{
|
|
|
|
TagDecl *tag_decl = dyn_cast<TagDecl>(tag_type->getDecl());
|
|
|
|
if (tag_decl)
|
|
|
|
{
|
|
|
|
tag_decl->setTagKind ((TagDecl::TagKind)kind);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark DeclContext Functions
|
|
|
|
|
|
|
|
DeclContext *
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::GetDeclContextForType (clang_type_t clang_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
|
2010-09-13 11:32:57 +08:00
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-07-30 10:42:06 +08:00
|
|
|
case clang::Type::UnaryTransform: break;
|
2010-07-28 10:04:09 +08:00
|
|
|
case clang::Type::FunctionNoProto: break;
|
|
|
|
case clang::Type::FunctionProto: break;
|
|
|
|
case clang::Type::IncompleteArray: break;
|
|
|
|
case clang::Type::VariableArray: break;
|
|
|
|
case clang::Type::ConstantArray: break;
|
2011-03-15 08:17:19 +08:00
|
|
|
case clang::Type::DependentSizedArray: break;
|
2010-07-28 10:04:09 +08:00
|
|
|
case clang::Type::ExtVector: break;
|
2011-03-15 08:17:19 +08:00
|
|
|
case clang::Type::DependentSizedExtVector: break;
|
2010-07-28 10:04:09 +08:00
|
|
|
case clang::Type::Vector: break;
|
|
|
|
case clang::Type::Builtin: break;
|
|
|
|
case clang::Type::BlockPointer: break;
|
|
|
|
case clang::Type::Pointer: break;
|
|
|
|
case clang::Type::LValueReference: break;
|
|
|
|
case clang::Type::RValueReference: break;
|
|
|
|
case clang::Type::MemberPointer: break;
|
|
|
|
case clang::Type::Complex: break;
|
|
|
|
case clang::Type::ObjCObject: break;
|
|
|
|
case clang::Type::ObjCInterface: return cast<ObjCObjectType>(qual_type.getTypePtr())->getInterface();
|
|
|
|
case clang::Type::ObjCObjectPointer: return ClangASTContext::GetDeclContextForType (cast<ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType().getAsOpaquePtr());
|
|
|
|
case clang::Type::Record: return cast<RecordType>(qual_type)->getDecl();
|
|
|
|
case clang::Type::Enum: return cast<EnumType>(qual_type)->getDecl();
|
2010-12-13 09:26:27 +08:00
|
|
|
case clang::Type::Typedef: return ClangASTContext::GetDeclContextForType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
|
2011-08-12 07:56:13 +08:00
|
|
|
case clang::Type::Elaborated: return ClangASTContext::GetDeclContextForType (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
|
2010-07-28 10:04:09 +08:00
|
|
|
case clang::Type::TypeOfExpr: break;
|
|
|
|
case clang::Type::TypeOf: break;
|
|
|
|
case clang::Type::Decltype: break;
|
|
|
|
//case clang::Type::QualifiedName: break;
|
|
|
|
case clang::Type::TemplateSpecialization: break;
|
2011-03-15 08:17:19 +08:00
|
|
|
case clang::Type::DependentTemplateSpecialization: break;
|
|
|
|
case clang::Type::TemplateTypeParm: break;
|
|
|
|
case clang::Type::SubstTemplateTypeParm: break;
|
|
|
|
case clang::Type::SubstTemplateTypeParmPack:break;
|
|
|
|
case clang::Type::PackExpansion: break;
|
|
|
|
case clang::Type::UnresolvedUsing: break;
|
|
|
|
case clang::Type::Paren: break;
|
|
|
|
case clang::Type::Attributed: break;
|
|
|
|
case clang::Type::Auto: break;
|
|
|
|
case clang::Type::InjectedClassName: break;
|
|
|
|
case clang::Type::DependentName: break;
|
2011-10-08 08:49:15 +08:00
|
|
|
case clang::Type::Atomic: break;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
// No DeclContext in this type...
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark Namespace Declarations
|
|
|
|
|
|
|
|
NamespaceDecl *
|
2011-10-15 05:34:45 +08:00
|
|
|
ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, DeclContext *decl_ctx)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-10-15 05:34:45 +08:00
|
|
|
NamespaceDecl *namespace_decl = NULL;
|
2011-11-01 07:51:19 +08:00
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
TranslationUnitDecl *translation_unit_decl = ast->getTranslationUnitDecl ();
|
|
|
|
if (decl_ctx == NULL)
|
|
|
|
decl_ctx = translation_unit_decl;
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (name)
|
|
|
|
{
|
2011-10-15 05:34:45 +08:00
|
|
|
IdentifierInfo &identifier_info = ast->Idents.get(name);
|
|
|
|
DeclarationName decl_name (&identifier_info);
|
|
|
|
clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
|
|
|
|
for (clang::DeclContext::lookup_iterator pos = result.first, end = result.second; pos != end; ++pos)
|
|
|
|
{
|
|
|
|
namespace_decl = dyn_cast<clang::NamespaceDecl>(*pos);
|
|
|
|
if (namespace_decl)
|
|
|
|
return namespace_decl;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace_decl = NamespaceDecl::Create(*ast, decl_ctx, SourceLocation(), SourceLocation(), &identifier_info);
|
|
|
|
|
2011-11-01 07:51:19 +08:00
|
|
|
decl_ctx->addDecl (namespace_decl);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (decl_ctx == translation_unit_decl)
|
|
|
|
{
|
|
|
|
namespace_decl = translation_unit_decl->getAnonymousNamespace();
|
|
|
|
if (namespace_decl)
|
|
|
|
return namespace_decl;
|
|
|
|
|
|
|
|
namespace_decl = NamespaceDecl::Create(*ast, decl_ctx, SourceLocation(), SourceLocation(), NULL);
|
|
|
|
translation_unit_decl->setAnonymousNamespace (namespace_decl);
|
|
|
|
translation_unit_decl->addDecl (namespace_decl);
|
|
|
|
assert (namespace_decl == translation_unit_decl->getAnonymousNamespace());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
|
|
|
|
if (parent_namespace_decl)
|
|
|
|
{
|
|
|
|
namespace_decl = parent_namespace_decl->getAnonymousNamespace();
|
|
|
|
if (namespace_decl)
|
|
|
|
return namespace_decl;
|
|
|
|
namespace_decl = NamespaceDecl::Create(*ast, decl_ctx, SourceLocation(), SourceLocation(), NULL);
|
|
|
|
parent_namespace_decl->setAnonymousNamespace (namespace_decl);
|
|
|
|
parent_namespace_decl->addDecl (namespace_decl);
|
|
|
|
assert (namespace_decl == parent_namespace_decl->getAnonymousNamespace());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// BAD!!!
|
|
|
|
}
|
|
|
|
}
|
2011-10-26 09:06:27 +08:00
|
|
|
|
2011-11-01 07:51:19 +08:00
|
|
|
|
|
|
|
if (namespace_decl)
|
|
|
|
{
|
|
|
|
// If we make it here, we are creating the anonymous namespace decl
|
|
|
|
// for the first time, so we need to do the using directive magic
|
|
|
|
// like SEMA does
|
|
|
|
UsingDirectiveDecl* using_directive_decl = UsingDirectiveDecl::Create (*ast,
|
|
|
|
decl_ctx,
|
|
|
|
SourceLocation(),
|
|
|
|
SourceLocation(),
|
|
|
|
NestedNameSpecifierLoc(),
|
|
|
|
SourceLocation(),
|
|
|
|
namespace_decl,
|
|
|
|
decl_ctx);
|
|
|
|
using_directive_decl->setImplicit();
|
|
|
|
decl_ctx->addDecl(using_directive_decl);
|
|
|
|
}
|
|
|
|
}
|
2011-10-26 09:06:27 +08:00
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
2011-11-01 07:51:19 +08:00
|
|
|
VerifyDecl(namespace_decl);
|
2011-10-26 09:06:27 +08:00
|
|
|
#endif
|
2011-10-15 05:34:45 +08:00
|
|
|
return namespace_decl;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark Function Types
|
|
|
|
|
|
|
|
FunctionDecl *
|
2011-10-15 06:47:18 +08:00
|
|
|
ClangASTContext::CreateFunctionDeclaration (DeclContext *decl_ctx, const char *name, clang_type_t function_clang_type, int storage, bool is_inline)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-10-15 06:47:18 +08:00
|
|
|
FunctionDecl *func_decl = NULL;
|
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
if (decl_ctx == NULL)
|
|
|
|
decl_ctx = ast->getTranslationUnitDecl();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-10-15 06:47:18 +08:00
|
|
|
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);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-10-15 06:47:18 +08:00
|
|
|
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);
|
2011-10-26 09:06:27 +08:00
|
|
|
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
|
|
|
VerifyDecl(func_decl);
|
|
|
|
#endif
|
|
|
|
|
2011-10-15 06:47:18 +08:00
|
|
|
return func_decl;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ClangASTContext::CreateFunctionType (ASTContext *ast,
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t result_type,
|
|
|
|
clang_type_t *args,
|
2010-09-17 04:40:25 +08:00
|
|
|
unsigned num_args,
|
|
|
|
bool is_variadic,
|
|
|
|
unsigned type_quals)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
assert (ast != NULL);
|
2010-06-09 00:52:24 +08:00
|
|
|
std::vector<QualType> qual_type_args;
|
|
|
|
for (unsigned i=0; i<num_args; ++i)
|
|
|
|
qual_type_args.push_back (QualType::getFromOpaquePtr(args[i]));
|
|
|
|
|
|
|
|
// TODO: Detect calling convention in DWARF?
|
2011-01-19 07:32:05 +08:00
|
|
|
FunctionProtoType::ExtProtoInfo proto_info;
|
|
|
|
proto_info.Variadic = is_variadic;
|
2011-03-15 08:17:19 +08:00
|
|
|
proto_info.ExceptionSpecType = EST_None;
|
2011-01-19 07:32:05 +08:00
|
|
|
proto_info.TypeQuals = type_quals;
|
2011-03-15 08:17:19 +08:00
|
|
|
proto_info.RefQualifier = RQ_None;
|
2011-01-19 07:32:05 +08:00
|
|
|
proto_info.NumExceptions = 0;
|
|
|
|
proto_info.Exceptions = NULL;
|
|
|
|
|
2011-10-15 06:47:18 +08:00
|
|
|
return ast->getFunctionType (QualType::getFromOpaquePtr(result_type),
|
|
|
|
qual_type_args.empty() ? NULL : &qual_type_args.front(),
|
|
|
|
qual_type_args.size(),
|
|
|
|
proto_info).getAsOpaquePtr(); // NoReturn);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ParmVarDecl *
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::CreateParameterDeclaration (const char *name, clang_type_t param_type, int storage)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
assert (ast != NULL);
|
|
|
|
return ParmVarDecl::Create(*ast,
|
|
|
|
ast->getTranslationUnitDecl(),
|
2010-06-09 00:52:24 +08:00
|
|
|
SourceLocation(),
|
2011-03-15 08:17:19 +08:00
|
|
|
SourceLocation(),
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
name && name[0] ? &ast->Idents.get(name) : NULL,
|
2010-09-17 04:40:25 +08:00
|
|
|
QualType::getFromOpaquePtr(param_type),
|
2010-06-09 00:52:24 +08:00
|
|
|
NULL,
|
|
|
|
(VarDecl::StorageClass)storage,
|
|
|
|
(VarDecl::StorageClass)storage,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ClangASTContext::SetFunctionParameters (FunctionDecl *function_decl, ParmVarDecl **params, unsigned num_params)
|
|
|
|
{
|
|
|
|
if (function_decl)
|
2011-10-08 07:18:13 +08:00
|
|
|
function_decl->setParams (ArrayRef<ParmVarDecl*>(params, num_params));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark Array Types
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::CreateArrayType (clang_type_t element_type, size_t element_count, uint32_t bit_stride)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (element_type)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
assert (ast != NULL);
|
2010-06-09 00:52:24 +08:00
|
|
|
llvm::APInt ap_element_count (64, element_count);
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return ast->getConstantArrayType(QualType::getFromOpaquePtr(element_type),
|
2010-06-09 00:52:24 +08:00
|
|
|
ap_element_count,
|
|
|
|
ArrayType::Normal,
|
|
|
|
0).getAsOpaquePtr(); // ElemQuals
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark TagDecl
|
|
|
|
|
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::StartTagDeclarationDefinition (clang_type_t clang_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
2011-01-27 12:42:51 +08:00
|
|
|
const clang::Type *t = qual_type.getTypePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (t)
|
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const TagType *tag_type = dyn_cast<TagType>(t);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (tag_type)
|
|
|
|
{
|
|
|
|
TagDecl *tag_decl = tag_type->getDecl();
|
|
|
|
if (tag_decl)
|
|
|
|
{
|
|
|
|
tag_decl->startDefinition();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::CompleteTagDeclarationDefinition (clang_type_t clang_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
2010-09-29 11:44:17 +08:00
|
|
|
|
|
|
|
CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
|
|
|
|
|
|
|
|
if (cxx_record_decl)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-09-29 11:44:17 +08:00
|
|
|
cxx_record_decl->completeDefinition();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-01-27 12:42:51 +08:00
|
|
|
const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type);
|
2010-10-25 08:29:48 +08:00
|
|
|
|
|
|
|
if (objc_class_type)
|
|
|
|
{
|
|
|
|
ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
|
|
|
|
|
|
|
|
class_interface_decl->setForwardDecl(false);
|
|
|
|
}
|
|
|
|
|
2010-09-29 11:44:17 +08:00
|
|
|
const EnumType *enum_type = dyn_cast<EnumType>(qual_type.getTypePtr());
|
|
|
|
|
|
|
|
if (enum_type)
|
|
|
|
{
|
|
|
|
EnumDecl *enum_decl = enum_type->getDecl();
|
|
|
|
|
|
|
|
if (enum_decl)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-09-29 11:44:17 +08:00
|
|
|
/// TODO This really needs to be fixed.
|
|
|
|
|
|
|
|
unsigned NumPositiveBits = 1;
|
|
|
|
unsigned NumNegativeBits = 0;
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast = getASTContext();
|
2010-10-12 12:29:14 +08:00
|
|
|
|
|
|
|
QualType promotion_qual_type;
|
|
|
|
// If the enum integer type is less than an integer in bit width,
|
|
|
|
// then we must promote it to an integer size.
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (ast->getTypeSize(enum_decl->getIntegerType()) < ast->getTypeSize(ast->IntTy))
|
2010-10-12 12:29:14 +08:00
|
|
|
{
|
|
|
|
if (enum_decl->getIntegerType()->isSignedIntegerType())
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
promotion_qual_type = ast->IntTy;
|
2010-10-12 12:29:14 +08:00
|
|
|
else
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
promotion_qual_type = ast->UnsignedIntTy;
|
2010-10-12 12:29:14 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
promotion_qual_type = enum_decl->getIntegerType();
|
|
|
|
|
|
|
|
enum_decl->completeDefinition(enum_decl->getIntegerType(), promotion_qual_type, NumPositiveBits, NumNegativeBits);
|
2010-09-29 11:44:17 +08:00
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark Enumeration Types
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2011-01-14 12:54:56 +08:00
|
|
|
ClangASTContext::CreateEnumerationType
|
|
|
|
(
|
|
|
|
const char *name,
|
|
|
|
DeclContext *decl_ctx,
|
|
|
|
const Declaration &decl,
|
|
|
|
clang_type_t integer_qual_type
|
|
|
|
)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
// TODO: Do something intelligent with the Declaration object passed in
|
|
|
|
// like maybe filling in the SourceLocation with it...
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
assert (ast != NULL);
|
2010-10-12 12:29:14 +08:00
|
|
|
|
|
|
|
// TODO: ask about these...
|
|
|
|
// const bool IsScoped = false;
|
|
|
|
// const bool IsFixed = false;
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
EnumDecl *enum_decl = EnumDecl::Create (*ast,
|
2011-01-14 12:54:56 +08:00
|
|
|
decl_ctx,
|
2010-10-12 12:29:14 +08:00
|
|
|
SourceLocation(),
|
|
|
|
SourceLocation(),
|
2011-03-15 08:17:19 +08:00
|
|
|
name && name[0] ? &ast->Idents.get(name) : NULL,
|
2010-12-13 09:26:27 +08:00
|
|
|
NULL,
|
|
|
|
false, // IsScoped
|
|
|
|
false, // IsScopedUsingClassTag
|
|
|
|
false); // IsFixed
|
2011-01-18 09:03:44 +08:00
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (enum_decl)
|
2010-09-13 07:17:56 +08:00
|
|
|
{
|
|
|
|
// TODO: check if we should be setting the promotion type too?
|
|
|
|
enum_decl->setIntegerType(QualType::getFromOpaquePtr (integer_qual_type));
|
2011-01-18 09:03:44 +08:00
|
|
|
|
|
|
|
enum_decl->setAccess(AS_public); // TODO respect what's in the debug info
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return ast->getTagDeclType(enum_decl).getAsOpaquePtr();
|
2010-09-13 07:17:56 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::GetEnumerationIntegerType (clang_type_t enum_clang_type)
|
|
|
|
{
|
|
|
|
QualType enum_qual_type (QualType::getFromOpaquePtr(enum_clang_type));
|
|
|
|
|
2011-01-27 12:42:51 +08:00
|
|
|
const clang::Type *clang_type = enum_qual_type.getTypePtr();
|
2010-09-29 09:12:09 +08:00
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
const EnumType *enum_type = dyn_cast<EnumType>(clang_type);
|
|
|
|
if (enum_type)
|
|
|
|
{
|
|
|
|
EnumDecl *enum_decl = enum_type->getDecl();
|
|
|
|
if (enum_decl)
|
|
|
|
return enum_decl->getIntegerType().getAsOpaquePtr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
|
|
|
ClangASTContext::AddEnumerationValueToEnumerationType
|
|
|
|
(
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t enum_clang_type,
|
|
|
|
clang_type_t enumerator_clang_type,
|
2010-06-09 00:52:24 +08:00
|
|
|
const Declaration &decl,
|
|
|
|
const char *name,
|
|
|
|
int64_t enum_value,
|
|
|
|
uint32_t enum_value_bit_size
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (enum_clang_type && enumerator_clang_type && name)
|
|
|
|
{
|
|
|
|
// TODO: Do something intelligent with the Declaration object passed in
|
|
|
|
// like maybe filling in the SourceLocation with it...
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast = getASTContext();
|
2010-06-09 00:52:24 +08:00
|
|
|
IdentifierTable *identifier_table = getIdentifierTable();
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
assert (ast != NULL);
|
2010-06-09 00:52:24 +08:00
|
|
|
assert (identifier_table != NULL);
|
|
|
|
QualType enum_qual_type (QualType::getFromOpaquePtr(enum_clang_type));
|
|
|
|
|
2011-01-27 12:42:51 +08:00
|
|
|
const clang::Type *clang_type = enum_qual_type.getTypePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
const EnumType *enum_type = dyn_cast<EnumType>(clang_type);
|
|
|
|
|
|
|
|
if (enum_type)
|
|
|
|
{
|
|
|
|
llvm::APSInt enum_llvm_apsint(enum_value_bit_size, false);
|
|
|
|
enum_llvm_apsint = enum_value;
|
|
|
|
EnumConstantDecl *enumerator_decl =
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
EnumConstantDecl::Create (*ast,
|
|
|
|
enum_type->getDecl(),
|
|
|
|
SourceLocation(),
|
|
|
|
name ? &identifier_table->get(name) : NULL, // Identifier
|
|
|
|
QualType::getFromOpaquePtr(enumerator_clang_type),
|
|
|
|
NULL,
|
|
|
|
enum_llvm_apsint);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (enumerator_decl)
|
|
|
|
{
|
|
|
|
enum_type->getDecl()->addDecl(enumerator_decl);
|
2011-10-26 09:06:27 +08:00
|
|
|
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
|
|
|
VerifyDecl(enumerator_decl);
|
|
|
|
#endif
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark Pointers & References
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::CreatePointerType (clang_type_t clang_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-14 10:59:59 +08:00
|
|
|
return CreatePointerType (getASTContext(), clang_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::CreatePointerType (clang::ASTContext *ast, clang_type_t clang_type)
|
|
|
|
{
|
|
|
|
if (ast && clang_type)
|
2010-07-30 04:06:32 +08:00
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
|
2010-09-13 11:32:57 +08:00
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
2010-07-30 04:06:32 +08:00
|
|
|
{
|
|
|
|
case clang::Type::ObjCObject:
|
|
|
|
case clang::Type::ObjCInterface:
|
2010-12-14 10:59:59 +08:00
|
|
|
return ast->getObjCObjectPointerType(qual_type).getAsOpaquePtr();
|
2010-07-30 04:06:32 +08:00
|
|
|
|
|
|
|
default:
|
2010-12-14 10:59:59 +08:00
|
|
|
return ast->getPointerType(qual_type).getAsOpaquePtr();
|
2010-07-30 04:06:32 +08:00
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2011-01-13 16:53:35 +08:00
|
|
|
ClangASTContext::CreateLValueReferenceType (clang::ASTContext *ast,
|
|
|
|
clang_type_t clang_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (clang_type)
|
2011-01-13 16:53:35 +08:00
|
|
|
return ast->getLValueReferenceType (QualType::getFromOpaquePtr(clang_type)).getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
2011-01-13 16:53:35 +08:00
|
|
|
ClangASTContext::CreateRValueReferenceType (clang::ASTContext *ast,
|
|
|
|
clang_type_t clang_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (clang_type)
|
2011-01-13 16:53:35 +08:00
|
|
|
return ast->getRValueReferenceType (QualType::getFromOpaquePtr(clang_type)).getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::CreateMemberPointerType (clang_type_t clang_pointee_type, clang_type_t clang_class_type)
|
2010-06-12 09:20:30 +08:00
|
|
|
{
|
|
|
|
if (clang_pointee_type && clang_pointee_type)
|
|
|
|
return getASTContext()->getMemberPointerType(QualType::getFromOpaquePtr(clang_pointee_type),
|
|
|
|
QualType::getFromOpaquePtr(clang_class_type).getTypePtr()).getAsOpaquePtr();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-26 07:55:37 +08:00
|
|
|
uint32_t
|
2010-06-09 00:52:24 +08:00
|
|
|
ClangASTContext::GetPointerBitSize ()
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast = getASTContext();
|
|
|
|
return ast->getTypeSize(ast->VoidPtrTy);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-06-30 06:09:02 +08:00
|
|
|
bool
|
|
|
|
ClangASTContext::IsPossibleDynamicType (clang::ASTContext *ast, clang_type_t clang_type, clang_type_t *dynamic_pointee_type)
|
|
|
|
{
|
|
|
|
QualType pointee_qual_type;
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
bool success = false;
|
|
|
|
switch (type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::Builtin:
|
|
|
|
if (cast<clang::BuiltinType>(qual_type)->getKind() == clang::BuiltinType::ObjCId)
|
|
|
|
{
|
|
|
|
if (dynamic_pointee_type)
|
|
|
|
*dynamic_pointee_type = clang_type;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::ObjCObjectPointer:
|
|
|
|
if (dynamic_pointee_type)
|
|
|
|
*dynamic_pointee_type = cast<ObjCObjectPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case clang::Type::Pointer:
|
|
|
|
pointee_qual_type = cast<PointerType>(qual_type)->getPointeeType();
|
|
|
|
success = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::LValueReference:
|
|
|
|
case clang::Type::RValueReference:
|
|
|
|
pointee_qual_type = cast<ReferenceType>(qual_type)->getPointeeType();
|
|
|
|
success = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::Typedef:
|
2011-07-09 02:27:39 +08:00
|
|
|
return ClangASTContext::IsPossibleDynamicType (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), dynamic_pointee_type);
|
2011-08-12 07:56:13 +08:00
|
|
|
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::IsPossibleDynamicType (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), dynamic_pointee_type);
|
|
|
|
|
2011-06-30 06:09:02 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
// Check to make sure what we are pointing too is a possible dynamic C++ type
|
|
|
|
// We currently accept any "void *" (in case we have a class that has been
|
|
|
|
// watered down to an opaque pointer) and virtual C++ classes.
|
|
|
|
const clang::Type::TypeClass pointee_type_class = pointee_qual_type->getTypeClass();
|
|
|
|
switch (pointee_type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::Builtin:
|
|
|
|
switch (cast<clang::BuiltinType>(pointee_qual_type)->getKind())
|
|
|
|
{
|
|
|
|
case clang::BuiltinType::UnknownAny:
|
|
|
|
case clang::BuiltinType::Void:
|
|
|
|
if (dynamic_pointee_type)
|
|
|
|
*dynamic_pointee_type = pointee_qual_type.getAsOpaquePtr();
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case clang::BuiltinType::NullPtr:
|
|
|
|
case clang::BuiltinType::Bool:
|
|
|
|
case clang::BuiltinType::Char_U:
|
|
|
|
case clang::BuiltinType::UChar:
|
|
|
|
case clang::BuiltinType::WChar_U:
|
|
|
|
case clang::BuiltinType::Char16:
|
|
|
|
case clang::BuiltinType::Char32:
|
|
|
|
case clang::BuiltinType::UShort:
|
|
|
|
case clang::BuiltinType::UInt:
|
|
|
|
case clang::BuiltinType::ULong:
|
|
|
|
case clang::BuiltinType::ULongLong:
|
|
|
|
case clang::BuiltinType::UInt128:
|
|
|
|
case clang::BuiltinType::Char_S:
|
|
|
|
case clang::BuiltinType::SChar:
|
|
|
|
case clang::BuiltinType::WChar_S:
|
|
|
|
case clang::BuiltinType::Short:
|
|
|
|
case clang::BuiltinType::Int:
|
|
|
|
case clang::BuiltinType::Long:
|
|
|
|
case clang::BuiltinType::LongLong:
|
|
|
|
case clang::BuiltinType::Int128:
|
|
|
|
case clang::BuiltinType::Float:
|
|
|
|
case clang::BuiltinType::Double:
|
|
|
|
case clang::BuiltinType::LongDouble:
|
|
|
|
case clang::BuiltinType::Dependent:
|
|
|
|
case clang::BuiltinType::Overload:
|
|
|
|
case clang::BuiltinType::ObjCId:
|
|
|
|
case clang::BuiltinType::ObjCClass:
|
|
|
|
case clang::BuiltinType::ObjCSel:
|
|
|
|
case clang::BuiltinType::BoundMember:
|
2011-10-22 11:33:13 +08:00
|
|
|
case clang::BuiltinType::Half:
|
|
|
|
case clang::BuiltinType::ARCUnbridgedCast:
|
2011-11-04 11:34:56 +08:00
|
|
|
//case clang::BuiltinType::PseudoObject:
|
2011-06-30 06:09:02 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::Record:
|
|
|
|
{
|
|
|
|
CXXRecordDecl *cxx_record_decl = pointee_qual_type->getAsCXXRecordDecl();
|
|
|
|
if (cxx_record_decl)
|
|
|
|
{
|
|
|
|
if (GetCompleteQualType (ast, pointee_qual_type))
|
|
|
|
{
|
|
|
|
success = cxx_record_decl->isDynamicClass();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We failed to get the complete type, so we have to
|
|
|
|
// treat this as a void * which we might possibly be
|
|
|
|
// able to complete
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
if (dynamic_pointee_type)
|
|
|
|
*dynamic_pointee_type = pointee_qual_type.getAsOpaquePtr();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::ObjCObject:
|
|
|
|
case clang::Type::ObjCInterface:
|
|
|
|
{
|
|
|
|
const clang::ObjCObjectType *objc_class_type = pointee_qual_type->getAsObjCQualifiedInterfaceType();
|
|
|
|
if (objc_class_type)
|
|
|
|
{
|
|
|
|
GetCompleteQualType (ast, pointee_qual_type);
|
|
|
|
if (dynamic_pointee_type)
|
|
|
|
*dynamic_pointee_type = pointee_qual_type.getAsOpaquePtr();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dynamic_pointee_type)
|
|
|
|
*dynamic_pointee_type = NULL;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-30 08:49:24 +08:00
|
|
|
bool
|
|
|
|
ClangASTContext::IsPossibleCPlusPlusDynamicType (clang::ASTContext *ast, clang_type_t clang_type, clang_type_t *dynamic_pointee_type)
|
|
|
|
{
|
|
|
|
QualType pointee_qual_type;
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
bool success = false;
|
|
|
|
switch (type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::Pointer:
|
|
|
|
pointee_qual_type = cast<PointerType>(qual_type)->getPointeeType();
|
|
|
|
success = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::LValueReference:
|
|
|
|
case clang::Type::RValueReference:
|
|
|
|
pointee_qual_type = cast<ReferenceType>(qual_type)->getPointeeType();
|
|
|
|
success = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::Typedef:
|
|
|
|
return ClangASTContext::IsPossibleCPlusPlusDynamicType (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), dynamic_pointee_type);
|
|
|
|
|
2011-08-12 07:56:13 +08:00
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::IsPossibleCPlusPlusDynamicType (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
|
|
|
|
|
2011-05-30 08:49:24 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
// Check to make sure what we are pointing too is a possible dynamic C++ type
|
|
|
|
// We currently accept any "void *" (in case we have a class that has been
|
|
|
|
// watered down to an opaque pointer) and virtual C++ classes.
|
|
|
|
const clang::Type::TypeClass pointee_type_class = pointee_qual_type->getTypeClass();
|
|
|
|
switch (pointee_type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::Builtin:
|
|
|
|
switch (cast<clang::BuiltinType>(pointee_qual_type)->getKind())
|
|
|
|
{
|
|
|
|
case clang::BuiltinType::UnknownAny:
|
|
|
|
case clang::BuiltinType::Void:
|
|
|
|
if (dynamic_pointee_type)
|
|
|
|
*dynamic_pointee_type = pointee_qual_type.getAsOpaquePtr();
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case clang::BuiltinType::NullPtr:
|
|
|
|
case clang::BuiltinType::Bool:
|
|
|
|
case clang::BuiltinType::Char_U:
|
|
|
|
case clang::BuiltinType::UChar:
|
|
|
|
case clang::BuiltinType::WChar_U:
|
|
|
|
case clang::BuiltinType::Char16:
|
|
|
|
case clang::BuiltinType::Char32:
|
|
|
|
case clang::BuiltinType::UShort:
|
|
|
|
case clang::BuiltinType::UInt:
|
|
|
|
case clang::BuiltinType::ULong:
|
|
|
|
case clang::BuiltinType::ULongLong:
|
|
|
|
case clang::BuiltinType::UInt128:
|
|
|
|
case clang::BuiltinType::Char_S:
|
|
|
|
case clang::BuiltinType::SChar:
|
|
|
|
case clang::BuiltinType::WChar_S:
|
|
|
|
case clang::BuiltinType::Short:
|
|
|
|
case clang::BuiltinType::Int:
|
|
|
|
case clang::BuiltinType::Long:
|
|
|
|
case clang::BuiltinType::LongLong:
|
|
|
|
case clang::BuiltinType::Int128:
|
|
|
|
case clang::BuiltinType::Float:
|
|
|
|
case clang::BuiltinType::Double:
|
|
|
|
case clang::BuiltinType::LongDouble:
|
|
|
|
case clang::BuiltinType::Dependent:
|
|
|
|
case clang::BuiltinType::Overload:
|
|
|
|
case clang::BuiltinType::ObjCId:
|
|
|
|
case clang::BuiltinType::ObjCClass:
|
|
|
|
case clang::BuiltinType::ObjCSel:
|
|
|
|
case clang::BuiltinType::BoundMember:
|
2011-10-22 11:33:13 +08:00
|
|
|
case clang::BuiltinType::Half:
|
|
|
|
case clang::BuiltinType::ARCUnbridgedCast:
|
2011-11-04 11:34:56 +08:00
|
|
|
//case clang::BuiltinType::PseudoObject:
|
2011-05-30 08:49:24 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case clang::Type::Record:
|
|
|
|
{
|
|
|
|
CXXRecordDecl *cxx_record_decl = pointee_qual_type->getAsCXXRecordDecl();
|
|
|
|
if (cxx_record_decl)
|
|
|
|
{
|
|
|
|
if (GetCompleteQualType (ast, pointee_qual_type))
|
|
|
|
{
|
2011-06-02 09:26:44 +08:00
|
|
|
success = cxx_record_decl->isDynamicClass();
|
2011-05-30 08:49:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We failed to get the complete type, so we have to
|
|
|
|
// treat this as a void * which we might possibly be
|
|
|
|
// able to complete
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
if (dynamic_pointee_type)
|
|
|
|
*dynamic_pointee_type = pointee_qual_type.getAsOpaquePtr();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dynamic_pointee_type)
|
|
|
|
*dynamic_pointee_type = NULL;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-10-28 03:41:13 +08:00
|
|
|
bool
|
|
|
|
ClangASTContext::IsReferenceType (clang_type_t clang_type, clang_type_t *target_type)
|
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
|
|
|
|
switch (type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::LValueReference:
|
|
|
|
if (target_type)
|
|
|
|
*target_type = cast<LValueReferenceType>(qual_type)->desugar().getAsOpaquePtr();
|
|
|
|
return true;
|
|
|
|
case clang::Type::RValueReference:
|
|
|
|
if (target_type)
|
|
|
|
*target_type = cast<LValueReferenceType>(qual_type)->desugar().getAsOpaquePtr();
|
|
|
|
return true;
|
|
|
|
case clang::Type::Typedef:
|
|
|
|
return ClangASTContext::IsReferenceType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::IsReferenceType (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2011-05-30 08:49:24 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::IsPointerOrReferenceType (clang_type_t clang_type, clang_type_t*target_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
2010-09-13 11:32:57 +08:00
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-25 08:29:48 +08:00
|
|
|
case clang::Type::Builtin:
|
|
|
|
switch (cast<clang::BuiltinType>(qual_type)->getKind())
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case clang::BuiltinType::ObjCId:
|
|
|
|
case clang::BuiltinType::ObjCClass:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::ObjCObjectPointer:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (target_type)
|
|
|
|
*target_type = cast<ObjCObjectPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
|
|
|
|
return true;
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::BlockPointer:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (target_type)
|
|
|
|
*target_type = cast<BlockPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
|
|
|
|
return true;
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Pointer:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (target_type)
|
|
|
|
*target_type = cast<PointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
|
|
|
|
return true;
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::MemberPointer:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (target_type)
|
|
|
|
*target_type = cast<MemberPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
|
|
|
|
return true;
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::LValueReference:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (target_type)
|
|
|
|
*target_type = cast<LValueReferenceType>(qual_type)->desugar().getAsOpaquePtr();
|
|
|
|
return true;
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::RValueReference:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (target_type)
|
|
|
|
*target_type = cast<LValueReferenceType>(qual_type)->desugar().getAsOpaquePtr();
|
|
|
|
return true;
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Typedef:
|
2010-12-13 09:26:27 +08:00
|
|
|
return ClangASTContext::IsPointerOrReferenceType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
|
2011-08-12 07:56:13 +08:00
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::IsPointerOrReferenceType (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
|
2010-06-09 00:52:24 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::IsIntegerType (clang_type_t clang_type, bool &is_signed)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (!clang_type)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
const BuiltinType *builtin_type = dyn_cast<BuiltinType>(qual_type->getCanonicalTypeInternal());
|
|
|
|
|
|
|
|
if (builtin_type)
|
|
|
|
{
|
|
|
|
if (builtin_type->isInteger())
|
|
|
|
is_signed = builtin_type->isSignedInteger();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-07-09 02:27:39 +08:00
|
|
|
ClangASTContext::IsPointerType (clang_type_t clang_type, clang_type_t *target_type)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-07-09 02:27:39 +08:00
|
|
|
if (target_type)
|
|
|
|
*target_type = NULL;
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
2010-09-13 11:32:57 +08:00
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-25 08:29:48 +08:00
|
|
|
case clang::Type::Builtin:
|
|
|
|
switch (cast<clang::BuiltinType>(qual_type)->getKind())
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case clang::BuiltinType::ObjCId:
|
|
|
|
case clang::BuiltinType::ObjCClass:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::ObjCObjectPointer:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (target_type)
|
|
|
|
*target_type = cast<ObjCObjectPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
|
|
|
|
return true;
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::BlockPointer:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (target_type)
|
|
|
|
*target_type = cast<BlockPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
|
|
|
|
return true;
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Pointer:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (target_type)
|
|
|
|
*target_type = cast<PointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
|
|
|
|
return true;
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::MemberPointer:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (target_type)
|
|
|
|
*target_type = cast<MemberPointerType>(qual_type)->getPointeeType().getAsOpaquePtr();
|
|
|
|
return true;
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::Typedef:
|
2011-07-09 02:27:39 +08:00
|
|
|
return ClangASTContext::IsPointerType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), target_type);
|
2011-08-12 07:56:13 +08:00
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::IsPointerType (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), target_type);
|
2010-06-09 00:52:24 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::IsFloatingPointType (clang_type_t clang_type, uint32_t &count, bool &is_complex)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
|
|
|
|
if (const BuiltinType *BT = dyn_cast<BuiltinType>(qual_type->getCanonicalTypeInternal()))
|
|
|
|
{
|
|
|
|
clang::BuiltinType::Kind kind = BT->getKind();
|
|
|
|
if (kind >= BuiltinType::Float && kind <= BuiltinType::LongDouble)
|
|
|
|
{
|
|
|
|
count = 1;
|
|
|
|
is_complex = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (const ComplexType *CT = dyn_cast<ComplexType>(qual_type->getCanonicalTypeInternal()))
|
|
|
|
{
|
|
|
|
if (IsFloatingPointType(CT->getElementType().getAsOpaquePtr(), count, is_complex))
|
|
|
|
{
|
|
|
|
count = 2;
|
|
|
|
is_complex = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (const VectorType *VT = dyn_cast<VectorType>(qual_type->getCanonicalTypeInternal()))
|
|
|
|
{
|
|
|
|
if (IsFloatingPointType(VT->getElementType().getAsOpaquePtr(), count, is_complex))
|
|
|
|
{
|
|
|
|
count = VT->getNumElements();
|
|
|
|
is_complex = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-07-06 10:13:41 +08:00
|
|
|
bool
|
|
|
|
ClangASTContext::IsScalarType (lldb::clang_type_t clang_type)
|
|
|
|
{
|
|
|
|
bool is_signed;
|
|
|
|
if (ClangASTContext::IsIntegerType(clang_type, is_signed))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
uint32_t count;
|
|
|
|
bool is_complex;
|
|
|
|
return ClangASTContext::IsFloatingPointType(clang_type, count, is_complex) && !is_complex;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ClangASTContext::IsPointerToScalarType (lldb::clang_type_t clang_type)
|
|
|
|
{
|
|
|
|
if (!IsPointerType(clang_type))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
lldb::clang_type_t pointee_type = qual_type.getTypePtr()->getPointeeType().getAsOpaquePtr();
|
|
|
|
return IsScalarType(pointee_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ClangASTContext::IsArrayOfScalarType (lldb::clang_type_t clang_type)
|
|
|
|
{
|
|
|
|
if (!IsArrayType(clang_type))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
lldb::clang_type_t item_type = cast<ArrayType>(qual_type.getTypePtr())->getElementType().getAsOpaquePtr();
|
|
|
|
return IsScalarType(item_type);
|
|
|
|
}
|
|
|
|
|
2010-10-15 06:52:14 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
ClangASTContext::GetCXXClassName (clang_type_t clang_type, std::string &class_name)
|
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
|
|
|
|
CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
|
|
|
|
if (cxx_record_decl)
|
|
|
|
{
|
|
|
|
class_name.assign (cxx_record_decl->getIdentifier()->getNameStart());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class_name.clear();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-24 13:15:53 +08:00
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::IsCXXClassType (clang_type_t clang_type)
|
2010-09-24 13:15:53 +08:00
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
if (qual_type->getAsCXXRecordDecl() != NULL)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-10-14 07:13:20 +08:00
|
|
|
bool
|
|
|
|
ClangASTContext::IsBeingDefined (lldb::clang_type_t clang_type)
|
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
const clang::TagType *tag_type = dyn_cast<clang::TagType>(qual_type);
|
|
|
|
if (tag_type)
|
|
|
|
return tag_type->isBeingDefined();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-09-24 13:15:53 +08:00
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::IsObjCClassType (clang_type_t clang_type)
|
2010-09-24 13:15:53 +08:00
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
if (qual_type->isObjCObjectOrInterfaceType())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-27 11:32:59 +08:00
|
|
|
bool
|
|
|
|
ClangASTContext::IsCharType (clang_type_t clang_type)
|
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
return QualType::getFromOpaquePtr(clang_type)->isCharType();
|
|
|
|
return false;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::IsCStringType (clang_type_t clang_type, uint32_t &length)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-27 11:32:59 +08:00
|
|
|
clang_type_t pointee_or_element_clang_type = NULL;
|
|
|
|
Flags type_flags (ClangASTContext::GetTypeInfo (clang_type, NULL, &pointee_or_element_clang_type));
|
|
|
|
|
|
|
|
if (pointee_or_element_clang_type == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (type_flags.AnySet (eTypeIsArray | eTypeIsPointer))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-27 11:32:59 +08:00
|
|
|
QualType pointee_or_element_qual_type (QualType::getFromOpaquePtr (pointee_or_element_clang_type));
|
|
|
|
|
|
|
|
if (pointee_or_element_qual_type.getUnqualifiedType()->isCharType())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-27 11:32:59 +08:00
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
if (type_flags.Test (eTypeIsArray))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-27 11:32:59 +08:00
|
|
|
// We know the size of the array and it could be a C string
|
|
|
|
// since it is an array of characters
|
|
|
|
length = cast<ConstantArrayType>(qual_type.getTypePtr())->getSize().getLimitedValue();
|
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-10-27 11:32:59 +08:00
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-27 11:32:59 +08:00
|
|
|
length = 0;
|
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-09-13 11:32:57 +08:00
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::IsFunctionPointerType (clang_type_t clang_type)
|
2010-09-13 11:32:57 +08:00
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
|
|
|
|
if (qual_type->isFunctionPointerType())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
|
|
|
{
|
2011-03-15 08:17:19 +08:00
|
|
|
default:
|
|
|
|
break;
|
2010-09-13 11:32:57 +08:00
|
|
|
case clang::Type::Typedef:
|
2010-12-13 09:26:27 +08:00
|
|
|
return ClangASTContext::IsFunctionPointerType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
|
2011-08-12 07:56:13 +08:00
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::IsFunctionPointerType (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
|
2010-09-13 11:32:57 +08:00
|
|
|
|
|
|
|
case clang::Type::LValueReference:
|
|
|
|
case clang::Type::RValueReference:
|
|
|
|
{
|
2011-01-27 12:42:51 +08:00
|
|
|
const ReferenceType *reference_type = cast<ReferenceType>(qual_type.getTypePtr());
|
2010-09-13 11:32:57 +08:00
|
|
|
if (reference_type)
|
|
|
|
return ClangASTContext::IsFunctionPointerType (reference_type->getPointeeType().getAsOpaquePtr());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-27 11:32:59 +08:00
|
|
|
size_t
|
|
|
|
ClangASTContext::GetArraySize (clang_type_t clang_type)
|
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
2011-07-10 01:12:27 +08:00
|
|
|
QualType qual_type(QualType::getFromOpaquePtr(clang_type));
|
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
|
|
|
{
|
|
|
|
case clang::Type::ConstantArray:
|
|
|
|
{
|
|
|
|
const ConstantArrayType *array = cast<ConstantArrayType>(QualType::getFromOpaquePtr(clang_type).getTypePtr());
|
|
|
|
if (array)
|
|
|
|
return array->getSize().getLimitedValue();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case clang::Type::Typedef:
|
|
|
|
return ClangASTContext::GetArraySize(cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
|
2011-08-12 07:56:13 +08:00
|
|
|
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::GetArraySize(cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
|
2011-07-12 08:18:11 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2011-07-10 01:12:27 +08:00
|
|
|
}
|
2010-10-27 11:32:59 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2010-09-13 11:32:57 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::IsArrayType (clang_type_t clang_type, clang_type_t*member_type, uint64_t *size)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (!clang_type)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
|
2010-09-13 11:32:57 +08:00
|
|
|
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
|
|
|
switch (type_class)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-03-15 08:17:19 +08:00
|
|
|
default:
|
|
|
|
break;
|
2011-07-10 01:12:27 +08:00
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::ConstantArray:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (member_type)
|
|
|
|
*member_type = cast<ConstantArrayType>(qual_type)->getElementType().getAsOpaquePtr();
|
|
|
|
if (size)
|
2011-04-02 02:14:08 +08:00
|
|
|
*size = cast<ConstantArrayType>(qual_type)->getSize().getLimitedValue(ULLONG_MAX);
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
2011-07-10 01:12:27 +08:00
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::IncompleteArray:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (member_type)
|
|
|
|
*member_type = cast<IncompleteArrayType>(qual_type)->getElementType().getAsOpaquePtr();
|
|
|
|
if (size)
|
|
|
|
*size = 0;
|
|
|
|
return true;
|
2011-07-10 01:12:27 +08:00
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::VariableArray:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (member_type)
|
|
|
|
*member_type = cast<VariableArrayType>(qual_type)->getElementType().getAsOpaquePtr();
|
|
|
|
if (size)
|
|
|
|
*size = 0;
|
2011-02-02 08:52:14 +08:00
|
|
|
return true;
|
2011-07-10 01:12:27 +08:00
|
|
|
|
2010-07-22 06:12:05 +08:00
|
|
|
case clang::Type::DependentSizedArray:
|
2010-06-09 00:52:24 +08:00
|
|
|
if (member_type)
|
|
|
|
*member_type = cast<DependentSizedArrayType>(qual_type)->getElementType().getAsOpaquePtr();
|
|
|
|
if (size)
|
|
|
|
*size = 0;
|
|
|
|
return true;
|
2011-07-10 01:12:27 +08:00
|
|
|
|
|
|
|
case clang::Type::Typedef:
|
|
|
|
return ClangASTContext::IsArrayType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
|
|
|
|
member_type,
|
|
|
|
size);
|
2011-08-12 07:56:13 +08:00
|
|
|
|
|
|
|
case clang::Type::Elaborated:
|
|
|
|
return ClangASTContext::IsArrayType (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(),
|
|
|
|
member_type,
|
|
|
|
size);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark Typedefs
|
|
|
|
|
2010-09-29 09:12:09 +08:00
|
|
|
clang_type_t
|
|
|
|
ClangASTContext::CreateTypedefType (const char *name, clang_type_t clang_type, DeclContext *decl_ctx)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ASTContext *ast = getASTContext();
|
2010-06-09 00:52:24 +08:00
|
|
|
IdentifierTable *identifier_table = getIdentifierTable();
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
assert (ast != NULL);
|
2010-06-09 00:52:24 +08:00
|
|
|
assert (identifier_table != NULL);
|
|
|
|
if (decl_ctx == NULL)
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
decl_ctx = ast->getTranslationUnitDecl();
|
|
|
|
TypedefDecl *decl = TypedefDecl::Create (*ast,
|
|
|
|
decl_ctx,
|
|
|
|
SourceLocation(),
|
2011-03-15 08:17:19 +08:00
|
|
|
SourceLocation(),
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
name ? &identifier_table->get(name) : NULL, // Identifier
|
|
|
|
ast->CreateTypeSourceInfo(qual_type));
|
2011-01-18 09:03:44 +08:00
|
|
|
|
2011-10-15 06:47:18 +08:00
|
|
|
//decl_ctx->addDecl (decl);
|
|
|
|
|
2011-01-18 09:03:44 +08:00
|
|
|
decl->setAccess(AS_public); // TODO respect proper access specifier
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// Get a uniqued QualType for the typedef decl type
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return ast->getTypedefType (decl).getAsOpaquePtr();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disable this for now since I can't seem to get a nicely formatted float
|
|
|
|
// out of the APFloat class without just getting the float, double or quad
|
|
|
|
// and then using a formatted print on it which defeats the purpose. We ideally
|
|
|
|
// would like to get perfect string values for any kind of float semantics
|
|
|
|
// so we can support remote targets. The code below also requires a patch to
|
|
|
|
// llvm::APInt.
|
|
|
|
//bool
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
//ClangASTContext::ConvertFloatValueToString (ASTContext *ast, clang_type_t clang_type, const uint8_t* bytes, size_t byte_size, int apint_byte_order, std::string &float_str)
|
2010-06-09 00:52:24 +08:00
|
|
|
//{
|
|
|
|
// uint32_t count = 0;
|
|
|
|
// bool is_complex = false;
|
|
|
|
// if (ClangASTContext::IsFloatingPointType (clang_type, count, is_complex))
|
|
|
|
// {
|
|
|
|
// unsigned num_bytes_per_float = byte_size / count;
|
|
|
|
// unsigned num_bits_per_float = num_bytes_per_float * 8;
|
|
|
|
//
|
|
|
|
// float_str.clear();
|
|
|
|
// uint32_t i;
|
|
|
|
// for (i=0; i<count; i++)
|
|
|
|
// {
|
|
|
|
// APInt ap_int(num_bits_per_float, bytes + i * num_bytes_per_float, (APInt::ByteOrder)apint_byte_order);
|
|
|
|
// bool is_ieee = false;
|
|
|
|
// APFloat ap_float(ap_int, is_ieee);
|
|
|
|
// char s[1024];
|
|
|
|
// unsigned int hex_digits = 0;
|
|
|
|
// bool upper_case = false;
|
|
|
|
//
|
|
|
|
// if (ap_float.convertToHexString(s, hex_digits, upper_case, APFloat::rmNearestTiesToEven) > 0)
|
|
|
|
// {
|
|
|
|
// if (i > 0)
|
|
|
|
// float_str.append(", ");
|
|
|
|
// float_str.append(s);
|
|
|
|
// if (i == 1 && is_complex)
|
|
|
|
// float_str.append(1, 'i');
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return !float_str.empty();
|
|
|
|
// }
|
|
|
|
// return false;
|
|
|
|
//}
|
|
|
|
|
|
|
|
size_t
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
ClangASTContext::ConvertStringToFloatValue (ASTContext *ast, clang_type_t clang_type, const char *s, uint8_t *dst, size_t dst_size)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (clang_type)
|
|
|
|
{
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
uint32_t count = 0;
|
|
|
|
bool is_complex = false;
|
|
|
|
if (ClangASTContext::IsFloatingPointType (clang_type, count, is_complex))
|
|
|
|
{
|
|
|
|
// TODO: handle complex and vector types
|
|
|
|
if (count != 1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
StringRef s_sref(s);
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
APFloat ap_float(ast->getFloatTypeSemantics(qual_type), s_sref);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
const uint64_t bit_size = ast->getTypeSize (qual_type);
|
2010-06-09 00:52:24 +08:00
|
|
|
const uint64_t byte_size = bit_size / 8;
|
|
|
|
if (dst_size >= byte_size)
|
|
|
|
{
|
|
|
|
if (bit_size == sizeof(float)*8)
|
|
|
|
{
|
|
|
|
float float32 = ap_float.convertToFloat();
|
|
|
|
::memcpy (dst, &float32, byte_size);
|
|
|
|
return byte_size;
|
|
|
|
}
|
|
|
|
else if (bit_size >= 64)
|
|
|
|
{
|
|
|
|
llvm::APInt ap_int(ap_float.bitcastToAPInt());
|
|
|
|
::memcpy (dst, ap_int.getRawData(), byte_size);
|
|
|
|
return byte_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2010-09-17 10:24:29 +08:00
|
|
|
|
|
|
|
unsigned
|
2010-09-29 09:12:09 +08:00
|
|
|
ClangASTContext::GetTypeQualifiers(clang_type_t clang_type)
|
2010-09-17 10:24:29 +08:00
|
|
|
{
|
|
|
|
assert (clang_type);
|
|
|
|
|
|
|
|
QualType qual_type (QualType::getFromOpaquePtr(clang_type));
|
|
|
|
|
|
|
|
return qual_type.getQualifiers().getCVRQualifiers();
|
|
|
|
}
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
ClangASTContext::GetCompleteType (clang::ASTContext *ast, lldb::clang_type_t clang_type)
|
|
|
|
{
|
|
|
|
if (clang_type == NULL)
|
|
|
|
return false;
|
|
|
|
|
2011-01-20 12:18:48 +08:00
|
|
|
return GetCompleteQualType (ast, clang::QualType::getFromOpaquePtr(clang_type));
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
ClangASTContext::GetCompleteType (clang_type_t clang_type)
|
|
|
|
{
|
|
|
|
return ClangASTContext::GetCompleteType (getASTContext(), clang_type);
|
|
|
|
}
|
|
|
|
|
2011-06-25 08:44:06 +08:00
|
|
|
bool
|
|
|
|
ClangASTContext::GetCompleteDecl (clang::ASTContext *ast,
|
|
|
|
clang::Decl *decl)
|
|
|
|
{
|
|
|
|
if (!decl)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ExternalASTSource *ast_source = ast->getExternalSource();
|
|
|
|
|
|
|
|
if (!ast_source)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
|
|
|
|
{
|
|
|
|
if (tag_decl->getDefinition())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!tag_decl->hasExternalLexicalStorage())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ast_source->CompleteType(tag_decl);
|
|
|
|
|
|
|
|
return !tag_decl->getTypeForDecl()->isIncompleteType();
|
|
|
|
}
|
|
|
|
else if (clang::ObjCInterfaceDecl *objc_interface_decl = llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
|
|
|
|
{
|
|
|
|
if (!objc_interface_decl->isForwardDecl())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!objc_interface_decl->hasExternalLexicalStorage())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ast_source->CompleteType(objc_interface_decl);
|
|
|
|
|
|
|
|
return !objc_interface_decl->isForwardDecl();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-05 05:02:57 +08:00
|
|
|
clang::DeclContext *
|
|
|
|
ClangASTContext::GetAsDeclContext (clang::CXXMethodDecl *cxx_method_decl)
|
|
|
|
{
|
2011-08-19 14:19:25 +08:00
|
|
|
return llvm::dyn_cast<clang::DeclContext>(cxx_method_decl);
|
2011-08-05 05:02:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
clang::DeclContext *
|
|
|
|
ClangASTContext::GetAsDeclContext (clang::ObjCMethodDecl *objc_method_decl)
|
|
|
|
{
|
2011-08-19 14:19:25 +08:00
|
|
|
return llvm::dyn_cast<clang::DeclContext>(objc_method_decl);
|
2011-08-05 05:02:57 +08:00
|
|
|
}
|
|
|
|
|