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
2014-09-17 01:28:40 +08:00
# include <mutex>
2010-06-09 00:52:24 +08:00
# 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
2014-07-02 05:22:11 +08:00
// related features using "#ifndef NDEBUG" preprocessor blocks to do one thing
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
// 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"
2012-12-04 02:29:55 +08:00
# include "clang/AST/Attr.h"
2010-06-09 00:52:24 +08:00
# 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"
2012-02-07 05:28:03 +08:00
# include "clang/Basic/Diagnostic.h"
2010-06-09 00:52:24 +08:00
# 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"
2014-09-17 01:28:40 +08:00
# include "lldb/Core/ThreadSafeDenseMap.h"
2013-07-12 06:46:58 +08:00
# include "lldb/Core/UniqueCStringMap.h"
2011-10-22 11:33:13 +08:00
# include "lldb/Expression/ASTDumper.h"
2011-12-03 11:15:28 +08:00
# include "lldb/Symbol/ClangExternalASTSourceCommon.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-14 03:06:42 +08:00
# include <stdio.h>
2013-07-12 07:36:31 +08:00
# include <mutex>
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 ;
2014-09-17 01:28:40 +08:00
typedef lldb_private : : ThreadSafeDenseMap < clang : : ASTContext * , ClangASTContext * > ClangASTMap ;
2014-08-20 05:46:37 +08:00
static ClangASTMap &
GetASTMap ( )
{
2014-09-17 01:28:40 +08:00
static ClangASTMap * g_map_ptr = nullptr ;
static std : : once_flag g_once_flag ;
std : : call_once ( g_once_flag , [ ] ( ) {
g_map_ptr = new ClangASTMap ( ) ; // leaked on purpose to avoid spins
} ) ;
return * g_map_ptr ;
2014-08-20 05:46:37 +08:00
}
2013-07-12 06:46:58 +08:00
clang : : AccessSpecifier
ClangASTContext : : 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 ;
}
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.
2014-07-02 05:22:11 +08:00
// Set some properties which depend solely on the input kind; it would be nice
2010-06-09 00:52:24 +08:00
// 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 ) ;
2012-11-13 05:26:32 +08:00
Opts . LineComment = Std . hasLineComments ( ) ;
2010-06-09 00:52:24 +08:00
Opts . C99 = Std . isC99 ( ) ;
Opts . CPlusPlus = Std . isCPlusPlus ( ) ;
2013-01-02 20:55:00 +08:00
Opts . CPlusPlus11 = Std . isCPlusPlus11 ( ) ;
2010-06-09 00:52:24 +08:00
Opts . Digraphs = Std . hasDigraphs ( ) ;
Opts . GNUMode = Std . isGNUMode ( ) ;
Opts . GNUInline = ! Std . isC99 ( ) ;
Opts . HexFloats = Std . hasHexFloats ( ) ;
Opts . ImplicitInt = Std . hasImplicitInt ( ) ;
2013-01-10 10:37:22 +08:00
Opts . WChar = true ;
2010-06-09 00:52:24 +08:00
// 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")
2013-02-20 03:16:37 +08:00
Opts . setValueVisibilityMode ( 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).
2012-09-25 06:25:51 +08:00
Opts . NoInlineDefine = ! Opt ;
2010-06-09 00:52:24 +08:00
// 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 ( ) ,
2012-10-18 06:11:14 +08:00
m_target_options_rp ( ) ,
2010-06-09 00:52:24 +08:00
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 ( ) ,
2014-04-20 21:17:36 +08:00
m_callback_tag_decl ( nullptr ) ,
m_callback_objc_decl ( nullptr ) ,
m_callback_baton ( nullptr ) ,
2013-07-12 06:46:58 +08:00
m_pointer_byte_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
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 ( )
{
2014-08-20 05:46:37 +08:00
if ( m_ast_ap . get ( ) )
{
2014-09-17 01:28:40 +08:00
GetASTMap ( ) . Erase ( m_ast_ap . get ( ) ) ;
2014-08-20 05:46:37 +08:00
}
2010-06-09 00:52:24 +08:00
m_builtins_ap . reset ( ) ;
m_selector_table_ap . reset ( ) ;
m_identifier_table_ap . reset ( ) ;
m_target_info_ap . reset ( ) ;
2012-10-18 06:11:14 +08:00
m_target_options_rp . 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 ( ) ;
2012-10-18 06:11:14 +08:00
m_target_options_rp . reset ( ) ;
2010-06-09 00:52:24 +08:00
m_target_info_ap . reset ( ) ;
m_identifier_table_ap . reset ( ) ;
m_selector_table_ap . reset ( ) ;
m_builtins_ap . reset ( ) ;
2013-07-12 06:46:58 +08:00
m_pointer_byte_size = 0 ;
2010-06-09 00:52:24 +08:00
}
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 )
2014-04-20 21:17:36 +08:00
return ast - > getExternalSource ( ) ! = nullptr ;
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 ;
}
void
2014-02-28 01:18:23 +08:00
ClangASTContext : : SetExternalSource ( llvm : : IntrusiveRefCntPtr < ExternalASTSource > & ast_source_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
{
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 )
{
2014-02-28 01:18:23 +08:00
llvm : : IntrusiveRefCntPtr < ExternalASTSource > empty_ast_source_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
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 ( )
{
2014-04-20 21:17:36 +08:00
if ( m_ast_ap . get ( ) = = nullptr )
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 ( ) ,
* getIdentifierTable ( ) ,
* getSelectorTable ( ) ,
2014-05-03 23:05:45 +08:00
* getBuiltinContext ( ) ) ) ;
m_ast_ap - > InitBuiltinTypes ( * getTargetInfo ( ) ) ;
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 ) ;
2014-08-20 05:46:37 +08:00
2014-09-17 01:28:40 +08:00
GetASTMap ( ) . Insert ( m_ast_ap . get ( ) , this ) ;
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
}
2014-08-20 05:46:37 +08:00
ClangASTContext *
ClangASTContext : : GetASTContext ( clang : : ASTContext * ast )
{
2014-09-17 01:28:40 +08:00
ClangASTContext * clang_ast = GetASTMap ( ) . Lookup ( ast ) ;
2014-08-20 05:46:37 +08:00
return clang_ast ;
}
2010-06-09 00:52:24 +08:00
Builtin : : Context *
ClangASTContext : : getBuiltinContext ( )
{
2014-04-20 21:17:36 +08:00
if ( m_builtins_ap . get ( ) = = nullptr )
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 ( )
{
2014-04-20 21:17:36 +08:00
if ( m_identifier_table_ap . get ( ) = = nullptr )
m_identifier_table_ap . reset ( new IdentifierTable ( * ClangASTContext : : getLanguageOptions ( ) , nullptr ) ) ;
2010-06-09 00:52:24 +08:00
return m_identifier_table_ap . get ( ) ;
}
LangOptions *
ClangASTContext : : getLanguageOptions ( )
{
2014-04-20 21:17:36 +08:00
if ( m_language_options_ap . get ( ) = = nullptr )
2010-06-09 00:52:24 +08:00
{
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 ( )
{
2014-04-20 21:17:36 +08:00
if ( m_selector_table_ap . get ( ) = = nullptr )
2010-06-09 00:52:24 +08:00
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 ( )
{
2014-04-20 21:17:36 +08:00
if ( m_file_manager_ap . get ( ) = = nullptr )
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 ( )
{
2014-04-20 21:17:36 +08:00
if ( m_source_manager_ap . get ( ) = = nullptr )
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
{
2014-04-20 21:17:36 +08:00
if ( m_diagnostics_engine_ap . get ( ) = = nullptr )
2010-11-20 05:46:54 +08:00
{
llvm : : IntrusiveRefCntPtr < DiagnosticIDs > diag_id_sp ( new DiagnosticIDs ( ) ) ;
2012-10-25 09:00:25 +08:00
m_diagnostics_engine_ap . reset ( new DiagnosticsEngine ( diag_id_sp , new DiagnosticOptions ( ) ) ) ;
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 )
{
2012-02-04 16:49:35 +08:00
llvm : : SmallVector < char , 32 > diag_str ( 10 ) ;
2010-12-11 08:08:56 +08:00
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 :
2013-03-28 07:08:40 +08:00
Log * m_log ;
2010-12-11 08:08:56 +08:00
} ;
2011-10-08 07:18:13 +08:00
DiagnosticConsumer *
ClangASTContext : : getDiagnosticConsumer ( )
2010-12-11 08:08:56 +08:00
{
2014-04-20 21:17:36 +08:00
if ( m_diagnostic_consumer_ap . get ( ) = = nullptr )
2011-10-08 07:18:13 +08:00
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
}
2014-07-09 07:46:39 +08:00
std : : shared_ptr < TargetOptions > &
ClangASTContext : : getTargetOptions ( ) {
2014-07-05 11:06:05 +08:00
if ( m_target_options_rp . get ( ) = = nullptr & & ! m_target_triple . empty ( ) )
2010-06-09 00:52:24 +08:00
{
2014-07-06 13:36:57 +08:00
m_target_options_rp = std : : make_shared < TargetOptions > ( ) ;
2014-07-05 11:06:05 +08:00
if ( m_target_options_rp . get ( ) ! = nullptr )
2012-10-18 06:11:14 +08:00
m_target_options_rp - > Triple = m_target_triple ;
2010-06-09 00:52:24 +08:00
}
2014-07-06 13:36:57 +08:00
return m_target_options_rp ;
2010-06-09 00:52:24 +08:00
}
TargetInfo *
ClangASTContext : : getTargetInfo ( )
{
2012-05-08 09:45:38 +08:00
// target_triple should be something like "x86_64-apple-macosx"
2014-04-20 21:17:36 +08:00
if ( m_target_info_ap . get ( ) = = nullptr & & ! m_target_triple . empty ( ) )
2012-11-17 05:35:22 +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 ;
}
2013-07-12 06:46:58 +08:00
ClangASTType
2010-08-05 09:57:25 +08:00
ClangASTContext : : GetBuiltinTypeForEncodingAndBitSize ( Encoding encoding , uint32_t bit_size )
2010-06-09 00:52:24 +08:00
{
2013-07-12 06:46:58 +08:00
return ClangASTContext : : GetBuiltinTypeForEncodingAndBitSize ( getASTContext ( ) , encoding , bit_size ) ;
2010-06-09 00:52:24 +08:00
}
2013-07-12 06:46:58 +08:00
ClangASTType
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 )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ) ;
2010-06-09 00:52:24 +08:00
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 ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , 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 ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedCharTy . 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
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedShortTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedShortTy . 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
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedIntTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedIntTy . 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
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedLongTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedLongTy . 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
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedLongLongTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedLongLongTy . 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
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedInt128Ty ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , 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 ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > CharTy . 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
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > ShortTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > ShortTy . 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
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > IntTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > IntTy . 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
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > LongTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > LongTy . 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
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > LongLongTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > LongLongTy . 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
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > Int128Ty ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , 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 ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > FloatTy . 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
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > DoubleTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > DoubleTy . 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
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > LongDoubleTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > LongDoubleTy . getAsOpaquePtr ( ) ) ;
2010-06-09 00:52:24 +08:00
break ;
2010-08-05 09:57:25 +08:00
case eEncodingVector :
2012-03-07 09:12:24 +08:00
// Sanity check that bit_size is a multiple of 8's.
if ( bit_size & & ! ( bit_size & 0x7u ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > getExtVectorType ( ast - > UnsignedCharTy , bit_size / 8 ) . getAsOpaquePtr ( ) ) ;
2012-03-07 09:12:24 +08:00
break ;
2010-06-09 00:52:24 +08:00
}
2013-07-12 06:46:58 +08:00
return ClangASTType ( ) ;
}
lldb : : BasicType
ClangASTContext : : GetBasicTypeEnumeration ( const ConstString & name )
{
if ( name )
{
typedef UniqueCStringMap < lldb : : BasicType > TypeNameToBasicTypeMap ;
static TypeNameToBasicTypeMap g_type_map ;
static std : : once_flag g_once_flag ;
std : : call_once ( g_once_flag , [ ] ( ) {
// "void"
g_type_map . Append ( ConstString ( " void " ) . GetCString ( ) , eBasicTypeVoid ) ;
// "char"
g_type_map . Append ( ConstString ( " char " ) . GetCString ( ) , eBasicTypeChar ) ;
g_type_map . Append ( ConstString ( " signed char " ) . GetCString ( ) , eBasicTypeSignedChar ) ;
g_type_map . Append ( ConstString ( " unsigned char " ) . GetCString ( ) , eBasicTypeUnsignedChar ) ;
g_type_map . Append ( ConstString ( " wchar_t " ) . GetCString ( ) , eBasicTypeWChar ) ;
g_type_map . Append ( ConstString ( " signed wchar_t " ) . GetCString ( ) , eBasicTypeSignedWChar ) ;
g_type_map . Append ( ConstString ( " unsigned wchar_t " ) . GetCString ( ) , eBasicTypeUnsignedWChar ) ;
// "short"
g_type_map . Append ( ConstString ( " short " ) . GetCString ( ) , eBasicTypeShort ) ;
g_type_map . Append ( ConstString ( " short int " ) . GetCString ( ) , eBasicTypeShort ) ;
g_type_map . Append ( ConstString ( " unsigned short " ) . GetCString ( ) , eBasicTypeUnsignedShort ) ;
g_type_map . Append ( ConstString ( " unsigned short int " ) . GetCString ( ) , eBasicTypeUnsignedShort ) ;
// "int"
g_type_map . Append ( ConstString ( " int " ) . GetCString ( ) , eBasicTypeInt ) ;
g_type_map . Append ( ConstString ( " signed int " ) . GetCString ( ) , eBasicTypeInt ) ;
g_type_map . Append ( ConstString ( " unsigned int " ) . GetCString ( ) , eBasicTypeUnsignedInt ) ;
g_type_map . Append ( ConstString ( " unsigned " ) . GetCString ( ) , eBasicTypeUnsignedInt ) ;
// "long"
g_type_map . Append ( ConstString ( " long " ) . GetCString ( ) , eBasicTypeLong ) ;
g_type_map . Append ( ConstString ( " long int " ) . GetCString ( ) , eBasicTypeLong ) ;
g_type_map . Append ( ConstString ( " unsigned long " ) . GetCString ( ) , eBasicTypeUnsignedLong ) ;
g_type_map . Append ( ConstString ( " unsigned long int " ) . GetCString ( ) , eBasicTypeUnsignedLong ) ;
// "long long"
g_type_map . Append ( ConstString ( " long long " ) . GetCString ( ) , eBasicTypeLongLong ) ;
g_type_map . Append ( ConstString ( " long long int " ) . GetCString ( ) , eBasicTypeLongLong ) ;
g_type_map . Append ( ConstString ( " unsigned long long " ) . GetCString ( ) , eBasicTypeUnsignedLongLong ) ;
g_type_map . Append ( ConstString ( " unsigned long long int " ) . GetCString ( ) , eBasicTypeUnsignedLongLong ) ;
// "int128"
g_type_map . Append ( ConstString ( " __int128_t " ) . GetCString ( ) , eBasicTypeInt128 ) ;
g_type_map . Append ( ConstString ( " __uint128_t " ) . GetCString ( ) , eBasicTypeUnsignedInt128 ) ;
2014-07-02 05:22:11 +08:00
// Miscellaneous
2013-07-12 06:46:58 +08:00
g_type_map . Append ( ConstString ( " bool " ) . GetCString ( ) , eBasicTypeBool ) ;
g_type_map . Append ( ConstString ( " float " ) . GetCString ( ) , eBasicTypeFloat ) ;
g_type_map . Append ( ConstString ( " double " ) . GetCString ( ) , eBasicTypeDouble ) ;
g_type_map . Append ( ConstString ( " long double " ) . GetCString ( ) , eBasicTypeLongDouble ) ;
g_type_map . Append ( ConstString ( " id " ) . GetCString ( ) , eBasicTypeObjCID ) ;
g_type_map . Append ( ConstString ( " SEL " ) . GetCString ( ) , eBasicTypeObjCSel ) ;
g_type_map . Append ( ConstString ( " nullptr " ) . GetCString ( ) , eBasicTypeNullPtr ) ;
g_type_map . Sort ( ) ;
} ) ;
return g_type_map . Find ( name . GetCString ( ) , eBasicTypeInvalid ) ;
}
return eBasicTypeInvalid ;
}
ClangASTType
ClangASTContext : : GetBasicType ( ASTContext * ast , const ConstString & name )
{
if ( ast )
{
lldb : : BasicType basic_type = ClangASTContext : : GetBasicTypeEnumeration ( name ) ;
return ClangASTContext : : GetBasicType ( ast , basic_type ) ;
}
return ClangASTType ( ) ;
}
uint32_t
ClangASTContext : : GetPointerByteSize ( )
{
if ( m_pointer_byte_size = = 0 )
m_pointer_byte_size = GetBasicType ( lldb : : eBasicTypeVoid ) . GetPointerType ( ) . GetByteSize ( ) ;
return m_pointer_byte_size ;
}
ClangASTType
ClangASTContext : : GetBasicType ( lldb : : BasicType basic_type )
{
return GetBasicType ( getASTContext ( ) , basic_type ) ;
}
ClangASTType
ClangASTContext : : GetBasicType ( ASTContext * ast , lldb : : BasicType basic_type )
{
if ( ast )
{
2014-04-20 21:17:36 +08:00
clang_type_t clang_type = nullptr ;
2013-07-12 06:46:58 +08:00
switch ( basic_type )
{
case eBasicTypeInvalid :
case eBasicTypeOther :
break ;
case eBasicTypeVoid :
clang_type = ast - > VoidTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeChar :
clang_type = ast - > CharTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeSignedChar :
clang_type = ast - > SignedCharTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeUnsignedChar :
clang_type = ast - > UnsignedCharTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeWChar :
clang_type = ast - > getWCharType ( ) . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeSignedWChar :
clang_type = ast - > getSignedWCharType ( ) . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeUnsignedWChar :
clang_type = ast - > getUnsignedWCharType ( ) . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeChar16 :
clang_type = ast - > Char16Ty . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeChar32 :
clang_type = ast - > Char32Ty . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeShort :
clang_type = ast - > ShortTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeUnsignedShort :
clang_type = ast - > UnsignedShortTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeInt :
clang_type = ast - > IntTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeUnsignedInt :
clang_type = ast - > UnsignedIntTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeLong :
clang_type = ast - > LongTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeUnsignedLong :
clang_type = ast - > UnsignedLongTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeLongLong :
clang_type = ast - > LongLongTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeUnsignedLongLong :
clang_type = ast - > UnsignedLongLongTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeInt128 :
clang_type = ast - > Int128Ty . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeUnsignedInt128 :
clang_type = ast - > UnsignedInt128Ty . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeBool :
clang_type = ast - > BoolTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeHalf :
clang_type = ast - > HalfTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeFloat :
clang_type = ast - > FloatTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeDouble :
clang_type = ast - > DoubleTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeLongDouble :
clang_type = ast - > LongDoubleTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeFloatComplex :
clang_type = ast - > FloatComplexTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeDoubleComplex :
clang_type = ast - > DoubleComplexTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeLongDoubleComplex :
clang_type = ast - > LongDoubleComplexTy . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeObjCID :
clang_type = ast - > getObjCIdType ( ) . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeObjCClass :
clang_type = ast - > getObjCClassType ( ) . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeObjCSel :
clang_type = ast - > getObjCSelType ( ) . getAsOpaquePtr ( ) ;
break ;
case eBasicTypeNullPtr :
clang_type = ast - > NullPtrTy . getAsOpaquePtr ( ) ;
break ;
}
if ( clang_type )
return ClangASTType ( ast , clang_type ) ;
}
return ClangASTType ( ) ;
2010-06-09 00:52:24 +08:00
}
2013-07-12 06:46:58 +08:00
ClangASTType
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 ( ) ;
2012-04-03 09:10:10 +08:00
# define streq(a,b) strcmp(a,b) == 0
2014-04-20 21:17:36 +08:00
assert ( ast ! = nullptr ) ;
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
{
switch ( dw_ate )
{
2012-04-03 09:10:10 +08:00
default :
break ;
case DW_ATE_address :
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > VoidPtrTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > VoidPtrTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
break ;
case DW_ATE_boolean :
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > BoolTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > BoolTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedCharTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedCharTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedShortTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedShortTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedIntTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedIntTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
break ;
case DW_ATE_lo_user :
// This has been seen to mean DW_AT_complex_integer
if ( type_name )
2010-06-09 00:52:24 +08:00
{
2012-04-03 09:10:10 +08:00
if ( : : strstr ( type_name , " complex " ) )
{
2013-07-12 06:46:58 +08:00
ClangASTType complex_int_clang_type = GetBuiltinTypeForDWARFEncodingAndBitSize ( " int " , DW_ATE_signed , bit_size / 2 ) ;
return ClangASTType ( ast , ast - > getComplexType ( complex_int_clang_type . GetQualType ( ) ) . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
}
2010-06-09 00:52:24 +08:00
}
2012-04-03 09:10:10 +08:00
break ;
case DW_ATE_complex_float :
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > FloatComplexTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > FloatComplexTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
else if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > DoubleComplexTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > DoubleComplexTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
else if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > LongDoubleComplexTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > LongDoubleComplexTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
else
2010-11-02 11:48:39 +08:00
{
2013-07-12 06:46:58 +08:00
ClangASTType complex_float_clang_type = GetBuiltinTypeForDWARFEncodingAndBitSize ( " float " , DW_ATE_float , bit_size / 2 ) ;
return ClangASTType ( ast , ast - > getComplexType ( complex_float_clang_type . GetQualType ( ) ) . getAsOpaquePtr ( ) ) ;
2010-11-02 11:48:39 +08:00
}
2012-04-03 09:10:10 +08:00
break ;
case DW_ATE_float :
2014-11-18 03:39:20 +08:00
if ( streq ( type_name , " float " ) & & QualTypeMatchesBitSize ( bit_size , ast , ast - > FloatTy ) )
return ClangASTType ( ast , ast - > FloatTy . getAsOpaquePtr ( ) ) ;
if ( streq ( type_name , " double " ) & & QualTypeMatchesBitSize ( bit_size , ast , ast - > DoubleTy ) )
return ClangASTType ( ast , ast - > DoubleTy . getAsOpaquePtr ( ) ) ;
if ( streq ( type_name , " long double " ) & & QualTypeMatchesBitSize ( bit_size , ast , ast - > LongDoubleTy ) )
return ClangASTType ( ast , ast - > LongDoubleTy . getAsOpaquePtr ( ) ) ;
// Fall back to not requring a name match
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > FloatTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > FloatTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > DoubleTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > DoubleTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > LongDoubleTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > LongDoubleTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
break ;
case DW_ATE_signed :
if ( type_name )
2010-06-09 00:52:24 +08:00
{
2012-04-03 09:10:10 +08:00
if ( streq ( type_name , " wchar_t " ) & &
QualTypeMatchesBitSize ( bit_size , ast , ast - > WCharTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > WCharTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( streq ( type_name , " void " ) & &
QualTypeMatchesBitSize ( bit_size , ast , ast - > VoidTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > VoidTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( strstr ( type_name , " long long " ) & &
QualTypeMatchesBitSize ( bit_size , ast , ast - > LongLongTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > LongLongTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( strstr ( type_name , " long " ) & &
QualTypeMatchesBitSize ( bit_size , ast , ast - > LongTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > LongTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( strstr ( type_name , " short " ) & &
QualTypeMatchesBitSize ( bit_size , ast , ast - > ShortTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > ShortTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( strstr ( type_name , " char " ) )
{
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > CharTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > CharTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > SignedCharTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > SignedCharTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
}
if ( strstr ( type_name , " int " ) )
{
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > IntTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > IntTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > Int128Ty ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > Int128Ty . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
}
2011-02-10 07:39:34 +08:00
}
2012-04-03 09:10:10 +08:00
// We weren't able to match up a type name, just search by size
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > CharTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > CharTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > ShortTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > ShortTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > IntTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > IntTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > LongTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > LongTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > LongLongTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > LongLongTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > Int128Ty ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > Int128Ty . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
break ;
case DW_ATE_signed_char :
if ( type_name )
2010-11-02 11:48:39 +08:00
{
2012-04-03 09:10:10 +08:00
if ( streq ( type_name , " signed char " ) )
{
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > SignedCharTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > SignedCharTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
}
2010-11-02 11:48:39 +08:00
}
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > CharTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > CharTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > SignedCharTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > SignedCharTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
break ;
2011-10-29 07:06:08 +08:00
2012-04-03 09:10:10 +08:00
case DW_ATE_unsigned :
if ( type_name )
2011-10-29 07:06:08 +08:00
{
2012-04-03 09:10:10 +08:00
if ( strstr ( type_name , " long long " ) )
{
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedLongLongTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedLongLongTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
}
else if ( strstr ( type_name , " long " ) )
{
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedLongTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedLongTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
}
else if ( strstr ( type_name , " short " ) )
{
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedShortTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedShortTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
}
else if ( strstr ( type_name , " char " ) )
{
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedCharTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedCharTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
}
else if ( strstr ( type_name , " int " ) )
{
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedIntTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedIntTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedInt128Ty ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedInt128Ty . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
}
2011-10-29 07:06:08 +08:00
}
2012-04-03 09:10:10 +08:00
// We weren't able to match up a type name, just search by size
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedCharTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedCharTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedShortTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedShortTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedIntTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedIntTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedLongTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedLongTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedLongLongTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedLongLongTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedInt128Ty ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedInt128Ty . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
break ;
case DW_ATE_unsigned_char :
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedCharTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedCharTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
if ( QualTypeMatchesBitSize ( bit_size , ast , ast - > UnsignedShortTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > UnsignedShortTy . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
break ;
case DW_ATE_imaginary_float :
break ;
case DW_ATE_UTF :
if ( type_name )
2011-10-29 07:06:08 +08:00
{
2012-04-03 09:10:10 +08:00
if ( streq ( type_name , " char16_t " ) )
{
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > Char16Ty . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
}
else if ( streq ( type_name , " char32_t " ) )
{
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > Char32Ty . getAsOpaquePtr ( ) ) ;
2012-04-03 09:10:10 +08:00
}
2011-10-29 07:06:08 +08:00
}
2012-04-03 09:10:10 +08:00
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 )
{
2012-01-05 11:57:59 +08:00
Host : : SystemLog ( Host : : eSystemLogError , " 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 ) ;
2011-05-18 02:15:05 +08:00
}
else
{
2012-01-05 11:57:59 +08:00
Host : : SystemLog ( Host : : eSystemLogError , " error: need to add support for DW_TAG_base_type encoded with DW_ATE = 0x%x, bit_size = %u \n " , dw_ate , bit_size ) ;
2011-05-18 02:15:05 +08:00
}
2013-07-12 06:46:58 +08:00
return ClangASTType ( ) ;
2010-08-03 08:35:52 +08:00
}
2013-07-12 06:46:58 +08:00
ClangASTType
2011-05-13 07:54:16 +08:00
ClangASTContext : : GetUnknownAnyType ( clang : : ASTContext * ast )
{
2013-07-12 06:46:58 +08:00
if ( ast )
return ClangASTType ( ast , ast - > UnknownAnyTy . getAsOpaquePtr ( ) ) ;
return ClangASTType ( ) ;
2011-05-13 07:54:16 +08:00
}
2013-07-12 06:46:58 +08:00
ClangASTType
2010-06-09 00:52:24 +08:00
ClangASTContext : : GetCStringType ( bool is_const )
{
2013-07-12 06:46:58 +08:00
ASTContext * ast = getASTContext ( ) ;
QualType char_type ( ast - > CharTy ) ;
2010-06-09 00:52:24 +08:00
if ( is_const )
char_type . addConst ( ) ;
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > getPointerType ( char_type ) . getAsOpaquePtr ( ) ) ;
2010-06-09 00:52:24 +08:00
}
2011-12-01 06:11:59 +08:00
clang : : DeclContext *
ClangASTContext : : GetTranslationUnitDecl ( clang : : ASTContext * ast )
{
return ast - > getTranslationUnitDecl ( ) ;
}
2013-07-12 06:46:58 +08:00
ClangASTType
2010-12-03 07:20:03 +08:00
ClangASTContext : : CopyType ( ASTContext * dst_ast ,
2013-07-12 06:46:58 +08:00
ClangASTType src )
2010-06-09 00:52:24 +08:00
{
2010-11-18 10:56:27 +08:00
FileSystemOptions file_system_options ;
2013-07-12 06:46:58 +08:00
ASTContext * src_ast = src . GetASTContext ( ) ;
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
2013-07-12 06:46:58 +08:00
QualType dst ( importer . Import ( src . GetQualType ( ) ) ) ;
2010-11-10 06:37:10 +08:00
2013-07-12 06:46:58 +08:00
return ClangASTType ( dst_ast , 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
2013-07-12 06:46:58 +08:00
ClangASTContext : : AreTypesSame ( ClangASTType type1 ,
ClangASTType type2 ,
2012-03-27 07:03:23 +08:00
bool ignore_qualifiers )
2010-07-16 06:30:52 +08:00
{
2013-07-12 06:46:58 +08:00
ASTContext * ast = type1 . GetASTContext ( ) ;
if ( ast ! = type2 . GetASTContext ( ) )
return false ;
if ( type1 . GetOpaqueQualType ( ) = = type2 . GetOpaqueQualType ( ) )
2012-04-07 01:38:55 +08:00
return true ;
2013-07-12 06:46:58 +08:00
QualType type1_qual = type1 . GetQualType ( ) ;
QualType type2_qual = type2 . GetQualType ( ) ;
2012-02-18 10:01:03 +08:00
if ( ignore_qualifiers )
{
type1_qual = type1_qual . getUnqualifiedType ( ) ;
type2_qual = type2_qual . getUnqualifiedType ( ) ;
}
2013-07-12 06:46:58 +08:00
return ast - > hasSameType ( type1_qual , type2_qual ) ;
2010-06-09 00:52:24 +08:00
}
2014-12-05 09:21:59 +08:00
ClangASTType
ClangASTContext : : GetTypeForDecl ( clang : : NamedDecl * decl )
{
if ( clang : : ObjCInterfaceDecl * interface_decl = llvm : : dyn_cast < clang : : ObjCInterfaceDecl > ( decl ) )
return GetTypeForDecl ( interface_decl ) ;
if ( clang : : TagDecl * tag_decl = llvm : : dyn_cast < clang : : TagDecl > ( decl ) )
return GetTypeForDecl ( tag_decl ) ;
return ClangASTType ( ) ;
}
2010-06-09 00:52:24 +08:00
2013-07-12 06:46:58 +08:00
ClangASTType
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 : : 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...
2014-12-05 09:21:59 +08:00
ASTContext * ast = & decl - > getASTContext ( ) ;
2013-07-12 06:46:58 +08:00
if ( ast )
return ClangASTType ( ast , ast - > getTagDeclType ( decl ) . getAsOpaquePtr ( ) ) ;
return ClangASTType ( ) ;
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
}
2013-07-12 06:46:58 +08:00
ClangASTType
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 : : 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...
2014-12-05 09:21:59 +08:00
ASTContext * ast = & decl - > getASTContext ( ) ;
2013-07-12 06:46:58 +08:00
if ( ast )
return ClangASTType ( ast , ast - > getObjCInterfaceType ( decl ) . getAsOpaquePtr ( ) ) ;
return ClangASTType ( ) ;
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
}
2010-06-09 00:52:24 +08:00
# pragma mark Structure, Unions, Classes
2013-07-12 06:46:58 +08:00
ClangASTType
2013-03-08 09:37:30 +08:00
ClangASTContext : : CreateRecordType ( DeclContext * decl_ctx ,
AccessType access_type ,
const char * name ,
int kind ,
LanguageType language ,
ClangASTMetadata * metadata )
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 ( ) ;
2014-04-20 21:17:36 +08:00
assert ( ast ! = nullptr ) ;
2012-04-18 09:06:17 +08:00
2014-04-20 21:17:36 +08:00
if ( decl_ctx = = nullptr )
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 ;
2012-04-18 09:06:17 +08:00
return CreateObjCClass ( name , decl_ctx , isForwardDecl , isInternal , metadata ) ;
2010-07-28 10:04:09 +08:00
}
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.
2014-02-18 08:31:38 +08:00
bool is_anonymous = ( ! name ) | | ( ! name [ 0 ] ) ;
2011-10-22 11:33:13 +08:00
CXXRecordDecl * decl = CXXRecordDecl : : Create ( * ast ,
( TagDecl : : TagKind ) kind ,
decl_ctx ,
SourceLocation ( ) ,
SourceLocation ( ) ,
2014-04-20 21:17:36 +08:00
is_anonymous ? nullptr : & ast - > Idents . get ( name ) ) ;
2014-02-18 08:31:38 +08:00
if ( is_anonymous )
decl - > setAnonymousStructOrUnion ( true ) ;
2012-01-14 06:10:18 +08:00
2013-03-08 09:37:30 +08:00
if ( decl )
2011-10-26 11:31:36 +08:00
{
2013-03-08 09:37:30 +08:00
if ( metadata )
2013-03-27 09:48:02 +08:00
SetMetadata ( ast , decl , * metadata ) ;
2013-03-08 09:37:30 +08:00
2011-10-26 11:31:36 +08:00
if ( access_type ! = eAccessNone )
decl - > setAccess ( ConvertAccessTypeToAccessSpecifier ( access_type ) ) ;
2013-03-08 09:37:30 +08:00
if ( decl_ctx )
decl_ctx - > addDecl ( decl ) ;
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > getTagDeclType ( decl ) . getAsOpaquePtr ( ) ) ;
2011-10-26 11:31:36 +08:00
}
2013-07-12 06:46:58 +08:00
return ClangASTType ( ) ;
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
}
2012-02-06 14:42:51 +08:00
static TemplateParameterList *
CreateTemplateParameterList ( ASTContext * ast ,
2012-09-25 06:25:51 +08:00
const ClangASTContext : : TemplateParameterInfos & template_param_infos ,
2012-02-06 14:42:51 +08:00
llvm : : SmallVector < NamedDecl * , 8 > & template_param_decls )
2011-10-22 11:33:13 +08:00
{
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 ] ;
2013-04-24 06:38:02 +08:00
2014-04-20 21:17:36 +08:00
IdentifierInfo * identifier_info = nullptr ;
2013-04-24 06:38:02 +08:00
if ( name & & name [ 0 ] )
identifier_info = & ast - > Idents . get ( name ) ;
2012-09-25 06:25:51 +08:00
if ( template_param_infos . args [ i ] . getKind ( ) = = TemplateArgument : : Integral )
2011-10-22 11:33:13 +08:00
{
template_param_decls . push_back ( NonTypeTemplateParmDecl : : Create ( * ast ,
ast - > getTranslationUnitDecl ( ) , // Is this the right decl context?, SourceLocation StartLoc,
SourceLocation ( ) ,
SourceLocation ( ) ,
depth ,
i ,
2013-04-24 06:38:02 +08:00
identifier_info ,
2011-12-02 10:09:28 +08:00
template_param_infos . args [ i ] . getIntegralType ( ) ,
2011-10-22 11:33:13 +08:00
parameter_pack ,
2014-04-20 21:17:36 +08:00
nullptr ) ) ;
2012-02-06 14:42:51 +08:00
2011-10-22 11:33:13 +08:00
}
else
{
template_param_decls . push_back ( TemplateTypeParmDecl : : Create ( * ast ,
ast - > getTranslationUnitDecl ( ) , // Is this the right decl context?
SourceLocation ( ) ,
SourceLocation ( ) ,
depth ,
i ,
2013-04-24 06:38:02 +08:00
identifier_info ,
2011-10-22 11:33:13 +08:00
is_typename ,
parameter_pack ) ) ;
}
}
2012-02-06 14:42:51 +08:00
TemplateParameterList * template_param_list = TemplateParameterList : : Create ( * ast ,
SourceLocation ( ) ,
SourceLocation ( ) ,
& template_param_decls . front ( ) ,
template_param_decls . size ( ) ,
SourceLocation ( ) ) ;
return template_param_list ;
}
clang : : FunctionTemplateDecl *
ClangASTContext : : CreateFunctionTemplateDecl ( clang : : DeclContext * decl_ctx ,
clang : : FunctionDecl * func_decl ,
const char * name ,
const TemplateParameterInfos & template_param_infos )
{
// /// \brief Create a function template node.
ASTContext * ast = getASTContext ( ) ;
llvm : : SmallVector < NamedDecl * , 8 > template_param_decls ;
TemplateParameterList * template_param_list = CreateTemplateParameterList ( ast ,
template_param_infos ,
template_param_decls ) ;
FunctionTemplateDecl * func_tmpl_decl = FunctionTemplateDecl : : Create ( * ast ,
decl_ctx ,
func_decl - > getLocation ( ) ,
func_decl - > getDeclName ( ) ,
template_param_list ,
func_decl ) ;
for ( size_t i = 0 , template_param_decl_count = template_param_decls . size ( ) ;
i < template_param_decl_count ;
+ + i )
{
// TODO: verify which decl context we should put template_param_decls into..
template_param_decls [ i ] - > setDeclContext ( func_decl ) ;
}
return func_tmpl_decl ;
}
void
ClangASTContext : : CreateFunctionTemplateSpecializationInfo ( FunctionDecl * func_decl ,
clang : : FunctionTemplateDecl * func_tmpl_decl ,
const TemplateParameterInfos & infos )
{
TemplateArgumentList template_args ( TemplateArgumentList : : OnStack ,
infos . args . data ( ) ,
infos . args . size ( ) ) ;
func_decl - > setFunctionTemplateSpecialization ( func_tmpl_decl ,
& template_args ,
2014-04-20 21:17:36 +08:00
nullptr ) ;
2012-02-06 14:42:51 +08:00
}
ClassTemplateDecl *
ClangASTContext : : CreateClassTemplateDecl ( DeclContext * decl_ctx ,
lldb : : AccessType access_type ,
const char * class_name ,
int kind ,
const TemplateParameterInfos & template_param_infos )
{
ASTContext * ast = getASTContext ( ) ;
2011-10-22 11:33:13 +08:00
2014-04-20 21:17:36 +08:00
ClassTemplateDecl * class_template_decl = nullptr ;
if ( decl_ctx = = nullptr )
2012-02-06 14:42:51 +08:00
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 ) ;
2012-12-22 05:34:42 +08:00
for ( NamedDecl * decl : result )
2012-02-06 14:42:51 +08:00
{
2012-12-22 05:34:42 +08:00
class_template_decl = dyn_cast < clang : : ClassTemplateDecl > ( decl ) ;
2012-02-06 14:42:51 +08:00
if ( class_template_decl )
return class_template_decl ;
}
llvm : : SmallVector < NamedDecl * , 8 > template_param_decls ;
2011-10-22 11:33:13 +08:00
2012-02-06 14:42:51 +08:00
TemplateParameterList * template_param_list = CreateTemplateParameterList ( ast ,
template_param_infos ,
template_param_decls ) ;
2011-10-22 11:33:13 +08:00
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 ) ;
2011-12-02 10:09:28 +08:00
for ( size_t i = 0 , template_param_decl_count = template_param_decls . size ( ) ;
i < template_param_decl_count ;
+ + i )
{
template_param_decls [ i ] - > setDeclContext ( template_cxx_decl ) ;
}
2011-11-19 09:35:08 +08:00
// With templated classes, we say that a class is templated with
// specializations, but that the bare class has no functions.
2013-02-01 14:55:48 +08:00
//template_cxx_decl->startDefinition();
//template_cxx_decl->completeDefinition();
2011-11-19 09:35:08 +08:00
2011-10-22 11:33:13 +08:00
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 ,
2014-04-20 21:17:36 +08:00
nullptr ) ;
2011-10-22 11:33:13 +08:00
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 ) ) ;
2012-02-04 16:49:35 +08:00
//if (TagDecl *ctx_tag_decl = dyn_cast<TagDecl>(decl_ctx))
// CompleteTagDeclarationDefinition(GetTypeForDecl(ctx_tag_decl));
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 ( ) ,
2014-04-20 21:17:36 +08:00
nullptr ) ;
2011-10-22 11:33:13 +08:00
2013-02-01 14:55:48 +08:00
class_template_specialization_decl - > setSpecializationKind ( TSK_ExplicitSpecialization ) ;
2011-10-22 11:33:13 +08:00
return class_template_specialization_decl ;
}
2013-07-12 06:46:58 +08:00
ClangASTType
2011-10-22 11:33:13 +08:00
ClangASTContext : : CreateClassTemplateSpecializationType ( ClassTemplateSpecializationDecl * class_template_specialization_decl )
{
if ( class_template_specialization_decl )
{
ASTContext * ast = getASTContext ( ) ;
if ( ast )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > getTagDeclType ( class_template_specialization_decl ) . 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
}
2013-07-12 06:46:58 +08:00
return ClangASTType ( ) ;
2010-06-09 00:52:24 +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 ;
2014-07-02 05:22:11 +08:00
// The parameter count doesn't include "this"
2011-06-19 11:43:27 +08:00
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 )
{
2012-02-04 16:49:35 +08:00
switch ( op_kind )
{
default :
break ;
// C++ standard allows any number of arguments to new/delete
case OO_New :
case OO_Array_New :
case OO_Delete :
case OO_Array_Delete :
return true ;
}
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 ;
}
2013-07-12 06:46:58 +08:00
clang : : AccessSpecifier
ClangASTContext : : UnifyAccessSpecifiers ( clang : : AccessSpecifier lhs , clang : : AccessSpecifier rhs )
2010-09-17 10:58:26 +08:00
{
2013-07-12 06:46:58 +08:00
clang : : AccessSpecifier ret = lhs ;
2010-09-24 13:15:53 +08:00
2013-07-12 06:46:58 +08:00
// Make the access equal to the stricter of the field and the nested field's access
switch ( ret )
{
case clang : : AS_none :
break ;
case clang : : AS_private :
break ;
case clang : : AS_protected :
if ( rhs = = AS_private )
ret = AS_private ;
break ;
case clang : : AS_public :
ret = rhs ;
break ;
}
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
2013-07-12 06:46:58 +08:00
return ret ;
}
2010-10-01 11:45:20 +08:00
2013-07-12 06:46:58 +08:00
bool
ClangASTContext : : FieldIsBitfield ( FieldDecl * field , uint32_t & bitfield_bit_size )
{
return FieldIsBitfield ( getASTContext ( ) , field , bitfield_bit_size ) ;
}
2010-06-09 00:52:24 +08:00
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
)
{
2014-04-20 21:17:36 +08:00
if ( ast = = nullptr | | field = = nullptr )
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 )
{
2014-04-20 21:17:36 +08:00
if ( record_decl = = nullptr )
2010-06-09 00:52:24 +08:00
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 ;
}
2010-07-23 02:30:50 +08:00
# pragma mark Objective C Classes
2013-07-12 06:46:58 +08:00
ClangASTType
2012-04-18 09:06:17 +08:00
ClangASTContext : : CreateObjCClass
2010-07-23 02:30:50 +08:00
(
const char * name ,
DeclContext * decl_ctx ,
bool isForwardDecl ,
2012-04-18 09:06:17 +08:00
bool isInternal ,
2012-10-27 10:54:13 +08:00
ClangASTMetadata * metadata
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
ASTContext * ast = getASTContext ( ) ;
2014-04-20 21:17:36 +08:00
assert ( ast ! = nullptr ) ;
2010-07-23 02:30:50 +08:00
assert ( name & & name [ 0 ] ) ;
2014-04-20 21:17:36 +08:00
if ( decl_ctx = = nullptr )
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
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 ) ,
2014-04-20 21:17:36 +08:00
nullptr ,
2010-07-23 02:30:50 +08:00
SourceLocation ( ) ,
2012-02-04 16:49:35 +08:00
/*isForwardDecl,*/
2010-07-23 02:30:50 +08:00
isInternal ) ;
2010-07-28 10:04:09 +08:00
2012-10-27 10:54:13 +08:00
if ( decl & & metadata )
2013-03-27 09:48:02 +08:00
SetMetadata ( ast , decl , * metadata ) ;
2012-04-18 09:06:17 +08:00
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > getObjCInterfaceType ( decl ) ) ;
2010-07-23 02:30:50 +08:00
}
2010-06-09 00:52:24 +08:00
2013-07-12 06:46:58 +08:00
static inline bool
BaseSpecifierIsEmpty ( const CXXBaseSpecifier * b )
{
return ClangASTContext : : RecordHasFields ( b - > getType ( ) - > getAsCXXRecordDecl ( ) ) = = false ;
}
uint32_t
ClangASTContext : : GetNumBaseClasses ( const CXXRecordDecl * cxx_record_decl , bool omit_empty_base_classes )
2010-07-23 02:30:50 +08:00
{
2013-07-12 06:46:58 +08:00
uint32_t num_bases = 0 ;
if ( cxx_record_decl )
2010-07-23 02:30:50 +08:00
{
2013-07-12 06:46:58 +08:00
if ( omit_empty_base_classes )
2010-07-23 02:30:50 +08:00
{
2013-07-12 06:46:58 +08:00
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 )
2010-07-23 02:30:50 +08:00
{
2013-07-12 06:46:58 +08:00
// Skip empty base classes
if ( omit_empty_base_classes )
2010-07-23 02:30:50 +08:00
{
2013-07-12 06:46:58 +08:00
if ( BaseSpecifierIsEmpty ( base_class ) )
continue ;
2010-07-23 02:30:50 +08:00
}
2013-07-12 06:46:58 +08:00
+ + num_bases ;
2010-07-23 02:30:50 +08:00
}
}
2013-07-12 06:46:58 +08:00
else
num_bases = cxx_record_decl - > getNumBases ( ) ;
2010-07-23 02:30:50 +08:00
}
2013-07-12 06:46:58 +08:00
return num_bases ;
2010-07-23 02:30:50 +08:00
}
2013-07-12 06:46:58 +08:00
# pragma mark Namespace Declarations
2010-07-23 02:30:50 +08:00
2013-07-12 06:46:58 +08:00
NamespaceDecl *
ClangASTContext : : GetUniqueNamespaceDeclaration ( const char * name , DeclContext * decl_ctx )
{
2014-04-20 21:17:36 +08:00
NamespaceDecl * namespace_decl = nullptr ;
2013-07-12 06:46:58 +08:00
ASTContext * ast = getASTContext ( ) ;
TranslationUnitDecl * translation_unit_decl = ast - > getTranslationUnitDecl ( ) ;
2014-04-20 21:17:36 +08:00
if ( decl_ctx = = nullptr )
2013-07-12 06:46:58 +08:00
decl_ctx = translation_unit_decl ;
2011-11-12 09:36:43 +08:00
2013-07-12 06:46:58 +08:00
if ( name )
2010-07-23 02:30:50 +08:00
{
2013-07-12 06:46:58 +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 ( NamedDecl * decl : result )
2010-07-23 02:30:50 +08:00
{
2013-07-12 06:46:58 +08:00
namespace_decl = dyn_cast < clang : : NamespaceDecl > ( decl ) ;
if ( namespace_decl )
return namespace_decl ;
2011-11-12 09:36:43 +08:00
}
2010-07-28 10:04:09 +08:00
2013-07-12 06:46:58 +08:00
namespace_decl = NamespaceDecl : : Create ( * ast ,
decl_ctx ,
false ,
SourceLocation ( ) ,
SourceLocation ( ) ,
& identifier_info ,
2014-04-20 21:17:36 +08:00
nullptr ) ;
2010-07-28 10:04:09 +08:00
2013-07-12 06:46:58 +08:00
decl_ctx - > addDecl ( namespace_decl ) ;
2010-09-24 13:15:53 +08:00
}
2013-07-12 06:46:58 +08:00
else
2010-09-24 13:15:53 +08:00
{
2013-07-12 06:46:58 +08:00
if ( decl_ctx = = translation_unit_decl )
2010-09-24 13:15:53 +08:00
{
2013-07-12 06:46:58 +08:00
namespace_decl = translation_unit_decl - > getAnonymousNamespace ( ) ;
if ( namespace_decl )
return namespace_decl ;
namespace_decl = NamespaceDecl : : Create ( * ast ,
decl_ctx ,
false ,
2010-09-24 13:15:53 +08:00
SourceLocation ( ) ,
2011-03-15 08:17:19 +08:00
SourceLocation ( ) ,
2014-04-20 21:17:36 +08:00
nullptr ,
nullptr ) ;
2013-07-12 06:46:58 +08:00
translation_unit_decl - > setAnonymousNamespace ( namespace_decl ) ;
translation_unit_decl - > addDecl ( namespace_decl ) ;
assert ( namespace_decl = = translation_unit_decl - > getAnonymousNamespace ( ) ) ;
2012-02-03 09:30:30 +08:00
}
2013-07-12 06:46:58 +08:00
else
2010-10-25 08:29:48 +08:00
{
2013-07-12 06:46:58 +08:00
NamespaceDecl * parent_namespace_decl = cast < NamespaceDecl > ( decl_ctx ) ;
if ( parent_namespace_decl )
2013-04-06 07:27:21 +08:00
{
2013-07-12 06:46:58 +08:00
namespace_decl = parent_namespace_decl - > getAnonymousNamespace ( ) ;
if ( namespace_decl )
return namespace_decl ;
namespace_decl = NamespaceDecl : : Create ( * ast ,
decl_ctx ,
false ,
SourceLocation ( ) ,
SourceLocation ( ) ,
2014-04-20 21:17:36 +08:00
nullptr ,
nullptr ) ;
2013-07-12 06:46:58 +08:00
parent_namespace_decl - > setAnonymousNamespace ( namespace_decl ) ;
parent_namespace_decl - > addDecl ( namespace_decl ) ;
assert ( namespace_decl = = parent_namespace_decl - > getAnonymousNamespace ( ) ) ;
2013-04-06 07:27:21 +08:00
}
2013-07-12 06:46:58 +08:00
else
2013-04-06 07:27:21 +08:00
{
2013-07-12 06:46:58 +08:00
// BAD!!!
2013-04-06 07:27:21 +08:00
}
}
2013-07-12 06:46:58 +08:00
2013-04-06 07:27:21 +08:00
2013-07-12 06:46:58 +08:00
if ( namespace_decl )
2013-04-06 07:27:21 +08:00
{
2013-07-12 06:46:58 +08:00
// 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 ) ;
2013-04-06 07:27:21 +08:00
}
2010-06-09 00:52:24 +08:00
}
2011-10-26 09:06:27 +08:00
# ifdef LLDB_CONFIGURATION_DEBUG
2013-07-12 06:46:58 +08:00
VerifyDecl ( namespace_decl ) ;
# endif
return namespace_decl ;
2011-07-06 10:13:41 +08:00
}
2013-07-12 06:46:58 +08:00
# pragma mark Function Types
2010-10-15 06:52:14 +08:00
2013-07-12 06:46:58 +08:00
FunctionDecl *
ClangASTContext : : CreateFunctionDeclaration ( DeclContext * decl_ctx ,
const char * name ,
const ClangASTType & function_clang_type ,
int storage ,
bool is_inline )
2010-10-15 06:52:14 +08:00
{
2014-04-20 21:17:36 +08:00
FunctionDecl * func_decl = nullptr ;
2013-07-12 06:46:58 +08:00
ASTContext * ast = getASTContext ( ) ;
2014-04-20 21:17:36 +08:00
if ( decl_ctx = = nullptr )
2013-07-12 06:46:58 +08:00
decl_ctx = ast - > getTranslationUnitDecl ( ) ;
2010-10-15 06:52:14 +08:00
2013-07-12 06:46:58 +08:00
const bool hasWrittenPrototype = true ;
const bool isConstexprSpecified = false ;
2010-10-15 06:52:14 +08:00
2013-07-12 06:46:58 +08:00
if ( name & & name [ 0 ] )
2010-09-24 13:15:53 +08:00
{
2013-07-12 06:46:58 +08:00
func_decl = FunctionDecl : : Create ( * ast ,
decl_ctx ,
SourceLocation ( ) ,
SourceLocation ( ) ,
DeclarationName ( & ast - > Idents . get ( name ) ) ,
function_clang_type . GetQualType ( ) ,
2014-04-20 21:17:36 +08:00
nullptr ,
2014-11-01 07:20:13 +08:00
( clang : : StorageClass ) storage ,
2013-07-12 06:46:58 +08:00
is_inline ,
hasWrittenPrototype ,
isConstexprSpecified ) ;
2010-09-24 13:15:53 +08:00
}
2013-07-12 06:46:58 +08:00
else
2011-10-14 07:13:20 +08:00
{
2013-07-12 06:46:58 +08:00
func_decl = FunctionDecl : : Create ( * ast ,
decl_ctx ,
SourceLocation ( ) ,
SourceLocation ( ) ,
DeclarationName ( ) ,
function_clang_type . GetQualType ( ) ,
2014-04-20 21:17:36 +08:00
nullptr ,
2014-11-01 07:20:13 +08:00
( clang : : StorageClass ) storage ,
2013-07-12 06:46:58 +08:00
is_inline ,
hasWrittenPrototype ,
isConstexprSpecified ) ;
2011-10-14 07:13:20 +08:00
}
2013-07-12 06:46:58 +08:00
if ( func_decl )
decl_ctx - > addDecl ( func_decl ) ;
# ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl ( func_decl ) ;
# endif
return func_decl ;
2011-10-14 07:13:20 +08:00
}
2013-07-12 06:46:58 +08:00
ClangASTType
ClangASTContext : : CreateFunctionType ( ASTContext * ast ,
const ClangASTType & result_type ,
const ClangASTType * args ,
unsigned num_args ,
bool is_variadic ,
unsigned type_quals )
2010-09-24 13:15:53 +08:00
{
2014-04-20 21:17:36 +08:00
assert ( ast ! = nullptr ) ;
2013-07-12 06:46:58 +08:00
std : : vector < QualType > qual_type_args ;
for ( unsigned i = 0 ; i < num_args ; + + i )
qual_type_args . push_back ( args [ i ] . GetQualType ( ) ) ;
2010-09-24 13:15:53 +08:00
2013-07-12 06:46:58 +08:00
// TODO: Detect calling convention in DWARF?
FunctionProtoType : : ExtProtoInfo proto_info ;
proto_info . Variadic = is_variadic ;
2014-08-01 20:19:15 +08:00
proto_info . ExceptionSpec = EST_None ;
2013-07-12 06:46:58 +08:00
proto_info . TypeQuals = type_quals ;
proto_info . RefQualifier = RQ_None ;
2014-08-01 20:19:15 +08:00
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > getFunctionType ( result_type . GetQualType ( ) ,
qual_type_args ,
proto_info ) . getAsOpaquePtr ( ) ) ;
2012-02-23 07:57:45 +08:00
}
2013-07-12 06:46:58 +08:00
ParmVarDecl *
ClangASTContext : : CreateParameterDeclaration ( const char * name , const ClangASTType & param_type , int storage )
2012-02-23 07:57:45 +08:00
{
2013-07-12 06:46:58 +08:00
ASTContext * ast = getASTContext ( ) ;
2014-04-20 21:17:36 +08:00
assert ( ast ! = nullptr ) ;
2013-07-12 06:46:58 +08:00
return ParmVarDecl : : Create ( * ast ,
ast - > getTranslationUnitDecl ( ) ,
SourceLocation ( ) ,
SourceLocation ( ) ,
2014-04-20 21:17:36 +08:00
name & & name [ 0 ] ? & ast - > Idents . get ( name ) : nullptr ,
2013-07-12 06:46:58 +08:00
param_type . GetQualType ( ) ,
2014-04-20 21:17:36 +08:00
nullptr ,
2014-11-01 07:20:13 +08:00
( clang : : StorageClass ) storage ,
2014-04-20 21:17:36 +08:00
nullptr ) ;
2012-02-23 07:57:45 +08:00
}
2010-09-24 13:15:53 +08:00
2013-07-12 06:46:58 +08:00
void
ClangASTContext : : SetFunctionParameters ( FunctionDecl * function_decl , ParmVarDecl * * params , unsigned num_params )
2010-10-27 11:32:59 +08:00
{
2013-07-12 06:46:58 +08:00
if ( function_decl )
function_decl - > setParams ( ArrayRef < ParmVarDecl * > ( params , num_params ) ) ;
2010-10-27 11:32:59 +08:00
}
2010-06-09 00:52:24 +08:00
2010-10-27 11:32:59 +08:00
2013-07-12 06:46:58 +08:00
# pragma mark Array Types
ClangASTType
ClangASTContext : : CreateArrayType ( const ClangASTType & element_type ,
size_t element_count ,
bool is_vector )
{
if ( element_type . IsValid ( ) )
2010-06-09 00:52:24 +08:00
{
2013-07-12 06:46:58 +08:00
ASTContext * ast = getASTContext ( ) ;
2014-04-20 21:17:36 +08:00
assert ( ast ! = nullptr ) ;
2013-07-12 06:46:58 +08:00
if ( is_vector )
{
return ClangASTType ( ast , ast - > getExtVectorType ( element_type . GetQualType ( ) , element_count ) . getAsOpaquePtr ( ) ) ;
}
else
2010-06-09 00:52:24 +08:00
{
2013-07-12 06:46:58 +08:00
llvm : : APInt ap_element_count ( 64 , element_count ) ;
if ( element_count = = 0 )
2010-06-09 00:52:24 +08:00
{
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > getIncompleteArrayType ( element_type . GetQualType ( ) ,
ArrayType : : Normal ,
0 ) . getAsOpaquePtr ( ) ) ;
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
{
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > getConstantArrayType ( element_type . GetQualType ( ) ,
ap_element_count ,
ArrayType : : Normal ,
0 ) . getAsOpaquePtr ( ) ) ;
2010-09-13 11:32:57 +08:00
}
}
}
2013-07-12 06:46:58 +08:00
return ClangASTType ( ) ;
2010-09-13 11:32:57 +08:00
}
2014-10-30 07:08:02 +08:00
ClangASTType
ClangASTContext : : GetOrCreateStructForIdentifier ( const ConstString & type_name ,
2014-10-30 08:53:28 +08:00
const std : : initializer_list < std : : pair < const char * , ClangASTType > > & type_fields ,
bool packed )
2014-10-30 07:08:02 +08:00
{
ClangASTType type ;
if ( ( type = GetTypeForIdentifier < clang : : CXXRecordDecl > ( type_name ) ) . IsValid ( ) )
return type ;
type = CreateRecordType ( nullptr , lldb : : eAccessPublic , type_name . GetCString ( ) , clang : : TTK_Struct , lldb : : eLanguageTypeC ) ;
type . StartTagDeclarationDefinition ( ) ;
for ( const auto & field : type_fields )
type . AddFieldToRecordType ( field . first , field . second , lldb : : eAccessPublic , 0 ) ;
2014-10-30 08:53:28 +08:00
if ( packed )
type . SetIsPacked ( ) ;
2014-10-30 07:08:02 +08:00
type . CompleteTagDeclarationDefinition ( ) ;
return type ;
}
2013-05-03 02:54:54 +08:00
2013-07-12 06:46:58 +08:00
# pragma mark Enumeration Types
2010-09-13 11:32:57 +08:00
2013-07-12 06:46:58 +08:00
ClangASTType
ClangASTContext : : CreateEnumerationType
(
const char * name ,
DeclContext * decl_ctx ,
const Declaration & decl ,
const ClangASTType & integer_clang_type
)
2010-06-09 00:52:24 +08:00
{
2013-07-12 06:46:58 +08:00
// TODO: Do something intelligent with the Declaration object passed in
// like maybe filling in the SourceLocation with it...
ASTContext * ast = getASTContext ( ) ;
// TODO: ask about these...
// const bool IsScoped = false;
// const bool IsFixed = false;
2011-07-10 01:12:27 +08:00
2013-07-12 06:46:58 +08:00
EnumDecl * enum_decl = EnumDecl : : Create ( * ast ,
decl_ctx ,
SourceLocation ( ) ,
SourceLocation ( ) ,
2014-04-20 21:17:36 +08:00
name & & name [ 0 ] ? & ast - > Idents . get ( name ) : nullptr ,
nullptr ,
2013-07-12 06:46:58 +08:00
false , // IsScoped
false , // IsScopedUsingClassTag
false ) ; // IsFixed
2011-07-10 01:12:27 +08:00
2011-08-12 07:56:13 +08:00
2013-07-12 06:46:58 +08:00
if ( enum_decl )
2010-06-09 00:52:24 +08:00
{
2013-07-12 06:46:58 +08:00
// TODO: check if we should be setting the promotion type too?
enum_decl - > setIntegerType ( integer_clang_type . GetQualType ( ) ) ;
2011-01-18 09:03:44 +08:00
2013-07-12 06:46:58 +08:00
enum_decl - > setAccess ( AS_public ) ; // TODO respect what's in the debug info
return ClangASTType ( ast , ast - > getTagDeclType ( enum_decl ) . getAsOpaquePtr ( ) ) ;
2010-06-09 00:52:24 +08:00
}
2013-07-12 06:46:58 +08:00
return ClangASTType ( ) ;
2010-06-09 00:52:24 +08:00
}
// 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;
//}
2014-08-16 07:00:02 +08:00
ClangASTType
ClangASTContext : : GetIntTypeFromBitSize ( clang : : ASTContext * ast ,
size_t bit_size , bool is_signed )
{
if ( ast )
{
if ( is_signed )
{
if ( bit_size = = ast - > getTypeSize ( ast - > SignedCharTy ) )
return ClangASTType ( ast , ast - > SignedCharTy . getAsOpaquePtr ( ) ) ;
if ( bit_size = = ast - > getTypeSize ( ast - > ShortTy ) )
return ClangASTType ( ast , ast - > ShortTy . getAsOpaquePtr ( ) ) ;
if ( bit_size = = ast - > getTypeSize ( ast - > IntTy ) )
return ClangASTType ( ast , ast - > IntTy . getAsOpaquePtr ( ) ) ;
if ( bit_size = = ast - > getTypeSize ( ast - > LongTy ) )
return ClangASTType ( ast , ast - > LongTy . getAsOpaquePtr ( ) ) ;
if ( bit_size = = ast - > getTypeSize ( ast - > LongLongTy ) )
return ClangASTType ( ast , ast - > LongLongTy . getAsOpaquePtr ( ) ) ;
if ( bit_size = = ast - > getTypeSize ( ast - > Int128Ty ) )
return ClangASTType ( ast , ast - > Int128Ty . getAsOpaquePtr ( ) ) ;
}
else
{
if ( bit_size = = ast - > getTypeSize ( ast - > UnsignedCharTy ) )
return ClangASTType ( ast , ast - > UnsignedCharTy . getAsOpaquePtr ( ) ) ;
if ( bit_size = = ast - > getTypeSize ( ast - > UnsignedShortTy ) )
return ClangASTType ( ast , ast - > UnsignedShortTy . getAsOpaquePtr ( ) ) ;
if ( bit_size = = ast - > getTypeSize ( ast - > UnsignedIntTy ) )
return ClangASTType ( ast , ast - > UnsignedIntTy . getAsOpaquePtr ( ) ) ;
if ( bit_size = = ast - > getTypeSize ( ast - > UnsignedLongTy ) )
return ClangASTType ( ast , ast - > UnsignedLongTy . getAsOpaquePtr ( ) ) ;
if ( bit_size = = ast - > getTypeSize ( ast - > UnsignedLongLongTy ) )
return ClangASTType ( ast , ast - > UnsignedLongLongTy . getAsOpaquePtr ( ) ) ;
if ( bit_size = = ast - > getTypeSize ( ast - > UnsignedInt128Ty ) )
return ClangASTType ( ast , ast - > UnsignedInt128Ty . getAsOpaquePtr ( ) ) ;
}
}
return ClangASTType ( ) ;
}
ClangASTType
ClangASTContext : : GetPointerSizedIntType ( clang : : ASTContext * ast , bool is_signed )
{
if ( ast )
return GetIntTypeFromBitSize ( ast , ast - > getTypeSize ( ast - > VoidPtrTy ) , is_signed ) ;
return ClangASTType ( ) ;
}
2010-09-17 10:24:29 +08:00
2013-07-12 06:46:58 +08:00
ClangASTType
2013-06-12 05:56:55 +08:00
ClangASTContext : : GetFloatTypeFromBitSize ( clang : : ASTContext * ast ,
size_t bit_size )
{
if ( ast )
{
if ( bit_size = = ast - > getTypeSize ( ast - > FloatTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > FloatTy . getAsOpaquePtr ( ) ) ;
2013-06-12 05:56:55 +08:00
else if ( bit_size = = ast - > getTypeSize ( ast - > DoubleTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > DoubleTy . getAsOpaquePtr ( ) ) ;
2013-06-12 05:56:55 +08:00
else if ( bit_size = = ast - > getTypeSize ( ast - > LongDoubleTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > LongDoubleTy . getAsOpaquePtr ( ) ) ;
2013-06-12 05:56:55 +08:00
else if ( bit_size = = ast - > getTypeSize ( ast - > HalfTy ) )
2013-07-12 06:46:58 +08:00
return ClangASTType ( ast , ast - > HalfTy . getAsOpaquePtr ( ) ) ;
2013-06-12 05:56:55 +08:00
}
2013-07-12 06:46:58 +08:00
return ClangASTType ( ) ;
2012-03-24 09:11:14 +08:00
}
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 ) )
{
2012-03-30 08:51:13 +08:00
if ( tag_decl - > isCompleteDefinition ( ) )
2011-06-25 08:44:06 +08:00
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 ) )
{
2012-02-04 16:49:35 +08:00
if ( objc_interface_decl - > getDefinition ( ) )
2011-06-25 08:44:06 +08:00
return true ;
if ( ! objc_interface_decl - > hasExternalLexicalStorage ( ) )
return false ;
ast_source - > CompleteType ( objc_interface_decl ) ;
2012-02-04 16:49:35 +08:00
return ! objc_interface_decl - > getTypeForDecl ( ) - > isIncompleteType ( ) ;
2011-06-25 08:44:06 +08:00
}
else
{
return false ;
}
}
2012-10-27 10:54:13 +08:00
void
2013-03-27 09:48:02 +08:00
ClangASTContext : : SetMetadataAsUserID ( const void * object ,
2012-10-27 10:54:13 +08:00
user_id_t user_id )
{
ClangASTMetadata meta_data ;
meta_data . SetUserID ( user_id ) ;
SetMetadata ( object , meta_data ) ;
}
2012-04-13 08:10:03 +08:00
void
ClangASTContext : : SetMetadata ( clang : : ASTContext * ast ,
2013-03-27 09:48:02 +08:00
const void * object ,
2012-10-27 10:54:13 +08:00
ClangASTMetadata & metadata )
2012-04-13 08:10:03 +08:00
{
ClangExternalASTSourceCommon * external_source =
static_cast < ClangExternalASTSourceCommon * > ( ast - > getExternalSource ( ) ) ;
if ( external_source )
external_source - > SetMetadata ( object , metadata ) ;
}
2012-10-27 10:54:13 +08:00
ClangASTMetadata *
2012-04-13 08:10:03 +08:00
ClangASTContext : : GetMetadata ( clang : : ASTContext * ast ,
2013-03-27 09:48:02 +08:00
const void * object )
2012-04-13 08:10:03 +08:00
{
ClangExternalASTSourceCommon * external_source =
static_cast < ClangExternalASTSourceCommon * > ( ast - > getExternalSource ( ) ) ;
if ( external_source & & external_source - > HasMetadata ( object ) )
return external_source - > GetMetadata ( object ) ;
else
2014-04-20 21:17:36 +08:00
return nullptr ;
2012-04-13 08:10:03 +08:00
}
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
}
2012-07-14 08:53:55 +08:00
bool
ClangASTContext : : GetClassMethodInfoForDeclContext ( clang : : DeclContext * decl_ctx ,
lldb : : LanguageType & language ,
bool & is_instance_method ,
ConstString & language_object_name )
{
language_object_name . Clear ( ) ;
language = eLanguageTypeUnknown ;
is_instance_method = false ;
if ( decl_ctx )
{
if ( clang : : CXXMethodDecl * method_decl = llvm : : dyn_cast < clang : : CXXMethodDecl > ( decl_ctx ) )
{
if ( method_decl - > isStatic ( ) )
{
is_instance_method = false ;
}
else
{
language_object_name . SetCString ( " this " ) ;
is_instance_method = true ;
}
language = eLanguageTypeC_plus_plus ;
return true ;
}
else if ( clang : : ObjCMethodDecl * method_decl = llvm : : dyn_cast < clang : : ObjCMethodDecl > ( decl_ctx ) )
{
// Both static and instance methods have a "self" object in objective C
language_object_name . SetCString ( " self " ) ;
if ( method_decl - > isInstanceMethod ( ) )
{
is_instance_method = true ;
}
else
{
is_instance_method = false ;
}
language = eLanguageTypeObjC ;
return true ;
}
2012-10-27 10:54:13 +08:00
else if ( clang : : FunctionDecl * function_decl = llvm : : dyn_cast < clang : : FunctionDecl > ( decl_ctx ) )
{
2013-03-27 09:48:02 +08:00
ClangASTMetadata * metadata = GetMetadata ( & decl_ctx - > getParentASTContext ( ) , function_decl ) ;
2012-10-27 10:54:13 +08:00
if ( metadata & & metadata - > HasObjectPtr ( ) )
{
language_object_name . SetCString ( metadata - > GetObjectPtrName ( ) ) ;
language = eLanguageTypeObjC ;
is_instance_method = true ;
}
return true ;
}
2012-07-14 08:53:55 +08:00
}
return false ;
}