Add builtin definition for scanf, including extending the builtin encoding to
represent builtins that have the "scanf" attribution (via the format attribute) just like we do with printf functions. Follow-up work is needed to add similar support for fscanf et al. This is to support format-string checking for scanf functions. llvm-svn: 108499
This commit is contained in:
@@ -93,3 +93,23 @@ Builtin::Context::isPrintfLike(unsigned ID, unsigned &FormatIdx,
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: Refactor with isPrintfLike.
|
||||
bool
|
||||
Builtin::Context::isScanfLike(unsigned ID, unsigned &FormatIdx,
|
||||
bool &HasVAListArg) {
|
||||
const char *Scanf = strpbrk(GetRecord(ID).Attributes, "sS");
|
||||
if (!Scanf)
|
||||
return false;
|
||||
|
||||
HasVAListArg = (*Scanf == 'S');
|
||||
|
||||
++Scanf;
|
||||
assert(*Scanf == ':' && "s or S specifier must have be followed by a ':'");
|
||||
++Scanf;
|
||||
|
||||
assert(strchr(Scanf, ':') && "printf specifier must end with a ':'");
|
||||
FormatIdx = strtol(Scanf, 0, 10);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user