@@ -3119,104 +3119,105 @@ def StrLen : LibBuiltin<"string.h"> {
31193119// FIXME: This list is incomplete.
31203120def Printf : LibBuiltin<" stdio.h" > {
31213121 let Spellings = [" printf" ];
3122- let Attributes = [PrintfFormat<0 >];
3122+ let Attributes = [PrintfFormat<0 >, NonNull<NonOptimizing, [ 0 ]> ];
31233123 let Prototype = " int(char const*, ...)" ;
31243124}
31253125
31263126// FIXME: The builtin and library function should have the same signature.
31273127def BuiltinPrintf : Builtin {
31283128 let Spellings = [" __builtin_printf" ];
3129- let Attributes = [NoThrow, PrintfFormat<0 >, FunctionWithBuiltinPrefix];
3129+ let Attributes = [NoThrow, PrintfFormat<0 >, FunctionWithBuiltinPrefix,
3130+ NonNull<NonOptimizing, [0 ]>];
31303131 let Prototype = " int(char const* restrict, ...)" ;
31313132}
31323133
31333134def FPrintf : LibBuiltin<" stdio.h" > {
31343135 let Spellings = [" fprintf" ];
3135- let Attributes = [NoThrow, PrintfFormat<1 >];
3136+ let Attributes = [NoThrow, PrintfFormat<1 >, NonNull<NonOptimizing, [ 0 , 1 ]> ];
31363137 let Prototype = " int(FILE* restrict, char const* restrict, ...)" ;
31373138 let AddBuiltinPrefixedAlias = 1 ;
31383139}
31393140
31403141def SnPrintf : LibBuiltin<" stdio.h" > {
31413142 let Spellings = [" snprintf" ];
3142- let Attributes = [NoThrow, PrintfFormat<2 >];
3143+ let Attributes = [NoThrow, PrintfFormat<2 >, NonNull<NonOptimizing, [ 2 ]> ];
31433144 let Prototype = " int(char* restrict, size_t, char const* restrict, ...)" ;
31443145 let AddBuiltinPrefixedAlias = 1 ;
31453146}
31463147
31473148def SPrintf : LibBuiltin<" stdio.h" > {
31483149 let Spellings = [" sprintf" ];
3149- let Attributes = [NoThrow, PrintfFormat<1 >];
3150+ let Attributes = [NoThrow, PrintfFormat<1 >, NonNull<NonOptimizing, [ 0 , 1 ]> ];
31503151 let Prototype = " int(char* restrict, char const* restrict, ...)" ;
31513152 let AddBuiltinPrefixedAlias = 1 ;
31523153}
31533154
31543155def VPrintf : LibBuiltin<" stdio.h" > {
31553156 let Spellings = [" vprintf" ];
3156- let Attributes = [NoThrow, VPrintfFormat<0 >];
3157+ let Attributes = [NoThrow, VPrintfFormat<0 >, NonNull<NonOptimizing, [ 0 ]> ];
31573158 let Prototype = " int(char const* restrict, __builtin_va_list)" ;
31583159 let AddBuiltinPrefixedAlias = 1 ;
31593160}
31603161
31613162def VfPrintf : LibBuiltin<" stdio.h" > {
31623163 let Spellings = [" vfprintf" ];
3163- let Attributes = [NoThrow, VPrintfFormat<1 >];
3164+ let Attributes = [NoThrow, VPrintfFormat<1 >, NonNull<NonOptimizing, [ 0 , 1 ]> ];
31643165 let Prototype = " int(FILE* restrict, char const* restrict, __builtin_va_list)" ;
31653166 let AddBuiltinPrefixedAlias = 1 ;
31663167}
31673168
31683169def VsnPrintf : LibBuiltin<" stdio.h" > {
31693170 let Spellings = [" vsnprintf" ];
3170- let Attributes = [NoThrow, VPrintfFormat<2 >];
3171+ let Attributes = [NoThrow, VPrintfFormat<2 >, NonNull<NonOptimizing, [ 2 ]> ];
31713172 let Prototype = " int(char* restrict, size_t, char const* restrict, __builtin_va_list)" ;
31723173 let AddBuiltinPrefixedAlias = 1 ;
31733174}
31743175
31753176def VsPrintf : LibBuiltin<" stdio.h" > {
31763177 let Spellings = [" vsprintf" ];
3177- let Attributes = [NoThrow, VPrintfFormat<1 >];
3178+ let Attributes = [NoThrow, VPrintfFormat<1 >, NonNull<NonOptimizing, [ 0 , 1 ]> ];
31783179 let Prototype = " int(char* restrict, char const* restrict, __builtin_va_list)" ;
31793180 let AddBuiltinPrefixedAlias = 1 ;
31803181}
31813182
31823183def Scanf : LibBuiltin<" stdio.h" > {
31833184 let Spellings = [" scanf" ];
3184- let Attributes = [ScanfFormat<0 >];
3185+ let Attributes = [ScanfFormat<0 >, NonNull<NonOptimizing, [ 0 ]> ];
31853186 let Prototype = " int(char const* restrict, ...)" ;
31863187 let AddBuiltinPrefixedAlias = 1 ;
31873188}
31883189
31893190def FScanf : LibBuiltin<" stdio.h" > {
31903191 let Spellings = [" fscanf" ];
3191- let Attributes = [ScanfFormat<1 >];
3192+ let Attributes = [ScanfFormat<1 >, NonNull<NonOptimizing, [ 0 , 1 ]> ];
31923193 let Prototype = " int(FILE* restrict, char const* restrict, ...)" ;
31933194 let AddBuiltinPrefixedAlias = 1 ;
31943195}
31953196
31963197def SScanf : LibBuiltin<" stdio.h" > {
31973198 let Spellings = [" sscanf" ];
3198- let Attributes = [ScanfFormat<1 >];
3199+ let Attributes = [ScanfFormat<1 >, NonNull<NonOptimizing, [ 0 , 1 ]> ];
31993200 let Prototype = " int(char const* restrict, char const* restrict, ...)" ;
32003201 let AddBuiltinPrefixedAlias = 1 ;
32013202}
32023203
32033204def VScanf : LibBuiltin<" stdio.h" > {
32043205 let Spellings = [" vscanf" ];
3205- let Attributes = [VScanfFormat<0 >];
3206+ let Attributes = [VScanfFormat<0 >, NonNull<NonOptimizing, [ 0 ]> ];
32063207 let Prototype = " int(char const* restrict, __builtin_va_list)" ;
32073208 let AddBuiltinPrefixedAlias = 1 ;
32083209}
32093210
32103211def VFScanf : LibBuiltin<" stdio.h" > {
32113212 let Spellings = [" vfscanf" ];
3212- let Attributes = [VScanfFormat<1 >];
3213+ let Attributes = [VScanfFormat<1 >, NonNull<NonOptimizing, [ 0 , 1 ]> ];
32133214 let Prototype = " int(FILE* restrict, char const* restrict, __builtin_va_list)" ;
32143215 let AddBuiltinPrefixedAlias = 1 ;
32153216}
32163217
32173218def VSScanf : LibBuiltin<" stdio.h" > {
32183219 let Spellings = [" vsscanf" ];
3219- let Attributes = [VScanfFormat<1 >];
3220+ let Attributes = [VScanfFormat<1 >, NonNull<NonOptimizing, [ 0 , 1 ]> ];
32203221 let Prototype = " int(char const* restrict, char const* restrict, __builtin_va_list)" ;
32213222 let AddBuiltinPrefixedAlias = 1 ;
32223223}
0 commit comments