Skip to content

Commit

Permalink
Provide MSVC-friendly wrapper for this==nullptr
Browse files Browse the repository at this point in the history
MSVC neither supports the attribute we've used, nor deletes the check.
  • Loading branch information
ppenzin authored and rhuanjl committed Apr 18, 2024
1 parent 5cdd17f commit 2a574fa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Common/DataStructures/ImmutableList.h
Original file line number Diff line number Diff line change
Expand Up @@ -749,12 +749,16 @@ namespace regex
return result;
}

bool __attribute__((noinline)) CheckNull( void* obj ) { return obj == nullptr; }
#ifndef _MSC_VER
bool __attribute__((noinline)) CheckEq(void* obj1, void *obj2) { return obj1 == obj2; }
#else
#define CheckEq(a, b) (a) == (b)
#endif

// Info: Return true if the list is empty.
bool IsEmpty()
{
return CheckNull(this);
return CheckEq(this, Empty());
}

// Info: Return a list containing the given single value
Expand Down

0 comments on commit 2a574fa

Please # to comment.