Index: packages/Python/lldbsuite/test/expression_command/test/TestExprs.py =================================================================== --- packages/Python/lldbsuite/test/expression_command/test/TestExprs.py +++ packages/Python/lldbsuite/test/expression_command/test/TestExprs.py @@ -253,3 +253,20 @@ self.expect('print_hi', substrs=['(int) $', '6']) + + def test_expr_commands_typeof(self): + """Throw typeof expression at lldb.""" + self.build() + + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=False) + + self.runCmd("run", RUN_SUCCEEDED) + + # runCmd: expression p int i; __typeof__(i) j = 1; j + # output: (typeof (i)) $0 = 1 + self.expect("expression p int i; __typeof__(i) j = 1; j", + substrs=['(typeof (i)) $', + "1"]) Index: source/Symbol/ClangASTContext.cpp =================================================================== --- source/Symbol/ClangASTContext.cpp +++ source/Symbol/ClangASTContext.cpp @@ -4046,9 +4046,13 @@ ->getUnderlyingType()) .GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOfExpr: - return 0; + return CompilerType(getASTContext(), + llvm::cast(qual_type)->getUnderlyingExpr()->getType()) + .GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOf: - return 0; + return CompilerType(getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) + .GetTypeInfo(pointee_or_element_clang_type); case clang::Type::UnresolvedUsing: return 0; @@ -4255,9 +4259,14 @@ break; case clang::Type::TypeOfExpr: - break; + return CompilerType(getASTContext(), + llvm::cast(qual_type)->getUnderlyingExpr()->getType()) + .GetTypeClass(); case clang::Type::TypeOf: - break; + return CompilerType(getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) + .GetTypeClass(); + case clang::Type::Decltype: break; case clang::Type::TemplateSpecialization: @@ -5060,7 +5069,14 @@ return CompilerType(getASTContext(), llvm::cast(qual_type)->desugar()) .GetEncoding(count); - + case clang::Type::TypeOfExpr: + return CompilerType(getASTContext(), + llvm::cast(qual_type)->getUnderlyingExpr()->getType()) + .GetEncoding(count); + case clang::Type::TypeOf: + return CompilerType(getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) + .GetEncoding(count); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5074,8 +5090,6 @@ 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: @@ -5214,6 +5228,14 @@ getASTContext(), llvm::cast(qual_type)->getNamedType()) .GetFormat(); + case clang::Type::TypeOfExpr: + return CompilerType(getASTContext(), + llvm::cast(qual_type)->getUnderlyingExpr()->getType()) + .GetFormat(); + case clang::Type::TypeOf: + return CompilerType(getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) + .GetFormat(); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5227,8 +5249,6 @@ 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: @@ -6264,9 +6284,11 @@ return GetNumPointeeChildren( llvm::cast(qual_type)->getNamedType()); case clang::Type::TypeOfExpr: - return 0; + return GetNumPointeeChildren( + llvm::cast(qual_type)->getUnderlyingExpr()->getType()); case clang::Type::TypeOf: - return 0; + return GetNumPointeeChildren( + llvm::cast(qual_type)->getUnderlyingType()); case clang::Type::Decltype: return 0; case clang::Type::Record: @@ -10086,4 +10108,3 @@ lldbassert(m_scratch_ast_source_ap != nullptr); return m_scratch_ast_source_ap->GetMergerUnchecked(); } -