@@ -293,22 +293,15 @@ bool Builtin::Context::isScanfLike(unsigned ID, unsigned &FormatIdx,
293293 return isLike (ID, FormatIdx, HasVAListArg, " sS" );
294294}
295295
296- bool Builtin::Context::IsNonNull (unsigned ID,
297- llvm::SmallVectorImpl<int > &Indxs) const {
298-
299- const char *CalleePos = ::strchr (getAttributesString (ID), ' N' );
300- if (!CalleePos)
301- return false ;
302-
303- ++CalleePos;
304- assert (*CalleePos == ' <' &&
305- " Callback callee specifier must be followed by a '<'" );
306- ++CalleePos;
296+ static void parseCommaSeparatedIndices (const char *CurrPos,
297+ llvm::SmallVectorImpl<int > &Indxs) {
298+ assert (*CurrPos == ' <' && " Expected '<' to start index list" );
299+ ++CurrPos;
307300
308301 char *EndPos;
309- int CalleeIdx = ::strtol (CalleePos , &EndPos, 10 );
310- assert (CalleeIdx >= 0 && " Callee index is supposed to be positive!" );
311- Indxs.push_back (CalleeIdx );
302+ int PosIdx = ::strtol (CurrPos , &EndPos, 10 );
303+ assert (PosIdx >= 0 && " Index is supposed to be positive!" );
304+ Indxs.push_back (PosIdx );
312305
313306 while (*EndPos == ' ,' ) {
314307 const char *PayloadPos = EndPos + 1 ;
@@ -317,7 +310,19 @@ bool Builtin::Context::IsNonNull(unsigned ID,
317310 Indxs.push_back (PayloadIdx);
318311 }
319312
320- assert (*EndPos == ' >' && " Callback callee specifier must end with a '>'" );
313+ assert (*EndPos == ' >' && " Index list must end with '>'" );
314+ }
315+
316+ bool Builtin::Context::isNonNull (unsigned ID,
317+ llvm::SmallVectorImpl<int > &Indxs) const {
318+
319+ const char *AttrPos = ::strchr (getAttributesString (ID), ' N' );
320+ if (!AttrPos)
321+ return false ;
322+
323+ ++AttrPos;
324+ parseCommaSeparatedIndices (AttrPos, Indxs);
325+
321326 return true ;
322327}
323328
@@ -328,23 +333,8 @@ bool Builtin::Context::performsCallback(unsigned ID,
328333 return false ;
329334
330335 ++CalleePos;
331- assert (*CalleePos == ' <' &&
332- " Callback callee specifier must be followed by a '<'" );
333- ++CalleePos;
334-
335- char *EndPos;
336- int CalleeIdx = ::strtol (CalleePos, &EndPos, 10 );
337- assert (CalleeIdx >= 0 && " Callee index is supposed to be positive!" );
338- Encoding.push_back (CalleeIdx);
339-
340- while (*EndPos == ' ,' ) {
341- const char *PayloadPos = EndPos + 1 ;
342-
343- int PayloadIdx = ::strtol (PayloadPos, &EndPos, 10 );
344- Encoding.push_back (PayloadIdx);
345- }
336+ parseCommaSeparatedIndices (CalleePos, Encoding);
346337
347- assert (*EndPos == ' >' && " Callback callee specifier must end with a '>'" );
348338 return true ;
349339}
350340
0 commit comments