[compiler-rt] r330616 - Fix clang-cl warnings in compiler-rt

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 23 10:05:47 PDT 2018


Author: rnk
Date: Mon Apr 23 10:05:47 2018
New Revision: 330616

URL: http://llvm.org/viewvc/llvm-project?rev=330616&view=rev
Log:
Fix clang-cl warnings in compiler-rt

The profile library was missing some includes and was erroneously using
ftruncate. WinASan was using `= {0}` to initialize structs, which
creates -Wmissing-field-initializers and -Wmissing-braces warnings with
clang. Use `= {}` instead, since this is C++.

Modified:
    compiler-rt/trunk/lib/profile/InstrProfilingFile.c
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc

Modified: compiler-rt/trunk/lib/profile/InstrProfilingFile.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingFile.c?rev=330616&r1=330615&r2=330616&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingFile.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingFile.c Mon Apr 23 10:05:47 2018
@@ -19,6 +19,7 @@
 #include "WindowsMMap.h"
 /* For _chsize_s */
 #include <io.h>
+#include <process.h>
 #else
 #include <sys/file.h>
 #include <sys/mman.h>
@@ -186,7 +187,7 @@ static int doProfileMerging(FILE *Profil
 
   // Truncate the file in case merging of value profile did not happend to
   // prevent from leaving garbage data at the end of the profile file.
-  ftruncate(fileno(ProfileFile), __llvm_profile_get_size_for_buffer());
+  COMPILER_RT_FTRUNCATE(ProfileFile, __llvm_profile_get_size_for_buffer());
 
   (void)munmap(ProfileBuffer, ProfileFileSize);
   *MergeDone = 1;

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=330616&r1=330615&r2=330616&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Mon Apr 23 10:05:47 2018
@@ -6537,6 +6537,7 @@ INTERCEPTOR(wchar_t *, wcsncat, wchar_t
 #define INIT_WCSCAT
 #endif
 
+#if SANITIZER_INTERCEPT_STRXFRM
 static SIZE_T RealStrLen(const char *str) { return REAL(strlen)(str); }
 
 static SIZE_T RealStrLen(const wchar_t *str) { return REAL(wcslen)(str); }
@@ -6553,7 +6554,6 @@ static SIZE_T RealStrLen(const wchar_t *
     return res;                                                            \
   }
 
-#if SANITIZER_INTERCEPT_STRXFRM
 INTERCEPTOR(SIZE_T, strxfrm, char *dest, const char *src, SIZE_T len) {
   STRXFRM_INTERCEPTOR_IMPL(strxfrm, dest, src, len);
 }

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=330616&r1=330615&r2=330616&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Mon Apr 23 10:05:47 2018
@@ -492,7 +492,7 @@ void SleepForMillis(int millis) {
 }
 
 u64 NanoTime() {
-  static LARGE_INTEGER frequency = {0};
+  static LARGE_INTEGER frequency = {};
   LARGE_INTEGER counter;
   if (UNLIKELY(frequency.QuadPart == 0)) {
     QueryPerformanceFrequency(&frequency);
@@ -1059,7 +1059,7 @@ bool GetRandom(void *buffer, uptr length
 }
 
 u32 GetNumberOfCPUs() {
-  SYSTEM_INFO sysinfo = {0};
+  SYSTEM_INFO sysinfo = {};
   GetNativeSystemInfo(&sysinfo);
   return sysinfo.dwNumberOfProcessors;
 }




More information about the llvm-commits mailing list