type = cast<clang::AtomicType>(type)->getValueType();
break;
case clang::Type::Auto:
+ case clang::Type::Decltype:
case clang::Type::Elaborated:
case clang::Type::Paren:
case clang::Type::Typedef:
+ case clang::Type::TypeOf:
+ case clang::Type::TypeOfExpr:
type = type->getLocallyUnqualifiedSingleStepDesugaredType();
break;
default:
return eTypeHasChildren | eTypeIsVector;
case clang::Type::DependentTemplateSpecialization:
return eTypeIsTemplate;
- case clang::Type::Decltype:
- return CompilerType(this, llvm::cast<clang::DecltypeType>(qual_type)
- ->getUnderlyingType()
- .getAsOpaquePtr())
- .GetTypeInfo(pointee_or_element_clang_type);
case clang::Type::Enum:
if (pointee_or_element_clang_type)
->getUnderlyingType()
.getAsOpaquePtr())
.GetTypeInfo(pointee_or_element_clang_type);
- case clang::Type::TypeOfExpr:
- return CompilerType(this, llvm::cast<clang::TypeOfExprType>(qual_type)
- ->getUnderlyingExpr()
- ->getType()
- .getAsOpaquePtr())
- .GetTypeInfo(pointee_or_element_clang_type);
- case clang::Type::TypeOf:
- return CompilerType(this, llvm::cast<clang::TypeOfType>(qual_type)
- ->getUnderlyingType()
- .getAsOpaquePtr())
- .GetTypeInfo(pointee_or_element_clang_type);
case clang::Type::UnresolvedUsing:
return 0;
switch (qual_type->getTypeClass()) {
case clang::Type::Atomic:
case clang::Type::Auto:
+ case clang::Type::Decltype:
case clang::Type::Elaborated:
case clang::Type::Paren:
+ case clang::Type::TypeOf:
+ case clang::Type::TypeOfExpr:
llvm_unreachable("Handled in RemoveWrappingTypes!");
case clang::Type::UnaryTransform:
break;
case clang::Type::PackExpansion:
break;
- case clang::Type::TypeOfExpr:
- return CompilerType(this, llvm::cast<clang::TypeOfExprType>(qual_type)
- ->getUnderlyingExpr()
- ->getType()
- .getAsOpaquePtr())
- .GetTypeClass();
- case clang::Type::TypeOf:
- return CompilerType(this, llvm::cast<clang::TypeOfType>(qual_type)
- ->getUnderlyingType()
- .getAsOpaquePtr())
- .GetTypeClass();
- case clang::Type::Decltype:
- return CompilerType(this, llvm::cast<clang::TypeOfType>(qual_type)
- ->getUnderlyingType()
- .getAsOpaquePtr())
- .GetTypeClass();
case clang::Type::TemplateSpecialization:
break;
case clang::Type::DeducedTemplateSpecialization:
switch (qual_type->getTypeClass()) {
case clang::Type::Atomic:
case clang::Type::Auto:
+ case clang::Type::Decltype:
case clang::Type::Elaborated:
case clang::Type::Paren:
case clang::Type::Typedef:
+ case clang::Type::TypeOf:
+ case clang::Type::TypeOfExpr:
llvm_unreachable("Handled in RemoveWrappingTypes!");
case clang::Type::UnaryTransform:
break;
case clang::Type::Enum:
return lldb::eEncodingSint;
- case clang::Type::TypeOfExpr:
- return CompilerType(this, llvm::cast<clang::TypeOfExprType>(qual_type)
- ->getUnderlyingExpr()
- ->getType()
- .getAsOpaquePtr())
- .GetEncoding(count);
- case clang::Type::TypeOf:
- return CompilerType(this, llvm::cast<clang::TypeOfType>(qual_type)
- ->getUnderlyingType()
- .getAsOpaquePtr())
- .GetEncoding(count);
- case clang::Type::Decltype:
- return CompilerType(this, llvm::cast<clang::DecltypeType>(qual_type)
- ->getUnderlyingType()
- .getAsOpaquePtr())
- .GetEncoding(count);
case clang::Type::DependentSizedArray:
case clang::Type::DependentSizedExtVector:
case clang::Type::UnresolvedUsing:
switch (qual_type->getTypeClass()) {
case clang::Type::Atomic:
case clang::Type::Auto:
+ case clang::Type::Decltype:
case clang::Type::Elaborated:
case clang::Type::Paren:
case clang::Type::Typedef:
+ case clang::Type::TypeOf:
+ case clang::Type::TypeOfExpr:
llvm_unreachable("Handled in RemoveWrappingTypes!");
case clang::Type::UnaryTransform:
break;
break;
case clang::Type::Enum:
return lldb::eFormatEnum;
- case clang::Type::TypeOfExpr:
- return CompilerType(this, llvm::cast<clang::TypeOfExprType>(qual_type)
- ->getUnderlyingExpr()
- ->getType()
- .getAsOpaquePtr())
- .GetFormat();
- case clang::Type::TypeOf:
- return CompilerType(this, llvm::cast<clang::TypeOfType>(qual_type)
- ->getUnderlyingType()
- .getAsOpaquePtr())
- .GetFormat();
- case clang::Type::Decltype:
- return CompilerType(this, llvm::cast<clang::DecltypeType>(qual_type)
- ->getUnderlyingType()
- .getAsOpaquePtr())
- .GetFormat();
case clang::Type::DependentSizedArray:
case clang::Type::DependentSizedExtVector:
case clang::Type::UnresolvedUsing:
return 0; // When we function pointers, they have no children...
case clang::Type::UnresolvedUsing:
return 0;
- case clang::Type::TypeOfExpr:
- return GetNumPointeeChildren(llvm::cast<clang::TypeOfExprType>(qual_type)
- ->getUnderlyingExpr()
- ->getType());
- case clang::Type::TypeOf:
- return GetNumPointeeChildren(
- llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType());
- case clang::Type::Decltype:
- return GetNumPointeeChildren(
- llvm::cast<clang::DecltypeType>(qual_type)->getUnderlyingType());
case clang::Type::Record:
return 0;
case clang::Type::Enum:
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
-
-#include "clang/AST/DeclCXX.h"
-
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/Declaration.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/ExprCXX.h"
+#include "gtest/gtest.h"
using namespace clang;
using namespace lldb;
EXPECT_EQ(int_type, result->type);
}
}
+
+static QualType makeConstInt(clang::ASTContext &ctxt) {
+ QualType result(ctxt.IntTy);
+ result.addConst();
+ return result;
+}
+
+TEST_F(TestClangASTContext, TestGetTypeClassDeclType) {
+ clang::ASTContext &ctxt = *m_ast->getASTContext();
+ auto *nullptr_expr = new (ctxt) CXXNullPtrLiteralExpr(ctxt.NullPtrTy, SourceLocation());
+ QualType t = ctxt.getDecltypeType(nullptr_expr, makeConstInt(ctxt));
+ EXPECT_EQ(lldb::eTypeClassBuiltin, m_ast->GetTypeClass(t.getAsOpaquePtr()));
+}
+
+TEST_F(TestClangASTContext, TestGetTypeClassTypeOf) {
+ clang::ASTContext &ctxt = *m_ast->getASTContext();
+ QualType t = ctxt.getTypeOfType(makeConstInt(ctxt));
+ EXPECT_EQ(lldb::eTypeClassBuiltin, m_ast->GetTypeClass(t.getAsOpaquePtr()));
+}
+
+TEST_F(TestClangASTContext, TestGetTypeClassTypeOfExpr) {
+ clang::ASTContext &ctxt = *m_ast->getASTContext();
+ auto *nullptr_expr = new (ctxt) CXXNullPtrLiteralExpr(ctxt.NullPtrTy, SourceLocation());
+ QualType t = ctxt.getTypeOfExprType(nullptr_expr);
+ EXPECT_EQ(lldb::eTypeClassBuiltin, m_ast->GetTypeClass(t.getAsOpaquePtr()));
+}
+
+TEST_F(TestClangASTContext, TestGetTypeClassNested) {
+ clang::ASTContext &ctxt = *m_ast->getASTContext();
+ QualType t_base = ctxt.getTypeOfType(makeConstInt(ctxt));
+ QualType t = ctxt.getTypeOfType(t_base);
+ EXPECT_EQ(lldb::eTypeClassBuiltin, m_ast->GetTypeClass(t.getAsOpaquePtr()));
+}