2121
2222namespace clang ::CIRGen {
2323
24- struct CIRGenFunctionInfoArgInfo {
25- CanQualType type;
26- };
27-
2824// / A class for recording the number of arguments that a function signature
2925// / requires.
3026class RequiredArgs {
@@ -72,16 +68,15 @@ class RequiredArgs {
7268
7369class CIRGenFunctionInfo final
7470 : public llvm::FoldingSetNode,
75- private llvm::TrailingObjects<CIRGenFunctionInfo,
76- CIRGenFunctionInfoArgInfo> {
77- using ArgInfo = CIRGenFunctionInfoArgInfo;
78-
71+ private llvm::TrailingObjects<CIRGenFunctionInfo, CanQualType> {
7972 RequiredArgs required;
8073
8174 unsigned numArgs;
8275
83- ArgInfo *getArgsBuffer () { return getTrailingObjects<ArgInfo>(); }
84- const ArgInfo *getArgsBuffer () const { return getTrailingObjects<ArgInfo>(); }
76+ CanQualType *getArgTypes () { return getTrailingObjects<CanQualType>(); }
77+ const CanQualType *getArgTypes () const {
78+ return getTrailingObjects<CanQualType>();
79+ }
8580
8681 CIRGenFunctionInfo () : required(RequiredArgs::All) {}
8782
@@ -96,8 +91,8 @@ class CIRGenFunctionInfo final
9691 // these have to be public.
9792 friend class TrailingObjects ;
9893
99- using const_arg_iterator = const ArgInfo *;
100- using arg_iterator = ArgInfo *;
94+ using const_arg_iterator = const CanQualType *;
95+ using arg_iterator = CanQualType *;
10196
10297 // This function has to be CamelCase because llvm::FoldingSet requires so.
10398 // NOLINTNEXTLINE(readability-identifier-naming)
@@ -112,49 +107,41 @@ class CIRGenFunctionInfo final
112107
113108 // NOLINTNEXTLINE(readability-identifier-naming)
114109 void Profile (llvm::FoldingSetNodeID &id) {
115- // It's unfortunate that we are looping over the arguments twice (here and
116- // in the static Profile function we call from here), but if the Profile
117- // functions get out of sync, we can end up with incorrect function
118- // signatures, and we don't have the argument types in the format that the
119- // static Profile function requires.
120- llvm::SmallVector<CanQualType, 16 > argTypes;
121- for (const ArgInfo &argInfo : arguments ())
122- argTypes.push_back (argInfo.type );
123-
124- Profile (id, required, getReturnType (), argTypes);
110+ // If the Profile functions get out of sync, we can end up with incorrect
111+ // function signatures, so we call the static Profile function here rather
112+ // than duplicating the logic.
113+ Profile (id, required, getReturnType (), arguments ());
125114 }
126115
127- llvm::ArrayRef<ArgInfo > arguments () const {
128- return llvm::ArrayRef<ArgInfo>( argInfoBegin (), numArgs);
116+ llvm::ArrayRef<CanQualType > arguments () const {
117+ return llvm::ArrayRef<CanQualType>( argTypesBegin (), numArgs);
129118 }
130119
131- llvm::ArrayRef<ArgInfo > requiredArguments () const {
132- return llvm::ArrayRef<ArgInfo>( argInfoBegin (), getNumRequiredArgs ());
120+ llvm::ArrayRef<CanQualType > requiredArguments () const {
121+ return llvm::ArrayRef<CanQualType>( argTypesBegin (), getNumRequiredArgs ());
133122 }
134123
135- CanQualType getReturnType () const { return getArgsBuffer ()[0 ]. type ; }
124+ CanQualType getReturnType () const { return getArgTypes ()[0 ]; }
136125
137- const_arg_iterator argInfoBegin () const { return getArgsBuffer () + 1 ; }
138- const_arg_iterator argInfoEnd () const {
139- return getArgsBuffer () + 1 + numArgs;
140- }
141- arg_iterator argInfoBegin () { return getArgsBuffer () + 1 ; }
142- arg_iterator argInfoEnd () { return getArgsBuffer () + 1 + numArgs; }
126+ const_arg_iterator argTypesBegin () const { return getArgTypes () + 1 ; }
127+ const_arg_iterator argTypesEnd () const { return getArgTypes () + 1 + numArgs; }
128+ arg_iterator argTypesBegin () { return getArgTypes () + 1 ; }
129+ arg_iterator argTypesEnd () { return getArgTypes () + 1 + numArgs; }
143130
144- unsigned argInfoSize () const { return numArgs; }
131+ unsigned argTypeSize () const { return numArgs; }
145132
146- llvm::MutableArrayRef<ArgInfo> argInfos () {
147- return llvm::MutableArrayRef<ArgInfo>( argInfoBegin (), numArgs);
133+ llvm::MutableArrayRef<CanQualType> argTypes () {
134+ return llvm::MutableArrayRef<CanQualType>( argTypesBegin (), numArgs);
148135 }
149- llvm::ArrayRef<ArgInfo> argInfos () const {
150- return llvm::ArrayRef<ArgInfo>( argInfoBegin (), numArgs);
136+ llvm::ArrayRef<CanQualType> argTypes () const {
137+ return llvm::ArrayRef<CanQualType>( argTypesBegin (), numArgs);
151138 }
152139
153140 bool isVariadic () const { return required.allowsOptionalArgs (); }
154141 RequiredArgs getRequiredArgs () const { return required; }
155142 unsigned getNumRequiredArgs () const {
156143 return isVariadic () ? getRequiredArgs ().getNumRequiredArgs ()
157- : argInfoSize ();
144+ : argTypeSize ();
158145 }
159146};
160147
0 commit comments