clang  14.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"
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 
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 
39  for (llvm::FoldingSet<CGFunctionInfo>::iterator
40  I = FunctionInfos.begin(), E = FunctionInfos.end(); I != E; )
41  delete &*I++;
42 }
43 
45  return CGM.getCodeGenOpts();
46 }
47 
49  llvm::StructType *Ty,
50  StringRef suffix) {
52  llvm::raw_svector_ostream OS(TypeName);
53  OS << RD->getKindName() << '.';
54 
55  // FIXME: We probably want to make more tweaks to the printing policy. For
56  // example, we should probably enable PrintCanonicalTypes and
57  // FullyQualifiedNames.
59  Policy.SuppressInlineNamespace = false;
60 
61  // Name the codegen type after the typedef name
62  // if there is no tag type name available
63  if (RD->getIdentifier()) {
64  // FIXME: We should not have to check for a null decl context here.
65  // Right now we do it because the implicit Obj-C decls don't have one.
66  if (RD->getDeclContext())
67  RD->printQualifiedName(OS, Policy);
68  else
69  RD->printName(OS);
70  } else if (const TypedefNameDecl *TDD = RD->getTypedefNameForAnonDecl()) {
71  // FIXME: We should not have to check for a null decl context here.
72  // Right now we do it because the implicit Obj-C decls don't have one.
73  if (TDD->getDeclContext())
74  TDD->printQualifiedName(OS, Policy);
75  else
76  TDD->printName(OS);
77  } else
78  OS << "anon";
79 
80  if (!suffix.empty())
81  OS << suffix;
82 
83  Ty->setName(OS.str());
84 }
85 
86 /// ConvertTypeForMem - Convert type T into a llvm::Type. This differs from
87 /// ConvertType in that it is used to convert to the memory representation for
88 /// a type. For example, the scalar representation for _Bool is i1, but the
89 /// memory representation is usually i8 or i32, depending on the target.
90 llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T, bool ForBitField) {
91  if (T->isConstantMatrixType()) {
92  const Type *Ty = Context.getCanonicalType(T).getTypePtr();
93  const ConstantMatrixType *MT = cast<ConstantMatrixType>(Ty);
94  return llvm::ArrayType::get(ConvertType(MT->getElementType()),
95  MT->getNumRows() * MT->getNumColumns());
96  }
97 
98  llvm::Type *R = ConvertType(T);
99 
100  // If this is a bool type, or an ExtIntType in a bitfield representation,
101  // map this integer to the target-specified size.
102  if ((ForBitField && T->isExtIntType()) ||
103  (!T->isExtIntType() && R->isIntegerTy(1)))
104  return llvm::IntegerType::get(getLLVMContext(),
105  (unsigned)Context.getTypeSize(T));
106 
107  // Else, don't map it.
108  return R;
109 }
110 
111 /// isRecordLayoutComplete - Return true if the specified type is already
112 /// completely laid out.
114  llvm::DenseMap<const Type*, llvm::StructType *>::const_iterator I =
115  RecordDeclTypes.find(Ty);
116  return I != RecordDeclTypes.end() && !I->second->isOpaque();
117 }
118 
119 static bool
122 
123 
124 /// isSafeToConvert - Return true if it is safe to convert the specified record
125 /// decl to IR and lay it out, false if doing so would cause us to get into a
126 /// recursive compilation mess.
127 static bool
130  // If we have already checked this type (maybe the same type is used by-value
131  // multiple times in multiple structure fields, don't check again.
132  if (!AlreadyChecked.insert(RD).second)
133  return true;
134 
135  const Type *Key = CGT.getContext().getTagDeclType(RD).getTypePtr();
136 
137  // If this type is already laid out, converting it is a noop.
138  if (CGT.isRecordLayoutComplete(Key)) return true;
139 
140  // If this type is currently being laid out, we can't recursively compile it.
141  if (CGT.isRecordBeingLaidOut(Key))
142  return false;
143 
144  // If this type would require laying out bases that are currently being laid
145  // out, don't do it. This includes virtual base classes which get laid out
146  // when a class is translated, even though they aren't embedded by-value into
147  // the class.
148  if (const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
149  for (const auto &I : CRD->bases())
150  if (!isSafeToConvert(I.getType()->castAs<RecordType>()->getDecl(), CGT,
151  AlreadyChecked))
152  return false;
153  }
154 
155  // If this type would require laying out members that are currently being laid
156  // out, don't do it.
157  for (const auto *I : RD->fields())
158  if (!isSafeToConvert(I->getType(), CGT, AlreadyChecked))
159  return false;
160 
161  // If there are no problems, lets do it.
162  return true;
163 }
164 
165 /// isSafeToConvert - Return true if it is safe to convert this field type,
166 /// which requires the structure elements contained by-value to all be
167 /// recursively safe to convert.
168 static bool
171  // Strip off atomic type sugar.
172  if (const auto *AT = T->getAs<AtomicType>())
173  T = AT->getValueType();
174 
175  // If this is a record, check it.
176  if (const auto *RT = T->getAs<RecordType>())
177  return isSafeToConvert(RT->getDecl(), CGT, AlreadyChecked);
178 
179  // If this is an array, check the elements, which are embedded inline.
180  if (const auto *AT = CGT.getContext().getAsArrayType(T))
181  return isSafeToConvert(AT->getElementType(), CGT, AlreadyChecked);
182 
183  // Otherwise, there is no concern about transforming this. We only care about
184  // things that are contained by-value in a structure that can have another
185  // structure as a member.
186  return true;
187 }
188 
189 
190 /// isSafeToConvert - Return true if it is safe to convert the specified record
191 /// decl to IR and lay it out, false if doing so would cause us to get into a
192 /// recursive compilation mess.
193 static bool isSafeToConvert(const RecordDecl *RD, CodeGenTypes &CGT) {
194  // If no structs are being laid out, we can certainly do this one.
195  if (CGT.noRecordsBeingLaidOut()) return true;
196 
198  return isSafeToConvert(RD, CGT, AlreadyChecked);
199 }
200 
201 /// isFuncParamTypeConvertible - Return true if the specified type in a
202 /// function parameter or result position can be converted to an IR type at this
203 /// point. This boils down to being whether it is complete, as well as whether
204 /// we've temporarily deferred expanding the type because we're in a recursive
205 /// context.
207  // Some ABIs cannot have their member pointers represented in IR unless
208  // certain circumstances have been reached.
209  if (const auto *MPT = Ty->getAs<MemberPointerType>())
211 
212  // If this isn't a tagged type, we can convert it!
213  const TagType *TT = Ty->getAs<TagType>();
214  if (!TT) return true;
215 
216  // Incomplete types cannot be converted.
217  if (TT->isIncompleteType())
218  return false;
219 
220  // If this is an enum, then it is always safe to convert.
221  const RecordType *RT = dyn_cast<RecordType>(TT);
222  if (!RT) return true;
223 
224  // Otherwise, we have to be careful. If it is a struct that we're in the
225  // process of expanding, then we can't convert the function type. That's ok
226  // though because we must be in a pointer context under the struct, so we can
227  // just convert it to a dummy type.
228  //
229  // We decide this by checking whether ConvertRecordDeclType returns us an
230  // opaque type for a struct that we know is defined.
231  return isSafeToConvert(RT->getDecl(), *this);
232 }
233 
234 
235 /// Code to verify a given function type is complete, i.e. the return type
236 /// and all of the parameter types are complete. Also check to see if we are in
237 /// a RS_StructPointer context, and if so whether any struct types have been
238 /// pended. If so, we don't want to ask the ABI lowering code to handle a type
239 /// that cannot be converted to an IR type.
242  return false;
243 
244  if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FT))
245  for (unsigned i = 0, e = FPT->getNumParams(); i != e; i++)
246  if (!isFuncParamTypeConvertible(FPT->getParamType(i)))
247  return false;
248 
249  return true;
250 }
251 
252 /// UpdateCompletedType - When we find the full definition for a TagDecl,
253 /// replace the 'opaque' type we previously made for it if applicable.
255  // If this is an enum being completed, then we flush all non-struct types from
256  // the cache. This allows function types and other things that may be derived
257  // from the enum to be recomputed.
258  if (const EnumDecl *ED = dyn_cast<EnumDecl>(TD)) {
259  // Only flush the cache if we've actually already converted this type.
260  if (TypeCache.count(ED->getTypeForDecl())) {
261  // Okay, we formed some types based on this. We speculated that the enum
262  // would be lowered to i32, so we only need to flush the cache if this
263  // didn't happen.
264  if (!ConvertType(ED->getIntegerType())->isIntegerTy(32))
265  TypeCache.clear();
266  }
267  // If necessary, provide the full definition of a type only used with a
268  // declaration so far.
269  if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
270  DI->completeType(ED);
271  return;
272  }
273 
274  // If we completed a RecordDecl that we previously used and converted to an
275  // anonymous type, then go ahead and complete it now.
276  const RecordDecl *RD = cast<RecordDecl>(TD);
277  if (RD->isDependentType()) return;
278 
279  // Only complete it if we converted it already. If we haven't converted it
280  // yet, we'll just do it lazily.
281  if (RecordDeclTypes.count(Context.getTagDeclType(RD).getTypePtr()))
283 
284  // If necessary, provide the full definition of a type only used with a
285  // declaration so far.
286  if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
287  DI->completeType(RD);
288 }
289 
291  QualType T = Context.getRecordType(RD);
292  T = Context.getCanonicalType(T);
293 
294  const Type *Ty = T.getTypePtr();
295  if (RecordsWithOpaqueMemberPointers.count(Ty)) {
296  TypeCache.clear();
297  RecordsWithOpaqueMemberPointers.clear();
298  }
299 }
300 
301 static llvm::Type *getTypeForFormat(llvm::LLVMContext &VMContext,
302  const llvm::fltSemantics &format,
303  bool UseNativeHalf = false) {
304  if (&format == &llvm::APFloat::IEEEhalf()) {
305  if (UseNativeHalf)
306  return llvm::Type::getHalfTy(VMContext);
307  else
308  return llvm::Type::getInt16Ty(VMContext);
309  }
310  if (&format == &llvm::APFloat::BFloat())
311  return llvm::Type::getBFloatTy(VMContext);
312  if (&format == &llvm::APFloat::IEEEsingle())
313  return llvm::Type::getFloatTy(VMContext);
314  if (&format == &llvm::APFloat::IEEEdouble())
315  return llvm::Type::getDoubleTy(VMContext);
316  if (&format == &llvm::APFloat::IEEEquad())
317  return llvm::Type::getFP128Ty(VMContext);
318  if (&format == &llvm::APFloat::PPCDoubleDouble())
319  return llvm::Type::getPPC_FP128Ty(VMContext);
320  if (&format == &llvm::APFloat::x87DoubleExtended())
321  return llvm::Type::getX86_FP80Ty(VMContext);
322  llvm_unreachable("Unknown float format!");
323 }
324 
325 llvm::Type *CodeGenTypes::ConvertFunctionTypeInternal(QualType QFT) {
326  assert(QFT.isCanonical());
327  const Type *Ty = QFT.getTypePtr();
328  const FunctionType *FT = cast<FunctionType>(QFT.getTypePtr());
329  // First, check whether we can build the full function type. If the
330  // function type depends on an incomplete type (e.g. a struct or enum), we
331  // cannot lower the function type.
332  if (!isFuncTypeConvertible(FT)) {
333  // This function's type depends on an incomplete tag type.
334 
335  // Force conversion of all the relevant record types, to make sure
336  // we re-convert the FunctionType when appropriate.
337  if (const RecordType *RT = FT->getReturnType()->getAs<RecordType>())
338  ConvertRecordDeclType(RT->getDecl());
339  if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FT))
340  for (unsigned i = 0, e = FPT->getNumParams(); i != e; i++)
341  if (const RecordType *RT = FPT->getParamType(i)->getAs<RecordType>())
342  ConvertRecordDeclType(RT->getDecl());
343 
344  SkippedLayout = true;
345 
346  // Return a placeholder type.
347  return llvm::StructType::get(getLLVMContext());
348  }
349 
350  // While we're converting the parameter types for a function, we don't want
351  // to recursively convert any pointed-to structs. Converting directly-used
352  // structs is ok though.
353  if (!RecordsBeingLaidOut.insert(Ty).second) {
354  SkippedLayout = true;
355  return llvm::StructType::get(getLLVMContext());
356  }
357 
358  // The function type can be built; call the appropriate routines to
359  // build it.
360  const CGFunctionInfo *FI;
361  if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FT)) {
364  } else {
365  const FunctionNoProtoType *FNPT = cast<FunctionNoProtoType>(FT);
368  }
369 
370  llvm::Type *ResultType = nullptr;
371  // If there is something higher level prodding our CGFunctionInfo, then
372  // don't recurse into it again.
373  if (FunctionsBeingProcessed.count(FI)) {
374 
375  ResultType = llvm::StructType::get(getLLVMContext());
376  SkippedLayout = true;
377  } else {
378 
379  // Otherwise, we're good to go, go ahead and convert it.
380  ResultType = GetFunctionType(*FI);
381  }
382 
383  RecordsBeingLaidOut.erase(Ty);
384 
385  if (SkippedLayout)
386  TypeCache.clear();
387 
388  if (RecordsBeingLaidOut.empty())
389  while (!DeferredRecords.empty())
390  ConvertRecordDeclType(DeferredRecords.pop_back_val());
391  return ResultType;
392 }
393 
394 /// ConvertType - Convert the specified type to its LLVM form.
396  T = Context.getCanonicalType(T);
397 
398  const Type *Ty = T.getTypePtr();
399 
400  // For the device-side compilation, CUDA device builtin surface/texture types
401  // may be represented in different types.
402  if (Context.getLangOpts().CUDAIsDevice) {
404  if (auto *Ty = CGM.getTargetCodeGenInfo()
406  return Ty;
407  } else if (T->isCUDADeviceBuiltinTextureType()) {
408  if (auto *Ty = CGM.getTargetCodeGenInfo()
410  return Ty;
411  }
412  }
413 
414  // RecordTypes are cached and processed specially.
415  if (const RecordType *RT = dyn_cast<RecordType>(Ty))
416  return ConvertRecordDeclType(RT->getDecl());
417 
418  // See if type is already cached.
419  llvm::DenseMap<const Type *, llvm::Type *>::iterator TCI = TypeCache.find(Ty);
420  // If type is found in map then use it. Otherwise, convert type T.
421  if (TCI != TypeCache.end())
422  return TCI->second;
423 
424  // If we don't have it in the cache, convert it now.
425  llvm::Type *ResultType = nullptr;
426  switch (Ty->getTypeClass()) {
427  case Type::Record: // Handled above.
428 #define TYPE(Class, Base)
429 #define ABSTRACT_TYPE(Class, Base)
430 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
431 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
432 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
433 #include "clang/AST/TypeNodes.inc"
434  llvm_unreachable("Non-canonical or dependent types aren't possible.");
435 
436  case Type::Builtin: {
437  switch (cast<BuiltinType>(Ty)->getKind()) {
438  case BuiltinType::Void:
439  case BuiltinType::ObjCId:
440  case BuiltinType::ObjCClass:
441  case BuiltinType::ObjCSel:
442  // LLVM void type can only be used as the result of a function call. Just
443  // map to the same as char.
444  ResultType = llvm::Type::getInt8Ty(getLLVMContext());
445  break;
446 
447  case BuiltinType::Bool:
448  // Note that we always return bool as i1 for use as a scalar type.
449  ResultType = llvm::Type::getInt1Ty(getLLVMContext());
450  break;
451 
452  case BuiltinType::Char_S:
453  case BuiltinType::Char_U:
454  case BuiltinType::SChar:
455  case BuiltinType::UChar:
456  case BuiltinType::Short:
457  case BuiltinType::UShort:
458  case BuiltinType::Int:
459  case BuiltinType::UInt:
460  case BuiltinType::Long:
461  case BuiltinType::ULong:
462  case BuiltinType::LongLong:
463  case BuiltinType::ULongLong:
464  case BuiltinType::WChar_S:
465  case BuiltinType::WChar_U:
466  case BuiltinType::Char8:
467  case BuiltinType::Char16:
468  case BuiltinType::Char32:
469  case BuiltinType::ShortAccum:
470  case BuiltinType::Accum:
471  case BuiltinType::LongAccum:
472  case BuiltinType::UShortAccum:
473  case BuiltinType::UAccum:
474  case BuiltinType::ULongAccum:
475  case BuiltinType::ShortFract:
476  case BuiltinType::Fract:
477  case BuiltinType::LongFract:
478  case BuiltinType::UShortFract:
479  case BuiltinType::UFract:
480  case BuiltinType::ULongFract:
481  case BuiltinType::SatShortAccum:
482  case BuiltinType::SatAccum:
483  case BuiltinType::SatLongAccum:
484  case BuiltinType::SatUShortAccum:
485  case BuiltinType::SatUAccum:
486  case BuiltinType::SatULongAccum:
487  case BuiltinType::SatShortFract:
488  case BuiltinType::SatFract:
489  case BuiltinType::SatLongFract:
490  case BuiltinType::SatUShortFract:
491  case BuiltinType::SatUFract:
492  case BuiltinType::SatULongFract:
493  ResultType = llvm::IntegerType::get(getLLVMContext(),
494  static_cast<unsigned>(Context.getTypeSize(T)));
495  break;
496 
497  case BuiltinType::Float16:
498  ResultType =
500  /* UseNativeHalf = */ true);
501  break;
502 
503  case BuiltinType::Half:
504  // Half FP can either be storage-only (lowered to i16) or native.
505  ResultType = getTypeForFormat(
507  Context.getLangOpts().NativeHalfType ||
509  break;
510  case BuiltinType::BFloat16:
511  case BuiltinType::Float:
512  case BuiltinType::Double:
513  case BuiltinType::LongDouble:
514  case BuiltinType::Float128:
515  case BuiltinType::Ibm128:
516  ResultType = getTypeForFormat(getLLVMContext(),
517  Context.getFloatTypeSemantics(T),
518  /* UseNativeHalf = */ false);
519  break;
520 
521  case BuiltinType::NullPtr:
522  // Model std::nullptr_t as i8*
523  ResultType = llvm::Type::getInt8PtrTy(getLLVMContext());
524  break;
525 
526  case BuiltinType::UInt128:
527  case BuiltinType::Int128:
528  ResultType = llvm::IntegerType::get(getLLVMContext(), 128);
529  break;
530 
531 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
532  case BuiltinType::Id:
533 #include "clang/Basic/OpenCLImageTypes.def"
534 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
535  case BuiltinType::Id:
536 #include "clang/Basic/OpenCLExtensionTypes.def"
537  case BuiltinType::OCLSampler:
538  case BuiltinType::OCLEvent:
539  case BuiltinType::OCLClkEvent:
540  case BuiltinType::OCLQueue:
541  case BuiltinType::OCLReserveID:
542  ResultType = CGM.getOpenCLRuntime().convertOpenCLSpecificType(Ty);
543  break;
544  case BuiltinType::SveInt8:
545  case BuiltinType::SveUint8:
546  case BuiltinType::SveInt8x2:
547  case BuiltinType::SveUint8x2:
548  case BuiltinType::SveInt8x3:
549  case BuiltinType::SveUint8x3:
550  case BuiltinType::SveInt8x4:
551  case BuiltinType::SveUint8x4:
552  case BuiltinType::SveInt16:
553  case BuiltinType::SveUint16:
554  case BuiltinType::SveInt16x2:
555  case BuiltinType::SveUint16x2:
556  case BuiltinType::SveInt16x3:
557  case BuiltinType::SveUint16x3:
558  case BuiltinType::SveInt16x4:
559  case BuiltinType::SveUint16x4:
560  case BuiltinType::SveInt32:
561  case BuiltinType::SveUint32:
562  case BuiltinType::SveInt32x2:
563  case BuiltinType::SveUint32x2:
564  case BuiltinType::SveInt32x3:
565  case BuiltinType::SveUint32x3:
566  case BuiltinType::SveInt32x4:
567  case BuiltinType::SveUint32x4:
568  case BuiltinType::SveInt64:
569  case BuiltinType::SveUint64:
570  case BuiltinType::SveInt64x2:
571  case BuiltinType::SveUint64x2:
572  case BuiltinType::SveInt64x3:
573  case BuiltinType::SveUint64x3:
574  case BuiltinType::SveInt64x4:
575  case BuiltinType::SveUint64x4:
576  case BuiltinType::SveBool:
577  case BuiltinType::SveFloat16:
578  case BuiltinType::SveFloat16x2:
579  case BuiltinType::SveFloat16x3:
580  case BuiltinType::SveFloat16x4:
581  case BuiltinType::SveFloat32:
582  case BuiltinType::SveFloat32x2:
583  case BuiltinType::SveFloat32x3:
584  case BuiltinType::SveFloat32x4:
585  case BuiltinType::SveFloat64:
586  case BuiltinType::SveFloat64x2:
587  case BuiltinType::SveFloat64x3:
588  case BuiltinType::SveFloat64x4:
589  case BuiltinType::SveBFloat16:
590  case BuiltinType::SveBFloat16x2:
591  case BuiltinType::SveBFloat16x3:
592  case BuiltinType::SveBFloat16x4: {
594  Context.getBuiltinVectorTypeInfo(cast<BuiltinType>(Ty));
595  return llvm::ScalableVectorType::get(ConvertType(Info.ElementType),
596  Info.EC.getKnownMinValue() *
597  Info.NumVectors);
598  }
599 #define PPC_VECTOR_TYPE(Name, Id, Size) \
600  case BuiltinType::Id: \
601  ResultType = \
602  llvm::FixedVectorType::get(ConvertType(Context.BoolTy), Size); \
603  break;
604 #include "clang/Basic/PPCTypes.def"
605 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
606 #include "clang/Basic/RISCVVTypes.def"
607  {
609  Context.getBuiltinVectorTypeInfo(cast<BuiltinType>(Ty));
610  return llvm::ScalableVectorType::get(ConvertType(Info.ElementType),
611  Info.EC.getKnownMinValue() *
612  Info.NumVectors);
613  }
614  case BuiltinType::Dependent:
615 #define BUILTIN_TYPE(Id, SingletonId)
616 #define PLACEHOLDER_TYPE(Id, SingletonId) \
617  case BuiltinType::Id:
618 #include "clang/AST/BuiltinTypes.def"
619  llvm_unreachable("Unexpected placeholder builtin type!");
620  }
621  break;
622  }
623  case Type::Auto:
624  case Type::DeducedTemplateSpecialization:
625  llvm_unreachable("Unexpected undeduced type!");
626  case Type::Complex: {
627  llvm::Type *EltTy = ConvertType(cast<ComplexType>(Ty)->getElementType());
628  ResultType = llvm::StructType::get(EltTy, EltTy);
629  break;
630  }
631  case Type::LValueReference:
632  case Type::RValueReference: {
633  const ReferenceType *RTy = cast<ReferenceType>(Ty);
634  QualType ETy = RTy->getPointeeType();
635  llvm::Type *PointeeType = ConvertTypeForMem(ETy);
636  unsigned AS = Context.getTargetAddressSpace(ETy);
637  ResultType = llvm::PointerType::get(PointeeType, AS);
638  break;
639  }
640  case Type::Pointer: {
641  const PointerType *PTy = cast<PointerType>(Ty);
642  QualType ETy = PTy->getPointeeType();
643  llvm::Type *PointeeType = ConvertTypeForMem(ETy);
644  if (PointeeType->isVoidTy())
645  PointeeType = llvm::Type::getInt8Ty(getLLVMContext());
646 
647  unsigned AS = PointeeType->isFunctionTy()
648  ? getDataLayout().getProgramAddressSpace()
649  : Context.getTargetAddressSpace(ETy);
650 
651  ResultType = llvm::PointerType::get(PointeeType, AS);
652  break;
653  }
654 
655  case Type::VariableArray: {
656  const VariableArrayType *A = cast<VariableArrayType>(Ty);
657  assert(A->getIndexTypeCVRQualifiers() == 0 &&
658  "FIXME: We only handle trivial array types so far!");
659  // VLAs resolve to the innermost element type; this matches
660  // the return of alloca, and there isn't any obviously better choice.
661  ResultType = ConvertTypeForMem(A->getElementType());
662  break;
663  }
664  case Type::IncompleteArray: {
665  const IncompleteArrayType *A = cast<IncompleteArrayType>(Ty);
666  assert(A->getIndexTypeCVRQualifiers() == 0 &&
667  "FIXME: We only handle trivial array types so far!");
668  // int X[] -> [0 x int], unless the element type is not sized. If it is
669  // unsized (e.g. an incomplete struct) just use [0 x i8].
670  ResultType = ConvertTypeForMem(A->getElementType());
671  if (!ResultType->isSized()) {
672  SkippedLayout = true;
673  ResultType = llvm::Type::getInt8Ty(getLLVMContext());
674  }
675  ResultType = llvm::ArrayType::get(ResultType, 0);
676  break;
677  }
678  case Type::ConstantArray: {
679  const ConstantArrayType *A = cast<ConstantArrayType>(Ty);
680  llvm::Type *EltTy = ConvertTypeForMem(A->getElementType());
681 
682  // Lower arrays of undefined struct type to arrays of i8 just to have a
683  // concrete type.
684  if (!EltTy->isSized()) {
685  SkippedLayout = true;
686  EltTy = llvm::Type::getInt8Ty(getLLVMContext());
687  }
688 
689  ResultType = llvm::ArrayType::get(EltTy, A->getSize().getZExtValue());
690  break;
691  }
692  case Type::ExtVector:
693  case Type::Vector: {
694  const VectorType *VT = cast<VectorType>(Ty);
695  ResultType = llvm::FixedVectorType::get(ConvertType(VT->getElementType()),
696  VT->getNumElements());
697  break;
698  }
699  case Type::ConstantMatrix: {
700  const ConstantMatrixType *MT = cast<ConstantMatrixType>(Ty);
701  ResultType =
702  llvm::FixedVectorType::get(ConvertType(MT->getElementType()),
703  MT->getNumRows() * MT->getNumColumns());
704  break;
705  }
706  case Type::FunctionNoProto:
707  case Type::FunctionProto:
708  ResultType = ConvertFunctionTypeInternal(T);
709  break;
710  case Type::ObjCObject:
711  ResultType = ConvertType(cast<ObjCObjectType>(Ty)->getBaseType());
712  break;
713 
714  case Type::ObjCInterface: {
715  // Objective-C interfaces are always opaque (outside of the
716  // runtime, which can do whatever it likes); we never refine
717  // these.
718  llvm::Type *&T = InterfaceTypes[cast<ObjCInterfaceType>(Ty)];
719  if (!T)
721  ResultType = T;
722  break;
723  }
724 
725  case Type::ObjCObjectPointer: {
726  // Protocol qualifications do not influence the LLVM type, we just return a
727  // pointer to the underlying interface type. We don't need to worry about
728  // recursive conversion.
729  llvm::Type *T =
730  ConvertTypeForMem(cast<ObjCObjectPointerType>(Ty)->getPointeeType());
731  ResultType = T->getPointerTo();
732  break;
733  }
734 
735  case Type::Enum: {
736  const EnumDecl *ED = cast<EnumType>(Ty)->getDecl();
737  if (ED->isCompleteDefinition() || ED->isFixed())
738  return ConvertType(ED->getIntegerType());
739  // Return a placeholder 'i32' type. This can be changed later when the
740  // type is defined (see UpdateCompletedType), but is likely to be the
741  // "right" answer.
742  ResultType = llvm::Type::getInt32Ty(getLLVMContext());
743  break;
744  }
745 
746  case Type::BlockPointer: {
747  const QualType FTy = cast<BlockPointerType>(Ty)->getPointeeType();
748  llvm::Type *PointeeType = CGM.getLangOpts().OpenCL
750  : ConvertTypeForMem(FTy);
751  unsigned AS = Context.getTargetAddressSpace(FTy);
752  ResultType = llvm::PointerType::get(PointeeType, AS);
753  break;
754  }
755 
756  case Type::MemberPointer: {
757  auto *MPTy = cast<MemberPointerType>(Ty);
758  if (!getCXXABI().isMemberPointerConvertible(MPTy)) {
759  RecordsWithOpaqueMemberPointers.insert(MPTy->getClass());
761  } else {
762  ResultType = getCXXABI().ConvertMemberPointerType(MPTy);
763  }
764  break;
765  }
766 
767  case Type::Atomic: {
768  QualType valueType = cast<AtomicType>(Ty)->getValueType();
769  ResultType = ConvertTypeForMem(valueType);
770 
771  // Pad out to the inflated size if necessary.
772  uint64_t valueSize = Context.getTypeSize(valueType);
773  uint64_t atomicSize = Context.getTypeSize(Ty);
774  if (valueSize != atomicSize) {
775  assert(valueSize < atomicSize);
776  llvm::Type *elts[] = {
777  ResultType,
778  llvm::ArrayType::get(CGM.Int8Ty, (atomicSize - valueSize) / 8)
779  };
780  ResultType = llvm::StructType::get(getLLVMContext(),
781  llvm::makeArrayRef(elts));
782  }
783  break;
784  }
785  case Type::Pipe: {
786  ResultType = CGM.getOpenCLRuntime().getPipeType(cast<PipeType>(Ty));
787  break;
788  }
789  case Type::ExtInt: {
790  const auto &EIT = cast<ExtIntType>(Ty);
791  ResultType = llvm::Type::getIntNTy(getLLVMContext(), EIT->getNumBits());
792  break;
793  }
794  }
795 
796  assert(ResultType && "Didn't convert a type?");
797 
798  TypeCache[Ty] = ResultType;
799  return ResultType;
800 }
801 
803  return isPaddedAtomicType(type->castAs<AtomicType>());
804 }
805 
807  return Context.getTypeSize(type) != Context.getTypeSize(type->getValueType());
808 }
809 
810 /// ConvertRecordDeclType - Lay out a tagged decl type like struct or union.
811 llvm::StructType *CodeGenTypes::ConvertRecordDeclType(const RecordDecl *RD) {
812  // TagDecl's are not necessarily unique, instead use the (clang)
813  // type connected to the decl.
814  const Type *Key = Context.getTagDeclType(RD).getTypePtr();
815 
816  llvm::StructType *&Entry = RecordDeclTypes[Key];
817 
818  // If we don't have a StructType at all yet, create the forward declaration.
819  if (!Entry) {
821  addRecordTypeName(RD, Entry, "");
822  }
823  llvm::StructType *Ty = Entry;
824 
825  // If this is still a forward declaration, or the LLVM type is already
826  // complete, there's nothing more to do.
827  RD = RD->getDefinition();
828  if (!RD || !RD->isCompleteDefinition() || !Ty->isOpaque())
829  return Ty;
830 
831  // If converting this type would cause us to infinitely loop, don't do it!
832  if (!isSafeToConvert(RD, *this)) {
833  DeferredRecords.push_back(RD);
834  return Ty;
835  }
836 
837  // Okay, this is a definition of a type. Compile the implementation now.
838  bool InsertResult = RecordsBeingLaidOut.insert(Key).second;
839  (void)InsertResult;
840  assert(InsertResult && "Recursively compiling a struct?");
841 
842  // Force conversion of non-virtual base classes recursively.
843  if (const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
844  for (const auto &I : CRD->bases()) {
845  if (I.isVirtual()) continue;
846  ConvertRecordDeclType(I.getType()->castAs<RecordType>()->getDecl());
847  }
848  }
849 
850  // Layout fields.
851  std::unique_ptr<CGRecordLayout> Layout = ComputeRecordLayout(RD, Ty);
852  CGRecordLayouts[Key] = std::move(Layout);
853 
854  // We're done laying out this struct.
855  bool EraseResult = RecordsBeingLaidOut.erase(Key); (void)EraseResult;
856  assert(EraseResult && "struct not in RecordsBeingLaidOut set?");
857 
858  // If this struct blocked a FunctionType conversion, then recompute whatever
859  // was derived from that.
860  // FIXME: This is hugely overconservative.
861  if (SkippedLayout)
862  TypeCache.clear();
863 
864  // If we're done converting the outer-most record, then convert any deferred
865  // structs as well.
866  if (RecordsBeingLaidOut.empty())
867  while (!DeferredRecords.empty())
868  ConvertRecordDeclType(DeferredRecords.pop_back_val());
869 
870  return Ty;
871 }
872 
873 /// getCGRecordLayout - Return record layout info for the given record decl.
874 const CGRecordLayout &
876  const Type *Key = Context.getTagDeclType(RD).getTypePtr();
877 
878  auto I = CGRecordLayouts.find(Key);
879  if (I != CGRecordLayouts.end())
880  return *I->second;
881  // Compute the type information.
883 
884  // Now try again.
885  I = CGRecordLayouts.find(Key);
886 
887  assert(I != CGRecordLayouts.end() &&
888  "Unable to find record layout information for type");
889  return *I->second;
890 }
891 
893  assert((T->isAnyPointerType() || T->isBlockPointerType()) && "Invalid type");
894  return isZeroInitializable(T);
895 }
896 
898  if (T->getAs<PointerType>())
899  return Context.getTargetNullPointerValue(T) == 0;
900 
901  if (const auto *AT = Context.getAsArrayType(T)) {
902  if (isa<IncompleteArrayType>(AT))
903  return true;
904  if (const auto *CAT = dyn_cast<ConstantArrayType>(AT))
905  if (Context.getConstantArrayElementCount(CAT) == 0)
906  return true;
907  T = Context.getBaseElementType(T);
908  }
909 
910  // Records are non-zero-initializable if they contain any
911  // non-zero-initializable subobjects.
912  if (const RecordType *RT = T->getAs<RecordType>()) {
913  const RecordDecl *RD = RT->getDecl();
914  return isZeroInitializable(RD);
915  }
916 
917  // We have to ask the ABI about member pointers.
918  if (const MemberPointerType *MPT = T->getAs<MemberPointerType>())
919  return getCXXABI().isZeroInitializable(MPT);
920 
921  // Everything else is okay.
922  return true;
923 }
924 
927 }
clang::TagDecl::getKindName
StringRef getKindName() const
Definition: Decl.h:3503
clang::CodeGen::CodeGenTypes::getContext
ASTContext & getContext() const
Definition: CodeGenTypes.h:116
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:414
clang::ASTContext::BuiltinVectorTypeInfo::NumVectors
unsigned NumVectors
Definition: ASTContext.h:1451
clang::Type::isConstantMatrixType
bool isConstantMatrixType() const
Definition: Type.h:6786
clang::Type::isBlockPointerType
bool isBlockPointerType() const
Definition: Type.h:6680
clang::CodeGen::CodeGenTypes::noRecordsBeingLaidOut
bool noRecordsBeingLaidOut() const
Definition: CodeGenTypes.h:306
type
clang::ConstantArrayType
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2929
clang::CodeGen::CodeGenModule::getOpenCLRuntime
CGOpenCLRuntime & getOpenCLRuntime()
Return a reference to the configured OpenCL runtime.
Definition: CodeGenModule.h:610
clang::ASTContext::BuiltinVectorTypeInfo::ElementType
QualType ElementType
Definition: ASTContext.h:1449
clang::ConstantArrayType::getSize
const llvm::APInt & getSize() const
Definition: Type.h:2952
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:290
clang::MultiVersionKind::Target
@ Target
CGRecordLayout.h
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:673
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:3795
clang::CodeGen::CodeGenTypes::getCodeGenOpts
const CodeGenOptions & getCodeGenOpts() const
Definition: CodeGenTypes.cpp:44
clang::ASTContext::getFloatTypeSemantics
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
Definition: ASTContext.cpp:1703
clang::ASTContext::getBaseElementType
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Definition: ASTContext.cpp:6300
DeclCXX.h
TargetInfo.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:206
clang::CodeGen::CodeGenTypes::getLLVMContext
llvm::LLVMContext & getLLVMContext()
Definition: CodeGenTypes.h:120
clang::CodeGen::CodeGenModule::getGenericBlockLiteralType
llvm::Type * getGenericBlockLiteralType()
The type of a generic block literal.
Definition: CGBlocks.cpp:1141
clang::RecordDecl::getDefinition
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
Definition: Decl.h:4064
llvm::SmallPtrSet
Definition: ASTContext.h:82
clang::TagType
Definition: Type.h:4589
clang::CodeGen::CodeGenModule::getLangOpts
const LangOptions & getLangOpts() const
Definition: CodeGenModule.h:703
clang::TagDecl::getTypedefNameForAnonDecl
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition: Decl.h:3538
clang::CodeGen::TargetCodeGenInfo::getCUDADeviceBuiltinTextureDeviceType
virtual llvm::Type * getCUDADeviceBuiltinTextureDeviceType() const
Return the device-side type for the CUDA device builtin texture type.
Definition: TargetInfo.h:348
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:59
clang::CodeGen::CodeGenModule::getTargetCodeGenInfo
const TargetCodeGenInfo & getTargetCodeGenInfo()
Definition: TargetInfo.cpp:11083
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3546
clang::FunctionNoProtoType
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition: Type.h:3847
clang::CodeGen::CodeGenTypes::ConvertType
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
Definition: CodeGenTypes.cpp:395
clang::EnumDecl
Represents an enum.
Definition: Decl.h:3590
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1490
clang::PrintingPolicy::SuppressInlineNamespace
unsigned SuppressInlineNamespace
Suppress printing parts of scope specifiers that correspond to inline namespaces, where the name is u...
Definition: PrettyPrinter.h:139
DeclObjC.h
clang::ReferenceType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:2769
clang::CodeGen::TargetCodeGenInfo::getCUDADeviceBuiltinSurfaceDeviceType
virtual llvm::Type * getCUDADeviceBuiltinSurfaceDeviceType() const
Return the device-side type for the CUDA device builtin surface type.
Definition: TargetInfo.h:343
clang::CanQual::getTypePtr
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
Definition: CanonicalType.h:83
clang::Type::isCUDADeviceBuiltinTextureType
bool isCUDADeviceBuiltinTextureType() const
Check if the type is the CUDA device builtin texture type.
Definition: Type.cpp:4335
clang::CodeGen::CodeGenTypes::ConvertTypeForMem
llvm::Type * ConvertTypeForMem(QualType T, bool ForBitField=false)
ConvertTypeForMem - Convert type T into a llvm::Type.
Definition: CodeGenTypes.cpp:90
CGCall.h
clang::ArrayType::getIndexTypeCVRQualifiers
unsigned getIndexTypeCVRQualifiers() const
Definition: Type.h:2914
clang::CodeGen::CGRecordLayout::isZeroInitializable
bool isZeroInitializable() const
Check whether this struct can be C++ zero-initialized with a zeroinitializer.
Definition: CGRecordLayout.h:185
clang::RecordType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4613
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:113
clang::CodeGen::CodeGenModule::isPaddedAtomicType
bool isPaddedAtomicType(QualType type)
Definition: CodeGenTypes.cpp:802
clang::ASTContext::getAsArrayType
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
Definition: ASTContext.cpp:6189
clang::VectorType
Represents a GCC generic vector type.
Definition: Type.h:3229
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:11495
clang::CodeGen::CodeGenModule::getCodeGenOpts
const CodeGenOptions & getCodeGenOpts() const
Definition: CodeGenModule.h:708
CGFunctionInfo.h
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:191
clang::ConstantMatrixType
Represents a concrete matrix type with constant number of rows and columns.
Definition: Type.h:3455
clang::ASTContext::getConstantArrayElementCount
uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const
Return number of constant array elements.
Definition: ASTContext.cpp:6320
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7161
clang::ASTContext::BuiltinVectorTypeInfo::EC
llvm::ElementCount EC
Definition: ASTContext.h:1450
clang::CodeGen::CGRecordLayout
CGRecordLayout - This class handles struct and union layout info while lowering AST types to LLVM typ...
Definition: CGRecordLayout.h:121
clang::ASTContext::getBuiltinVectorTypeInfo
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
Definition: ASTContext.cpp:3801
clang::ASTContext::getTypeSize
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:2245
clang::CodeGen::CGDebugInfo
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
Definition: CGDebugInfo.h:56
clang::ConstantMatrixType::getNumColumns
unsigned getNumColumns() const
Returns the number of columns in the matrix.
Definition: Type.h:3476
Expr.h
llvm::SmallString
Definition: LLVM.h:37
clang::CodeGen::CodeGenTypes::~CodeGenTypes
~CodeGenTypes()
Definition: CodeGenTypes.cpp:38
ASTContext.h
clang::ASTContext::getRecordType
QualType getRecordType(const RecordDecl *Decl) const
Definition: ASTContext.cpp:4596
clang::Type::getPointeeType
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition: Type.cpp:625
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3328
clang::ASTContext::getCanonicalType
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2468
clang::CanQual
Represents a canonical, potentially-qualified type.
Definition: CanonicalType.h:65
clang::TagDecl::isCompleteDefinition
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3433
clang::MatrixType::getElementType
QualType getElementType() const
Returns type of the elements being stored in the matrix.
Definition: Type.h:3433
clang::CodeGen::CodeGenTypes::UpdateCompletedType
void UpdateCompletedType(const TagDecl *TD)
UpdateCompletedType - When we find the full definition for a TagDecl, replace the 'opaque' type we pr...
Definition: CodeGenTypes.cpp:254
clang::CodeGenOptions
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
Definition: CodeGenOptions.h:49
getKind
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:998
clang::Type::getTypeClass
TypeClass getTypeClass() const
Definition: Type.h:1858
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:892
clang::IncompleteArrayType
Represents a C array with an unspecified size.
Definition: Type.h:2989
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:240
clang::CodeGen::CodeGenModule::getModuleDebugInfo
CGDebugInfo * getModuleDebugInfo()
Definition: CodeGenModule.h:694
clang::ASTContext::getTargetAddressSpace
unsigned getTargetAddressSpace(QualType T) const
Definition: ASTContext.h:2720
clang::CodeGen::CodeGenTypes::getCGRecordLayout
const CGRecordLayout & getCGRecordLayout(const RecordDecl *)
getCGRecordLayout - Return record layout info for the given record decl.
Definition: CodeGenTypes.cpp:875
clang::CodeGen::CodeGenTypes::GetFunctionType
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.
Definition: CGCall.cpp:1595
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:255
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:302
clang::QualType::isCanonical
bool isCanonical() const
Definition: Type.h:6468
clang::VariableArrayType
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:3033
clang::NamedDecl::getIdentifier
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:270
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:5702
clang::FunctionProtoType
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3885
clang::ASTContext::getPrintingPolicy
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:687
clang::CodeGen::CodeGenModule
This class organizes the cross-function state that is used while generating LLVM code.
Definition: CodeGenModule.h:284
clang::RecordDecl::fields
field_range fields() const
Definition: Decl.h:4079
clang::CodeGen::CodeGenTypes::CodeGenTypes
CodeGenTypes(CodeGenModule &cgm)
Definition: CodeGenTypes.cpp:31
CodeGenTypes.h
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::ASTContext::getTargetInfo
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:747
clang::MemberPointerType
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2831
clang::CodeGen::CGFunctionInfo
CGFunctionInfo - Class to encapsulate the information about a function definition.
Definition: CGFunctionInfo.h:546
CGCXXABI.h
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::convertOpenCLSpecificType
virtual llvm::Type * convertOpenCLSpecificType(const Type *T)
Definition: CGOpenCLRuntime.cpp:33
clang::PointerType
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2640
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:169
clang::CodeGen::CGOpenCLRuntime::getPipeType
virtual llvm::Type * getPipeType(const PipeType *T, StringRef Name, llvm::Type *&PipeTy)
Definition: CGOpenCLRuntime.cpp:79
clang::DeclaratorContext::TypeName
@ TypeName
clang::CodeGen::CodeGenTypes::getCXXABI
CGCXXABI & getCXXABI() const
Definition: CodeGenTypes.h:119
clang::CodeGen::CodeGenTypes::isRecordBeingLaidOut
bool isRecordBeingLaidOut(const Type *Ty) const
Definition: CodeGenTypes.h:309
clang::ASTContext::BuiltinVectorTypeInfo
Definition: ASTContext.h:1448
getTypeForFormat
static llvm::Type * getTypeForFormat(llvm::LLVMContext &VMContext, const llvm::fltSemantics &format, bool UseNativeHalf=false)
Definition: CodeGenTypes.cpp:301
clang
Definition: CalledOnceCheck.h:17
clang::Type::isAnyPointerType
bool isAnyPointerType() const
Definition: Type.h:6676
CGOpenCLRuntime.h
clang::VectorType::getElementType
QualType getElementType() const
Definition: Type.h:3270
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:48
clang::EnumDecl::getIntegerType
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition: Decl.h:3746
clang::CodeGen::CodeGenTypes::ConvertRecordDeclType
llvm::StructType * ConvertRecordDeclType(const RecordDecl *TD)
ConvertRecordDeclType - Lay out a tagged decl type like struct or union.
Definition: CodeGenTypes.cpp:811
clang::FunctionType::getReturnType
QualType getReturnType() const
Definition: Type.h:3809
clang::CodeGen::CodeGenTypes::getDataLayout
const llvm::DataLayout & getDataLayout() const
Definition: CodeGenTypes.h:113
clang::NamedDecl::printName
virtual void printName(raw_ostream &os) const
Pretty-print the unqualified name of this declaration.
Definition: Decl.cpp:1578
clang::TypedefNameDecl
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3180
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:197
clang::QualType::getTypePtr
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6424
clang::RecordType::getDecl
RecordDecl * getDecl() const
Definition: Type.h:4623
clang::ReferenceType
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2751
clang::PointerType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:2650
clang::VectorType::getNumElements
unsigned getNumElements() const
Definition: Type.h:3271
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:897
clang::AtomicType
Definition: Type.h:6242
clang::CodeGen::CodeGenTypes::ComputeRecordLayout
std::unique_ptr< CGRecordLayout > ComputeRecordLayout(const RecordDecl *D, llvm::StructType *Ty)
Compute a new LLVM record layout object for the given record.
Definition: CGRecordLayoutBuilder.cpp:878
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:3484
clang::ArrayType::getElementType
QualType getElementType() const
Definition: Type.h:2904
clang::CodeGen::CodeGenTypeCache::Int8Ty
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
Definition: CodeGenTypeCache.h:37
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:1589
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:2217
clang::ConstantMatrixType::getNumRows
unsigned getNumRows() const
Returns the number of rows in the matrix.
Definition: Type.h:3473
clang::Type::isCUDADeviceBuiltinSurfaceType
bool isCUDADeviceBuiltinSurfaceType() const
Check if the type is the CUDA device builtin surface type.
Definition: Type.cpp:4328
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3859
clang::Type::isExtIntType
bool isExtIntType() const
Definition: Type.h:6890
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::ASTContext::getLangOpts
const LangOptions & getLangOpts() const
Definition: ASTContext.h:765
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:865
RecordLayout.h
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:439