@@ -31,50 +31,70 @@ using namespace CodeGen;
31
31
32
32
// FIXME: Use iterator and sidestep silly type array creation.
33
33
34
- CGFunctionInfo::CGFunctionInfo (const FunctionTypeNoProto *FTNP) {
35
- ArgTypes.push_back (FTNP->getResultType ());
34
+ const
35
+ CGFunctionInfo &CodeGenTypes::getFunctionInfo (const FunctionTypeNoProto *FTNP) {
36
+ return getFunctionInfo (FTNP->getResultType (),
37
+ llvm::SmallVector<QualType, 16 >());
36
38
}
37
39
38
- CGFunctionInfo::CGFunctionInfo (const FunctionTypeProto *FTP) {
39
- ArgTypes.push_back (FTP->getResultType ());
40
+ const
41
+ CGFunctionInfo &CodeGenTypes::getFunctionInfo (const FunctionTypeProto *FTP) {
42
+ llvm::SmallVector<QualType, 16 > ArgTys;
43
+ // FIXME: Kill copy.
40
44
for (unsigned i = 0 , e = FTP->getNumArgs (); i != e; ++i)
41
- ArgTypes.push_back (FTP->getArgType (i));
45
+ ArgTys.push_back (FTP->getArgType (i));
46
+ return getFunctionInfo (FTP->getResultType (), ArgTys);
42
47
}
43
48
44
- // FIXME: Is there really any reason to have this still?
45
- CGFunctionInfo::CGFunctionInfo (const FunctionDecl *FD) {
49
+ const CGFunctionInfo &CodeGenTypes::getFunctionInfo (const FunctionDecl *FD) {
46
50
const FunctionType *FTy = FD->getType ()->getAsFunctionType ();
47
- const FunctionTypeProto *FTP = dyn_cast<FunctionTypeProto>(FTy);
48
-
49
- ArgTypes.push_back (FTy->getResultType ());
50
- if (FTP) {
51
- for (unsigned i = 0 , e = FTP->getNumArgs (); i != e; ++i)
52
- ArgTypes.push_back (FTP->getArgType (i));
53
- }
51
+ if (const FunctionTypeProto *FTP = dyn_cast<FunctionTypeProto>(FTy))
52
+ return getFunctionInfo (FTP);
53
+ return getFunctionInfo (cast<FunctionTypeNoProto>(FTy));
54
54
}
55
55
56
- CGFunctionInfo::CGFunctionInfo (const ObjCMethodDecl *MD,
57
- const ASTContext &Context) {
58
- ArgTypes .push_back (MD->getResultType ());
59
- ArgTypes .push_back (MD-> getSelfDecl ()-> getType ());
60
- ArgTypes. push_back (Context. getObjCSelType ());
56
+ const CGFunctionInfo & CodeGenTypes::getFunctionInfo (const ObjCMethodDecl *MD) {
57
+ llvm::SmallVector<QualType, 16 > ArgTys;
58
+ ArgTys .push_back (MD->getSelfDecl ()-> getType ());
59
+ ArgTys .push_back (Context. getObjCSelType ());
60
+ // FIXME: Kill copy?
61
61
for (ObjCMethodDecl::param_const_iterator i = MD->param_begin (),
62
62
e = MD->param_end (); i != e; ++i)
63
- ArgTypes.push_back ((*i)->getType ());
63
+ ArgTys.push_back ((*i)->getType ());
64
+ return getFunctionInfo (MD->getResultType (), ArgTys);
64
65
}
65
66
66
- CGFunctionInfo::CGFunctionInfo (QualType ResTy, const CallArgList &Args) {
67
- ArgTypes.push_back (ResTy);
67
+ const CGFunctionInfo &CodeGenTypes::getFunctionInfo (QualType ResTy,
68
+ const CallArgList &Args) {
69
+ // FIXME: Kill copy.
70
+ llvm::SmallVector<QualType, 16 > ArgTys;
68
71
for (CallArgList::const_iterator i = Args.begin (), e = Args.end ();
69
72
i != e; ++i)
70
- ArgTypes.push_back (i->second );
73
+ ArgTys.push_back (i->second );
74
+ return getFunctionInfo (ResTy, ArgTys);
71
75
}
72
76
73
- CGFunctionInfo::CGFunctionInfo (QualType ResTy, const FunctionArgList &Args) {
74
- ArgTypes.push_back (ResTy);
77
+ const CGFunctionInfo &CodeGenTypes::getFunctionInfo (QualType ResTy,
78
+ const FunctionArgList &Args) {
79
+ // FIXME: Kill copy.
80
+ llvm::SmallVector<QualType, 16 > ArgTys;
75
81
for (FunctionArgList::const_iterator i = Args.begin (), e = Args.end ();
76
82
i != e; ++i)
77
- ArgTypes.push_back (i->second );
83
+ ArgTys.push_back (i->second );
84
+ return getFunctionInfo (ResTy, ArgTys);
85
+ }
86
+
87
+ const CGFunctionInfo &CodeGenTypes::getFunctionInfo (QualType ResTy,
88
+ const llvm::SmallVector<QualType, 16 > &ArgTys) {
89
+ return *new CGFunctionInfo (ResTy, ArgTys);
90
+ }
91
+
92
+ /* **/
93
+
94
+ CGFunctionInfo::CGFunctionInfo (QualType ResTy,
95
+ const llvm::SmallVector<QualType, 16 > &ArgTys) {
96
+ ArgTypes.push_back (ResTy);
97
+ ArgTypes.insert (ArgTypes.end (), ArgTys.begin (), ArgTys.end ());
78
98
}
79
99
80
100
ArgTypeIterator CGFunctionInfo::argtypes_begin () const {
0 commit comments