[compiler-rt] r248816 - [sanitizer] Fix Clang-tidy modernize-use-nullptr warnings in lib/sanitizer_common headers, unify closing inclusion guards. Patch by Eugene Zelenko

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 11:23:36 PDT 2015


Author: kcc
Date: Tue Sep 29 13:23:36 2015
New Revision: 248816

URL: http://llvm.org/viewvc/llvm-project?rev=248816&view=rev
Log:
[sanitizer] Fix Clang-tidy modernize-use-nullptr warnings in lib/sanitizer_common headers, unify closing inclusion guards. Patch by Eugene Zelenko

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_addrhashmap.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_internal.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_format.inc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector_interface.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_lfstack.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_list.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_persistent_allocator.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_stackdepot.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_stackdepotbase.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_addrhashmap.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_addrhashmap.h?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_addrhashmap.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_addrhashmap.h Tue Sep 29 13:23:36 2015
@@ -143,7 +143,7 @@ bool AddrHashMap<T, kSize>::Handle::crea
 
 template<typename T, uptr kSize>
 bool AddrHashMap<T, kSize>::Handle::exists() const {
-  return cell_ != 0;
+  return cell_ != nullptr;
 }
 
 template<typename T, uptr kSize>
@@ -160,7 +160,7 @@ void AddrHashMap<T, kSize>::acquire(Hand
   h->created_ = false;
   h->addidx_ = -1U;
   h->bucket_ = b;
-  h->cell_ = 0;
+  h->cell_ = nullptr;
 
   // If we want to remove the element, we need exclusive access to the bucket,
   // so skip the lock-free phase.
@@ -250,7 +250,7 @@ void AddrHashMap<T, kSize>::acquire(Hand
   }
 
   // Store in the add cells.
-  if (add == 0) {
+  if (!add) {
     // Allocate a new add array.
     const uptr kInitSize = 64;
     add = (AddBucket*)InternalAlloc(kInitSize);
@@ -282,7 +282,7 @@ void AddrHashMap<T, kSize>::acquire(Hand
 
 template<typename T, uptr kSize>
 void AddrHashMap<T, kSize>::release(Handle *h) {
-  if (h->cell_ == 0)
+  if (!h->cell_)
     return;
   Bucket *b = h->bucket_;
   Cell *c = h->cell_;

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h Tue Sep 29 13:23:36 2015
@@ -347,7 +347,7 @@ class SizeClassAllocator64 {
     CHECK_LT(class_id, kNumClasses);
     RegionInfo *region = GetRegionInfo(class_id);
     Batch *b = region->free_list.Pop();
-    if (b == 0)
+    if (!b)
       b = PopulateFreeList(stat, c, class_id, region);
     region->n_allocated += b->count;
     return b;
@@ -371,16 +371,16 @@ class SizeClassAllocator64 {
   void *GetBlockBegin(const void *p) {
     uptr class_id = GetSizeClass(p);
     uptr size = SizeClassMap::Size(class_id);
-    if (!size) return 0;
+    if (!size) return nullptr;
     uptr chunk_idx = GetChunkIdx((uptr)p, size);
     uptr reg_beg = (uptr)p & ~(kRegionSize - 1);
     uptr beg = chunk_idx * size;
     uptr next_beg = beg + size;
-    if (class_id >= kNumClasses) return 0;
+    if (class_id >= kNumClasses) return nullptr;
     RegionInfo *region = GetRegionInfo(class_id);
     if (region->mapped_user >= next_beg)
       return reinterpret_cast<void*>(reg_beg + beg);
-    return 0;
+    return nullptr;
   }
 
   static uptr GetActuallyAllocatedSize(void *p) {
@@ -609,6 +609,7 @@ class TwoLevelByteMap {
     internal_memset(map1_, 0, sizeof(map1_));
     mu_.Init();
   }
+
   void TestOnlyUnmap() {
     for (uptr i = 0; i < kSize1; i++) {
       u8 *p = Get(i);
@@ -872,9 +873,9 @@ class SizeClassAllocator32 {
     uptr reg = AllocateRegion(stat, class_id);
     uptr n_chunks = kRegionSize / (size + kMetadataSize);
     uptr max_count = SizeClassMap::MaxCached(class_id);
-    Batch *b = 0;
+    Batch *b = nullptr;
     for (uptr i = reg; i < reg + n_chunks * size; i += size) {
-      if (b == 0) {
+      if (!b) {
         if (SizeClassMap::SizeClassRequiresSeparateTransferBatch(class_id))
           b = (Batch*)c->Allocate(this, SizeClassMap::ClassID(sizeof(Batch)));
         else
@@ -885,7 +886,7 @@ class SizeClassAllocator32 {
       if (b->count == max_count) {
         CHECK_GT(b->count, 0);
         sci->free_list.push_back(b);
-        b = 0;
+        b = nullptr;
       }
     }
     if (b) {
@@ -1065,7 +1066,7 @@ class LargeMmapAllocator {
 
   void *ReturnNullOrDie() {
     if (atomic_load(&may_return_null_, memory_order_acquire))
-      return 0;
+      return nullptr;
     ReportAllocatorCannotReturnNull();
   }
 
@@ -1105,7 +1106,7 @@ class LargeMmapAllocator {
   }
 
   bool PointerIsMine(const void *p) {
-    return GetBlockBegin(p) != 0;
+    return GetBlockBegin(p) != nullptr;
   }
 
   uptr GetActuallyAllocatedSize(void *p) {
@@ -1134,13 +1135,13 @@ class LargeMmapAllocator {
         nearest_chunk = ch;
     }
     if (!nearest_chunk)
-      return 0;
+      return nullptr;
     Header *h = reinterpret_cast<Header *>(nearest_chunk);
     CHECK_GE(nearest_chunk, h->map_beg);
     CHECK_LT(nearest_chunk, h->map_beg + h->map_size);
     CHECK_LE(nearest_chunk, p);
     if (h->map_beg + h->map_size <= p)
-      return 0;
+      return nullptr;
     return GetUser(h);
   }
 
@@ -1150,7 +1151,7 @@ class LargeMmapAllocator {
     mutex_.CheckLocked();
     uptr p = reinterpret_cast<uptr>(ptr);
     uptr n = n_chunks_;
-    if (!n) return 0;
+    if (!n) return nullptr;
     if (!chunks_sorted_) {
       // Do one-time sort. chunks_sorted_ is reset in Allocate/Deallocate.
       SortArray(reinterpret_cast<uptr*>(chunks_), n);
@@ -1162,7 +1163,7 @@ class LargeMmapAllocator {
           chunks_[n - 1]->map_size;
     }
     if (p < min_mmap_ || p >= max_mmap_)
-      return 0;
+      return nullptr;
     uptr beg = 0, end = n - 1;
     // This loop is a log(n) lower_bound. It does not check for the exact match
     // to avoid expensive cache-thrashing loads.
@@ -1183,7 +1184,7 @@ class LargeMmapAllocator {
 
     Header *h = chunks_[beg];
     if (h->map_beg + h->map_size <= p || p < h->map_beg)
-      return 0;
+      return nullptr;
     return GetUser(h);
   }
 
@@ -1312,7 +1313,7 @@ class CombinedAllocator {
 
   void *ReturnNullOrDie() {
     if (MayReturnNull())
-      return 0;
+      return nullptr;
     ReportAllocatorCannotReturnNull();
   }
 
@@ -1344,7 +1345,7 @@ class CombinedAllocator {
       return Allocate(cache, new_size, alignment);
     if (!new_size) {
       Deallocate(cache, p);
-      return 0;
+      return nullptr;
     }
     CHECK(PointerIsMine(p));
     uptr old_size = GetActuallyAllocatedSize(p);
@@ -1449,7 +1450,6 @@ class CombinedAllocator {
 // Returns true if calloc(size, n) should return 0 due to overflow in size*n.
 bool CallocShouldReturnNullDueToOverflow(uptr size, uptr n);
 
-}  // namespace __sanitizer
-
-#endif  // SANITIZER_ALLOCATOR_H
+} // namespace __sanitizer
 
+#endif // SANITIZER_ALLOCATOR_H

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_internal.h?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_internal.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_internal.h Tue Sep 29 13:23:36 2015
@@ -1,4 +1,4 @@
-//===-- sanitizer_allocator_internal.h -------------------------- C++ -----===//
+//===-- sanitizer_allocator_internal.h --------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -45,19 +45,19 @@ typedef SizeClassAllocatorLocalCache<Pri
 typedef CombinedAllocator<PrimaryInternalAllocator, InternalAllocatorCache,
                           LargeMmapAllocator<> > InternalAllocator;
 
-void *InternalAlloc(uptr size, InternalAllocatorCache *cache = 0);
-void InternalFree(void *p, InternalAllocatorCache *cache = 0);
+void *InternalAlloc(uptr size, InternalAllocatorCache *cache = nullptr);
+void InternalFree(void *p, InternalAllocatorCache *cache = nullptr);
 InternalAllocator *internal_allocator();
 
 enum InternalAllocEnum {
   INTERNAL_ALLOC
 };
 
-}  // namespace __sanitizer
+} // namespace __sanitizer
 
 inline void *operator new(__sanitizer::operator_new_size_type size,
                           InternalAllocEnum) {
   return InternalAlloc(size);
 }
 
-#endif  // SANITIZER_ALLOCATOR_INTERNAL_H
+#endif // SANITIZER_ALLOCATOR_INTERNAL_H

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=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Tue Sep 29 13:23:36 2015
@@ -31,6 +31,7 @@
 //   COMMON_INTERCEPTOR_HANDLE_RECVMSG
 //   COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED
 //===----------------------------------------------------------------------===//
+
 #include "interception/interception.h"
 #include "sanitizer_addrhashmap.h"
 #include "sanitizer_placement_new.h"
@@ -1319,14 +1320,14 @@ INTERCEPTOR(__sanitizer_passwd *, getpwn
   COMMON_INTERCEPTOR_ENTER(ctx, getpwnam, name);
   COMMON_INTERCEPTOR_READ_RANGE(ctx, name, REAL(strlen)(name) + 1);
   __sanitizer_passwd *res = REAL(getpwnam)(name);
-  if (res != 0) unpoison_passwd(ctx, res);
+  if (res) unpoison_passwd(ctx, res);
   return res;
 }
 INTERCEPTOR(__sanitizer_passwd *, getpwuid, u32 uid) {
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, getpwuid, uid);
   __sanitizer_passwd *res = REAL(getpwuid)(uid);
-  if (res != 0) unpoison_passwd(ctx, res);
+  if (res) unpoison_passwd(ctx, res);
   return res;
 }
 INTERCEPTOR(__sanitizer_group *, getgrnam, const char *name) {
@@ -1334,14 +1335,14 @@ INTERCEPTOR(__sanitizer_group *, getgrna
   COMMON_INTERCEPTOR_ENTER(ctx, getgrnam, name);
   COMMON_INTERCEPTOR_READ_RANGE(ctx, name, REAL(strlen)(name) + 1);
   __sanitizer_group *res = REAL(getgrnam)(name);
-  if (res != 0) unpoison_group(ctx, res);
+  if (res) unpoison_group(ctx, res);
   return res;
 }
 INTERCEPTOR(__sanitizer_group *, getgrgid, u32 gid) {
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, getgrgid, gid);
   __sanitizer_group *res = REAL(getgrgid)(gid);
-  if (res != 0) unpoison_group(ctx, res);
+  if (res) unpoison_group(ctx, res);
   return res;
 }
 #define INIT_GETPWNAM_AND_FRIENDS      \
@@ -1430,14 +1431,14 @@ INTERCEPTOR(__sanitizer_passwd *, getpwe
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, getpwent, dummy);
   __sanitizer_passwd *res = REAL(getpwent)(dummy);
-  if (res != 0) unpoison_passwd(ctx, res);
+  if (res) unpoison_passwd(ctx, res);
   return res;
 }
 INTERCEPTOR(__sanitizer_group *, getgrent, int dummy) {
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, getgrent, dummy);
   __sanitizer_group *res = REAL(getgrent)(dummy);
-  if (res != 0) unpoison_group(ctx, res);;
+  if (res) unpoison_group(ctx, res);;
   return res;
 }
 #define INIT_GETPWENT                  \
@@ -1452,14 +1453,14 @@ INTERCEPTOR(__sanitizer_passwd *, fgetpw
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, fgetpwent, fp);
   __sanitizer_passwd *res = REAL(fgetpwent)(fp);
-  if (res != 0) unpoison_passwd(ctx, res);
+  if (res) unpoison_passwd(ctx, res);
   return res;
 }
 INTERCEPTOR(__sanitizer_group *, fgetgrent, void *fp) {
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, fgetgrent, fp);
   __sanitizer_group *res = REAL(fgetgrent)(fp);
-  if (res != 0) unpoison_group(ctx, res);
+  if (res) unpoison_group(ctx, res);
   return res;
 }
 #define INIT_FGETPWENT                  \
@@ -2367,7 +2368,7 @@ INTERCEPTOR(__sanitizer_dirent *, opendi
   COMMON_INTERCEPTOR_ENTER(ctx, opendir, path);
   COMMON_INTERCEPTOR_READ_RANGE(ctx, path, REAL(strlen)(path) + 1);
   __sanitizer_dirent *res = REAL(opendir)(path);
-  if (res != 0)
+  if (res)
     COMMON_INTERCEPTOR_DIR_ACQUIRE(ctx, path);
   return res;
 }
@@ -2557,7 +2558,7 @@ UNUSED static inline void FixRealStrtolE
 
 UNUSED static inline void StrtolFixAndCheck(void *ctx, const char *nptr,
                              char **endptr, char *real_endptr, int base) {
-  if (endptr != 0) {
+  if (endptr) {
     *endptr = real_endptr;
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, endptr, sizeof(*endptr));
   }
@@ -2787,7 +2788,7 @@ INTERCEPTOR(char *, realpath, const char
   // version of a versioned symbol. For realpath(), this gives us something
   // (called __old_realpath) that does not handle NULL in the second argument.
   // Handle it as part of the interceptor.
-  char *allocated_path = 0;
+  char *allocated_path = nullptr;
   if (!resolved_path)
     allocated_path = resolved_path = (char *)WRAP(malloc)(path_max + 1);
 
@@ -2958,10 +2959,11 @@ INTERCEPTOR(int, scandir, char *dirp, __
   // FIXME: under ASan the call below may write to freed memory and corrupt
   // its metadata. See
   // https://code.google.com/p/address-sanitizer/issues/detail?id=321.
-  int res = REAL(scandir)(dirp, namelist, filter ? wrapped_scandir_filter : 0,
-                          compar ? wrapped_scandir_compar : 0);
-  scandir_filter = 0;
-  scandir_compar = 0;
+  int res = REAL(scandir)(dirp, namelist,
+                          filter ? wrapped_scandir_filter : nullptr,
+                          compar ? wrapped_scandir_compar : nullptr);
+  scandir_filter = nullptr;
+  scandir_compar = nullptr;
   if (namelist && res > 0) {
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, namelist, sizeof(*namelist));
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, *namelist, sizeof(**namelist) * res);
@@ -3011,10 +3013,11 @@ INTERCEPTOR(int, scandir64, char *dirp,
   // its metadata. See
   // https://code.google.com/p/address-sanitizer/issues/detail?id=321.
   int res =
-      REAL(scandir64)(dirp, namelist, filter ? wrapped_scandir64_filter : 0,
-                      compar ? wrapped_scandir64_compar : 0);
-  scandir64_filter = 0;
-  scandir64_compar = 0;
+      REAL(scandir64)(dirp, namelist,
+                      filter ? wrapped_scandir64_filter : nullptr,
+                      compar ? wrapped_scandir64_compar : nullptr);
+  scandir64_filter = nullptr;
+  scandir64_compar = nullptr;
   if (namelist && res > 0) {
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, namelist, sizeof(*namelist));
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, *namelist, sizeof(**namelist) * res);
@@ -4144,7 +4147,7 @@ INTERCEPTOR(SIZE_T, iconv, void *cd, cha
     COMMON_INTERCEPTOR_READ_RANGE(ctx, *inbuf, *inbytesleft);
   if (outbytesleft)
     COMMON_INTERCEPTOR_READ_RANGE(ctx, outbytesleft, sizeof(*outbytesleft));
-  void *outbuf_orig = outbuf ? *outbuf : 0;
+  void *outbuf_orig = outbuf ? *outbuf : nullptr;
   // FIXME: under ASan the call below may write to freed memory and corrupt
   // its metadata. See
   // https://code.google.com/p/address-sanitizer/issues/detail?id=321.

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_format.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_format.inc?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_format.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_format.inc Tue Sep 29 13:23:36 2015
@@ -13,6 +13,7 @@
 // with a few common GNU extensions.
 //
 //===----------------------------------------------------------------------===//
+
 #include <stdarg.h>
 
 static const char *parse_number(const char *p, int *out) {
@@ -191,7 +192,7 @@ static const char *scanf_parse_next(cons
       continue;
     }
     if (*p == '\0') {
-      return 0;
+      return nullptr;
     }
     // %n$
     p = maybe_parse_param_index(p, &dir->argIdx);
@@ -206,7 +207,7 @@ static const char *scanf_parse_next(cons
       p = parse_number(p, &dir->fieldWidth);
       CHECK(p);
       if (dir->fieldWidth <= 0)  // Width if at all must be non-zero
-        return 0;
+        return nullptr;
     }
     // m
     if (*p == 'm') {
@@ -226,8 +227,8 @@ static const char *scanf_parse_next(cons
       while (*p && *p != ']')
         ++p;
       if (*p == 0)
-        return 0; // unexpected end of string
-                  // Consume the closing ']'.
+        return nullptr; // unexpected end of string
+                        // Consume the closing ']'.
       ++p;
     }
     // This is unfortunately ambiguous between old GNU extension
@@ -251,7 +252,7 @@ static const char *scanf_parse_next(cons
         while (*q && *q != ']' && *q != '%')
           ++q;
         if (*q == 0 || *q == '%')
-          return 0;
+          return nullptr;
         p = q + 1; // Consume the closing ']'.
         dir->maybeGnuMalloc = true;
       }
@@ -395,7 +396,7 @@ static const char *printf_parse_next(con
       continue;
     }
     if (*p == '\0') {
-      return 0;
+      return nullptr;
     }
     // %n$
     p = maybe_parse_param_index(p, &dir->precisionIdx);
@@ -408,7 +409,7 @@ static const char *printf_parse_next(con
     p = maybe_parse_number_or_star(p, &dir->fieldWidth,
                                    &dir->starredWidth);
     if (!p)
-      return 0;
+      return nullptr;
     // Precision
     if (*p == '.') {
       ++p;
@@ -416,7 +417,7 @@ static const char *printf_parse_next(con
       p = maybe_parse_number_or_star(p, &dir->fieldPrecision,
                                      &dir->starredPrecision);
       if (!p)
-        return 0;
+        return nullptr;
       // m$
       if (dir->starredPrecision) {
         p = maybe_parse_param_index(p, &dir->precisionIdx);
@@ -556,4 +557,4 @@ static void printf_common(void *ctx, con
   }
 }
 
-#endif  // SANITIZER_INTERCEPT_PRINTF
+#endif // SANITIZER_INTERCEPT_PRINTF

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc Tue Sep 29 13:23:36 2015
@@ -520,7 +520,7 @@ static const ioctl_desc *ioctl_table_loo
   if (left == right && ioctl_table[left].req == req)
     return ioctl_table + left;
   else
-    return 0;
+    return nullptr;
 }
 
 static bool ioctl_decode(unsigned req, ioctl_desc *desc) {
@@ -567,7 +567,7 @@ static const ioctl_desc *ioctl_lookup(un
       (desc->type == ioctl_desc::READWRITE || desc->type == ioctl_desc::WRITE ||
        desc->type == ioctl_desc::READ))
     return desc;
-  return 0;
+  return nullptr;
 }
 
 static void ioctl_common_pre(void *ctx, const ioctl_desc *desc, int d,

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector_interface.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector_interface.h?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector_interface.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector_interface.h Tue Sep 29 13:23:36 2015
@@ -72,10 +72,10 @@ struct DDCallback {
 struct DDetector {
   static DDetector *Create(const DDFlags *flags);
 
-  virtual DDPhysicalThread* CreatePhysicalThread() { return 0; }
+  virtual DDPhysicalThread* CreatePhysicalThread() { return nullptr; }
   virtual void DestroyPhysicalThread(DDPhysicalThread *pt) {}
 
-  virtual DDLogicalThread* CreateLogicalThread(u64 ctx) { return 0; }
+  virtual DDLogicalThread* CreateLogicalThread(u64 ctx) { return nullptr; }
   virtual void DestroyLogicalThread(DDLogicalThread *lt) {}
 
   virtual void MutexInit(DDCallback *cb, DDMutex *m) {}
@@ -85,7 +85,7 @@ struct DDetector {
   virtual void MutexBeforeUnlock(DDCallback *cb, DDMutex *m, bool wlock) {}
   virtual void MutexDestroy(DDCallback *cb, DDMutex *m) {}
 
-  virtual DDReport *GetReport(DDCallback *cb) { return 0; }
+  virtual DDReport *GetReport(DDCallback *cb) { return nullptr; }
 };
 
 } // namespace __sanitizer

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_lfstack.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_lfstack.h?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_lfstack.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_lfstack.h Tue Sep 29 13:23:36 2015
@@ -49,8 +49,8 @@ struct LFStack {
     u64 cmp = atomic_load(&head_, memory_order_acquire);
     for (;;) {
       T *cur = (T*)(uptr)(cmp & kPtrMask);
-      if (cur == 0)
-        return 0;
+      if (!cur)
+        return nullptr;
       T *nxt = cur->next;
       u64 cnt = (cmp & kCounterMask);
       u64 xch = (u64)(uptr)nxt | cnt;
@@ -68,6 +68,6 @@ struct LFStack {
 
   atomic_uint64_t head_;
 };
-}  // namespace __sanitizer
+} // namespace __sanitizer
 
-#endif  // #ifndef SANITIZER_LFSTACK_H
+#endif // SANITIZER_LFSTACK_H

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h Tue Sep 29 13:23:36 2015
@@ -13,6 +13,7 @@
 // functions are intercepted. Instead, we implement a tiny subset of libc here.
 // FIXME: Some of functions declared in this file are in fact POSIX, not libc.
 //===----------------------------------------------------------------------===//
+
 #ifndef SANITIZER_LIBC_H
 #define SANITIZER_LIBC_H
 
@@ -75,8 +76,8 @@ uptr internal_getppid();
 uptr internal_sched_yield();
 
 // Error handling
-bool internal_iserror(uptr retval, int *rverrno = 0);
+bool internal_iserror(uptr retval, int *rverrno = nullptr);
 
-}  // namespace __sanitizer
+} // namespace __sanitizer
 
-#endif  // SANITIZER_LIBC_H
+#endif // SANITIZER_LIBC_H

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_list.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_list.h?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_list.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_list.h Tue Sep 29 13:23:36 2015
@@ -11,6 +11,7 @@
 // ThreadSanitizer, etc run-times.
 //
 //===----------------------------------------------------------------------===//
+
 #ifndef SANITIZER_LIST_H
 #define SANITIZER_LIST_H
 
@@ -29,7 +30,7 @@ struct IntrusiveList {
   friend class Iterator;
 
   void clear() {
-    first_ = last_ = 0;
+    first_ = last_ = nullptr;
     size_ = 0;
   }
 
@@ -38,11 +39,11 @@ struct IntrusiveList {
 
   void push_back(Item *x) {
     if (empty()) {
-      x->next = 0;
+      x->next = nullptr;
       first_ = last_ = x;
       size_ = 1;
     } else {
-      x->next = 0;
+      x->next = nullptr;
       last_->next = x;
       last_ = x;
       size_++;
@@ -51,7 +52,7 @@ struct IntrusiveList {
 
   void push_front(Item *x) {
     if (empty()) {
-      x->next = 0;
+      x->next = nullptr;
       first_ = last_ = x;
       size_ = 1;
     } else {
@@ -64,8 +65,8 @@ struct IntrusiveList {
   void pop_front() {
     CHECK(!empty());
     first_ = first_->next;
-    if (first_ == 0)
-      last_ = 0;
+    if (!first_)
+      last_ = nullptr;
     size_--;
   }
 
@@ -125,7 +126,7 @@ struct IntrusiveList {
       if (current_) current_ = current_->next;
       return ret;
     }
-    bool hasNext() const { return current_ != 0; }
+    bool hasNext() const { return current_ != nullptr; }
    private:
     ListTy *list_;
     ItemTy *current_;
@@ -140,6 +141,6 @@ struct IntrusiveList {
   Item *last_;
 };
 
-}  // namespace __sanitizer
+} // namespace __sanitizer
 
-#endif  // SANITIZER_LIST_H
+#endif // SANITIZER_LIST_H

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_persistent_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_persistent_allocator.h?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_persistent_allocator.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_persistent_allocator.h Tue Sep 29 13:23:36 2015
@@ -10,6 +10,7 @@
 // A fast memory allocator that does not support free() nor realloc().
 // All allocations are forever.
 //===----------------------------------------------------------------------===//
+
 #ifndef SANITIZER_PERSISTENT_ALLOCATOR_H
 #define SANITIZER_PERSISTENT_ALLOCATOR_H
 
@@ -36,7 +37,7 @@ inline void *PersistentAllocator::tryAll
   for (;;) {
     uptr cmp = atomic_load(&region_pos, memory_order_acquire);
     uptr end = atomic_load(&region_end, memory_order_acquire);
-    if (cmp == 0 || cmp + size > end) return 0;
+    if (cmp == 0 || cmp + size > end) return nullptr;
     if (atomic_compare_exchange_weak(&region_pos, &cmp, cmp + size,
                                      memory_order_acquire))
       return (void *)cmp;
@@ -68,4 +69,4 @@ inline void *PersistentAlloc(uptr sz) {
 
 } // namespace __sanitizer
 
-#endif  // SANITIZER_PERSISTENT_ALLOCATOR_H
+#endif // SANITIZER_PERSISTENT_ALLOCATOR_H

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h Tue Sep 29 13:23:36 2015
@@ -153,7 +153,7 @@ class QuarantineCache {
 
   QuarantineBatch *DequeueBatch() {
     if (list_.empty())
-      return 0;
+      return nullptr;
     QuarantineBatch *b = list_.front();
     list_.pop_front();
     SizeSub(b->size);
@@ -180,6 +180,6 @@ class QuarantineCache {
     return b;
   }
 };
-}  // namespace __sanitizer
+} // namespace __sanitizer
 
-#endif  // #ifndef SANITIZER_QUARANTINE_H
+#endif // SANITIZER_QUARANTINE_H

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stackdepot.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stackdepot.h?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stackdepot.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stackdepot.h Tue Sep 29 13:23:36 2015
@@ -10,6 +10,7 @@
 // This file is shared between AddressSanitizer and ThreadSanitizer
 // run-time libraries.
 //===----------------------------------------------------------------------===//
+
 #ifndef SANITIZER_STACKDEPOT_H
 #define SANITIZER_STACKDEPOT_H
 
@@ -23,7 +24,7 @@ namespace __sanitizer {
 struct StackDepotNode;
 struct StackDepotHandle {
   StackDepotNode *node_;
-  StackDepotHandle() : node_(0) {}
+  StackDepotHandle() : node_(nullptr) {}
   explicit StackDepotHandle(StackDepotNode *node) : node_(node) {}
   bool valid() { return node_; }
   u32 id();
@@ -66,6 +67,6 @@ class StackDepotReverseMap {
   void operator=(const StackDepotReverseMap&);
 };
 
-}  // namespace __sanitizer
+} // namespace __sanitizer
 
-#endif  // SANITIZER_STACKDEPOT_H
+#endif // SANITIZER_STACKDEPOT_H

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stackdepotbase.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stackdepotbase.h?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stackdepotbase.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stackdepotbase.h Tue Sep 29 13:23:36 2015
@@ -10,6 +10,7 @@
 // Implementation of a mapping from arbitrary values to unique 32-bit
 // identifiers.
 //===----------------------------------------------------------------------===//
+
 #ifndef SANITIZER_STACKDEPOTBASE_H
 #define SANITIZER_STACKDEPOTBASE_H
 
@@ -26,7 +27,7 @@ class StackDepotBase {
   typedef typename Node::args_type args_type;
   typedef typename Node::handle_type handle_type;
   // Maps stack trace to an unique id.
-  handle_type Put(args_type args, bool *inserted = 0);
+  handle_type Put(args_type args, bool *inserted = nullptr);
   // Retrieves a stored stack trace by the id.
   args_type Get(u32 id);
 
@@ -66,7 +67,7 @@ Node *StackDepotBase<Node, kReservedBits
       return s;
     }
   }
-  return 0;
+  return nullptr;
 }
 
 template <class Node, int kReservedBits, int kTabSizeLog>
@@ -172,5 +173,6 @@ void StackDepotBase<Node, kReservedBits,
   }
 }
 
-}  // namespace __sanitizer
-#endif  // SANITIZER_STACKDEPOTBASE_H
+} // namespace __sanitizer
+
+#endif // SANITIZER_STACKDEPOTBASE_H

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h?rev=248816&r1=248815&r2=248816&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_thread_registry.h Tue Sep 29 13:23:36 2015
@@ -79,7 +79,8 @@ class ThreadRegistry {
 
   ThreadRegistry(ThreadContextFactory factory, u32 max_threads,
                  u32 thread_quarantine_size, u32 max_reuse = 0);
-  void GetNumberOfThreads(uptr *total = 0, uptr *running = 0, uptr *alive = 0);
+  void GetNumberOfThreads(uptr *total = nullptr, uptr *running = nullptr,
+                          uptr *alive = nullptr);
   uptr GetMaxAliveThreads();
 
   void Lock() { mtx_.Lock(); }
@@ -142,7 +143,6 @@ class ThreadRegistry {
 
 typedef GenericScopedLock<ThreadRegistry> ThreadRegistryLock;
 
-}  // namespace __sanitizer
-
-#endif  // SANITIZER_THREAD_REGISTRY_H
+} // namespace __sanitizer
 
+#endif // SANITIZER_THREAD_REGISTRY_H




More information about the llvm-commits mailing list