/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/CodeGen/CodeGenABITypes.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //==--- CodeGenABITypes.cpp - Convert Clang types to LLVM types for ABI ----==// |
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 | | // CodeGenABITypes is a simple interface for getting LLVM types for |
10 | | // the parameters and the return value of a function given the Clang |
11 | | // types. |
12 | | // |
13 | | // The class is implemented as a public wrapper around the private |
14 | | // CodeGenTypes class in lib/CodeGen. |
15 | | // |
16 | | //===----------------------------------------------------------------------===// |
17 | | |
18 | | #include "clang/CodeGen/CodeGenABITypes.h" |
19 | | #include "CGCXXABI.h" |
20 | | #include "CGRecordLayout.h" |
21 | | #include "CodeGenFunction.h" |
22 | | #include "CodeGenModule.h" |
23 | | #include "clang/CodeGen/CGFunctionInfo.h" |
24 | | #include "clang/Lex/HeaderSearchOptions.h" |
25 | | #include "clang/Lex/PreprocessorOptions.h" |
26 | | |
27 | | using namespace clang; |
28 | | using namespace CodeGen; |
29 | | |
30 | | void CodeGen::addDefaultFunctionDefinitionAttributes(CodeGenModule &CGM, |
31 | 0 | llvm::AttrBuilder &attrs) { |
32 | 0 | CGM.addDefaultFunctionDefinitionAttributes(attrs); |
33 | 0 | } |
34 | | |
35 | | const CGFunctionInfo & |
36 | | CodeGen::arrangeObjCMessageSendSignature(CodeGenModule &CGM, |
37 | | const ObjCMethodDecl *MD, |
38 | 0 | QualType receiverType) { |
39 | 0 | return CGM.getTypes().arrangeObjCMessageSendSignature(MD, receiverType); |
40 | 0 | } |
41 | | |
42 | | const CGFunctionInfo & |
43 | | CodeGen::arrangeFreeFunctionType(CodeGenModule &CGM, |
44 | 0 | CanQual<FunctionProtoType> Ty) { |
45 | 0 | return CGM.getTypes().arrangeFreeFunctionType(Ty); |
46 | 0 | } |
47 | | |
48 | | const CGFunctionInfo & |
49 | | CodeGen::arrangeFreeFunctionType(CodeGenModule &CGM, |
50 | 0 | CanQual<FunctionNoProtoType> Ty) { |
51 | 0 | return CGM.getTypes().arrangeFreeFunctionType(Ty); |
52 | 0 | } |
53 | | |
54 | | const CGFunctionInfo & |
55 | | CodeGen::arrangeCXXMethodType(CodeGenModule &CGM, |
56 | | const CXXRecordDecl *RD, |
57 | | const FunctionProtoType *FTP, |
58 | 0 | const CXXMethodDecl *MD) { |
59 | 0 | return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD); |
60 | 0 | } |
61 | | |
62 | | const CGFunctionInfo & |
63 | | CodeGen::arrangeFreeFunctionCall(CodeGenModule &CGM, |
64 | | CanQualType returnType, |
65 | | ArrayRef<CanQualType> argTypes, |
66 | | FunctionType::ExtInfo info, |
67 | 0 | RequiredArgs args) { |
68 | 0 | return CGM.getTypes().arrangeLLVMFunctionInfo( |
69 | 0 | returnType, /*instanceMethod=*/false, /*chainCall=*/false, argTypes, |
70 | 0 | info, {}, args); |
71 | 0 | } |
72 | | |
73 | | ImplicitCXXConstructorArgs |
74 | | CodeGen::getImplicitCXXConstructorArgs(CodeGenModule &CGM, |
75 | 0 | const CXXConstructorDecl *D) { |
76 | | // We have to create a dummy CodeGenFunction here to pass to |
77 | | // getImplicitConstructorArgs(). In some cases (base and delegating |
78 | | // constructor calls), getImplicitConstructorArgs() can reach into the |
79 | | // CodeGenFunction to find parameters of the calling constructor to pass on to |
80 | | // the called constructor, but that can't happen here because we're asking for |
81 | | // the args for a complete, non-delegating constructor call. |
82 | 0 | CodeGenFunction CGF(CGM, /* suppressNewContext= */ true); |
83 | 0 | CGCXXABI::AddedStructorArgs addedArgs = |
84 | 0 | CGM.getCXXABI().getImplicitConstructorArgs(CGF, D, Ctor_Complete, |
85 | 0 | /* ForVirtualBase= */ false, |
86 | 0 | /* Delegating= */ false); |
87 | 0 | ImplicitCXXConstructorArgs implicitArgs; |
88 | 0 | for (const auto &arg : addedArgs.Prefix) { |
89 | 0 | implicitArgs.Prefix.push_back(arg.Value); |
90 | 0 | } |
91 | 0 | for (const auto &arg : addedArgs.Suffix) { |
92 | 0 | implicitArgs.Suffix.push_back(arg.Value); |
93 | 0 | } |
94 | 0 | return implicitArgs; |
95 | 0 | } |
96 | | |
97 | | llvm::FunctionType * |
98 | 0 | CodeGen::convertFreeFunctionType(CodeGenModule &CGM, const FunctionDecl *FD) { |
99 | 0 | assert(FD != nullptr && "Expected a non-null function declaration!"); |
100 | 0 | llvm::Type *T = CGM.getTypes().ConvertType(FD->getType()); |
101 | |
|
102 | 0 | if (auto FT = dyn_cast<llvm::FunctionType>(T)) |
103 | 0 | return FT; |
104 | | |
105 | 0 | return nullptr; |
106 | 0 | } |
107 | | |
108 | | llvm::Type * |
109 | 1 | CodeGen::convertTypeForMemory(CodeGenModule &CGM, QualType T) { |
110 | 1 | return CGM.getTypes().ConvertTypeForMem(T); |
111 | 1 | } |
112 | | |
113 | | unsigned CodeGen::getLLVMFieldNumber(CodeGenModule &CGM, |
114 | | const RecordDecl *RD, |
115 | 3 | const FieldDecl *FD) { |
116 | 3 | return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD); |
117 | 3 | } |
118 | | |
119 | | llvm::Value *CodeGen::getCXXDestructorImplicitParam( |
120 | | CodeGenModule &CGM, llvm::BasicBlock *InsertBlock, |
121 | | llvm::BasicBlock::iterator InsertPoint, const CXXDestructorDecl *D, |
122 | 0 | CXXDtorType Type, bool ForVirtualBase, bool Delegating) { |
123 | 0 | CodeGenFunction CGF(CGM, /*suppressNewContext=*/true); |
124 | 0 | CGF.CurCodeDecl = D; |
125 | 0 | CGF.CurFuncDecl = D; |
126 | 0 | CGF.CurFn = InsertBlock->getParent(); |
127 | 0 | CGF.Builder.SetInsertPoint(InsertBlock, InsertPoint); |
128 | 0 | return CGM.getCXXABI().getCXXDestructorImplicitParam( |
129 | 0 | CGF, D, Type, ForVirtualBase, Delegating); |
130 | 0 | } |