summaryrefslogtreecommitdiff
path: root/lldb/source/Symbol/ClangASTContext.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2018-02-20 10:15:08 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2018-02-20 10:15:08 +0000
commitfda6ea8fbcf768149a1c4b18cc2a15f38dc69785 (patch)
tree1148c2c0b54354afb8bd4335507e14a81f53a921 /lldb/source/Symbol/ClangASTContext.cpp
parent14348f8afb30c1090400faf851a1b8530078af1f (diff)
Handle typeof() expressions
Before this patch, LLDB was not able to evaluate expressions that resulted in a value with a typeof- or decltype-type. This patch fixes that. Before: (lldb) p int i; __typeof__(i) j = 1; j (typeof (i)) $0 = After: (lldb) p int i; __typeof__(i) j = 1; j (typeof (i)) $0 = 1 Differential revision: https://reviews.llvm.org/D43471 rdar://37461520
Diffstat (limited to 'lldb/source/Symbol/ClangASTContext.cpp')
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp82
1 files changed, 65 insertions, 17 deletions
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 673124cc0de..142a7cc6255 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -3964,7 +3964,10 @@ ClangASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type,
case clang::Type::DependentTemplateSpecialization:
return eTypeIsTemplate;
case clang::Type::Decltype:
- return 0;
+ return CompilerType(
+ getASTContext(),
+ llvm::cast<clang::DecltypeType>(qual_type)->getUnderlyingType())
+ .GetTypeInfo(pointee_or_element_clang_type);
case clang::Type::Enum:
if (pointee_or_element_clang_type)
@@ -4046,9 +4049,16 @@ ClangASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type,
->getUnderlyingType())
.GetTypeInfo(pointee_or_element_clang_type);
case clang::Type::TypeOfExpr:
- return 0;
+ return CompilerType(getASTContext(),
+ llvm::cast<clang::TypeOfExprType>(qual_type)
+ ->getUnderlyingExpr()
+ ->getType())
+ .GetTypeInfo(pointee_or_element_clang_type);
case clang::Type::TypeOf:
- return 0;
+ return CompilerType(
+ getASTContext(),
+ llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
+ .GetTypeInfo(pointee_or_element_clang_type);
case clang::Type::UnresolvedUsing:
return 0;
@@ -4255,11 +4265,21 @@ ClangASTContext::GetTypeClass(lldb::opaque_compiler_type_t type) {
break;
case clang::Type::TypeOfExpr:
- break;
+ return CompilerType(getASTContext(),
+ llvm::cast<clang::TypeOfExprType>(qual_type)
+ ->getUnderlyingExpr()
+ ->getType())
+ .GetTypeClass();
case clang::Type::TypeOf:
- break;
+ return CompilerType(
+ getASTContext(),
+ llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
+ .GetTypeClass();
case clang::Type::Decltype:
- break;
+ return CompilerType(
+ getASTContext(),
+ llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
+ .GetTypeClass();
case clang::Type::TemplateSpecialization:
break;
case clang::Type::DeducedTemplateSpecialization:
@@ -5060,7 +5080,22 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
return CompilerType(getASTContext(),
llvm::cast<clang::ParenType>(qual_type)->desugar())
.GetEncoding(count);
-
+ case clang::Type::TypeOfExpr:
+ return CompilerType(getASTContext(),
+ llvm::cast<clang::TypeOfExprType>(qual_type)
+ ->getUnderlyingExpr()
+ ->getType())
+ .GetEncoding(count);
+ case clang::Type::TypeOf:
+ return CompilerType(
+ getASTContext(),
+ llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
+ .GetEncoding(count);
+ case clang::Type::Decltype:
+ return CompilerType(
+ getASTContext(),
+ llvm::cast<clang::DecltypeType>(qual_type)->getUnderlyingType())
+ .GetEncoding(count);
case clang::Type::DependentSizedArray:
case clang::Type::DependentSizedExtVector:
case clang::Type::UnresolvedUsing:
@@ -5074,9 +5109,6 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
case clang::Type::PackExpansion:
case clang::Type::ObjCObject:
- case clang::Type::TypeOfExpr:
- case clang::Type::TypeOf:
- case clang::Type::Decltype:
case clang::Type::TemplateSpecialization:
case clang::Type::DeducedTemplateSpecialization:
case clang::Type::Atomic:
@@ -5214,6 +5246,22 @@ lldb::Format ClangASTContext::GetFormat(lldb::opaque_compiler_type_t type) {
getASTContext(),
llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
.GetFormat();
+ case clang::Type::TypeOfExpr:
+ return CompilerType(getASTContext(),
+ llvm::cast<clang::TypeOfExprType>(qual_type)
+ ->getUnderlyingExpr()
+ ->getType())
+ .GetFormat();
+ case clang::Type::TypeOf:
+ return CompilerType(
+ getASTContext(),
+ llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
+ .GetFormat();
+ case clang::Type::Decltype:
+ return CompilerType(
+ getASTContext(),
+ llvm::cast<clang::DecltypeType>(qual_type)->getUnderlyingType())
+ .GetFormat();
case clang::Type::DependentSizedArray:
case clang::Type::DependentSizedExtVector:
case clang::Type::UnresolvedUsing:
@@ -5227,9 +5275,6 @@ lldb::Format ClangASTContext::GetFormat(lldb::opaque_compiler_type_t type) {
case clang::Type::PackExpansion:
case clang::Type::ObjCObject:
- case clang::Type::TypeOfExpr:
- case clang::Type::TypeOf:
- case clang::Type::Decltype:
case clang::Type::TemplateSpecialization:
case clang::Type::DeducedTemplateSpecialization:
case clang::Type::Atomic:
@@ -6264,11 +6309,15 @@ uint32_t ClangASTContext::GetNumPointeeChildren(clang::QualType type) {
return GetNumPointeeChildren(
llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType());
case clang::Type::TypeOfExpr:
- return 0;
+ return GetNumPointeeChildren(llvm::cast<clang::TypeOfExprType>(qual_type)
+ ->getUnderlyingExpr()
+ ->getType());
case clang::Type::TypeOf:
- return 0;
+ return GetNumPointeeChildren(
+ llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType());
case clang::Type::Decltype:
- return 0;
+ return GetNumPointeeChildren(
+ llvm::cast<clang::DecltypeType>(qual_type)->getUnderlyingType());
case clang::Type::Record:
return 0;
case clang::Type::Enum:
@@ -10086,4 +10135,3 @@ ClangASTContextForExpressions::GetMergerUnchecked() {
lldbassert(m_scratch_ast_source_ap != nullptr);
return m_scratch_ast_source_ap->GetMergerUnchecked();
}
-