mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-10 17:03:13 +01:00
Correct issues found by AddressSanitizer.
This commit is contained in:
@@ -32,12 +32,20 @@ hash_t Identifier::hashCode()
|
||||
|
||||
bool Identifier::equals(RootObject *o)
|
||||
{
|
||||
#if IN_LLVM // ASan
|
||||
return this == o || strncmp(string,o->toChars(),len+1) == 0;
|
||||
#else
|
||||
return this == o || memcmp(string,o->toChars(),len+1) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int Identifier::compare(RootObject *o)
|
||||
{
|
||||
#if IN_LLVM // ASan
|
||||
return strncmp(string, o->toChars(), len + 1);
|
||||
#else
|
||||
return memcmp(string, o->toChars(), len + 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
char *Identifier::toChars()
|
||||
@@ -60,12 +68,21 @@ const char *Identifier::toHChars2()
|
||||
{ p = toChars();
|
||||
if (*p == '_')
|
||||
{
|
||||
#if IN_LLVM // ASan
|
||||
if (strncmp(p, "_staticCtor", 11) == 0)
|
||||
p = "static this";
|
||||
else if (strncmp(p, "_staticDtor", 11) == 0)
|
||||
p = "static ~this";
|
||||
else if (strncmp(p, "__invariant", 11) == 0)
|
||||
p = "invariant";
|
||||
#else
|
||||
if (memcmp(p, "_staticCtor", 11) == 0)
|
||||
p = "static this";
|
||||
else if (memcmp(p, "_staticDtor", 11) == 0)
|
||||
p = "static ~this";
|
||||
else if (memcmp(p, "__invariant", 11) == 0)
|
||||
p = "invariant";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -311,7 +311,11 @@ const char *ClassDeclaration::mangle(bool isv)
|
||||
this == object ||
|
||||
this == Type::typeinfoclass ||
|
||||
this == Module::moduleinfo ||
|
||||
#if IN_LLVM // ASan
|
||||
strncmp(ident->toChars(), "TypeInfo_", 9) == 0
|
||||
#else
|
||||
memcmp(ident->toChars(), "TypeInfo_", 9) == 0
|
||||
#endif
|
||||
)
|
||||
parent = NULL;
|
||||
|
||||
|
||||
@@ -138,6 +138,14 @@ void Mem::addroots(char* pStart, char* pEnd)
|
||||
|
||||
/* =================================================== */
|
||||
|
||||
#if defined(__has_feature)
|
||||
#if !__has_feature(address_sanitizer)
|
||||
#define DEFINE_NEW_DELETE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(DEFINE_NEW_DELETE)
|
||||
|
||||
#if IN_DMD
|
||||
|
||||
/* Allocate, but never release
|
||||
@@ -209,3 +217,6 @@ void operator delete(void *p)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -278,9 +278,13 @@ unsigned *Scope::saveFieldInit()
|
||||
{
|
||||
size_t dim = fieldinit_dim;
|
||||
fi = new unsigned[dim];
|
||||
#if IN_LLVM // ASan
|
||||
memcpy(fi, fieldinit, sizeof(*fi) * dim);
|
||||
#else
|
||||
fi[0] = dim;
|
||||
for (size_t i = 0; i < dim; i++)
|
||||
fi[i] = fieldinit[i];
|
||||
#endif
|
||||
}
|
||||
return fi;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user