clang 10.0.0git

CodeGenTypes.cpp
Go to the documentation of this file.
1 //===--- CodeGenTypes.cpp - Type translation for LLVM CodeGen -------------===//
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 // This is the code that handles AST -> LLVM type lowering.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "CodeGenTypes.h"
14 #include "CGCXXABI.h"
15 #include "CGCall.h"
16 #include "CGOpenCLRuntime.h"
17 #include "CGRecordLayout.h"
18 #include "TargetInfo.h"
19 #include "clang/AST/ASTContext.h"
20 #include "clang/AST/DeclCXX.h"
21 #include "clang/AST/DeclObjC.h"
22 #include "clang/AST/Expr.h"
23 #include "clang/AST/RecordLayout.h"
24 #include "clang/CodeGen/CGFunctionInfo.h"
25 #include "llvm/IR/DataLayout.h"
26 #include "llvm/IR/DerivedTypes.h"
27 #include "llvm/IR/Module.h"
28 using namespace clang;
29 using namespace CodeGen;
30
31 CodeGenTypes::CodeGenTypes(CodeGenModule &cgm)
32 : CGM(cgm), Context(cgm.getContext()), TheModule(cgm.getModule()),
33 Target(cgm.getTarget()), TheCXXABI(cgm.getCXXABI()),
34 TheABIInfo(cgm.getTargetCodeGenInfo().getABIInfo()) {
35 SkippedLayout = false;
36 }
37
38 CodeGenTypes::~CodeGenTypes() {
39 llvm::DeleteContainerSeconds(CGRecordLayouts);
40
41 for (llvm::FoldingSet<CGFunctionInfo>::iterator
42 I = FunctionInfos.begin(), E = FunctionInfos.end(); I != E; )
43 delete &*I++;
44 }
45
46 const CodeGenOptions &CodeGenTypes::getCodeGenOpts() const {
47 return CGM.getCodeGenOpts();
48 }
49
50 void CodeGenTypes::addRecordTypeName(const RecordDecl *RD,
51 llvm::StructType *Ty,
52 StringRef suffix) {
53 SmallString<256> TypeName;
54 llvm::raw_svector_ostream OS(TypeName);
55 OS << RD->getKindName() << '.';
56
57 // Name the codegen type after the typedef name
58 // if there is no tag type name available
59 if (RD->getIdentifier()) {
60 // FIXME: We should not have to check for a null decl context here.
61 // Right now we do it because the implicit Obj-C decls don't have one.
62 if (RD->getDeclContext())
63 RD->printQualifiedName(OS);
64 else
65 RD->printName(OS);
66 } else if (const TypedefNameDecl *TDD = RD->getTypedefNameForAnonDecl()) {
67 // FIXME: We should not have to check for a null decl context here.
68 // Right now we do it because the implicit Obj-C decls don't have one.
69 if (TDD->getDeclContext())
70 TDD->printQualifiedName(OS);
71 else
72 TDD->printName(OS);
73 } else
74 OS << "anon";
75
76 if (!suffix.empty())
77 OS << suffix;
78
79 Ty->setName(OS.str());
80 }
81
82 /// ConvertTypeForMem - Convert type T into a llvm::Type. This differs from
83 /// ConvertType in that it is used to convert to the memory representation for
84 /// a type. For example, the scalar representation for _Bool is i1, but the
85 /// memory representation is usually i8 or i32, depending on the target.
86 llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T) {
87 llvm::Type *R = ConvertType(T);
88
89 // If this is a non-bool type, don't map it.
90 if (!R->isIntegerTy(1))
91 return R;
92
93 // Otherwise, return an integer of the target-specified size.
94 return llvm::IntegerType::get(getLLVMContext(),
95 (unsigned)Context.getTypeSize(T));
96 }
97
98
99 /// isRecordLayoutComplete - Return true if the specified type is already
100 /// completely laid out.
101 bool CodeGenTypes::isRecordLayoutComplete(const Type *Ty) const {
102 llvm::DenseMap<const Type*, llvm::StructType *>::const_iterator I =
103 RecordDeclTypes.find(Ty);
104 return I != RecordDeclTypes.end() && !I->second->isOpaque();
105 }
106
107 static bool
108 isSafeToConvert(QualType T, CodeGenTypes &CGT,
109 llvm::SmallPtrSet<const RecordDecl*, 16> &AlreadyChecked);
110
111
112 /// isSafeToConvert - Return true if it is safe to convert the specified record
113 /// decl to IR and lay it out, false if doing so would cause us to get into a
114 /// recursive compilation mess.
115 static bool
116 isSafeToConvert(const RecordDecl *RD, CodeGenTypes &CGT,
117 llvm::SmallPtrSet<const RecordDecl*, 16> &AlreadyChecked) {
118 // If we have already checked this type (maybe the same type is used by-value
119 // multiple times in multiple structure fields, don't check again.
120 if (!AlreadyChecked.insert(RD).second)
121 return true;
122
123 const Type *Key = CGT.getContext().getTagDeclType(RD).getTypePtr();
124
125 // If this type is already laid out, converting it is a noop.
126 if (CGT.isRecordLayoutComplete(Key)) return true;
127
128 // If this type is currently being laid out, we can't recursively compile it.
129 if (CGT.isRecordBeingLaidOut(Key))
130 return false;
131
132 // If this type would require laying out bases that are currently being laid
133 // out, don't do it. This includes virtual base classes which get laid out
134 // when a class is translated, even though they aren't embedded by-value into
135 // the class.
136 if (const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
137 for (const auto &I : CRD->bases())
138 if (!isSafeToConvert(I.getType()->castAs<RecordType>()->getDecl(), CGT,
139 AlreadyChecked))
140 return false;
141 }
142
143 // If this type would require laying out members that are currently being laid
144 // out, don't do it.
145 for (const auto *I : RD->fields())
146 if (!isSafeToConvert(I->getType(), CGT, AlreadyChecked))
147 return false;
148
149 // If there are no problems, lets do it.
150 return true;
151 }
152
153 /// isSafeToConvert - Return true if it is safe to convert this field type,
154 /// which requires the structure elements contained by-value to all be
155 /// recursively safe to convert.
156 static bool
157 isSafeToConvert(QualType T, CodeGenTypes &CGT,
158 llvm::SmallPtrSet<const RecordDecl*, 16> &AlreadyChecked) {
159 // Strip off atomic type sugar.
160 if (const auto *AT = T->getAs<AtomicType>())
161 T = AT->getValueType();
162
163 // If this is a record, check it.
164 if (const auto *RT = T->getAs<RecordType>())
165 return isSafeToConvert(RT->getDecl(), CGT, AlreadyChecked);
166
167 // If this is an array, check the elements, which are embedded inline.
168 if (const auto *AT = CGT.getContext().getAsArrayType(T))
169 return isSafeToConvert(AT->getElementType(), CGT, AlreadyChecked);
170
171 // Otherwise, there is no concern about transforming this. We only care about
172 // things that are contained by-value in a structure that can have another
173 // structure as a member.
174 return true;
175 }
176
177
178 /// isSafeToConvert - Return true if it is safe to convert the specified record
179 /// decl to IR and lay it out, false if doing so would cause us to get into a
180 /// recursive compilation mess.
181 static bool isSafeToConvert(const RecordDecl *RD, CodeGenTypes &CGT) {
182 // If no structs are being laid out, we can certainly do this one.
183 if (CGT.noRecordsBeingLaidOut()) return true;
184
185 llvm::SmallPtrSet<const RecordDecl*, 16> AlreadyChecked;
186 return isSafeToConvert(RD, CGT, AlreadyChecked);
187 }
188
189 /// isFuncParamTypeConvertible - Return true if the specified type in a
190 /// function parameter or result position can be converted to an IR type at this
191 /// point. This boils down to being whether it is complete, as well as whether
192 /// we've temporarily deferred expanding the type because we're in a recursive
193 /// context.
194 bool CodeGenTypes::isFuncParamTypeConvertible(QualType Ty) {
195 // Some ABIs cannot have their member pointers represented in IR unless
196 // certain circumstances have been reached.
197 if (const auto *MPT = Ty->getAs<MemberPointerType>())
198 return getCXXABI().isMemberPointerConvertible(MPT);
199
200 // If this isn't a tagged type, we can convert it!
201 const TagType *TT = Ty->getAs<TagType>();
202 if (!TT) return true;
203
204 // Incomplete types cannot be converted.
205 if (TT->isIncompleteType())
206 return false;
207
208 // If this is an enum, then it is always safe to convert.
209 const RecordType *RT = dyn_cast<RecordType>(TT);
210 if (!RT) return true;
211
212 // Otherwise, we have to be careful. If it is a struct that we're in the
213 // process of expanding, then we can't convert the function type. That's ok
214 // though because we must be in a pointer context under the struct, so we can
215 // just convert it to a dummy type.
216 //
217 // We decide this by checking whether ConvertRecordDeclType returns us an
218 // opaque type for a struct that we know is defined.
219 return isSafeToConvert(RT->getDecl(), *this);
220 }
221
222
223 /// Code to verify a given function type is complete, i.e. the return type
224 /// and all of the parameter types are complete. Also check to see if we are in
225 /// a RS_StructPointer context, and if so whether any struct types have been
226 /// pended. If so, we don't want to ask the ABI lowering code to handle a type
227 /// that cannot be converted to an IR type.
228 bool CodeGenTypes::isFuncTypeConvertible(const FunctionType *FT) {
229 if (!isFuncParamTypeConvertible(FT->getReturnType()))
230 return false;
231
232 if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FT))
233 for (unsigned i = 0, e = FPT->getNumParams(); i != e; i++)
234 if (!isFuncParamTypeConvertible(FPT->getParamType(i)))
235 return false;
236
237 return true;
238 }
239
240 /// UpdateCompletedType - When we find the full definition for a TagDecl,
241 /// replace the 'opaque' type we previously made for it if applicable.
242 void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) {
243 // If this is an enum being completed, then we flush all non-struct types from
244 // the cache. This allows function types and other things that may be derived
245 // from the enum to be recomputed.
246 if (const EnumDecl *ED = dyn_cast<EnumDecl>(TD)) {
247 // Only flush the cache if we've actually already converted this type.
248 if (TypeCache.count(ED->getTypeForDecl())) {
249 // Okay, we formed some types based on this. We speculated that the enum
250 // would be lowered to i32, so we only need to flush the cache if this
251 // didn't happen.
252 if (!ConvertType(ED->getIntegerType())->isIntegerTy(32))
253 TypeCache.clear();
254 }
255 // If necessary, provide the full definition of a type only used with a
256 // declaration so far.
257 if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
258 DI->completeType(ED);
259 return;
260 }
261
262 // If we completed a RecordDecl that we previously used and converted to an
263 // anonymous type, then go ahead and complete it now.
264 const RecordDecl *RD = cast<RecordDecl>(TD);
265 if (RD->isDependentType()) return;
266
267 // Only complete it if we converted it already. If we haven't converted it
268 // yet, we'll just do it lazily.
269 if (RecordDeclTypes.count(Context.getTagDeclType(RD).getTypePtr()))
270 ConvertRecordDeclType(RD);
271
272 // If necessary, provide the full definition of a type only used with a
273 // declaration so far.
274 if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
275 DI->completeType(RD);
276 }
277
278 void CodeGenTypes::RefreshTypeCacheForClass(const CXXRecordDecl *RD) {
279 QualType T = Context.getRecordType(RD);
280 T = Context.getCanonicalType(T);
281
282 const Type *Ty = T.getTypePtr();
283 if (RecordsWithOpaqueMemberPointers.count(Ty)) {
284 TypeCache.clear();
285 RecordsWithOpaqueMemberPointers.clear();
286 }
287 }
288
289 static llvm::Type *getTypeForFormat(llvm::LLVMContext &VMContext,
290 const llvm::fltSemantics &format,
291 bool UseNativeHalf = false) {
292 if (&format == &llvm::APFloat::IEEEhalf()) {
293 if (UseNativeHalf)
294 return llvm::Type::getHalfTy(VMContext);
295 else
296 return llvm::Type::getInt16Ty(VMContext);
297 }
298 if (&format == &llvm::APFloat::IEEEsingle())
299 return llvm::Type::getFloatTy(VMContext);
300 if (&format == &llvm::APFloat::IEEEdouble())
301 return llvm::Type::getDoubleTy(VMContext);
302 if (&format == &llvm::APFloat::IEEEquad())
303 return llvm::Type::getFP128Ty(VMContext);
304 if (&format == &llvm::APFloat::PPCDoubleDouble())
305 return llvm::Type::getPPC_FP128Ty(VMContext);
306 if (&format == &llvm::APFloat::x87DoubleExtended())
307 return llvm::Type::getX86_FP80Ty(VMContext);
308 llvm_unreachable("Unknown float format!");
309 }
310
311 llvm::Type *CodeGenTypes::ConvertFunctionTypeInternal(QualType QFT) {
312 assert(QFT.isCanonical());
313 const Type *Ty = QFT.getTypePtr();
314 const FunctionType *FT = cast<FunctionType>(QFT.getTypePtr());
315 // First, check whether we can build the full function type. If the
316 // function type depends on an incomplete type (e.g. a struct or enum), we
317 // cannot lower the function type.
318 if (!isFuncTypeConvertible(FT)) {
319 // This function's type depends on an incomplete tag type.
320
321 // Force conversion of all the relevant record types, to make sure
322 // we re-convert the FunctionType when appropriate.
323 if (const RecordType *RT = FT->getReturnType()->getAs<RecordType>())
324 ConvertRecordDeclType(RT->getDecl());
325 if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FT))
326 for (unsigned i = 0, e = FPT->getNumParams(); i != e; i++)
327 if (const RecordType *RT = FPT->getParamType(i)->getAs<RecordType>())
328 ConvertRecordDeclType(RT->getDecl());
329
330 SkippedLayout = true;
331
332 // Return a placeholder type.
333 return llvm::StructType::get(getLLVMContext());
334 }
335
336 // While we're converting the parameter types for a function, we don't want
337 // to recursively convert any pointed-to structs. Converting directly-used
338 // structs is ok though.
339 if (!RecordsBeingLaidOut.insert(Ty).second) {
340 SkippedLayout = true;
341 return llvm::StructType::get(getLLVMContext());
342 }
343
344 // The function type can be built; call the appropriate routines to
345 // build it.
346 const CGFunctionInfo *FI;
347 if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FT)) {
348 FI = &arrangeFreeFunctionType(
349 CanQual<FunctionProtoType>::CreateUnsafe(QualType(FPT, 0)));
350 } else {
351 const FunctionNoProtoType *FNPT = cast<FunctionNoProtoType>(FT);
352 FI = &arrangeFreeFunctionType(
353 CanQual<FunctionNoProtoType>::CreateUnsafe(QualType(FNPT, 0)));
354 }
355
356 llvm::Type *ResultType = nullptr;
357 // If there is something higher level prodding our CGFunctionInfo, then
358 // don't recurse into it again.
359 if (FunctionsBeingProcessed.count(FI)) {
360
361 ResultType = llvm::StructType::get(getLLVMContext());
362 SkippedLayout = true;
363 } else {
364
365 // Otherwise, we're good to go, go ahead and convert it.
366 ResultType = GetFunctionType(*FI);
367 }
368
369 RecordsBeingLaidOut.erase(Ty);
370
371 if (SkippedLayout)
372 TypeCache.clear();
373
374 if (RecordsBeingLaidOut.empty())
375 while (!DeferredRecords.empty())
376 ConvertRecordDeclType(DeferredRecords.pop_back_val());
377 return ResultType;
378 }
379
380 /// ConvertType - Convert the specified type to its LLVM form.
381 llvm::Type *CodeGenTypes::ConvertType(QualType T) {
382 T = Context.getCanonicalType(T);
383
384 const Type *Ty = T.getTypePtr();
385
386 // RecordTypes are cached and processed specially.
387 if (const RecordType *RT = dyn_cast<RecordType>(Ty))
388 return ConvertRecordDeclType(RT->getDecl());
389
390 // See if type is already cached.
391 llvm::DenseMap<const Type *, llvm::Type *>::iterator TCI = TypeCache.find(Ty);
392 // If type is found in map then use it. Otherwise, convert type T.
393 if (TCI != TypeCache.end())
394 return TCI->second;
395
396 // If we don't have it in the cache, convert it now.
397 llvm::Type *ResultType = nullptr;
398 switch (Ty->getTypeClass()) {
399 case Type::Record: // Handled above.
400 #define TYPE(Class, Base)
401 #define ABSTRACT_TYPE(Class, Base)
402 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
403 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
404 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
405 #include "clang/AST/TypeNodes.inc"
406 llvm_unreachable("Non-canonical or dependent types aren't possible.");
407
408 case Type::Builtin: {
409 switch (cast<BuiltinType>(Ty)->getKind()) {
410 case BuiltinType::Void:
411 case BuiltinType::ObjCId:
412 case BuiltinType::ObjCClass:
413 case BuiltinType::ObjCSel:
414 // LLVM void type can only be used as the result of a function call. Just
415 // map to the same as char.
416 ResultType = llvm::Type::getInt8Ty(getLLVMContext());
417 break;
418
419 case BuiltinType::Bool:
420 // Note that we always return bool as i1 for use as a scalar type.
421 ResultType = llvm::Type::getInt1Ty(getLLVMContext());
422 break;
423
424 case BuiltinType::Char_S:
425 case BuiltinType::Char_U:
426 case BuiltinType::SChar:
427 case BuiltinType::UChar:
428 case BuiltinType::Short:
429 case BuiltinType::UShort:
430 case BuiltinType::Int:
431 case BuiltinType::UInt:
432 case BuiltinType::Long:
433 case BuiltinType::ULong:
434 case BuiltinType::LongLong:
435 case BuiltinType::ULongLong:
436 case BuiltinType::WChar_S:
437 case BuiltinType::WChar_U:
438 case BuiltinType::Char8:
439 case BuiltinType::Char16:
440 case BuiltinType::Char32:
441 case BuiltinType::ShortAccum:
442 case BuiltinType::Accum:
443 case BuiltinType::LongAccum:
444 case BuiltinType::UShortAccum:
445 case BuiltinType::UAccum:
446 case BuiltinType::ULongAccum:
447 case BuiltinType::ShortFract:
448 case BuiltinType::Fract:
449 case BuiltinType::LongFract:
450 case BuiltinType::UShortFract:
451 case BuiltinType::UFract:
452 case BuiltinType::ULongFract:
453 case BuiltinType::SatShortAccum:
454 case BuiltinType::SatAccum:
455 case BuiltinType::SatLongAccum:
456 case BuiltinType::SatUShortAccum:
457 case BuiltinType::SatUAccum:
458 case BuiltinType::SatULongAccum:
459 case BuiltinType::SatShortFract:
460 case BuiltinType::SatFract:
461 case BuiltinType::SatLongFract:
462 case BuiltinType::SatUShortFract:
463 case BuiltinType::SatUFract:
464 case BuiltinType::SatULongFract:
465 ResultType = llvm::IntegerType::get(getLLVMContext(),
466 static_cast<unsigned>(Context.getTypeSize(T)));
467 break;
468
469 case BuiltinType::Float16:
470 ResultType =
471 getTypeForFormat(getLLVMContext(), Context.getFloatTypeSemantics(T),
472 /* UseNativeHalf = */ true);
473 break;
474
475 case BuiltinType::Half:
476 // Half FP can either be storage-only (lowered to i16) or native.
477 ResultType = getTypeForFormat(
478 getLLVMContext(), Context.getFloatTypeSemantics(T),
479 Context.getLangOpts().NativeHalfType ||
480 !Context.getTargetInfo().useFP16ConversionIntrinsics());
481 break;
482 case BuiltinType::Float:
483 case BuiltinType::Double:
484 case BuiltinType::LongDouble:
485 case BuiltinType::Float128:
486 ResultType = getTypeForFormat(getLLVMContext(),
487 Context.getFloatTypeSemantics(T),
488 /* UseNativeHalf = */ false);
489 break;
490
491 case BuiltinType::NullPtr:
492 // Model std::nullptr_t as i8*
493 ResultType = llvm::Type::getInt8PtrTy(getLLVMContext());
494 break;
495
496 case BuiltinType::UInt128:
497 case BuiltinType::Int128:
498 ResultType = llvm::IntegerType::get(getLLVMContext(), 128);
499 break;
500
501 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
502 case BuiltinType::Id:
503 #include "clang/Basic/OpenCLImageTypes.def"
504 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
505 case BuiltinType::Id:
506 #include "clang/Basic/OpenCLExtensionTypes.def"
507 case BuiltinType::OCLSampler:
508 case BuiltinType::OCLEvent:
509 case BuiltinType::OCLClkEvent:
510 case BuiltinType::OCLQueue:
511 case BuiltinType::OCLReserveID:
512 ResultType = CGM.getOpenCLRuntime().convertOpenCLSpecificType(Ty);
513 break;
514
515 // TODO: real CodeGen support for SVE types requires more infrastructure
516 // to be added first. Report an error until then.
517 #define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
518 #include "clang/Basic/AArch64SVEACLETypes.def"
519 {
520 unsigned DiagID = CGM.getDiags().getCustomDiagID(
521 DiagnosticsEngine::Error,
522 "cannot yet generate code for SVE type '%0'");
523 auto *BT = cast<BuiltinType>(Ty);
524 auto Name = BT->getName(CGM.getContext().getPrintingPolicy());
525 CGM.getDiags().Report(DiagID) << Name;
526 // Return something safe.
527 ResultType = llvm::IntegerType::get(getLLVMContext(), 32);
528 break;
529 }
530
531 case BuiltinType::Dependent:
532 #define BUILTIN_TYPE(Id, SingletonId)
533 #define PLACEHOLDER_TYPE(Id, SingletonId) \
534 case BuiltinType::Id:
535 #include "clang/AST/BuiltinTypes.def"
536 llvm_unreachable("Unexpected placeholder builtin type!");
537 }
538 break;
539 }
540 case Type::Auto:
541 case Type::DeducedTemplateSpecialization:
542 llvm_unreachable("Unexpected undeduced type!");
543 case Type::Complex: {
544 llvm::Type *EltTy = ConvertType(cast<ComplexType>(Ty)->getElementType());
545 ResultType = llvm::StructType::get(EltTy, EltTy);
546 break;
547 }
548 case Type::LValueReference:
549 case Type::RValueReference: {
550 const ReferenceType *RTy = cast<ReferenceType>(Ty);
551 QualType ETy = RTy->getPointeeType();
552 llvm::Type *PointeeType = ConvertTypeForMem(ETy);
553 unsigned AS = Context.getTargetAddressSpace(ETy);
554 ResultType = llvm::PointerType::get(PointeeType, AS);
555 break;
556 }
557 case Type::Pointer: {
558 const PointerType *PTy = cast<PointerType>(Ty);
559 QualType ETy = PTy->getPointeeType();
560 llvm::Type *PointeeType = ConvertTypeForMem(ETy);
561 if (PointeeType->isVoidTy())
562 PointeeType = llvm::Type::getInt8Ty(getLLVMContext());
563 unsigned AS = Context.getTargetAddressSpace(ETy);
564 ResultType = llvm::PointerType::get(PointeeType, AS);
565 break;
566 }
567
568 case Type::VariableArray: {
569 const VariableArrayType *A = cast<VariableArrayType>(Ty);
570 assert(A->getIndexTypeCVRQualifiers() == 0 &&
571 "FIXME: We only handle trivial array types so far!");
572 // VLAs resolve to the innermost element type; this matches
573 // the return of alloca, and there isn't any obviously better choice.
574 ResultType = ConvertTypeForMem(A->getElementType());
575 break;
576 }
577 case Type::IncompleteArray: {
578 const IncompleteArrayType *A = cast<IncompleteArrayType>(Ty);
579 assert(A->getIndexTypeCVRQualifiers() == 0 &&
580 "FIXME: We only handle trivial array types so far!");
581 // int X[] -> [0 x int], unless the element type is not sized. If it is
582 // unsized (e.g. an incomplete struct) just use [0 x i8].
583 ResultType = ConvertTypeForMem(A->getElementType());
584 if (!ResultType->isSized()) {
585 SkippedLayout = true;
586 ResultType = llvm::Type::getInt8Ty(getLLVMContext());
587 }
588 ResultType = llvm::ArrayType::get(ResultType, 0);
589 break;
590 }
591 case Type::ConstantArray: {
592 const ConstantArrayType *A = cast<ConstantArrayType>(Ty);
593 llvm::Type *EltTy = ConvertTypeForMem(A->getElementType());
594
595 // Lower arrays of undefined struct type to arrays of i8 just to have a
596 // concrete type.
597 if (!EltTy->isSized()) {
598 SkippedLayout = true;
599 EltTy = llvm::Type::getInt8Ty(getLLVMContext());
600 }
601
602 ResultType = llvm::ArrayType::get(EltTy, A->getSize().getZExtValue());
603 break;
604 }
605 case Type::ExtVector:
606 case Type::Vector: {
607 const VectorType *VT = cast<VectorType>(Ty);
608 ResultType = llvm::VectorType::get(ConvertType(VT->getElementType()),
609 VT->getNumElements());
610 break;
611 }
612 case Type::FunctionNoProto:
613 case Type::FunctionProto:
614 ResultType = ConvertFunctionTypeInternal(T);
615 break;
616 case Type::ObjCObject:
617 ResultType = ConvertType(cast<ObjCObjectType>(Ty)->getBaseType());
618 break;
619
620 case Type::ObjCInterface: {
621 // Objective-C interfaces are always opaque (outside of the
622 // runtime, which can do whatever it likes); we never refine
623 // these.
624 llvm::Type *&T = InterfaceTypes[cast<ObjCInterfaceType>(Ty)];
625 if (!T)
626 T = llvm::StructType::create(getLLVMContext());
627 ResultType = T;
628 break;
629 }
630
631 case Type::ObjCObjectPointer: {
632 // Protocol qualifications do not influence the LLVM type, we just return a
633 // pointer to the underlying interface type. We don't need to worry about
634 // recursive conversion.
635 llvm::Type *T =
636 ConvertTypeForMem(cast<ObjCObjectPointerType>(Ty)->getPointeeType());
637 ResultType = T->getPointerTo();
638 break;
639 }
640
641 case Type::Enum: {
642 const EnumDecl *ED = cast<EnumType>(Ty)->getDecl();
643 if (ED->isCompleteDefinition() || ED->isFixed())
644 return ConvertType(ED->getIntegerType());
645 // Return a placeholder 'i32' type. This can be changed later when the
646 // type is defined (see UpdateCompletedType), but is likely to be the
647 // "right" answer.
648 ResultType = llvm::Type::getInt32Ty(getLLVMContext());
649 break;
650 }
651
652 case Type::BlockPointer: {
653 const QualType FTy = cast<BlockPointerType>(Ty)->getPointeeType();
654 llvm::Type *PointeeType = CGM.getLangOpts().OpenCL
655 ? CGM.getGenericBlockLiteralType()
656 : ConvertTypeForMem(FTy);
657 unsigned AS = Context.getTargetAddressSpace(FTy);
658 ResultType = llvm::PointerType::get(PointeeType, AS);
659 break;
660 }
661
662 case Type::MemberPointer: {
663 auto *MPTy = cast<MemberPointerType>(Ty);
664 if (!getCXXABI().isMemberPointerConvertible(MPTy)) {
665 RecordsWithOpaqueMemberPointers.insert(MPTy->getClass());
666 ResultType = llvm::StructType::create(getLLVMContext());
667 } else {
668 ResultType = getCXXABI().ConvertMemberPointerType(MPTy);
669 }
670 break;
671 }
672
673 case Type::Atomic: {
674 QualType valueType = cast<AtomicType>(Ty)->getValueType();
675 ResultType = ConvertTypeForMem(valueType);
676
677 // Pad out to the inflated size if necessary.
678 uint64_t valueSize = Context.getTypeSize(valueType);
679 uint64_t atomicSize = Context.getTypeSize(Ty);
680 if (valueSize != atomicSize) {
681 assert(valueSize < atomicSize);
682 llvm::Type *elts[] = {
683 ResultType,
684 llvm::ArrayType::get(CGM.Int8Ty, (atomicSize - valueSize) / 8)
685 };
686 ResultType = llvm::StructType::get(getLLVMContext(),
687 llvm::makeArrayRef(elts));
688 }
689 break;
690 }
691 case Type::Pipe: {
692 ResultType = CGM.getOpenCLRuntime().getPipeType(cast<PipeType>(Ty));
693 break;
694 }
695 }
696
697 assert(ResultType && "Didn't convert a type?");
698
699 TypeCache[Ty] = ResultType;
700 return ResultType;
701 }
702
703 bool CodeGenModule::isPaddedAtomicType(QualType type) {
704 return isPaddedAtomicType(type->castAs<AtomicType>());
705 }
706
707 bool CodeGenModule::isPaddedAtomicType(const AtomicType *type) {
708 return Context.getTypeSize(type) != Context.getTypeSize(type->getValueType());
709 }
710
711 /// ConvertRecordDeclType - Lay out a tagged decl type like struct or union.
712 llvm::StructType *CodeGenTypes::ConvertRecordDeclType(const RecordDecl *RD) {
713 // TagDecl's are not necessarily unique, instead use the (clang)
714 // type connected to the decl.
715 const Type *Key = Context.getTagDeclType(RD).getTypePtr();
716
717 llvm::StructType *&Entry = RecordDeclTypes[Key];
718
719 // If we don't have a StructType at all yet, create the forward declaration.
720 if (!Entry) {
721 Entry = llvm::StructType::create(getLLVMContext());
722 addRecordTypeName(RD, Entry, "");
723 }
724 llvm::StructType *Ty = Entry;
725
726 // If this is still a forward declaration, or the LLVM type is already
727 // complete, there's nothing more to do.
728 RD = RD->getDefinition();
729 if (!RD || !RD->isCompleteDefinition() || !Ty->isOpaque())
730 return Ty;
731
732 // If converting this type would cause us to infinitely loop, don't do it!
733 if (!isSafeToConvert(RD, *this)) {
734 DeferredRecords.push_back(RD);
735 return Ty;
736 }
737
738 // Okay, this is a definition of a type. Compile the implementation now.
739 bool InsertResult = RecordsBeingLaidOut.insert(Key).second;
740 (void)InsertResult;
741 assert(InsertResult && "Recursively compiling a struct?");
742
743 // Force conversion of non-virtual base classes recursively.
744 if (const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
745 for (const auto &I : CRD->bases()) {
746 if (I.isVirtual()) continue;
747 ConvertRecordDeclType(I.getType()->castAs<RecordType>()->getDecl());
748 }
749 }
750
751 // Layout fields.
752 CGRecordLayout *Layout = ComputeRecordLayout(RD, Ty);
753 CGRecordLayouts[Key] = Layout;
754
755 // We're done laying out this struct.
756 bool EraseResult = RecordsBeingLaidOut.erase(Key); (void)EraseResult;
757 assert(EraseResult && "struct not in RecordsBeingLaidOut set?");
758
759 // If this struct blocked a FunctionType conversion, then recompute whatever
760 // was derived from that.
761 // FIXME: This is hugely overconservative.
762 if (SkippedLayout)
763 TypeCache.clear();
764
765 // If we're done converting the outer-most record, then convert any deferred
766 // structs as well.
767 if (RecordsBeingLaidOut.empty())
768 while (!DeferredRecords.empty())
769 ConvertRecordDeclType(DeferredRecords.pop_back_val());
770
771 return Ty;
772 }
773
774 /// getCGRecordLayout - Return record layout info for the given record decl.
775 const CGRecordLayout &
776 CodeGenTypes::getCGRecordLayout(const RecordDecl *RD) {
777 const Type *Key = Context.getTagDeclType(RD).getTypePtr();
778
779 const CGRecordLayout *Layout = CGRecordLayouts.lookup(Key);
780 if (!Layout) {
781 // Compute the type information.
782 ConvertRecordDeclType(RD);
783
784 // Now try again.
785 Layout = CGRecordLayouts.lookup(Key);
786 }
787
788 assert(Layout && "Unable to find record layout information for type");
789 return *Layout;
790 }
791
792 bool CodeGenTypes::isPointerZeroInitializable(QualType T) {
793 assert((T->isAnyPointerType() || T->isBlockPointerType()) && "Invalid type");
794 return isZeroInitializable(T);
795 }
796
797 bool CodeGenTypes::isZeroInitializable(QualType T) {
798 if (T->getAs<PointerType>())
799 return Context.getTargetNullPointerValue(T) == 0;
800
801 if (const auto *AT = Context.getAsArrayType(T)) {
802 if (isa<IncompleteArrayType>(AT))
803 return true;
804 if (const auto *CAT = dyn_cast<ConstantArrayType>(AT))
805 if (Context.getConstantArrayElementCount(CAT) == 0)
806 return true;
807 T = Context.getBaseElementType(T);
808 }
809
810 // Records are non-zero-initializable if they contain any
811 // non-zero-initializable subobjects.
812 if (const RecordType *RT = T->getAs<RecordType>()) {
813 const RecordDecl *RD = RT->getDecl();
814 return isZeroInitializable(RD);
815 }
816
817 // We have to ask the ABI about member pointers.
818 if (const MemberPointerType *MPT = T->getAs<MemberPointerType>())
819 return getCXXABI().isZeroInitializable(MPT);
820
821 // Everything else is okay.
822 return true;
823 }
824
825 bool CodeGenTypes::isZeroInitializable(const RecordDecl *RD) {
826 return getCGRecordLayout(RD).isZeroInitializable();
827 }
clang::CodeGen::CodeGenTypes::noRecordsBeingLaidOut
bool noRecordsBeingLaidOut() const
Definition: CodeGenTypes.h:306
clang::CodeGen::CodeGenTypes::getCXXABI
CGCXXABI & getCXXABI() const
Definition: CodeGenTypes.h:119
clang::CodeGen::CodeGenModule::getOpenCLRuntime
CGOpenCLRuntime & getOpenCLRuntime()
Return a reference to the configured OpenCL runtime.
Definition: CodeGenModule.h:581
ASTContext.h
Defines the clang::ASTContext interface.
clang::CodeGen::CodeGenModule::getGenericBlockLiteralType
llvm::Type * getGenericBlockLiteralType()
The type of a generic block literal.
Definition: CGBlocks.cpp:1218
clang::PointerType
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2614
clang::PointerType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:2627
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:654
clang::Type::isBlockPointerType
bool isBlockPointerType() const
Definition: Type.h:6512
clang::CodeGen::CodeGenModule::getCodeGenOpts
const CodeGenOptions & getCodeGenOpts() const
Definition: CodeGenModule.h:680
clang::CodeGen::CodeGenTypes::UpdateCompletedType
void UpdateCompletedType(const TagDecl *TD)
UpdateCompletedType - When we find the full definition for a TagDecl, replace the &#39;opaque&#39; type we pr...
Definition: CodeGenTypes.cpp:242
CGCall.h
clang::CodeGen::CGRecordLayout
CGRecordLayout - This class handles struct and union layout info while lowering AST types to LLVM typ...
Definition: CGRecordLayout.h:108
getTypeForFormat
static llvm::Type * getTypeForFormat(llvm::LLVMContext &VMContext, const llvm::fltSemantics &format, bool UseNativeHalf=false)
Definition: CodeGenTypes.cpp:289
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3422
clang::CodeGen::CodeGenTypes::addRecordTypeName
void addRecordTypeName(const RecordDecl *RD, llvm::StructType *Ty, StringRef suffix)
addRecordTypeName - Compute a name from the given record decl with an optional suffix and name the gi...
Definition: CodeGenTypes.cpp:50
clang::CodeGen::CodeGenTypes::isRecordBeingLaidOut
bool isRecordBeingLaidOut(const Type *Ty) const
Definition: CodeGenTypes.h:309
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1450
clang::DiagnosticsEngine::Report
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1300
clang::ASTContext::getTargetInfo
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:707
DeclObjC.h
clang::AtomicType::getValueType
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition: Type.h:6140
clang::AutoTypeKeyword::Auto
auto
clang::CodeGen::CodeGenTypes::isFuncTypeConvertible
bool isFuncTypeConvertible(const FunctionType *FT)
isFuncTypeConvertible - Utility to check whether a function type can be converted to an LLVM type (i...
Definition: CodeGenTypes.cpp:228
clang::CodeGen::CodeGenTypeCache::Int8Ty
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
Definition: CodeGenTypeCache.h:37
clang::ArrayType::getElementType
QualType getElementType() const
Definition: Type.h:2910
clang::TagDecl::isCompleteDefinition
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3324
clang::EnumDecl::isFixed
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition: Decl.h:3684
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:7002
clang::CodeGen::CodeGenModule::getModuleDebugInfo
CGDebugInfo * getModuleDebugInfo()
Definition: CodeGenModule.h:666
clang::CodeGen::CGDebugInfo
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
Definition: CGDebugInfo.h:54
clang::CodeGen::CodeGenModule::getDiags
DiagnosticsEngine & getDiags() const
Definition: CodeGenModule.h:682
clang::CodeGen::CodeGenTypes::ConvertTypeForMem
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
Definition: CodeGenTypes.cpp:86
clang::CodeGen::CodeGenTypes::arrangeFreeFunctionType
const CGFunctionInfo & arrangeFreeFunctionType(CanQual< FunctionProtoType > Ty)
Arrange the argument and result information for a value of the given freestanding function type...
Definition: CGCall.cpp:194
clang::MultiVersionKind::Target
clang::NamedDecl::getIdentifier
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:244
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3748
CGRecordLayout.h
clang::CodeGen::CodeGenTypes::ConvertType
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
Definition: CodeGenTypes.cpp:381
clang::RecordDecl::getDefinition
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
Definition: Decl.h:3953
clang::RecordDecl::fields
field_range fields() const
Definition: Decl.h:3963
clang::CodeGen::CodeGenModule::isPaddedAtomicType
bool isPaddedAtomicType(QualType type)
Definition: CodeGenTypes.cpp:703
isSafeToConvert
static bool isSafeToConvert(QualType T, CodeGenTypes &CGT, llvm::SmallPtrSet< const RecordDecl *, 16 > &AlreadyChecked)
isSafeToConvert - Return true if it is safe to convert this field type, which requires the structure ...
Definition: CodeGenTypes.cpp:157
clang::ASTContext::getConstantArrayElementCount
uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const
Return number of constant array elements.
Definition: ASTContext.cpp:5842
clang::ASTContext::getPrintingPolicy
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:671
clang::QualType::getTypePtr
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6256
CGFunctionInfo.h
llvm::SmallString
Definition: LLVM.h:34
clang::CodeGen::CodeGenTypes::~CodeGenTypes
~CodeGenTypes()
Definition: CodeGenTypes.cpp:38
clang::CodeGen::CGRecordLayout::isZeroInitializable
bool isZeroInitializable() const
Check whether this struct can be C++ zero-initialized with a zeroinitializer.
Definition: CGRecordLayout.h:172
clang::CodeGen::CGCXXABI::ConvertMemberPointerType
virtual llvm::Type * ConvertMemberPointerType(const MemberPointerType *MPT)
Find the LLVM type used to represent the given member pointer type.
Definition: CGCXXABI.cpp:37
clang::CodeGen::CGOpenCLRuntime::getPipeType
virtual llvm::Type * getPipeType(const PipeType *T, StringRef Name, llvm::Type *&PipeTy)
Definition: CGOpenCLRuntime.cpp:79
clang::CodeGen::CGOpenCLRuntime::convertOpenCLSpecificType
virtual llvm::Type * convertOpenCLSpecificType(const Type *T)
Definition: CGOpenCLRuntime.cpp:33
clang::CodeGen::CGCXXABI::isZeroInitializable
virtual bool isZeroInitializable(const MemberPointerType *MPT)
Return true if the given member pointer can be zero-initialized (in the C++ sense) with an LLVM zeroi...
Definition: CGCXXABI.cpp:117
clang::FunctionNoProtoType
Represents a K&R-style &#39;int foo()&#39; function, which has no information available about its arguments...
Definition: Type.h:3717
clang::FunctionProtoType
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3754
clang::CodeGen::CodeGenTypes::isPointerZeroInitializable
bool isPointerZeroInitializable(QualType T)
Check if the pointer type can be zero-initialized (in the C++ sense) with an LLVM zeroinitializer...
Definition: CodeGenTypes.cpp:792
clang::TagDecl::isDependentType
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
Definition: Decl.h:3375
clang::CodeGen::CodeGenTypes::CodeGenTypes
CodeGenTypes(CodeGenModule &cgm)
Definition: CodeGenTypes.cpp:31
clang::TagDecl::getKindName
StringRef getKindName() const
Definition: Decl.h:3394
clang::ReferenceType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:2771
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7067
clang::ASTContext::getTagDeclType
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
Definition: ASTContext.cpp:5244
CGCXXABI.h
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:438
clang::CodeGen::CodeGenTypes::getCodeGenOpts
const CodeGenOptions & getCodeGenOpts() const
Definition: CodeGenTypes.cpp:46
clang::ASTContext::getRecordType
QualType getRecordType(const RecordDecl *Decl) const
Definition: ASTContext.cpp:4173
clang::VectorType
Represents a GCC generic vector type.
Definition: Type.h:3235
clang::NamedDecl::printQualifiedName
void printQualifiedName(raw_ostream &OS) const
Returns a human-readable qualified name for this declaration, like A::B::i, for i being member of nam...
Definition: Decl.cpp:1562
clang::CodeGen::CodeGenModule::getLangOpts
const LangOptions & getLangOpts() const
Definition: CodeGenModule.h:675
clang::CodeGen::CodeGenModule::getContext
ASTContext & getContext() const
Definition: CodeGenModule.h:674
clang::CodeGen::AlignmentSource::Type
The l-value was considered opaque, so the alignment was determined from a type.
clang::RecordType::getDecl
RecordDecl * getDecl() const
Definition: Type.h:4505
clang::TargetInfo::useFP16ConversionIntrinsics
virtual bool useFP16ConversionIntrinsics() const
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
Definition: TargetInfo.h:754
clang::NamedDecl::printName
virtual void printName(raw_ostream &os) const
Definition: Decl.cpp:1551
clang::FunctionType::getReturnType
QualType getReturnType() const
Definition: Type.h:3680
TargetInfo.h
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3219
clang::VectorType::getElementType
QualType getElementType() const
Definition: Type.h:3270
clang::ASTContext::getBaseElementType
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Definition: ASTContext.cpp:5822
clang::ASTContext::getAsArrayType
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
Definition: ASTContext.cpp:5711
clang::CanQual
Represents a canonical, potentially-qualified type.
Definition: CanonicalType.h:65
clang::CodeGen::CodeGenTypes::isRecordLayoutComplete
bool isRecordLayoutComplete(const Type *Ty) const
isRecordLayoutComplete - Return true if the specified type is already completely laid out...
Definition: CodeGenTypes.cpp:101
clang::Type::isAnyPointerType
bool isAnyPointerType() const
Definition: Type.h:6508
CGOpenCLRuntime.h
clang::CodeGen::CodeGenTypes::getLLVMContext
llvm::LLVMContext & getLLVMContext()
Definition: CodeGenTypes.h:120
clang::DiagnosticsEngine::getCustomDiagID
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
Definition: Diagnostic.h:782
clang::Type::getTypeClass
TypeClass getTypeClass() const
Definition: Type.h:1876
clang::AtomicType
Definition: Type.h:6125
clang::QualType::isCanonical
bool isCanonical() const
Definition: Type.h:6300
clang::ASTContext::getFloatTypeSemantics
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat &#39;semantics&#39; for the specified scalar floating point type.
Definition: ASTContext.cpp:1704
clang::TypedefNameDecl
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3071
clang::CodeGen::CGFunctionInfo
CGFunctionInfo - Class to encapsulate the information about a function definition.
Definition: CGFunctionInfo.h:476
clang::CodeGen::CodeGenModule
This class organizes the cross-function state that is used while generating LLVM code.
Definition: CodeGenModule.h:280
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
type
CodeGenTypes.h
clang::serialized_diags::create
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
Definition: SerializedDiagnosticPrinter.cpp:298
clang::CodeGen::CGCXXABI::isMemberPointerConvertible
virtual bool isMemberPointerConvertible(const MemberPointerType *MPT) const
Return whether or not a member pointers type is convertible to an IR type.
Definition: CGCXXABI.h:181
clang::EnumDecl
Represents an enum.
Definition: Decl.h:3481
clang::MemberPointerType
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2833
clang::CodeGen::CodeGenTypes::ConvertRecordDeclType
llvm::StructType * ConvertRecordDeclType(const RecordDecl *TD)
ConvertRecordDeclType - Lay out a tagged decl type like struct or union.
Definition: CodeGenTypes.cpp:712
clang::RecordType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4495
clang::ArrayType::getIndexTypeCVRQualifiers
unsigned getIndexTypeCVRQualifiers() const
Definition: Type.h:2920
clang::DiagnosticsEngine::Error
Definition: Diagnostic.h:157
clang::ConstantArrayType::getSize
const llvm::APInt & getSize() const
Definition: Type.h:2958
clang::CodeGen::CodeGenTypes
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
Definition: CodeGenTypes.h:59
clang::CodeGenOptions
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
Definition: CodeGenOptions.h:46
clang::ReferenceType
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2750
clang::ASTContext::getTypeSize
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:2104
clang::Type::isIncompleteType
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
Definition: Type.cpp:2115
clang::CodeGen::CodeGenTypes::getContext
ASTContext & getContext() const
Definition: CodeGenTypes.h:116
clang::ASTContext::getCanonicalType
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2305
DeclCXX.h
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
clang::TagDecl::getTypedefNameForAnonDecl
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition: Decl.h:3429
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:253
clang::IncompleteArrayType
Represents a C array with an unspecified size.
Definition: Type.h:2995
RecordLayout.h
clang::CodeGen::CodeGenTypes::isFuncParamTypeConvertible
bool isFuncParamTypeConvertible(QualType Ty)
isFuncParamTypeConvertible - Return true if the specified type in a function parameter or result posi...
Definition: CodeGenTypes.cpp:194
Expr.h
clang::CodeGen::CodeGenTypes::RefreshTypeCacheForClass
void RefreshTypeCacheForClass(const CXXRecordDecl *RD)
Remove stale types from the type cache when an inheritance model gets assigned to a class...
Definition: CodeGenTypes.cpp:278
clang::EnumDecl::getIntegerType
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition: Decl.h:3635
getKind
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:947
clang::VectorType::getNumElements
unsigned getNumElements() const
Definition: Type.h:3271
clang::ASTContext::getTargetNullPointerValue
uint64_t getTargetNullPointerValue(QualType QT) const
Get target-dependent integer value for null pointer which is used for constant folding.
Definition: ASTContext.cpp:10708
clang::CodeGen::CodeGenTypes::ComputeRecordLayout
CGRecordLayout * ComputeRecordLayout(const RecordDecl *D, llvm::StructType *Ty)
Compute a new LLVM record layout object for the given record.
Definition: CGRecordLayoutBuilder.cpp:732
clang::TagType
Definition: Type.h:4471
clang::VariableArrayType
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:3039
clang::ASTContext::getTargetAddressSpace
unsigned getTargetAddressSpace(QualType T) const
Definition: ASTContext.h:2557
clang::CodeGen::CodeGenTypes::getCGRecordLayout
const CGRecordLayout & getCGRecordLayout(const RecordDecl *)
getCGRecordLayout - Return record layout info for the given record decl.
Definition: CodeGenTypes.cpp:776
clang::ASTContext::getLangOpts
const LangOptions & getLangOpts() const
Definition: ASTContext.h:724
clang::ConstantArrayType
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2935
clang::CodeGen::CodeGenTypes::isZeroInitializable
bool isZeroInitializable(QualType T)
IsZeroInitializable - Return whether a type can be zero-initialized (in the C++ sense) with an LLVM z...
Definition: CodeGenTypes.cpp:797
clang::CodeGen::CodeGenTypes::GetFunctionType
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.
Definition: CGCall.cpp:1556