[compiler-rt][builtins] Add compiler flags to catch potential errors
authorAkira Hatanaka <ahatanaka@apple.com>
Mon, 22 Aug 2022 23:25:59 +0000 (16:25 -0700)
committerAkira Hatanaka <ahatanaka@apple.com>
Wed, 24 Aug 2022 22:52:31 +0000 (15:52 -0700)
commite1dcd4ba444b0aaac05c399670d870925cef4459
tree2fa29645393d40f3e277b3ee419c682df13b68e4
parentcff5bef948c91e4919de8a5fb9765e0edc13f3de
[compiler-rt][builtins] Add compiler flags to catch potential errors
that can lead to security vulnerabilities

Also, fix a few places that were causing -Wshadow and
-Wformat-nonliteral warnings to be emitted.

This reapplies the patch that was reverted in 0d66dc57e8c7 because it
broke a few bots.

I made changes so that cmake checks whether some of the flags are
supported by the compiler that is used before adding them to the list.
Also, I moved function add_security_warnings to CompilerRTUtils.cmake so
that it is defined before it's used.

Differential Revision: https://reviews.llvm.org/D131714
compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
compiler-rt/cmake/Modules/CompilerRTUtils.cmake
compiler-rt/cmake/config-ix.cmake
compiler-rt/include/profile/InstrProfData.inc
compiler-rt/lib/builtins/CMakeLists.txt
compiler-rt/lib/builtins/eprintf.c
compiler-rt/lib/profile/InstrProfiling.c
compiler-rt/lib/profile/InstrProfilingWriter.c