summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2015-11-07 02:06:57 +0000
committerEnrico Granata <egranata@apple.com>2015-11-07 02:06:57 +0000
commit7123e2b5d79b6ed18f56ebac1e8c8bc1a57ea23c (patch)
tree7cbfbd7a15cc2fdc98a4a3e736b0a7372253a154
parentea1df7fe9fc363e7583f691431b54fdb658fe0a8 (diff)
downloadbcm5719-llvm-7123e2b5d79b6ed18f56ebac1e8c8bc1a57ea23c.tar.gz
bcm5719-llvm-7123e2b5d79b6ed18f56ebac1e8c8bc1a57ea23c.zip
Add SBType::IsAnonymousType() and relative plumbing in the debugger internals
For language that support such a thing, this API allows to ask whether a type is anonymous (i.e. has been given no name) Comes with test case llvm-svn: 252390
-rw-r--r--lldb/include/lldb/API/SBType.h3
-rw-r--r--lldb/include/lldb/Symbol/ClangASTContext.h3
-rw-r--r--lldb/include/lldb/Symbol/CompilerType.h3
-rw-r--r--lldb/include/lldb/Symbol/TypeSystem.h3
-rw-r--r--lldb/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py5
-rw-r--r--lldb/packages/Python/lldbsuite/test/python_api/type/main.cpp6
-rw-r--r--lldb/scripts/interface/SBType.i3
-rw-r--r--lldb/source/API/SBType.cpp8
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp32
-rw-r--r--lldb/source/Symbol/CompilerType.cpp8
-rw-r--r--lldb/source/Symbol/TypeSystem.cpp6
11 files changed, 80 insertions, 0 deletions
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 119a9ccf992..e5ce10916e3 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -158,6 +158,9 @@ public:
bool
IsTypedefType ();
+ bool
+ IsAnonymousType ();
+
lldb::SBType
GetPointerType();
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index a6d17e43880..1062b848e16 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -606,6 +606,9 @@ public:
IsAggregateType (lldb::opaque_compiler_type_t type) override;
bool
+ IsAnonymousType (lldb::opaque_compiler_type_t type) override;
+
+ bool
IsBeingDefined (lldb::opaque_compiler_type_t type) override;
bool
diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index 7cb9e48369b..6e36c1bd639 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -107,6 +107,9 @@ public:
IsAggregateType () const;
bool
+ IsAnonymousType () const;
+
+ bool
IsBeingDefined () const;
bool
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h
index 0bc05263488..2190b6df115 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -153,6 +153,9 @@ public:
virtual bool
IsAggregateType (lldb::opaque_compiler_type_t type) = 0;
+
+ virtual bool
+ IsAnonymousType (lldb::opaque_compiler_type_t type);
virtual bool
IsCharType (lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py b/lldb/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py
index 58bf5e5b988..d9e5719844e 100644
--- a/lldb/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py
+++ b/lldb/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py
@@ -59,11 +59,16 @@ class TypeAndTypeListTestCase(TestBase):
for type in type_list:
self.assertTrue(type)
self.DebugSBType(type)
+ self.assertFalse(type.IsAnonymousType(), "Task is not anonymous")
for field in type.fields:
if field.name == "type":
for enum_member in field.type.enum_members:
self.assertTrue(enum_member)
self.DebugSBType(enum_member.type)
+ elif field.name == "my_type_is_nameless":
+ self.assertTrue(field.type.IsAnonymousType(), "my_type_is_nameless has an anonymous type")
+ elif field.name == "my_type_is_named":
+ self.assertFalse(field.type.IsAnonymousType(), "my_type_is_named has a named type")
# Pass an empty string. LLDB should not crash. :-)
fuzz_types = target.FindTypes(None)
diff --git a/lldb/packages/Python/lldbsuite/test/python_api/type/main.cpp b/lldb/packages/Python/lldbsuite/test/python_api/type/main.cpp
index 67b57ace08f..b7f3dcc7fbe 100644
--- a/lldb/packages/Python/lldbsuite/test/python_api/type/main.cpp
+++ b/lldb/packages/Python/lldbsuite/test/python_api/type/main.cpp
@@ -16,6 +16,12 @@ public:
TASK_TYPE_1,
TASK_TYPE_2
} type;
+ struct {
+ int x;
+ } my_type_is_nameless;
+ struct name {
+ int x;
+ } my_type_is_named;
Task(int i, Task *n):
id(i),
next(n),
diff --git a/lldb/scripts/interface/SBType.i b/lldb/scripts/interface/SBType.i
index 14bb11d2ee4..d73aacc1822 100644
--- a/lldb/scripts/interface/SBType.i
+++ b/lldb/scripts/interface/SBType.i
@@ -215,6 +215,9 @@ public:
bool
IsTypedefType ();
+ bool
+ IsAnonymousType ();
+
lldb::SBType
GetPointerType();
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index dcdbbc71d20..90a2e655172 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -264,6 +264,14 @@ SBType::IsTypedefType ()
return m_opaque_sp->GetCompilerType(true).IsTypedefType();
}
+bool
+SBType::IsAnonymousType ()
+{
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetCompilerType(true).IsAnonymousType();
+}
+
lldb::SBType
SBType::GetFunctionReturnType ()
{
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 3ac73782e2e..11e587c1061 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -2585,6 +2585,38 @@ ClangASTContext::IsAggregateType (lldb::opaque_compiler_type_t type)
}
bool
+ClangASTContext::IsAnonymousType (lldb::opaque_compiler_type_t type)
+{
+ clang::QualType qual_type (GetCanonicalQualType(type));
+
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Record:
+ {
+ if (const clang::RecordType *record_type = llvm::dyn_cast_or_null<clang::RecordType>(qual_type.getTypePtrOrNull()))
+ {
+ if (const clang::RecordDecl *record_decl = record_type->getDecl())
+ {
+ return record_decl->isAnonymousStructOrUnion();
+ }
+ }
+ break;
+ }
+ case clang::Type::Elaborated:
+ return IsAnonymousType(llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
+ case clang::Type::Typedef:
+ return IsAnonymousType(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
+ case clang::Type::Paren:
+ return IsAnonymousType(llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr());
+ default:
+ break;
+ }
+ // The clang type does have a value
+ return false;
+}
+
+bool
ClangASTContext::IsArrayType (lldb::opaque_compiler_type_t type,
CompilerType *element_type_ptr,
uint64_t *size,
diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index 061539a0310..e7cbe63a8a3 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -64,6 +64,14 @@ CompilerType::IsAggregateType () const
}
bool
+CompilerType::IsAnonymousType () const
+{
+ if (IsValid())
+ return m_type_system->IsAnonymousType(m_type);
+ return false;
+}
+
+bool
CompilerType::IsArrayType (CompilerType *element_type_ptr,
uint64_t *size,
bool *is_incomplete) const
diff --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp
index eb44b292603..5aa83b4b479 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -55,6 +55,12 @@ TypeSystem::CreateInstance (lldb::LanguageType language, Target *target)
return lldb::TypeSystemSP();
}
+bool
+TypeSystem::IsAnonymousType (lldb::opaque_compiler_type_t type)
+{
+ return false;
+}
+
CompilerType
TypeSystem::GetLValueReferenceType (lldb::opaque_compiler_type_t type)
{
OpenPOWER on IntegriCloud