[Lldb-commits] [lldb] r273750 - Made templates that have Enumeration values as arguments work correctly.
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Fri Jun 24 16:48:01 PDT 2016
Author: gclayton
Date: Fri Jun 24 18:48:00 2016
New Revision: 273750
URL: http://llvm.org/viewvc/llvm-project?rev=273750&view=rev
Log:
Made templates that have Enumeration values as arguments work correctly.
We were checking for integer types only before this. So I added the ability for CompilerType objects to check for integer and enum types.
Then I searched for places that were using the CompilerType::IsIntegerType(...) function. Many of these places also wanted to be checking for enumeration types as well, so I have fixed those places. These are in the ABI plug-ins where we are figuring out which arguments would go in where in regisers/stack when making a function call, or determining where the return value would live. The real fix for this is to use clang to compiler a CGFunctionInfo and then modify the code to be able to take the IR and a calling convention and have the backend answer the questions correctly for us so we don't need to create a really bad copy of the ABI in each plug-in, but that is beyond the scope of this bug fix.
Also added a test case to ensure this doesn't regress in the future.
Modified:
lldb/trunk/include/lldb/Symbol/ClangASTContext.h
lldb/trunk/include/lldb/Symbol/CompilerType.h
lldb/trunk/include/lldb/Symbol/TypeSystem.h
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateIntegerArgs.py
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/trunk/source/Symbol/ClangASTContext.cpp
lldb/trunk/source/Symbol/CompilerType.cpp
Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Fri Jun 24 18:48:00 2016
@@ -689,7 +689,10 @@ public:
bool
IsIntegerType (lldb::opaque_compiler_type_t type, bool &is_signed) override;
-
+
+ bool
+ IsEnumerationType (lldb::opaque_compiler_type_t type, bool &is_signed) override;
+
static bool
IsObjCClassType (const CompilerType& type);
Modified: lldb/trunk/include/lldb/Symbol/CompilerType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompilerType.h?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/CompilerType.h (original)
+++ lldb/trunk/include/lldb/Symbol/CompilerType.h Fri Jun 24 18:48:00 2016
@@ -153,7 +153,13 @@ public:
bool
IsIntegerType (bool &is_signed) const;
-
+
+ bool
+ IsEnumerationType (bool &is_signed) const;
+
+ bool
+ IsIntegerOrEnumerationType (bool &is_signed) const;
+
bool
IsPolymorphicClass () const;
Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Fri Jun 24 18:48:00 2016
@@ -208,7 +208,14 @@ public:
virtual bool
IsIntegerType (lldb::opaque_compiler_type_t type, bool &is_signed) = 0;
-
+
+ virtual bool
+ IsEnumerationType (lldb::opaque_compiler_type_t type, bool &is_signed)
+ {
+ is_signed = false;
+ return false;
+ }
+
virtual bool
IsPossibleDynamicType (lldb::opaque_compiler_type_t type,
CompilerType *target_type, // Can pass NULL
Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateIntegerArgs.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateIntegerArgs.py?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateIntegerArgs.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateIntegerArgs.py Fri Jun 24 18:48:00 2016
@@ -47,6 +47,7 @@ class TemplateIntegerArgsTestCase(TestBa
testpos = frame.FindVariable('testpos')
self.assertTrue(testpos.IsValid(), 'make sure we find a local variabble named "testpos"')
self.assertTrue(testpos.GetType().GetName() == 'TestObj<1>')
+
expr_result = frame.EvaluateExpression("testpos.getArg()")
self.assertTrue(expr_result.IsValid(), 'got a valid expression result from expression "testpos.getArg()"');
self.assertTrue(expr_result.GetValue() == "1", "testpos.getArg() == 1")
@@ -60,3 +61,23 @@ class TemplateIntegerArgsTestCase(TestBa
self.assertTrue(expr_result.IsValid(), 'got a valid expression result from expression "testneg.getArg()"');
self.assertTrue(expr_result.GetValue() == "-1", "testneg.getArg() == -1")
self.assertTrue(expr_result.GetType().GetName() == "int", 'expr_result.GetType().GetName() == "int"')
+
+ # Make sure "member" can be displayed and also used in an expression correctly
+ member = frame.FindVariable('member')
+ self.assertTrue(member.IsValid(), 'make sure we find a local variabble named "member"')
+ self.assertTrue(member.GetType().GetName() == 'EnumTemplate<EnumType::Member>')
+
+ expr_result = frame.EvaluateExpression("member.getMember()")
+ self.assertTrue(expr_result.IsValid(), 'got a valid expression result from expression "member.getMember()"');
+ self.assertTrue(expr_result.GetValue() == "123", "member.getMember() == 123")
+ self.assertTrue(expr_result.GetType().GetName() == "int", 'expr_result.GetType().GetName() == "int"')
+
+ # Make sure "subclass" can be displayed and also used in an expression correctly
+ subclass = frame.FindVariable('subclass')
+ self.assertTrue(subclass.IsValid(), 'make sure we find a local variabble named "subclass"')
+ self.assertTrue(subclass.GetType().GetName() == 'EnumTemplate<EnumType::Subclass>')
+
+ expr_result = frame.EvaluateExpression("subclass.getMember()")
+ self.assertTrue(expr_result.IsValid(), 'got a valid expression result from expression "subclass.getMember()"');
+ self.assertTrue(expr_result.GetValue() == "246", "subclass.getMember() == 246")
+ self.assertTrue(expr_result.GetType().GetName() == "int", 'expr_result.GetType().GetName() == "int"')
Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp Fri Jun 24 18:48:00 2016
@@ -17,9 +17,56 @@ public:
}
};
+//----------------------------------------------------------------------
+// Define a template class that we can specialize with an enumeration
+//----------------------------------------------------------------------
+enum class EnumType
+{
+ Member,
+ Subclass
+};
+
+template <EnumType Arg> class EnumTemplate;
+
+//----------------------------------------------------------------------
+// Specialization for use when "Arg" is "EnumType::Member"
+//----------------------------------------------------------------------
+template <>
+class EnumTemplate<EnumType::Member>
+{
+public:
+ EnumTemplate(int m) :
+ m_member(m)
+ {
+ }
+
+ int getMember() const
+ {
+ return m_member;
+ }
+
+protected:
+ int m_member;
+};
+
+//----------------------------------------------------------------------
+// Specialization for use when "Arg" is "EnumType::Subclass"
+//----------------------------------------------------------------------
+template <>
+class EnumTemplate<EnumType::Subclass> :
+ public EnumTemplate<EnumType::Member>
+{
+public:
+ EnumTemplate(int m) : EnumTemplate<EnumType::Member>(m)
+ {
+ }
+};
+
int main(int argc, char **argv)
{
TestObj<1> testpos;
TestObj<-1> testneg;
- return testpos.getArg() - testneg.getArg(); // Breakpoint 1
+ EnumTemplate<EnumType::Member> member(123);
+ EnumTemplate<EnumType::Subclass> subclass(123*2);
+ return testpos.getArg() - testneg.getArg() + member.getMember()*2 - subclass.getMember(); // Breakpoint 1
}
Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Fri Jun 24 18:48:00 2016
@@ -341,7 +341,7 @@ ABIMacOSX_arm::GetArgumentValues (Thread
{
bool is_signed = false;
size_t bit_width = 0;
- if (compiler_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed))
{
bit_width = compiler_type.GetBitSize(&thread);
}
@@ -459,7 +459,7 @@ ABIMacOSX_arm::GetReturnValueObjectImpl
// when reading data
const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfoByName("r0", 0);
- if (compiler_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed))
{
size_t bit_width = compiler_type.GetBitSize(&thread);
@@ -598,7 +598,7 @@ ABIMacOSX_arm::SetReturnValueObject(lldb
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType())
{
DataExtractor data;
Error data_error;
Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp Fri Jun 24 18:48:00 2016
@@ -327,7 +327,7 @@ ABIMacOSX_arm64::GetArgumentValues (Thre
{
bool is_signed = false;
size_t bit_width = 0;
- if (value_type.IsIntegerType (is_signed))
+ if (value_type.IsIntegerOrEnumerationType (is_signed))
{
bit_width = value_type.GetBitSize(&thread);
}
Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Fri Jun 24 18:48:00 2016
@@ -315,7 +315,7 @@ ABIMacOSX_i386::GetArgumentValues (Threa
{
bool is_signed;
- if (compiler_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
compiler_type.GetBitSize(&thread),
@@ -363,7 +363,7 @@ ABIMacOSX_i386::SetReturnValueObject(lld
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType())
{
DataExtractor data;
Error data_error;
@@ -436,7 +436,7 @@ ABIMacOSX_i386::GetReturnValueObjectImpl
bool is_signed;
- if (compiler_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed))
{
size_t bit_width = compiler_type.GetBitSize(&thread);
Modified: lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp Fri Jun 24 18:48:00 2016
@@ -341,7 +341,7 @@ ABISysV_arm::GetArgumentValues (Thread &
{
bool is_signed = false;
size_t bit_width = 0;
- if (compiler_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed))
{
bit_width = compiler_type.GetBitSize(&thread);
}
@@ -463,7 +463,7 @@ ABISysV_arm::GetReturnValueObjectImpl (T
size_t bit_width = compiler_type.GetBitSize(&thread);
size_t byte_size = compiler_type.GetByteSize(&thread);
- if (compiler_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed))
{
switch (bit_width)
{
@@ -775,7 +775,7 @@ ABISysV_arm::SetReturnValueObject(lldb::
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType())
{
DataExtractor data;
Error data_error;
Modified: lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp Fri Jun 24 18:48:00 2016
@@ -322,7 +322,7 @@ ABISysV_arm64::GetArgumentValues (Thread
{
bool is_signed = false;
size_t bit_width = 0;
- if (value_type.IsIntegerType (is_signed))
+ if (value_type.IsIntegerOrEnumerationType (is_signed))
{
bit_width = value_type.GetBitSize(&thread);
}
Modified: lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp Fri Jun 24 18:48:00 2016
@@ -325,7 +325,7 @@ ABISysV_i386::GetArgumentValues (Thread
if (compiler_type)
{
bool is_signed;
- if (compiler_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
compiler_type.GetBitSize(&thread),
Modified: lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp Fri Jun 24 18:48:00 2016
@@ -322,7 +322,7 @@ ABISysV_mips::SetReturnValueObject(lldb:
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType())
{
DataExtractor data;
Error data_error;
@@ -414,7 +414,7 @@ ABISysV_mips::GetReturnValueObjectImpl (
// In MIPS register "r2" (v0) holds the integer function return values
const RegisterInfo *r2_reg_info = reg_ctx->GetRegisterInfoByName("r2", 0);
size_t bit_width = return_compiler_type.GetBitSize(&thread);
- if (return_compiler_type.IsIntegerType (is_signed))
+ if (return_compiler_type.IsIntegerOrEnumerationType (is_signed))
{
switch (bit_width)
{
Modified: lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp Fri Jun 24 18:48:00 2016
@@ -686,7 +686,7 @@ ABISysV_mips64::GetReturnValueObjectImpl
uint32_t field_byte_offset = field_bit_offset/8;
- if (field_compiler_type.IsIntegerType (is_signed)
+ if (field_compiler_type.IsIntegerOrEnumerationType (is_signed)
|| field_compiler_type.IsPointerType ()
|| field_compiler_type.IsFloatingPointType (count, is_complex))
{
Modified: lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp Fri Jun 24 18:48:00 2016
@@ -403,7 +403,7 @@ ABISysV_ppc::GetArgumentValues (Thread &
return false;
bool is_signed;
- if (compiler_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
compiler_type.GetBitSize(&thread),
@@ -454,7 +454,7 @@ ABISysV_ppc::SetReturnValueObject(lldb::
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType())
{
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r3", 0);
@@ -755,7 +755,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (T
DataExtractor *copy_from_extractor = nullptr;
uint32_t copy_from_offset = 0;
- if (field_compiler_type.IsIntegerType (is_signed) || field_compiler_type.IsPointerType ())
+ if (field_compiler_type.IsIntegerOrEnumerationType (is_signed) || field_compiler_type.IsPointerType ())
{
if (integer_bytes < 8)
{
@@ -819,7 +819,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (T
&next_field_bit_offset,
nullptr,
nullptr);
- if (next_field_compiler_type.IsIntegerType (is_signed))
+ if (next_field_compiler_type.IsIntegerOrEnumerationType (is_signed))
in_gpr = true;
else
{
@@ -842,7 +842,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (T
&prev_field_bit_offset,
nullptr,
nullptr);
- if (prev_field_compiler_type.IsIntegerType (is_signed))
+ if (prev_field_compiler_type.IsIntegerOrEnumerationType (is_signed))
in_gpr = true;
else
{
Modified: lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp Fri Jun 24 18:48:00 2016
@@ -403,7 +403,7 @@ ABISysV_ppc64::GetArgumentValues (Thread
return false;
bool is_signed;
- if (compiler_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
compiler_type.GetBitSize(&thread),
@@ -454,7 +454,7 @@ ABISysV_ppc64::SetReturnValueObject(lldb
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType())
{
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r3", 0);
@@ -755,7 +755,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl
DataExtractor *copy_from_extractor = nullptr;
uint32_t copy_from_offset = 0;
- if (field_compiler_type.IsIntegerType (is_signed) || field_compiler_type.IsPointerType ())
+ if (field_compiler_type.IsIntegerOrEnumerationType (is_signed) || field_compiler_type.IsPointerType ())
{
if (integer_bytes < 8)
{
@@ -820,7 +820,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl
&next_field_bit_offset,
nullptr,
nullptr);
- if (next_field_compiler_type.IsIntegerType (is_signed))
+ if (next_field_compiler_type.IsIntegerOrEnumerationType (is_signed))
in_gpr = true;
else
{
@@ -843,7 +843,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl
&prev_field_bit_offset,
nullptr,
nullptr);
- if (prev_field_compiler_type.IsIntegerType (is_signed))
+ if (prev_field_compiler_type.IsIntegerOrEnumerationType (is_signed))
in_gpr = true;
else
{
Modified: lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp Fri Jun 24 18:48:00 2016
@@ -396,7 +396,7 @@ ABISysV_s390x::GetArgumentValues(Thread
return false;
bool is_signed;
- if (compiler_type.IsIntegerType(is_signed))
+ if (compiler_type.IsIntegerOrEnumerationType(is_signed))
{
ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread), is_signed, thread,
argument_register_ids, current_argument_register, current_stack_argument);
@@ -437,7 +437,7 @@ ABISysV_s390x::SetReturnValueObject(lldb
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (compiler_type.IsIntegerType(is_signed) || compiler_type.IsPointerType())
+ if (compiler_type.IsIntegerOrEnumerationType(is_signed) || compiler_type.IsPointerType())
{
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r2", 0);
Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Fri Jun 24 18:48:00 2016
@@ -432,7 +432,7 @@ ABISysV_x86_64::GetArgumentValues (Threa
return false;
bool is_signed;
- if (compiler_type.IsIntegerType (is_signed))
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
compiler_type.GetBitSize(&thread),
@@ -483,7 +483,7 @@ ABISysV_x86_64::SetReturnValueObject(lld
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
- if (compiler_type.IsIntegerType (is_signed) || compiler_type.IsPointerType())
+ if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType())
{
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("rax", 0);
@@ -844,7 +844,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl
DataExtractor *copy_from_extractor = nullptr;
uint32_t copy_from_offset = 0;
- if (field_compiler_type.IsIntegerType (is_signed) || field_compiler_type.IsPointerType ())
+ if (field_compiler_type.IsIntegerOrEnumerationType (is_signed) || field_compiler_type.IsPointerType ())
{
if (integer_bytes < 8)
{
@@ -914,7 +914,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl
&next_field_bit_offset,
nullptr,
nullptr);
- if (next_field_compiler_type.IsIntegerType (is_signed))
+ if (next_field_compiler_type.IsIntegerOrEnumerationType (is_signed))
in_gpr = true;
else
{
@@ -937,7 +937,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl
&prev_field_bit_offset,
nullptr,
nullptr);
- if (prev_field_compiler_type.IsIntegerType (is_signed))
+ if (prev_field_compiler_type.IsIntegerOrEnumerationType (is_signed))
in_gpr = true;
else
{
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Fri Jun 24 18:48:00 2016
@@ -1995,8 +1995,7 @@ DWARFASTParserClang::ParseTemplateDIE (c
{
DWARFAttributes attributes;
const size_t num_attributes = die.GetAttributes (attributes);
- const char *name = NULL;
- Type *lldb_type = NULL;
+ const char *name = nullptr;
CompilerType clang_type;
uint64_t uval64 = 0;
bool uval64_valid = false;
@@ -2017,7 +2016,7 @@ DWARFASTParserClang::ParseTemplateDIE (c
case DW_AT_type:
if (attributes.ExtractFormValueAtIndex(i, form_value))
{
- lldb_type = die.ResolveTypeUID(DIERef(form_value));
+ Type *lldb_type = die.ResolveTypeUID(DIERef(form_value));
if (lldb_type)
clang_type = lldb_type->GetForwardCompilerType ();
}
@@ -2047,12 +2046,12 @@ DWARFASTParserClang::ParseTemplateDIE (c
else
template_param_infos.names.push_back(NULL);
- if (tag == DW_TAG_template_value_parameter &&
- lldb_type != NULL &&
- clang_type.IsIntegerType (is_signed) &&
- uval64_valid)
+ // Get the signed value for any integer or enumeration if available
+ clang_type.IsIntegerOrEnumerationType (is_signed);
+
+ if (tag == DW_TAG_template_value_parameter && uval64_valid)
{
- llvm::APInt apint (lldb_type->GetByteSize() * 8, uval64, is_signed);
+ llvm::APInt apint (clang_type.GetBitSize(nullptr), uval64, is_signed);
template_param_infos.args.push_back(
clang::TemplateArgument(*ast, llvm::APSInt(apint, !is_signed), ClangUtil::GetQualType(clang_type)));
}
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Jun 24 18:48:00 2016
@@ -3293,6 +3293,23 @@ ClangASTContext::IsIntegerType (lldb::op
}
bool
+ClangASTContext::IsEnumerationType(lldb::opaque_compiler_type_t type, bool &is_signed)
+{
+ if (type)
+ {
+ const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(GetCanonicalQualType(type)->getCanonicalTypeInternal());
+
+ if (enum_type)
+ {
+ IsIntegerType(enum_type->getDecl()->getIntegerType().getAsOpaquePtr(), is_signed);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool
ClangASTContext::IsPointerType (lldb::opaque_compiler_type_t type, CompilerType *pointee_type)
{
if (type)
Modified: lldb/trunk/source/Symbol/CompilerType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompilerType.cpp?rev=273750&r1=273749&r2=273750&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/CompilerType.cpp (original)
+++ lldb/trunk/source/Symbol/CompilerType.cpp Fri Jun 24 18:48:00 2016
@@ -196,6 +196,20 @@ CompilerType::IsIntegerType (bool &is_si
}
bool
+CompilerType::IsEnumerationType (bool &is_signed) const
+{
+ if (IsValid())
+ return m_type_system->IsEnumerationType(m_type, is_signed);
+ return false;
+}
+
+bool
+CompilerType::IsIntegerOrEnumerationType (bool &is_signed) const
+{
+ return IsIntegerType(is_signed) || IsEnumerationType(is_signed);
+}
+
+bool
CompilerType::IsPointerType (CompilerType *pointee_type) const
{
if (IsValid())
More information about the lldb-commits
mailing list