20#include "clang/Basic/TargetInfo.h"
34 "AppleObjCTypeEncodingParser ASTContext",
45std::optional<std::string>
51 while (type.
Peek() !=
'"') {
62 total = 10 * total + (type.
Next() -
'0');
76 bool for_expression) {
80 retval.
name = *maybe_name;
84 uint32_t bitfield_size = 0;
85 retval.
type =
BuildType(ast_ctx, type, for_expression, &bitfield_size);
93 llvm::to_underlying(clang::TagTypeKind::Struct));
99 llvm::to_underlying(clang::TagTypeKind::Union));
104 char opener,
char closer, uint32_t kind) {
106 return clang::QualType();
113 const bool is_templated = name.find(
'<') != std::string::npos;
116 return clang::QualType();
117 bool in_union =
true;
118 std::vector<StructElement> elements;
120 if (type.
NextIf(closer)) {
125 if (element.type.isNull())
128 elements.push_back(element);
132 return clang::QualType();
135 return clang::QualType();
143 unsigned int count = 0;
144 for (
auto element : elements) {
145 if (element.name.empty()) {
147 elem_name.
Printf(
"__unnamed_%u", count);
148 element.name = std::string(elem_name.
GetString());
151 union_type, element.name.c_str(), ast_ctx.
GetType(element.type),
163 return clang::QualType();
165 clang::QualType element_type(
BuildType(ast_ctx, type, for_expression));
167 return clang::QualType();
169 CompilerType(ast_ctx.weak_from_this(), element_type.getAsOpaquePtr()),
182 return clang::QualType();
211 return clang::QualType();
214 switch (type.
Peek()) {
233 if (for_expression && !name.empty()) {
234 size_t less_than_pos = name.find(
'<');
236 if (less_than_pos != std::string::npos) {
237 if (less_than_pos == 0)
238 return ast_ctx.getObjCIdType();
240 name.erase(less_than_pos);
245 return clang::QualType();
253 assert(
false &&
"forward declaration without definition");
255 "forward declaration without definition: {0}", name);
256 return ast_ctx.getObjCIdType();
262 return ast_ctx.getObjCIdType();
269 uint32_t *bitfield_bit_size) {
271 return clang::QualType();
275 switch (type.
Peek()) {
279 return BuildStruct(clang_ast_ctx, type, for_expression);
281 return BuildArray(clang_ast_ctx, type, for_expression);
283 return BuildUnion(clang_ast_ctx, type, for_expression);
288 switch (type.
Next()) {
291 return clang::QualType();
293 return ast_ctx.CharTy;
295 return ast_ctx.IntTy;
297 return ast_ctx.ShortTy;
299 return ast_ctx.getIntTypeForBitwidth(32,
true);
305 return ast_ctx.LongLongTy;
307 return ast_ctx.UnsignedCharTy;
309 return ast_ctx.UnsignedIntTy;
311 return ast_ctx.UnsignedShortTy;
313 return ast_ctx.getIntTypeForBitwidth(32,
false);
316 return ast_ctx.UnsignedLongLongTy;
318 return ast_ctx.FloatTy;
320 return ast_ctx.DoubleTy;
322 return ast_ctx.BoolTy;
324 return ast_ctx.VoidTy;
326 return ast_ctx.getPointerType(ast_ctx.CharTy);
328 return ast_ctx.getObjCClassType();
330 return ast_ctx.getObjCSelType();
333 if (bitfield_bit_size) {
334 *bitfield_bit_size = size;
335 return ast_ctx.UnsignedIntTy;
337 return clang::QualType();
340 clang::QualType target_type =
341 BuildType(clang_ast_ctx, type, for_expression);
342 if (target_type.isNull())
343 return clang::QualType();
344 else if (target_type == ast_ctx.UnknownAnyTy)
345 return ast_ctx.UnknownAnyTy;
347 return ast_ctx.getConstType(target_type);
356 return ast_ctx.VoidPtrTy;
358 clang::QualType target_type =
359 BuildType(clang_ast_ctx, type, for_expression);
360 if (target_type.isNull())
361 return clang::QualType();
362 else if (target_type == ast_ctx.UnknownAnyTy)
363 return ast_ctx.UnknownAnyTy;
365 return ast_ctx.getPointerType(target_type);
369 return for_expression ? ast_ctx.UnknownAnyTy : clang::QualType();
375 bool for_expression) {
376 if (name && name[0]) {
378 clang::QualType qual_type =
BuildType(ast_ctx, lexer, for_expression);
379 return ast_ctx.
GetType(qual_type);
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
clang::QualType BuildType(TypeSystemClang &clang_ast_ctx, StringLexer &type, bool for_expression, uint32_t *bitfield_bit_size=nullptr)
clang::QualType BuildObjCObjectPointerType(TypeSystemClang &clang_ast_ctx, StringLexer &type, bool for_expression)
CompilerType RealizeType(TypeSystemClang &ast_ctx, const char *name, bool for_expression) override
uint32_t ReadNumber(StringLexer &type)
clang::QualType BuildAggregate(TypeSystemClang &clang_ast_ctx, StringLexer &type, bool for_expression, char opener, char closer, uint32_t kind)
std::optional< std::string > ReadQuotedString(StringLexer &type)
ObjCLanguageRuntime & m_runtime
StructElement ReadStructElement(TypeSystemClang &ast_ctx, StringLexer &type, bool for_expression)
AppleObjCTypeEncodingParser(ObjCLanguageRuntime &runtime)
clang::QualType BuildArray(TypeSystemClang &ast_ctx, StringLexer &type, bool for_expression)
clang::QualType BuildStruct(TypeSystemClang &ast_ctx, StringLexer &type, bool for_expression)
std::string ReadStructName(StringLexer &type)
clang::QualType BuildUnion(TypeSystemClang &ast_ctx, StringLexer &type, bool for_expression)
llvm::Triple & GetTriple()
Architecture triple accessor.
Generic representation of a type in a programming language.
A uniqued constant string class.
std::vector< CompilerType > FindTypes(ConstString name, uint32_t max_matches)
Look up the types that the DeclVendor currently knows about matching a given name.
std::shared_ptr< TypeSystemClang > m_scratch_ast_ctx_sp
Target & GetTarget()
Get the target object pointer for this module.
llvm::StringRef GetString() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
const ArchSpec & GetArchitecture() const
A TypeSystem implementation based on Clang.
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, lldb::AccessType access, uint32_t bitfield_bit_size)
CompilerType CreateArrayType(const CompilerType &element_type, std::optional< size_t > element_count, bool is_vector)
CompilerType GetType(clang::QualType qt)
Creates a CompilerType from the given QualType with the current TypeSystemClang instance as the Compi...
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, std::optional< ClangASTMetadata > metadata=std::nullopt, bool exports_symbols=false)
static bool StartTagDeclarationDefinition(const CompilerType &type)
clang::ASTContext & getASTContext() const
Returns the clang::ASTContext instance managed by this TypeSystemClang.
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
@ eLanguageTypeC
Non-standardized C, such as K&R.
static clang::QualType GetQualType(const CompilerType &ct)