[compiler-rt] r182198 - Replace CHECK(a == b); with CHECK_EQ(a, b); throughout asan_allocator2.cc

Kostya Serebryany kcc at google.com
Mon May 20 00:42:43 PDT 2013


Thanks!

For some reason our cpplint does not catch it (it does catch simpler
variants in the same file).
% cat check.cc
void foo() {
  CHECK(0 == m->a);         // Detected.
  CHECK(FOO_BAR == 0);      // Detected.
  CHECK(FOO_BAR == m->a);   // Missed.
}
% cpplint.py --filter=-legal check.cc
check.cc:2:  Consider using CHECK_EQ instead of CHECK(a == b)
 [readability/check] [2]
check.cc:3:  Consider using CHECK_EQ instead of CHECK(a == b)
 [readability/check] [2]
Done processing check.cc
Total errors found: 2
%



Oh, how I wish to have lint integrated with clang!!

--kcc


On Sat, May 18, 2013 at 10:27 PM, Timur Iskhodzhanov <timurrrr at google.com>wrote:

> Author: timurrrr
> Date: Sat May 18 13:27:33 2013
> New Revision: 182198
>
> URL: http://llvm.org/viewvc/llvm-project?rev=182198&view=rev
> Log:
> Replace CHECK(a == b); with CHECK_EQ(a, b); throughout asan_allocator2.cc
>
> Modified:
>     compiler-rt/trunk/lib/asan/asan_allocator2.cc
>
> Modified: compiler-rt/trunk/lib/asan/asan_allocator2.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator2.cc?rev=182198&r1=182197&r2=182198&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_allocator2.cc (original)
> +++ compiler-rt/trunk/lib/asan/asan_allocator2.cc Sat May 18 13:27:33 2013
> @@ -260,7 +260,7 @@ struct QuarantineCallback {
>    }
>
>    void Recycle(AsanChunk *m) {
> -    CHECK(m->chunk_state == CHUNK_QUARANTINE);
> +    CHECK_EQ(m->chunk_state, CHUNK_QUARANTINE);
>      m->chunk_state = CHUNK_AVAILABLE;
>      CHECK_NE(m->alloc_tid, kInvalidTid);
>      CHECK_NE(m->free_tid, kInvalidTid);
> @@ -454,7 +454,7 @@ static void Deallocate(void *ptr, StackT
>      m->free_context_id = 0;
>      StackTrace::CompressStack(stack, m->FreeStackBeg(),
> m->FreeStackSize());
>    }
> -  CHECK(m->chunk_state == CHUNK_QUARANTINE);
> +  CHECK_EQ(m->chunk_state, CHUNK_QUARANTINE);
>    // Poison the region.
>    PoisonShadow(m->Beg(),
>                 RoundUpTo(m->UsedSize(), SHADOW_GRANULARITY),
> @@ -488,7 +488,7 @@ static void *Reallocate(void *old_ptr, u
>    thread_stats.reallocs++;
>    thread_stats.realloced += new_size;
>
> -  CHECK(m->chunk_state == CHUNK_ALLOCATED);
> +  CHECK_EQ(m->chunk_state, CHUNK_ALLOCATED);
>    uptr old_size = m->UsedSize();
>    uptr memcpy_size = Min(new_size, old_size);
>    void *new_ptr = Allocate(new_size, 8, stack, FROM_MALLOC, true);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130520/261dc24b/attachment.html>


More information about the llvm-commits mailing list