[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 1 16:46:40 PDT 2020


nickdesaulniers added inline comments.


================
Comment at: clang/include/clang/Basic/Builtins.def:513
 BUILTIN(__builtin_printf, "icC*.", "Fp:0:")
+BUILTIN(__builtin_putchar, "ii", "F")
+BUILTIN(__builtin_puts, "icC*", "nF")
----------------
nickdesaulniers wrote:
> nickdesaulniers wrote:
> > rsmith wrote:
> > > aaron.ballman wrote:
> > > > Should we also add a builtin for `putc()` (I know that's often a macro, so I'm not certain if it applies)?
> > > Yes, GCC has a `__builtin_putc`, so it'd make sense for us to support that too.
> > Curious, `putc` isn't documented at https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html, which is what I was using.  It looks like `putc` was a part of ANSI C, so I'm not sure what else might be missing from my implementation.  Let me see if I can find a more complete list of C90 functions to verify.
> (retrieves copy of `The Standard C Library` from P. J. Plauger)
Looks like I'm missing:

>From stdlib.h:
* `div`
* `ldiv`
* `bsearch`
* `qsort`
* `rand`
* `srand`
* `atof`
* `atoi`
* `atol`
* `mblen`
* `mbstowcs`
* `mbtowc`
* `wcstombs`
* `wctomb`
* `abort`
* `atexit`
* `getenv`
* `system`

>From string.h:
* `strcoll`

>From stdio.h:
* `remove`
* `rename`
* `tmpfile`
* `fclose`
* `fflush`
* `freopen`
* `setvbuf`
* `scanfwrite`
* `fgetc`
* `fgets`
* `fputc`
* `getc`
* `getchar`
* `gets`
* `putc`
* `ungetc`
* `fgetpos`
* `fseek`
* `fsetpos`
* `ftell`
* `rewind`
* `clearerr`
* `feof`
* `ferror`
* `perror`

We look good on ctype.h and stdard.h.  Shall I very those against GCC and implement what's missing here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86508/new/

https://reviews.llvm.org/D86508



More information about the cfe-commits mailing list