20#include "clang/Basic/TargetInfo.h"
33 "AppleObjCTypeEncodingParser ASTContext",
57 total = 10 * total + (type.
Next() -
'0');
66 : type(
clang::QualType()) {}
71 bool for_expression) {
77 uint32_t bitfield_size = 0;
78 retval.
type =
BuildType(ast_ctx, type, for_expression, &bitfield_size);
86 llvm::to_underlying(clang::TagTypeKind::Struct));
92 llvm::to_underlying(clang::TagTypeKind::Union));
97 char opener,
char closer, uint32_t kind) {
99 return clang::QualType();
106 const bool is_templated = name.find(
'<') != std::string::npos;
109 return clang::QualType();
110 bool in_union =
true;
111 std::vector<StructElement> elements;
113 if (type.
NextIf(closer)) {
118 if (element.type.isNull())
121 elements.push_back(element);
125 return clang::QualType();
128 return clang::QualType();
136 unsigned int count = 0;
137 for (
auto element : elements) {
138 if (element.name.empty()) {
140 elem_name.
Printf(
"__unnamed_%u", count);
141 element.name = std::string(elem_name.
GetString());
144 union_type, element.name.c_str(), ast_ctx.
GetType(element.type),
156 return clang::QualType();
158 clang::QualType element_type(
BuildType(ast_ctx, type, for_expression));
160 return clang::QualType();
162 CompilerType(ast_ctx.weak_from_this(), element_type.getAsOpaquePtr()),
175 return clang::QualType();
204 switch (type.
Peek()) {
223 if (for_expression && !name.empty()) {
224 size_t less_than_pos = name.find(
'<');
226 if (less_than_pos != std::string::npos) {
227 if (less_than_pos == 0)
228 return ast_ctx.getObjCIdType();
230 name.erase(less_than_pos);
235 return clang::QualType();
243 assert(
false &&
"forward declaration without definition");
245 "forward declaration without definition: {0}", name);
246 return ast_ctx.getObjCIdType();
252 return ast_ctx.getObjCIdType();
259 uint32_t *bitfield_bit_size) {
261 return clang::QualType();
265 switch (type.
Peek()) {
269 return BuildStruct(clang_ast_ctx, type, for_expression);
271 return BuildArray(clang_ast_ctx, type, for_expression);
273 return BuildUnion(clang_ast_ctx, type, for_expression);
278 switch (type.
Next()) {
281 return clang::QualType();
283 return ast_ctx.CharTy;
285 return ast_ctx.IntTy;
287 return ast_ctx.ShortTy;
289 return ast_ctx.getIntTypeForBitwidth(32,
true);
295 return ast_ctx.LongLongTy;
297 return ast_ctx.UnsignedCharTy;
299 return ast_ctx.UnsignedIntTy;
301 return ast_ctx.UnsignedShortTy;
303 return ast_ctx.getIntTypeForBitwidth(32,
false);
306 return ast_ctx.UnsignedLongLongTy;
308 return ast_ctx.FloatTy;
310 return ast_ctx.DoubleTy;
312 return ast_ctx.BoolTy;
314 return ast_ctx.VoidTy;
316 return ast_ctx.getPointerType(ast_ctx.CharTy);
318 return ast_ctx.getObjCClassType();
320 return ast_ctx.getObjCSelType();
323 if (bitfield_bit_size) {
324 *bitfield_bit_size = size;
325 return ast_ctx.UnsignedIntTy;
327 return clang::QualType();
330 clang::QualType target_type =
331 BuildType(clang_ast_ctx, type, for_expression);
332 if (target_type.isNull())
333 return clang::QualType();
334 else if (target_type == ast_ctx.UnknownAnyTy)
335 return ast_ctx.UnknownAnyTy;
337 return ast_ctx.getConstType(target_type);
346 return ast_ctx.VoidPtrTy;
348 clang::QualType target_type =
349 BuildType(clang_ast_ctx, type, for_expression);
350 if (target_type.isNull())
351 return clang::QualType();
352 else if (target_type == ast_ctx.UnknownAnyTy)
353 return ast_ctx.UnknownAnyTy;
355 return ast_ctx.getPointerType(target_type);
359 return for_expression ? ast_ctx.UnknownAnyTy : clang::QualType();
365 bool for_expression) {
366 if (name && name[0]) {
368 clang::QualType qual_type =
BuildType(ast_ctx, lexer, for_expression);
369 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)
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 ReadQuotedString(StringLexer &type)
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.
virtual DeclVendor * GetDeclVendor()
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.
std::string::value_type Character
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.
#define UNUSED_IF_ASSERT_DISABLED(x)
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)