18#include "clang/Basic/TargetInfo.h"
31 "AppleObjCTypeEncodingParser ASTContext",
55 total = 10 * total + (type.
Next() -
'0');
64 : type(
clang::QualType()) {}
69 bool for_expression) {
76 retval.
type =
BuildType(ast_ctx, type, for_expression, &bitfield_size);
95 char opener,
char closer,
uint32_t kind) {
97 return clang::QualType();
104 const bool is_templated = name.find(
'<') != std::string::npos;
107 return clang::QualType();
108 bool in_union =
true;
109 std::vector<StructElement> elements;
111 if (type.
NextIf(closer)) {
116 if (element.type.isNull())
119 elements.push_back(element);
123 return clang::QualType();
126 return clang::QualType();
134 unsigned int count = 0;
135 for (
auto element : elements) {
136 if (element.name.empty()) {
138 elem_name.
Printf(
"__unnamed_%u", count);
139 element.name = std::string(elem_name.
GetString());
142 union_type, element.name.c_str(), ast_ctx.
GetType(element.type),
154 return clang::QualType();
156 clang::QualType element_type(
BuildType(ast_ctx, type, for_expression));
158 return clang::QualType();
160 CompilerType(ast_ctx.weak_from_this(), element_type.getAsOpaquePtr()),
173 return clang::QualType();
202 switch (type.
Peek()) {
221 if (for_expression && !name.empty()) {
222 size_t less_than_pos = name.find(
'<');
224 if (less_than_pos != std::string::npos) {
225 if (less_than_pos == 0)
226 return ast_ctx.getObjCIdType();
228 name.erase(less_than_pos);
233 return clang::QualType();
242 return ast_ctx.getObjCIdType();
247 return ast_ctx.getObjCIdType();
256 return clang::QualType();
260 switch (type.
Peek()) {
264 return BuildStruct(clang_ast_ctx, type, for_expression);
266 return BuildArray(clang_ast_ctx, type, for_expression);
268 return BuildUnion(clang_ast_ctx, type, for_expression);
273 switch (type.
Next()) {
276 return clang::QualType();
278 return ast_ctx.CharTy;
280 return ast_ctx.IntTy;
282 return ast_ctx.ShortTy;
284 return ast_ctx.getIntTypeForBitwidth(32,
true);
290 return ast_ctx.LongLongTy;
292 return ast_ctx.UnsignedCharTy;
294 return ast_ctx.UnsignedIntTy;
296 return ast_ctx.UnsignedShortTy;
298 return ast_ctx.getIntTypeForBitwidth(32,
false);
301 return ast_ctx.UnsignedLongLongTy;
303 return ast_ctx.FloatTy;
305 return ast_ctx.DoubleTy;
307 return ast_ctx.BoolTy;
309 return ast_ctx.VoidTy;
311 return ast_ctx.getPointerType(ast_ctx.CharTy);
313 return ast_ctx.getObjCClassType();
315 return ast_ctx.getObjCSelType();
318 if (bitfield_bit_size) {
319 *bitfield_bit_size = size;
320 return ast_ctx.UnsignedIntTy;
322 return clang::QualType();
325 clang::QualType target_type =
326 BuildType(clang_ast_ctx, type, for_expression);
327 if (target_type.isNull())
328 return clang::QualType();
329 else if (target_type == ast_ctx.UnknownAnyTy)
330 return ast_ctx.UnknownAnyTy;
332 return ast_ctx.getConstType(target_type);
341 return ast_ctx.VoidPtrTy;
343 clang::QualType target_type =
344 BuildType(clang_ast_ctx, type, for_expression);
345 if (target_type.isNull())
346 return clang::QualType();
347 else if (target_type == ast_ctx.UnknownAnyTy)
348 return ast_ctx.UnknownAnyTy;
350 return ast_ctx.getPointerType(target_type);
354 return for_expression ? ast_ctx.UnknownAnyTy : clang::QualType();
360 bool for_expression) {
361 if (name && name[0]) {
363 clang::QualType qual_type =
BuildType(ast_ctx, lexer, for_expression);
364 return ast_ctx.
GetType(qual_type);
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 GetType(clang::QualType qt)
Creates a CompilerType from the given QualType with the current TypeSystemClang instance as the Compi...
clang::ASTContext & getASTContext()
Returns the clang::ASTContext instance managed by this TypeSystemClang.
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
CompilerType CreateArrayType(const CompilerType &element_type, size_t element_count, bool is_vector)
static bool StartTagDeclarationDefinition(const CompilerType &type)
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, ClangASTMetadata *metadata=nullptr, bool exports_symbols=false)
#define UNUSED_IF_ASSERT_DISABLED(x)
A class that represents a running process on the host machine.
@ eLanguageTypeC
Non-standardized C, such as K&R.
static clang::QualType GetQualType(const CompilerType &ct)