clang  15.0.0git
CGCXXABI.cpp
Go to the documentation of this file.
1 //===----- CGCXXABI.cpp - Interface to C++ ABIs ---------------------------===//
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 provides an abstract class for C++ code generation. Concrete subclasses
10 // of this implement code generation for specific C++ ABIs.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "CGCXXABI.h"
15 #include "CGCleanup.h"
16 #include "clang/AST/Attr.h"
17 
18 using namespace clang;
19 using namespace CodeGen;
20 
22 
24  DiagnosticsEngine &Diags = CGF.CGM.getDiags();
25  unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
26  "cannot yet compile %0 in this ABI");
28  DiagID)
29  << S;
30 }
31 
33  return llvm::Constant::getNullValue(CGM.getTypes().ConvertType(T));
34 }
35 
36 llvm::Type *
39 }
40 
42  CodeGenFunction &CGF, const Expr *E, Address This,
43  llvm::Value *&ThisPtrForCall,
44  llvm::Value *MemPtr, const MemberPointerType *MPT) {
45  ErrorUnsupportedABI(CGF, "calls through member pointers");
46 
47  ThisPtrForCall = This.getPointer();
48  const auto *FPT = MPT->getPointeeType()->castAs<FunctionProtoType>();
49  const auto *RD =
50  cast<CXXRecordDecl>(MPT->getClass()->castAs<RecordType>()->getDecl());
51  llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(
52  CGM.getTypes().arrangeCXXMethodType(RD, FPT, /*FD=*/nullptr));
53  llvm::Constant *FnPtr = llvm::Constant::getNullValue(FTy->getPointerTo());
54  return CGCallee::forDirect(FnPtr, FPT);
55 }
56 
57 llvm::Value *
59  Address Base, llvm::Value *MemPtr,
60  const MemberPointerType *MPT) {
61  ErrorUnsupportedABI(CGF, "loads of member pointers");
62  llvm::Type *Ty = CGF.ConvertType(MPT->getPointeeType())
63  ->getPointerTo(Base.getAddressSpace());
64  return llvm::Constant::getNullValue(Ty);
65 }
66 
68  const CastExpr *E,
69  llvm::Value *Src) {
70  ErrorUnsupportedABI(CGF, "member function pointer conversions");
71  return GetBogusMemberPointer(E->getType());
72 }
73 
75  llvm::Constant *Src) {
76  return GetBogusMemberPointer(E->getType());
77 }
78 
79 llvm::Value *
81  llvm::Value *L,
82  llvm::Value *R,
83  const MemberPointerType *MPT,
84  bool Inequality) {
85  ErrorUnsupportedABI(CGF, "member function pointer comparison");
86  return CGF.Builder.getFalse();
87 }
88 
89 llvm::Value *
91  llvm::Value *MemPtr,
92  const MemberPointerType *MPT) {
93  ErrorUnsupportedABI(CGF, "member function pointer null testing");
94  return CGF.Builder.getFalse();
95 }
96 
97 llvm::Constant *
99  return GetBogusMemberPointer(QualType(MPT, 0));
100 }
101 
104  MD->getType(), MD->getParent()->getTypeForDecl()));
105 }
106 
108  CharUnits offset) {
109  return GetBogusMemberPointer(QualType(MPT, 0));
110 }
111 
112 llvm::Constant *CGCXXABI::EmitMemberPointer(const APValue &MP, QualType MPT) {
113  return GetBogusMemberPointer(MPT);
114 }
115 
117  // Fake answer.
118  return true;
119 }
120 
122  const CXXMethodDecl *MD = cast<CXXMethodDecl>(CGF.CurGD.getDecl());
123 
124  // FIXME: I'm not entirely sure I like using a fake decl just for code
125  // generation. Maybe we can come up with a better way?
126  auto *ThisDecl = ImplicitParamDecl::Create(
127  CGM.getContext(), nullptr, MD->getLocation(),
128  &CGM.getContext().Idents.get("this"), MD->getThisType(),
130  params.push_back(ThisDecl);
131  CGF.CXXABIThisDecl = ThisDecl;
132 
133  // Compute the presumed alignment of 'this', which basically comes
134  // down to whether we know it's a complete object or not.
135  auto &Layout = CGF.getContext().getASTRecordLayout(MD->getParent());
136  if (MD->getParent()->getNumVBases() == 0 || // avoid vcall in common case
137  MD->getParent()->isEffectivelyFinal() ||
139  CGF.CXXABIThisAlignment = Layout.getAlignment();
140  } else {
141  CGF.CXXABIThisAlignment = Layout.getNonVirtualAlignment();
142  }
143 }
144 
146  return CGF.Builder.CreateLoad(CGF.GetAddrOfLocalVar(getThisDecl(CGF)),
147  "this");
148 }
149 
150 void CGCXXABI::setCXXABIThisValue(CodeGenFunction &CGF, llvm::Value *ThisPtr) {
151  /// Initialize the 'this' slot.
152  assert(getThisDecl(CGF) && "no 'this' variable for function");
153  CGF.CXXABIThisValue = ThisPtr;
154 }
155 
156 bool CGCXXABI::mayNeedDestruction(const VarDecl *VD) const {
157  if (VD->needsDestruction(getContext()))
158  return true;
159 
160  // If the variable has an incomplete class type (or array thereof), it
161  // might need destruction.
162  const Type *T = VD->getType()->getBaseElementTypeUnsafe();
163  if (T->getAs<RecordType>() && T->isIncompleteType())
164  return true;
165 
166  return false;
167 }
168 
170  const VarDecl *VD, bool InspectInitForWeakDef) const {
171  VD = VD->getMostRecentDecl();
172  if (VD->hasAttr<ConstInitAttr>())
173  return true;
174 
175  // All later checks examine the initializer specified on the variable. If
176  // the variable is weak, such examination would not be correct.
177  if (!InspectInitForWeakDef && (VD->isWeak() || VD->hasAttr<SelectAnyAttr>()))
178  return false;
179 
180  const VarDecl *InitDecl = VD->getInitializingDeclaration();
181  if (!InitDecl)
182  return false;
183 
184  // If there's no initializer to run, this is constant initialization.
185  if (!InitDecl->hasInit())
186  return true;
187 
188  // If we have the only definition, we don't need a thread wrapper if we
189  // will emit the value as a constant.
190  if (isUniqueGVALinkage(getContext().GetGVALinkageForVariable(VD)))
191  return !mayNeedDestruction(VD) && InitDecl->evaluateValue();
192 
193  // Otherwise, we need a thread wrapper unless we know that every
194  // translation unit will emit the value as a constant. We rely on the
195  // variable being constant-initialized in every translation unit if it's
196  // constant-initialized in any translation unit, which isn't actually
197  // guaranteed by the standard but is necessary for sanity.
198  return InitDecl->hasConstantInitialization();
199 }
200 
202  RValue RV, QualType ResultType) {
203  assert(!CGF.hasAggregateEvaluationKind(ResultType) &&
204  "cannot handle aggregates");
205  CGF.EmitReturnOfRValue(RV, ResultType);
206 }
207 
210  return CharUnits::Zero();
211  return getArrayCookieSizeImpl(expr->getAllocatedType());
212 }
213 
215  // BOGUS
216  return CharUnits::Zero();
217 }
218 
220  Address NewPtr,
221  llvm::Value *NumElements,
222  const CXXNewExpr *expr,
223  QualType ElementType) {
224  // Should never be called.
225  ErrorUnsupportedABI(CGF, "array cookie initialization");
226  return Address::invalid();
227 }
228 
230  QualType elementType) {
231  // If the class's usual deallocation function takes two arguments,
232  // it needs a cookie.
233  if (expr->doesUsualArrayDeleteWantSize())
234  return true;
235 
236  return elementType.isDestructedType();
237 }
238 
240  // If the class's usual deallocation function takes two arguments,
241  // it needs a cookie.
242  if (expr->doesUsualArrayDeleteWantSize())
243  return true;
244 
245  return expr->getAllocatedType().isDestructedType();
246 }
247 
249  const CXXDeleteExpr *expr, QualType eltTy,
250  llvm::Value *&numElements,
251  llvm::Value *&allocPtr, CharUnits &cookieSize) {
252  // Derive a char* in the same address space as the pointer.
253  ptr = CGF.Builder.CreateElementBitCast(ptr, CGF.Int8Ty);
254 
255  // If we don't need an array cookie, bail out early.
256  if (!requiresArrayCookie(expr, eltTy)) {
257  allocPtr = ptr.getPointer();
258  numElements = nullptr;
259  cookieSize = CharUnits::Zero();
260  return;
261  }
262 
263  cookieSize = getArrayCookieSizeImpl(eltTy);
264  Address allocAddr =
265  CGF.Builder.CreateConstInBoundsByteGEP(ptr, -cookieSize);
266  allocPtr = allocAddr.getPointer();
267  numElements = readArrayCookieImpl(CGF, allocAddr, cookieSize);
268 }
269 
271  Address ptr,
272  CharUnits cookieSize) {
273  ErrorUnsupportedABI(CGF, "reading a new[] cookie");
274  return llvm::ConstantInt::get(CGF.SizeTy, 0);
275 }
276 
277 /// Returns the adjustment, in bytes, required for the given
278 /// member-pointer operation. Returns null if no adjustment is
279 /// required.
281  assert(E->getCastKind() == CK_DerivedToBaseMemberPointer ||
282  E->getCastKind() == CK_BaseToDerivedMemberPointer);
283 
284  QualType derivedType;
285  if (E->getCastKind() == CK_DerivedToBaseMemberPointer)
286  derivedType = E->getSubExpr()->getType();
287  else
288  derivedType = E->getType();
289 
290  const CXXRecordDecl *derivedClass =
291  derivedType->castAs<MemberPointerType>()->getClass()->getAsCXXRecordDecl();
292 
293  return CGM.GetNonVirtualBaseClassOffset(derivedClass,
294  E->path_begin(),
295  E->path_end());
296 }
297 
298 llvm::BasicBlock *
300  const CXXRecordDecl *RD) {
302  llvm_unreachable("shouldn't be called in this ABI");
303 
304  ErrorUnsupportedABI(CGF, "complete object detection in ctor");
305  return nullptr;
306 }
307 
308 void CGCXXABI::setCXXDestructorDLLStorage(llvm::GlobalValue *GV,
309  const CXXDestructorDecl *Dtor,
310  CXXDtorType DT) const {
311  // Assume the base C++ ABI has no special rules for destructor variants.
312  CGM.setDLLImportDLLExport(GV, Dtor);
313 }
314 
315 llvm::GlobalValue::LinkageTypes CGCXXABI::getCXXDestructorLinkage(
316  GVALinkage Linkage, const CXXDestructorDecl *Dtor, CXXDtorType DT) const {
317  // Delegate back to CGM by default.
319  /*IsConstantVariable=*/false);
320 }
321 
323  return false;
324 }
325 
326 llvm::CallInst *
328  llvm::Value *Exn) {
329  // Just call std::terminate and ignore the violating exception.
330  return CGF.EmitNounwindRuntimeCall(CGF.CGM.getTerminateFn());
331 }
332 
334  return CatchTypeInfo{nullptr, 0};
335 }
336 
337 std::vector<CharUnits> CGCXXABI::getVBPtrOffsets(const CXXRecordDecl *RD) {
338  return std::vector<CharUnits>();
339 }
340 
343  bool ForVirtualBase, bool Delegating, CallArgList &Args) {
344  AddedStructorArgs AddedArgs =
345  getImplicitConstructorArgs(CGF, D, Type, ForVirtualBase, Delegating);
346  for (size_t i = 0; i < AddedArgs.Prefix.size(); ++i) {
347  Args.insert(Args.begin() + 1 + i,
348  CallArg(RValue::get(AddedArgs.Prefix[i].Value),
349  AddedArgs.Prefix[i].Type));
350  }
351  for (const auto &arg : AddedArgs.Suffix) {
352  Args.add(RValue::get(arg.Value), arg.Type);
353  }
354  return AddedStructorArgCounts(AddedArgs.Prefix.size(),
355  AddedArgs.Suffix.size());
356 }
clang::CodeGen::CGCXXABI::ReadArrayCookie
virtual void ReadArrayCookie(CodeGenFunction &CGF, Address Ptr, const CXXDeleteExpr *expr, QualType ElementType, llvm::Value *&NumElements, llvm::Value *&AllocPtr, CharUnits &CookieSize)
Reads the array cookie associated with the given pointer, if it has one.
Definition: CGCXXABI.cpp:248
clang::CXXMethodDecl::getThisType
QualType getThisType() const
Return the type of the this pointer.
Definition: DeclCXX.cpp:2452
clang::isUniqueGVALinkage
bool isUniqueGVALinkage(GVALinkage L)
Do we know that this will be the only definition of this symbol (excluding inlining-only definitions)...
Definition: Linkage.h:87
clang::CodeGen::CodeGenTypeCache::SizeTy
llvm::IntegerType * SizeTy
Definition: CodeGenTypeCache.h:50
clang::CodeGen::CGCXXABI::getCXXDestructorLinkage
virtual llvm::GlobalValue::LinkageTypes getCXXDestructorLinkage(GVALinkage Linkage, const CXXDestructorDecl *Dtor, CXXDtorType DT) const
Definition: CGCXXABI.cpp:315
clang::CXXConstructorDecl
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2421
clang::CodeGen::CGCXXABI::EmitMemberPointerConversion
virtual llvm::Value * EmitMemberPointerConversion(CodeGenFunction &CGF, const CastExpr *E, llvm::Value *Src)
Perform a derived-to-base, base-to-derived, or bitcast member pointer conversion.
Definition: CGCXXABI.cpp:67
clang::CodeGen::RValue
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
Definition: CGValue.h:39
clang::CXXRecordDecl::isEffectivelyFinal
bool isEffectivelyFinal() const
Determine whether it's impossible for a class to be derived from this class.
Definition: DeclCXX.cpp:2021
clang::ImplicitParamDecl::CXXThis
@ CXXThis
Parameter for C++ 'this' argument.
Definition: Decl.h:1628
clang::CodeGen::CGCXXABI::EmitMemberFunctionPointer
virtual llvm::Constant * EmitMemberFunctionPointer(const CXXMethodDecl *MD)
Create a member pointer for the given method.
Definition: CGCXXABI.cpp:102
clang::CodeGen::CGCXXABI::ErrorUnsupportedABI
void ErrorUnsupportedABI(CodeGenFunction &CGF, StringRef S)
Issue a diagnostic about unsupported features in the ABI.
Definition: CGCXXABI.cpp:23
clang::Decl::hasAttr
bool hasAttr() const
Definition: DeclBase.h:542
clang::CodeGen::CodeGenFunction::CurCodeDecl
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
Definition: CodeGenFunction.h:322
clang::CodeGen::CodeGenFunction::EmitNounwindRuntimeCall
llvm::CallInst * EmitNounwindRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
clang::IdentifierTable::get
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Definition: IdentifierTable.h:596
clang::CodeGen::CGCXXABI::AddedStructorArgs
Additional implicit arguments to add to the beginning (Prefix) and end (Suffix) of a constructor / de...
Definition: CGCXXABI.h:313
clang::CastExpr::getSubExpr
Expr * getSubExpr()
Definition: Expr.h:3525
clang::ASTContext::getFullLoc
FullSourceLoc getFullLoc(SourceLocation Loc) const
Definition: ASTContext.h:806
clang::CodeGen::CGCXXABI::NeedsVTTParameter
virtual bool NeedsVTTParameter(GlobalDecl GD)
Return whether the given global decl needs a VTT parameter.
Definition: CGCXXABI.cpp:322
clang::CodeGen::CGCXXABI::InitializeArrayCookie
virtual Address InitializeArrayCookie(CodeGenFunction &CGF, Address NewPtr, llvm::Value *NumElements, const CXXNewExpr *expr, QualType ElementType)
Initialize the array cookie for the given allocation.
Definition: CGCXXABI.cpp:219
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:675
clang::TypeDecl::getTypeForDecl
const Type * getTypeForDecl() const
Definition: Decl.h:3182
Attr.h
clang::VarDecl::getInitializingDeclaration
VarDecl * getInitializingDeclaration()
Get the initializing declaration of this variable, if any.
Definition: Decl.cpp:2328
clang::GVALinkage
GVALinkage
A more specific kind of linkage than enum Linkage.
Definition: Linkage.h:73
clang::CodeGen::CodeGenModule::getContext
ASTContext & getContext() const
Definition: CodeGenModule.h:697
clang::DiagnosticsEngine
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:192
clang::CodeGen::CodeGenModule::getLLVMLinkageForDeclarator
llvm::GlobalValue::LinkageTypes getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage, bool IsConstantVariable)
Returns LLVM linkage for a declarator.
Definition: CodeGenModule.cpp:4897
clang::CodeGen::CGCXXABI::getMemberPointerAdjustment
llvm::Constant * getMemberPointerAdjustment(const CastExpr *E)
A utility method for computing the offset required for the given base-to-derived or derived-to-base m...
Definition: CGCXXABI.cpp:280
clang::CodeGen::CGCXXABI::setCXXABIThisValue
void setCXXABIThisValue(CodeGenFunction &CGF, llvm::Value *ThisPtr)
Definition: CGCXXABI.cpp:150
clang::TargetInfo::getCXXABI
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Definition: TargetInfo.h:1233
clang::VarDecl::hasConstantInitialization
bool hasConstantInitialization() const
Determine whether this variable has constant initialization.
Definition: Decl.cpp:2521
clang::CXXNewExpr
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition: ExprCXX.h:2139
clang::CodeGen::CallArgList::add
void add(RValue rvalue, QualType type)
Definition: CGCall.h:286
clang::CodeGen::CodeGenFunction::Builder
CGBuilderTy Builder
Definition: CodeGenFunction.h:269
clang::CodeGen::CodeGenTypes::ConvertType
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
Definition: CodeGenTypes.cpp:401
clang::CodeGen::CodeGenModule::setDLLImportDLLExport
void setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl D) const
Definition: CodeGenModule.cpp:1204
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1500
clang::CodeGen::CGCXXABI::mayNeedDestruction
bool mayNeedDestruction(const VarDecl *VD) const
Definition: CGCXXABI.cpp:156
clang::CodeGen::CodeGenFunction::GetAddrOfLocalVar
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
Definition: CodeGenFunction.h:2720
clang::GlobalDecl
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:56
clang::CodeGen::CGCXXABI::getCatchAllTypeInfo
virtual CatchTypeInfo getCatchAllTypeInfo()
Definition: CGCXXABI.cpp:333
clang::CodeGen::CGCXXABI::readArrayCookieImpl
virtual llvm::Value * readArrayCookieImpl(CodeGenFunction &IGF, Address ptr, CharUnits cookieSize)
Reads the array cookie for an allocation which is known to have one.
Definition: CGCXXABI.cpp:270
clang::CodeGen::CGCXXABI::loadIncomingCXXThis
llvm::Value * loadIncomingCXXThis(CodeGenFunction &CGF)
Loads the incoming C++ this pointer as it was passed by the caller.
Definition: CGCXXABI.cpp:145
clang::CodeGen::CGCXXABI::buildThisParam
void buildThisParam(CodeGenFunction &CGF, FunctionArgList &Params)
Build a parameter variable suitable for 'this'.
Definition: CGCXXABI.cpp:121
clang::VarDecl::hasInit
bool hasInit() const
Definition: Decl.cpp:2303
clang::CodeGen::CGCXXABI::EmitNullMemberPointer
virtual llvm::Constant * EmitNullMemberPointer(const MemberPointerType *MPT)
Create a null member pointer of the given type.
Definition: CGCXXABI.cpp:98
clang::ast_matchers::expr
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
Definition: ASTMatchersInternal.cpp:890
clang::RecordType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4647
clang::CXXCtorType
CXXCtorType
C++ constructor types.
Definition: ABI.h:24
clang::CodeGen::CGCXXABI::EmitMemberPointerComparison
virtual llvm::Value * EmitMemberPointerComparison(CodeGenFunction &CGF, llvm::Value *L, llvm::Value *R, const MemberPointerType *MPT, bool Inequality)
Emit a comparison between two member pointers. Returns an i1.
Definition: CGCXXABI.cpp:80
clang::CodeGen::CGCXXABI::getImplicitConstructorArgs
virtual AddedStructorArgs getImplicitConstructorArgs(CodeGenFunction &CGF, const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating)=0
clang::Linkage
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition: Linkage.h:23
clang::CodeGen::CGCXXABI::EmitMemberDataPointer
virtual llvm::Constant * EmitMemberDataPointer(const MemberPointerType *MPT, CharUnits offset)
Create a member pointer for the given field.
Definition: CGCXXABI.cpp:107
clang::CodeGen::CGCXXABI::addImplicitConstructorArgs
AddedStructorArgCounts addImplicitConstructorArgs(CodeGenFunction &CGF, const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating, CallArgList &Args)
Add any ABI-specific implicit arguments needed to call a constructor.
Definition: CGCXXABI.cpp:341
clang::CXXDtorType
CXXDtorType
C++ destructor types.
Definition: ABI.h:33
clang::MemberPointerType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:2860
CGCleanup.h
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7243
clang::DiagnosticsEngine::Error
@ Error
Definition: Diagnostic.h:200
clang::CastExpr::path_begin
path_iterator path_begin()
Definition: Expr.h:3545
clang::CXXDestructorDecl
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2688
clang::CodeGen::CGCXXABI::EmitLoadOfMemberFunctionPointer
virtual CGCallee EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF, const Expr *E, Address This, llvm::Value *&ThisPtrForCall, llvm::Value *MemPtr, const MemberPointerType *MPT)
Load a member function from an object and a member function pointer.
Definition: CGCXXABI.cpp:41
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:874
clang::CodeGen::CGCXXABI::~CGCXXABI
virtual ~CGCXXABI()
Definition: CGCXXABI.cpp:21
clang::CodeGen::CodeGenModule::getTypes
CodeGenTypes & getTypes()
Definition: CodeGenModule.h:721
clang::CodeGen::CGCXXABI::isEmittedWithConstantInitializer
bool isEmittedWithConstantInitializer(const VarDecl *VD, bool InspectInitForWeakDef=false) const
Determine whether we will definitely emit this variable with a constant initializer,...
Definition: CGCXXABI.cpp:169
clang::ValueDecl::isWeak
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.
Definition: Decl.cpp:4942
clang::Type::getAsCXXRecordDecl
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1759
clang::CodeGen::CGCXXABI::getVBPtrOffsets
virtual std::vector< CharUnits > getVBPtrOffsets(const CXXRecordDecl *RD)
Gets the offsets of all the virtual base pointers in a given class.
Definition: CGCXXABI.cpp:337
clang::CodeGen::CGBuilderTy::CreateConstInBoundsByteGEP
Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")
Given a pointer to i8, adjust it by a given constant offset.
Definition: CGBuilder.h:274
clang::CodeGen::CodeGenFunction::getContext
ASTContext & getContext() const
Definition: CodeGenFunction.h:1982
clang::MemberPointerType::getClass
const Type * getClass() const
Definition: Type.h:2874
clang::CharUnits::Zero
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
Definition: CharUnits.h:53
clang::CodeGen::Address
An aligned address.
Definition: Address.h:74
Base
clang::CodeGen::CGCXXABI::GetBogusMemberPointer
llvm::Constant * GetBogusMemberPointer(QualType T)
Get a null value for unsupported member pointers.
Definition: CGCXXABI.cpp:32
clang::CastExpr::getCastKind
CastKind getCastKind() const
Definition: Expr.h:3519
clang::CodeGen::CGCallee::forDirect
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
Definition: CGCall.h:133
clang::CodeGen::CodeGenModule::getTarget
const TargetInfo & getTarget() const
Definition: CodeGenModule.h:709
clang::CodeGen::CGCXXABI::setCXXDestructorDLLStorage
virtual void setCXXDestructorDLLStorage(llvm::GlobalValue *GV, const CXXDestructorDecl *Dtor, CXXDtorType DT) const
Definition: CGCXXABI.cpp:308
clang::CodeGen::CodeGenFunction::CurGD
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
Definition: CodeGenFunction.h:345
clang::CodeGen::CGCXXABI::emitTerminateForUnexpectedException
virtual llvm::CallInst * emitTerminateForUnexpectedException(CodeGenFunction &CGF, llvm::Value *Exn)
Definition: CGCXXABI.cpp:327
clang::CodeGen::CodeGenTypes::GetFunctionType
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.
Definition: CGCall.cpp:1613
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7310
clang::CodeGen::CGCXXABI::EmitMemberPointer
virtual llvm::Constant * EmitMemberPointer(const APValue &MP, QualType MPT)
Create a member pointer for the given member pointer constant.
Definition: CGCXXABI.cpp:112
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
clang::CodeGen::CodeGenTypes::arrangeCXXMethodType
const CGFunctionInfo & arrangeCXXMethodType(const CXXRecordDecl *RD, const FunctionProtoType *FTP, const CXXMethodDecl *MD)
Arrange the argument and result information for a call to an unknown C++ non-static member function o...
Definition: CGCall.cpp:264
clang::CodeGen::CodeGenModule::getTerminateFn
llvm::FunctionCallee getTerminateFn()
Get the declaration of std::terminate for the platform.
Definition: CGException.cpp:63
clang::CXXRecordDecl::getNumVBases
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
Definition: DeclCXX.h:611
clang::CodeGen::Address::getPointer
llvm::Value * getPointer() const
Definition: Address.h:93
clang::CodeGen::CodeGenFunction
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Definition: CodeGenFunction.h:231
clang::FunctionProtoType
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3898
clang::ASTContext::Idents
IdentifierTable & Idents
Definition: ASTContext.h:655
clang::CodeGen::CGCXXABI::AddedStructorArgCounts
Similar to AddedStructorArgs, but only notes the number of additional arguments.
Definition: CGCXXABI.h:333
clang::CodeGen::CodeGenModule::GetNonVirtualBaseClassOffset
llvm::Constant * GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd)
Returns the offset from a derived class to a class.
Definition: CGClass.cpp:197
clang::CXXDeleteExpr
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition: ExprCXX.h:2415
clang::CastExpr::path_end
path_iterator path_end()
Definition: Expr.h:3546
clang::CodeGen::CGCXXABI::requiresArrayCookie
virtual bool requiresArrayCookie(const CXXDeleteExpr *E, QualType eltType)
Definition: CGCXXABI.cpp:229
clang::CodeGen::Address::invalid
static Address invalid()
Definition: Address.h:90
clang::CodeGen::CGCallee
All available information about a concrete callee.
Definition: CGCall.h:63
clang::CodeGen::FunctionArgList
FunctionArgList - Type for representing both the decl and type of parameters to a function.
Definition: CGCall.h:356
clang::CodeGen::CGCXXABI::AddedStructorArgs::Suffix
SmallVector< Arg, 1 > Suffix
Definition: CGCXXABI.h:319
clang::CodeGen::CodeGenFunction::ConvertType
llvm::Type * ConvertType(QualType T)
Definition: CodeGenFunction.cpp:212
clang::CodeGen::CGCXXABI::CGM
CodeGenModule & CGM
Definition: CGCXXABI.h:45
clang::CodeGen::CGCXXABI::EmitReturnFromThunk
virtual void EmitReturnFromThunk(CodeGenFunction &CGF, RValue RV, QualType ResultType)
Definition: CGCXXABI.cpp:201
clang::CodeGen::CGCXXABI::EmitMemberPointerIsNotNull
virtual llvm::Value * EmitMemberPointerIsNotNull(CodeGenFunction &CGF, llvm::Value *MemPtr, const MemberPointerType *MPT)
Determine if a member pointer is non-null. Returns an i1.
Definition: CGCXXABI.cpp:90
clang::Redeclarable::getMostRecentDecl
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:226
clang::CodeGen::CodeGenFunction::hasAggregateEvaluationKind
static bool hasAggregateEvaluationKind(QualType T)
Definition: CodeGenFunction.h:2425
clang::TargetCXXABI::hasConstructorVariants
bool hasConstructorVariants() const
Does this ABI have different entrypoints for complete-object and base-subobject constructors?
Definition: TargetCXXABI.h:196
clang::CodeGen::CGBuilderTy::CreateElementBitCast
Address CreateElementBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Cast the element type of the given address to a different type, preserving information like the align...
Definition: CGBuilder.h:165
clang::MemberPointerType
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2844
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::CGCXXABI::EmitMemberDataPointerAddress
virtual llvm::Value * EmitMemberDataPointerAddress(CodeGenFunction &CGF, const Expr *E, Address Base, llvm::Value *MemPtr, const MemberPointerType *MPT)
Calculate an l-value from an object and a data member pointer.
Definition: CGCXXABI.cpp:58
clang::Type::getBaseElementTypeUnsafe
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
Definition: Type.h:7193
clang::CodeGen::CodeGenFunction::CGM
CodeGenModule & CGM
Definition: CodeGenFunction.h:261
clang::interp::This
bool This(InterpState &S, CodePtr OpPC)
Definition: Interp.h:829
clang::ImplicitParamDecl::Create
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
Definition: Decl.cpp:4950
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:867
clang
Definition: CalledOnceCheck.h:17
clang::CodeGen::CGCXXABI::EmitCtorCompleteObjectHandler
virtual llvm::BasicBlock * EmitCtorCompleteObjectHandler(CodeGenFunction &CGF, const CXXRecordDecl *RD)
Definition: CGCXXABI.cpp:299
clang::CodeGen::RValue::get
static RValue get(llvm::Value *V)
Definition: CGValue.h:89
clang::CodeGen::CatchTypeInfo
The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the type of a catch handler,...
Definition: CGCleanup.h:36
std::arg
__DEVICE__ _Tp arg(const std::complex< _Tp > &__c)
Definition: complex_cmath.h:40
clang::Expr::getType
QualType getType() const
Definition: Expr.h:141
clang::CodeGen::CodeGenModule::getDiags
DiagnosticsEngine & getDiags() const
Definition: CodeGenModule.h:705
clang::ASTContext::getPointerDiffType
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
Definition: ASTContext.cpp:5867
clang::ASTContext::getASTRecordLayout
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
Definition: RecordLayoutBuilder.cpp:3268
clang::GlobalDecl::getDecl
const Decl * getDecl() const
Definition: GlobalDecl.h:103
clang::RecordType::getDecl
RecordDecl * getDecl() const
Definition: Type.h:4657
clang::VarDecl::needsDestruction
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
Definition: Decl.cpp:2715
clang::CharUnits
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
clang::APValue
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition: APValue.h:122
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:685
clang::CodeGen::CallArg
Definition: CGCall.h:217
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::CodeGen::CGCXXABI::isThisCompleteObject
virtual bool isThisCompleteObject(GlobalDecl GD) const =0
Determine whether there's something special about the rules of the ABI tell us that 'this' is a compl...
clang::QualType::isDestructedType
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
Definition: Type.h:1222
clang::CodeGen::CodeGenTypeCache::Int8Ty
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
Definition: CodeGenTypeCache.h:37
clang::CodeGen::CGCXXABI::getArrayCookieSizeImpl
virtual CharUnits getArrayCookieSizeImpl(QualType elementType)
Returns the extra size required in order to store the array cookie for the given type.
Definition: CGCXXABI.cpp:214
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:2234
clang::CastExpr
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3475
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:425
clang::CodeGen::CallArgList
CallArgList - Type for representing both the value and type of arguments in a call.
Definition: CGCall.h:262
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:116
clang::CodeGen::CGCXXABI::GetArrayCookieSize
virtual CharUnits GetArrayCookieSize(const CXXNewExpr *expr)
Returns the extra size required in order to store the array cookie for the given new-expression.
Definition: CGCXXABI.cpp:208
clang::CodeGen::CGCXXABI::getContext
ASTContext & getContext() const
Definition: CGCXXABI.h:83
clang::CodeGen::CGCXXABI::AddedStructorArgs::Prefix
SmallVector< Arg, 1 > Prefix
Definition: CGCXXABI.h:318
clang::ASTContext::getMemberPointerType
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
Definition: ASTContext.cpp:3458
clang::VarDecl::evaluateValue
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
Definition: Decl.cpp:2451
clang::DiagnosticsEngine::Report
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1536
clang::CodeGen::CGCXXABI::getThisDecl
ImplicitParamDecl * getThisDecl(CodeGenFunction &CGF)
Definition: CGCXXABI.h:52
clang::CodeGen::CGBuilderTy::CreateLoad
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
Definition: CGBuilder.h:69
clang::CXXMethodDecl::getParent
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Definition: DeclCXX.h:2083
clang::CXXMethodDecl
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1968