[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
nickdesaulniers planned changes to this revision. nickdesaulniers added inline comments. Comment at: clang/docs/LanguageExtensions.rst:2422 +* ``vprintf`` +* ``vsprintf`` + Let me triple check the docs look good. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86508/new/ https://reviews.llvm.org/D86508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
nickdesaulniers marked 2 inline comments as done. 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: > > 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? > (`abort` should not have been in the above list; it's in GCC's docs and we > implement the builtin for it) > > From the above list, GCC has builtins for: > * fputc > * putc > > We already support `abort. Let me: > 1. file a docs bug against GCC for those 2 undocumented builtins. > 2. add implementations of them to this change. > 3. add a test case for pr/47387 just to be safe. 1. Filed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96907. 2. done 3. as long as clang adds the no-builtin-puts attribute, then pr/47387 is fixed. It may not be interesting to add a test for properly emitting the builtin, since clang/test/CodeGen/libcalls-fno-builtin.c already covers that. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86508/new/ https://reviews.llvm.org/D86508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
nickdesaulniers updated this revision to Diff 289572. nickdesaulniers added a comment. - add putc and fputc builtins Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86508/new/ https://reviews.llvm.org/D86508 Files: clang/docs/LanguageExtensions.rst clang/include/clang/Basic/Builtins.def clang/test/CodeGen/builtins.c clang/test/Preprocessor/has_builtin.c Index: clang/test/Preprocessor/has_builtin.c === --- /dev/null +++ clang/test/Preprocessor/has_builtin.c @@ -0,0 +1,457 @@ +// RUN: %clang_cc1 -verify -E %s +// expected-no-diagnostics + +// TODO: fill out this file +// Please sort by https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html. + +// ISO C90 +#if !__has_builtin(abort) +#warning "no builtin 'abort'" +#endif +#if !__has_builtin(__builtin_abort) +#warning "no builtin '__builtin_abort'" +#endif +#if !__has_builtin(abs) +#warning "no builtin 'abs'" +#endif +#if !__has_builtin(__builtin_abs) +#warning "no builtin '__builtin_abs'" +#endif +#if !__has_builtin(acos) +#warning "no builtin 'acos'" +#endif +#if !__has_builtin(__builtin_acos) +#warning "no builtin '__builtin_acos'" +#endif +#if !__has_builtin(asin) +#warning "no builtin 'asin'" +#endif +#if !__has_builtin(__builtin_asin) +#warning "no builtin '__builtin_asin'" +#endif +#if !__has_builtin(atan2) +#warning "no builtin 'atan2'" +#endif +#if !__has_builtin(__builtin_atan2) +#warning "no builtin '__builtin_atan2'" +#endif +#if !__has_builtin(atan) +#warning "no builtin 'atan'" +#endif +#if !__has_builtin(__builtin_atan) +#warning "no builtin '__builtin_atan'" +#endif +#if !__has_builtin(calloc) +#warning "no builtin 'calloc'" +#endif +#if !__has_builtin(__builtin_calloc) +#warning "no builtin '__builtin_calloc'" +#endif +#if !__has_builtin(ceil) +#warning "no builtin 'ceil'" +#endif +#if !__has_builtin(__builtin_ceil) +#warning "no builtin '__builtin_ceil'" +#endif +#if !__has_builtin(cosh) +#warning "no builtin 'cosh'" +#endif +#if !__has_builtin(__builtin_cosh) +#warning "no builtin '__builtin_cosh'" +#endif +#if !__has_builtin(cos) +#warning "no builtin 'cos'" +#endif +#if !__has_builtin(__builtin_cos) +#warning "no builtin '__builtin_cos'" +#endif +#if !__has_builtin(exit) +#warning "no builtin 'exit'" +#endif +#if !__has_builtin(__builtin_exit) +#warning "no builtin '__builtin_exit'" +#endif +#if !__has_builtin(exp) +#warning "no builtin 'exp'" +#endif +#if !__has_builtin(__builtin_exp) +#warning "no builtin '__builtin_exp'" +#endif +#if !__has_builtin(fabs) +#warning "no builtin 'fabs'" +#endif +#if !__has_builtin(__builtin_fabs) +#warning "no builtin '__builtin_fabs'" +#endif +#if !__has_builtin(floor) +#warning "no builtin 'floor'" +#endif +#if !__has_builtin(__builtin_floor) +#warning "no builtin '__builtin_floor'" +#endif +#if !__has_builtin(fmod) +#warning "no builtin 'fmod'" +#endif +#if !__has_builtin(__builtin_fmod) +#warning "no builtin '__builtin_fmod'" +#endif +#if !__has_builtin(fprintf) +#warning "no builtin 'fprintf'" +#endif +#if !__has_builtin(__builtin_fprintf) +#warning "no builtin '__builtin_fprintf'" +#endif +#if !__has_builtin(fputc) +#warning "no builtin 'fputc'" +#endif +#if !__has_builtin(__builtin_fputc) +#warning "no builtin '__builtin_fputs'" +#endif +#if !__has_builtin(fputs) +#warning "no builtin 'fputs'" +#endif +#if !__has_builtin(__builtin_fputs) +#warning "no builtin '__builtin_fputs'" +#endif +#if !__has_builtin(free) +#warning "no builtin 'free'" +#endif +#if !__has_builtin(__builtin_free) +#warning "no builtin '__builtin_free'" +#endif +#if !__has_builtin(frexp) +#warning "no builtin 'frexp'" +#endif +#if !__has_builtin(__builtin_frexp) +#warning "no builtin '__builtin_frexp'" +#endif +#if !__has_builtin(fscanf) +#warning "no builtin 'fscanf'" +#endif +#if !__has_builtin(__builtin_fscanf) +#warning "no builtin '__builtin_fscanf'" +#endif +#if !__has_builtin(isalnum) +#warning "no builtin 'isalnum'" +#endif +#if !__has_builtin(__builtin_isalnum) +#warning "no builtin '__builtin_isalnum'" +#endif +#if !__has_builtin(isalpha) +#warning "no builtin 'isalpha'" +#endif +#if !__has_builtin(__builtin_isalpha) +#warning "no builtin '__builtin_isalpha'" +#endif +#if !__has_builtin(iscntrl) +#warning "no builtin 'iscntrl'" +#endif +#if !__has_builtin(__builtin_iscntrl) +#warning "no builtin '__builtin_iscntrl'" +#endif +#if !__has_builtin(isdigit) +#warning "no builtin 'isdigit'" +#endif +#if !__has_builtin(__builtin_isdigit) +#warning "no builtin '__builtin_isdigit'" +#endif +#if !__has_builtin(isgraph) +#warning "no builtin 'isgraph'" +#endif +#if !__has_builtin(__builtin_isgraph) +#warning "no builtin '__builtin_isgraph'" +#endif +#if !__has_builtin(islower) +#warning "no builtin 'islower'" +#endif +#if !__has_builtin(__builtin_islower) +#warning "no builtin '__builtin_islower'" +#endif +#if !__has_builtin(isprint) +#warning "no builtin 'isprint'" +#endif +#if !__has_builtin(__builtin_isprint
[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
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: > > 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? (`abort` should not have been in the above list; it's in GCC's docs and we implement the builtin for it) From the above list, GCC has builtins for: * fputc * putc We already support `abort. Let me: 1. file a docs bug against GCC for those 2 undocumented builtins. 2. add implementations of them to this change. 3. add a test case for pr/47387 just to be safe. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86508/new/ https://reviews.llvm.org/D86508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
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 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
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: > 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) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86508/new/ https://reviews.llvm.org/D86508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
nickdesaulniers updated this revision to Diff 289312. nickdesaulniers marked an inline comment as done. nickdesaulniers added a comment. - rebase on master, precommitted getLangOpts() change, dropped p7.cpp test change Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86508/new/ https://reviews.llvm.org/D86508 Files: clang/docs/LanguageExtensions.rst clang/include/clang/Basic/Builtins.def clang/test/CodeGen/builtins.c clang/test/Preprocessor/has_builtin.c Index: clang/test/Preprocessor/has_builtin.c === --- /dev/null +++ clang/test/Preprocessor/has_builtin.c @@ -0,0 +1,445 @@ +// RUN: %clang_cc1 -verify -E %s +// expected-no-diagnostics + +// TODO: fill out this file +// Please sort by https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html. + +// ISO C90 +#if !__has_builtin(abort) +#warning "no builtin 'abort'" +#endif +#if !__has_builtin(__builtin_abort) +#warning "no builtin '__builtin_abort'" +#endif +#if !__has_builtin(abs) +#warning "no builtin 'abs'" +#endif +#if !__has_builtin(__builtin_abs) +#warning "no builtin '__builtin_abs'" +#endif +#if !__has_builtin(acos) +#warning "no builtin 'acos'" +#endif +#if !__has_builtin(__builtin_acos) +#warning "no builtin '__builtin_acos'" +#endif +#if !__has_builtin(asin) +#warning "no builtin 'asin'" +#endif +#if !__has_builtin(__builtin_asin) +#warning "no builtin '__builtin_asin'" +#endif +#if !__has_builtin(atan2) +#warning "no builtin 'atan2'" +#endif +#if !__has_builtin(__builtin_atan2) +#warning "no builtin '__builtin_atan2'" +#endif +#if !__has_builtin(atan) +#warning "no builtin 'atan'" +#endif +#if !__has_builtin(__builtin_atan) +#warning "no builtin '__builtin_atan'" +#endif +#if !__has_builtin(calloc) +#warning "no builtin 'calloc'" +#endif +#if !__has_builtin(__builtin_calloc) +#warning "no builtin '__builtin_calloc'" +#endif +#if !__has_builtin(ceil) +#warning "no builtin 'ceil'" +#endif +#if !__has_builtin(__builtin_ceil) +#warning "no builtin '__builtin_ceil'" +#endif +#if !__has_builtin(cosh) +#warning "no builtin 'cosh'" +#endif +#if !__has_builtin(__builtin_cosh) +#warning "no builtin '__builtin_cosh'" +#endif +#if !__has_builtin(cos) +#warning "no builtin 'cos'" +#endif +#if !__has_builtin(__builtin_cos) +#warning "no builtin '__builtin_cos'" +#endif +#if !__has_builtin(exit) +#warning "no builtin 'exit'" +#endif +#if !__has_builtin(__builtin_exit) +#warning "no builtin '__builtin_exit'" +#endif +#if !__has_builtin(exp) +#warning "no builtin 'exp'" +#endif +#if !__has_builtin(__builtin_exp) +#warning "no builtin '__builtin_exp'" +#endif +#if !__has_builtin(fabs) +#warning "no builtin 'fabs'" +#endif +#if !__has_builtin(__builtin_fabs) +#warning "no builtin '__builtin_fabs'" +#endif +#if !__has_builtin(floor) +#warning "no builtin 'floor'" +#endif +#if !__has_builtin(__builtin_floor) +#warning "no builtin '__builtin_floor'" +#endif +#if !__has_builtin(fmod) +#warning "no builtin 'fmod'" +#endif +#if !__has_builtin(__builtin_fmod) +#warning "no builtin '__builtin_fmod'" +#endif +#if !__has_builtin(fprintf) +#warning "no builtin 'fprintf'" +#endif +#if !__has_builtin(__builtin_fprintf) +#warning "no builtin '__builtin_fprintf'" +#endif +#if !__has_builtin(fputs) +#warning "no builtin 'fputs'" +#endif +#if !__has_builtin(__builtin_fputs) +#warning "no builtin '__builtin_fputs'" +#endif +#if !__has_builtin(free) +#warning "no builtin 'free'" +#endif +#if !__has_builtin(__builtin_free) +#warning "no builtin '__builtin_free'" +#endif +#if !__has_builtin(frexp) +#warning "no builtin 'frexp'" +#endif +#if !__has_builtin(__builtin_frexp) +#warning "no builtin '__builtin_frexp'" +#endif +#if !__has_builtin(fscanf) +#warning "no builtin 'fscanf'" +#endif +#if !__has_builtin(__builtin_fscanf) +#warning "no builtin '__builtin_fscanf'" +#endif +#if !__has_builtin(isalnum) +#warning "no builtin 'isalnum'" +#endif +#if !__has_builtin(__builtin_isalnum) +#warning "no builtin '__builtin_isalnum'" +#endif +#if !__has_builtin(isalpha) +#warning "no builtin 'isalpha'" +#endif +#if !__has_builtin(__builtin_isalpha) +#warning "no builtin '__builtin_isalpha'" +#endif +#if !__has_builtin(iscntrl) +#warning "no builtin 'iscntrl'" +#endif +#if !__has_builtin(__builtin_iscntrl) +#warning "no builtin '__builtin_iscntrl'" +#endif +#if !__has_builtin(isdigit) +#warning "no builtin 'isdigit'" +#endif +#if !__has_builtin(__builtin_isdigit) +#warning "no builtin '__builtin_isdigit'" +#endif +#if !__has_builtin(isgraph) +#warning "no builtin 'isgraph'" +#endif +#if !__has_builtin(__builtin_isgraph) +#warning "no builtin '__builtin_isgraph'" +#endif +#if !__has_builtin(islower) +#warning "no builtin 'islower'" +#endif +#if !__has_builtin(__builtin_islower) +#warning "no builtin '__builtin_islower'" +#endif +#if !__has_builtin(isprint) +#warning "no builtin 'isprint'" +#endif +#if !__has_builtin(__builtin_isprint) +#warning "no builtin '__builtin_isprint'" +#en
[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
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") 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. Comment at: clang/lib/Lex/PPMacroExpansion.cpp:348 // C++ Standing Document Extensions. - if (LangOpts.CPlusPlus) + if (getLangOpts().CPlusPlus) Ident__has_cpp_attribute = rsmith wrote: > The changes to this file appear to be independent of the rest of the patch. > Please go ahead and land this cleanup separately. done: 663f4f7edc2476231fa5bfc04519d5fd51a10112 Comment at: clang/test/CXX/over/over.oper/over.literal/p7.cpp:10 -void puts(const char *); +int puts(const char *); static inline void operator "" _puts(const char *c) { rsmith wrote: > Doesn't this also need to be `extern "C"` to be recognized as the builtin? Interesting, if I change this back to `void`, the test passes for me. I'm not sure why it ever failed then. Will drop this hunk from the diff. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86508/new/ https://reviews.llvm.org/D86508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
aaron.ballman added inline comments. Comment at: clang/include/clang/Basic/Builtins.def:488 +BUILTIN(__builtin_calloc, "v*zz", "F") +BUILTIN(__builtin_exit, "vi", "Fr") BUILTIN(__builtin_fprintf, "iP*cC*.", "Fp:1:") rsmith wrote: > aaron.ballman wrote: > > Should we be adding `atexit()` as well? > GCC doesn't have a `__builtin_atexit`, so we'd need some reason to invent one. Ah, I didn't realize this was for GCC compatibility. Thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86508/new/ https://reviews.llvm.org/D86508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
rsmith added inline comments. Comment at: clang/include/clang/Basic/Builtins.def:488 +BUILTIN(__builtin_calloc, "v*zz", "F") +BUILTIN(__builtin_exit, "vi", "Fr") BUILTIN(__builtin_fprintf, "iP*cC*.", "Fp:1:") aaron.ballman wrote: > Should we be adding `atexit()` as well? GCC doesn't have a `__builtin_atexit`, so we'd need some reason to invent one. 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") 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. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86508/new/ https://reviews.llvm.org/D86508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
aaron.ballman added inline comments. Comment at: clang/include/clang/Basic/Builtins.def:488 +BUILTIN(__builtin_calloc, "v*zz", "F") +BUILTIN(__builtin_exit, "vi", "Fr") BUILTIN(__builtin_fprintf, "iP*cC*.", "Fp:1:") Should we be adding `atexit()` as well? 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") Should we also add a builtin for `putc()` (I know that's often a macro, so I'm not certain if it applies)? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86508/new/ https://reviews.llvm.org/D86508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
rsmith added a comment. LGTM I've not checked all the types are correct (someone should double-check that prior to commit), but it looks like GCC provides these `__builtin_*` functions, so we should too. The addition of the non-`__builtin_` versions should improve our diagnostics but otherwise have no effect. Comment at: clang/lib/Lex/PPMacroExpansion.cpp:348 // C++ Standing Document Extensions. - if (LangOpts.CPlusPlus) + if (getLangOpts().CPlusPlus) Ident__has_cpp_attribute = The changes to this file appear to be independent of the rest of the patch. Please go ahead and land this cleanup separately. Comment at: clang/test/CXX/over/over.oper/over.literal/p7.cpp:10 -void puts(const char *); +int puts(const char *); static inline void operator "" _puts(const char *c) { Doesn't this also need to be `extern "C"` to be recognized as the builtin? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86508/new/ https://reviews.llvm.org/D86508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
nickdesaulniers added a comment. bumping for review. Are there additional reviewers we could add to share the burden? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86508/new/ https://reviews.llvm.org/D86508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D86508: [clang] implement+test remaining C90 __builtin_ functions
nickdesaulniers updated this revision to Diff 287573. nickdesaulniers added a comment. - misuploaded Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86508/new/ https://reviews.llvm.org/D86508 Files: clang/docs/LanguageExtensions.rst clang/include/clang/Basic/Builtins.def clang/lib/Lex/PPMacroExpansion.cpp clang/test/CXX/over/over.oper/over.literal/p7.cpp clang/test/CodeGen/builtins.c clang/test/Preprocessor/has_builtin.c Index: clang/test/Preprocessor/has_builtin.c === --- /dev/null +++ clang/test/Preprocessor/has_builtin.c @@ -0,0 +1,445 @@ +// RUN: %clang_cc1 -verify -E %s +// expected-no-diagnostics + +// TODO: fill out this file +// Please sort by https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html. + +// ISO C90 +#if !__has_builtin(abort) +#warning "no builtin 'abort'" +#endif +#if !__has_builtin(__builtin_abort) +#warning "no builtin '__builtin_abort'" +#endif +#if !__has_builtin(abs) +#warning "no builtin 'abs'" +#endif +#if !__has_builtin(__builtin_abs) +#warning "no builtin '__builtin_abs'" +#endif +#if !__has_builtin(acos) +#warning "no builtin 'acos'" +#endif +#if !__has_builtin(__builtin_acos) +#warning "no builtin '__builtin_acos'" +#endif +#if !__has_builtin(asin) +#warning "no builtin 'asin'" +#endif +#if !__has_builtin(__builtin_asin) +#warning "no builtin '__builtin_asin'" +#endif +#if !__has_builtin(atan2) +#warning "no builtin 'atan2'" +#endif +#if !__has_builtin(__builtin_atan2) +#warning "no builtin '__builtin_atan2'" +#endif +#if !__has_builtin(atan) +#warning "no builtin 'atan'" +#endif +#if !__has_builtin(__builtin_atan) +#warning "no builtin '__builtin_atan'" +#endif +#if !__has_builtin(calloc) +#warning "no builtin 'calloc'" +#endif +#if !__has_builtin(__builtin_calloc) +#warning "no builtin '__builtin_calloc'" +#endif +#if !__has_builtin(ceil) +#warning "no builtin 'ceil'" +#endif +#if !__has_builtin(__builtin_ceil) +#warning "no builtin '__builtin_ceil'" +#endif +#if !__has_builtin(cosh) +#warning "no builtin 'cosh'" +#endif +#if !__has_builtin(__builtin_cosh) +#warning "no builtin '__builtin_cosh'" +#endif +#if !__has_builtin(cos) +#warning "no builtin 'cos'" +#endif +#if !__has_builtin(__builtin_cos) +#warning "no builtin '__builtin_cos'" +#endif +#if !__has_builtin(exit) +#warning "no builtin 'exit'" +#endif +#if !__has_builtin(__builtin_exit) +#warning "no builtin '__builtin_exit'" +#endif +#if !__has_builtin(exp) +#warning "no builtin 'exp'" +#endif +#if !__has_builtin(__builtin_exp) +#warning "no builtin '__builtin_exp'" +#endif +#if !__has_builtin(fabs) +#warning "no builtin 'fabs'" +#endif +#if !__has_builtin(__builtin_fabs) +#warning "no builtin '__builtin_fabs'" +#endif +#if !__has_builtin(floor) +#warning "no builtin 'floor'" +#endif +#if !__has_builtin(__builtin_floor) +#warning "no builtin '__builtin_floor'" +#endif +#if !__has_builtin(fmod) +#warning "no builtin 'fmod'" +#endif +#if !__has_builtin(__builtin_fmod) +#warning "no builtin '__builtin_fmod'" +#endif +#if !__has_builtin(fprintf) +#warning "no builtin 'fprintf'" +#endif +#if !__has_builtin(__builtin_fprintf) +#warning "no builtin '__builtin_fprintf'" +#endif +#if !__has_builtin(fputs) +#warning "no builtin 'fputs'" +#endif +#if !__has_builtin(__builtin_fputs) +#warning "no builtin '__builtin_fputs'" +#endif +#if !__has_builtin(free) +#warning "no builtin 'free'" +#endif +#if !__has_builtin(__builtin_free) +#warning "no builtin '__builtin_free'" +#endif +#if !__has_builtin(frexp) +#warning "no builtin 'frexp'" +#endif +#if !__has_builtin(__builtin_frexp) +#warning "no builtin '__builtin_frexp'" +#endif +#if !__has_builtin(fscanf) +#warning "no builtin 'fscanf'" +#endif +#if !__has_builtin(__builtin_fscanf) +#warning "no builtin '__builtin_fscanf'" +#endif +#if !__has_builtin(isalnum) +#warning "no builtin 'isalnum'" +#endif +#if !__has_builtin(__builtin_isalnum) +#warning "no builtin '__builtin_isalnum'" +#endif +#if !__has_builtin(isalpha) +#warning "no builtin 'isalpha'" +#endif +#if !__has_builtin(__builtin_isalpha) +#warning "no builtin '__builtin_isalpha'" +#endif +#if !__has_builtin(iscntrl) +#warning "no builtin 'iscntrl'" +#endif +#if !__has_builtin(__builtin_iscntrl) +#warning "no builtin '__builtin_iscntrl'" +#endif +#if !__has_builtin(isdigit) +#warning "no builtin 'isdigit'" +#endif +#if !__has_builtin(__builtin_isdigit) +#warning "no builtin '__builtin_isdigit'" +#endif +#if !__has_builtin(isgraph) +#warning "no builtin 'isgraph'" +#endif +#if !__has_builtin(__builtin_isgraph) +#warning "no builtin '__builtin_isgraph'" +#endif +#if !__has_builtin(islower) +#warning "no builtin 'islower'" +#endif +#if !__has_builtin(__builtin_islower) +#warning "no builtin '__builtin_islower'" +#endif +#if !__has_builtin(isprint) +#warning "no builtin 'isprint'" +#endif +#if !__has_builtin(__builtin_isprint) +#warning "no builtin '__builtin_isprint'" +#endif +#if !__has_builtin(ispunc