1 //===-- AppleObjCTypeEncodingParser.h ---------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef liblldb_AppleObjCTypeEncodingParser_h_ 10 #define liblldb_AppleObjCTypeEncodingParser_h_ 11 12 #include "clang/AST/ASTContext.h" 13 14 #include "lldb/lldb-private.h" 15 16 #include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h" 17 18 namespace lldb_utility { 19 class StringLexer; 20 } 21 22 namespace lldb_private { 23 24 class AppleObjCTypeEncodingParser : public ObjCLanguageRuntime::EncodingToType { 25 public: 26 AppleObjCTypeEncodingParser(ObjCLanguageRuntime &runtime); 27 ~AppleObjCTypeEncodingParser() override = default; 28 29 CompilerType RealizeType(clang::ASTContext &ast_ctx, const char *name, 30 bool for_expression) override; 31 32 private: 33 struct StructElement { 34 std::string name; 35 clang::QualType type; 36 uint32_t bitfield; 37 38 StructElement(); 39 ~StructElement() = default; 40 }; 41 42 clang::QualType BuildType(clang::ASTContext &ast_ctx, 43 lldb_utility::StringLexer &type, 44 bool for_expression, 45 uint32_t *bitfield_bit_size = nullptr); 46 47 clang::QualType BuildStruct(clang::ASTContext &ast_ctx, 48 lldb_utility::StringLexer &type, 49 bool for_expression); 50 51 clang::QualType BuildAggregate(clang::ASTContext &ast_ctx, 52 lldb_utility::StringLexer &type, 53 bool for_expression, char opener, char closer, 54 uint32_t kind); 55 56 clang::QualType BuildUnion(clang::ASTContext &ast_ctx, 57 lldb_utility::StringLexer &type, 58 bool for_expression); 59 60 clang::QualType BuildArray(clang::ASTContext &ast_ctx, 61 lldb_utility::StringLexer &type, 62 bool for_expression); 63 64 std::string ReadStructName(lldb_utility::StringLexer &type); 65 66 StructElement ReadStructElement(clang::ASTContext &ast_ctx, 67 lldb_utility::StringLexer &type, 68 bool for_expression); 69 70 clang::QualType BuildObjCObjectPointerType(clang::ASTContext &ast_ctx, 71 lldb_utility::StringLexer &type, 72 bool for_expression); 73 74 uint32_t ReadNumber(lldb_utility::StringLexer &type); 75 76 std::string ReadQuotedString(lldb_utility::StringLexer &type); 77 78 ObjCLanguageRuntime &m_runtime; 79 }; 80 81 } // namespace lldb_private 82 83 #endif // liblldb_AppleObjCTypeEncodingParser_h_ 84