[clang] [clang][sema] Add nonnull attribute to builtin format functions (PR #158626)
Radovan Božić via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 16 06:57:25 PDT 2025
================
@@ -293,6 +293,34 @@ bool Builtin::Context::isScanfLike(unsigned ID, unsigned &FormatIdx,
return isLike(ID, FormatIdx, HasVAListArg, "sS");
}
+bool Builtin::Context::IsNonNull(unsigned ID,
+ llvm::SmallVectorImpl<int> &Indxs) const {
+
+ const char *CalleePos = ::strchr(getAttributesString(ID), 'N');
+ if (!CalleePos)
+ return false;
+
+ ++CalleePos;
+ assert(*CalleePos == '<' &&
+ "Callback callee specifier must be followed by a '<'");
+ ++CalleePos;
+
+ char *EndPos;
+ int CalleeIdx = ::strtol(CalleePos, &EndPos, 10);
+ assert(CalleeIdx >= 0 && "Callee index is supposed to be positive!");
+ Indxs.push_back(CalleeIdx);
+
+ while (*EndPos == ',') {
+ const char *PayloadPos = EndPos + 1;
+
+ int PayloadIdx = ::strtol(PayloadPos, &EndPos, 10);
+ Indxs.push_back(PayloadIdx);
+ }
+
+ assert(*EndPos == '>' && "Callback callee specifier must end with a '>'");
+ return true;
----------------
bozicrHT wrote:
Sounds reasonable — I’ll refactor the parsing logic into a small helper function (so both places can share it) and update the local variable names to better reflect their meaning in this context.
https://github.com/llvm/llvm-project/pull/158626
More information about the cfe-commits
mailing list