1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-02-20 13:54:14 +01:00

Added detection for clang compiler and fixed various warnings triggered by it (bug 4877, r=dvander).

This commit is contained in:
Scott Ehlert 2011-04-23 21:35:10 -05:00
parent 1eadc766c7
commit 29df2351c9
11 changed files with 24 additions and 19 deletions

View File

@ -67,15 +67,18 @@ class MMS:
#Set up defines
cxx = self.compiler.cxx
if isinstance(cxx, Cpp.GCC):
self.vendor = 'gcc'
if isinstance(cxx, Cpp.CompatGCC):
if isinstance(cxx, Cpp.GCC):
self.vendor = 'gcc'
elif isinstance(cxx, Cpp.Clang):
self.vendor = 'clang'
self.compiler.AddToListVar('CDEFINES', 'stricmp=strcasecmp')
self.compiler.AddToListVar('CDEFINES', '_stricmp=strcasecmp')
self.compiler.AddToListVar('CDEFINES', '_snprintf=snprintf')
self.compiler.AddToListVar('CDEFINES', '_vsnprintf=vsnprintf')
self.compiler.AddToListVar('CFLAGS', '-pipe')
self.compiler.AddToListVar('CFLAGS', '-fno-strict-aliasing')
if cxx.majorVersion >= 4:
if (self.vendor == 'gcc' and cxx.majorVersion >= 4) or self.vendor == 'clang':
self.compiler.AddToListVar('CFLAGS', '-fvisibility=hidden')
self.compiler.AddToListVar('CXXFLAGS', '-fvisibility-inlines-hidden')
self.compiler.AddToListVar('CFLAGS', '-Wall')
@ -83,16 +86,18 @@ class MMS:
self.compiler.AddToListVar('CFLAGS', '-Wno-uninitialized')
self.compiler.AddToListVar('CFLAGS', '-Wno-unused')
self.compiler.AddToListVar('CFLAGS', '-Wno-switch')
self.compiler.AddToListVar('CFLAGS', '-mfpmath=sse')
self.compiler.AddToListVar('CFLAGS', '-msse')
self.compiler.AddToListVar('CFLAGS', '-m32')
self.compiler.AddToListVar('POSTLINKFLAGS', '-m32')
self.compiler.AddToListVar('CFLAGS', '-static-libgcc')
self.compiler.AddToListVar('CXXFLAGS', '-fno-exceptions')
self.compiler.AddToListVar('CXXFLAGS', '-fno-rtti')
self.compiler.AddToListVar('CXXFLAGS', '-fno-threadsafe-statics')
self.compiler.AddToListVar('CXXFLAGS', '-Wno-non-virtual-dtor')
self.compiler.AddToListVar('CXXFLAGS', '-Wno-overloaded-virtual')
self.compiler.AddToListVar('CDEFINES', 'HAVE_STDINT_H')
if self.vendor == 'gcc':
self.compiler.AddToListVar('CFLAGS', '-mfpmath=sse')
self.compiler.AddToListVar('CFLAGS', '-static-libgcc')
elif isinstance(cxx, Cpp.MSVC):
self.vendor = 'msvc'
if AMBuild.options.debug == '1':
@ -128,7 +133,7 @@ class MMS:
#Optimization
if AMBuild.options.opt == '1':
self.compiler.AddToListVar('CDEFINES', 'NDEBUG')
if self.vendor == 'gcc':
if self.vendor == 'gcc' or self.vendor == 'clang':
self.compiler.AddToListVar('CFLAGS', '-O3')
elif self.vendor == 'msvc':
self.compiler.AddToListVar('CFLAGS', '/Ox')
@ -139,7 +144,7 @@ class MMS:
if AMBuild.options.debug == '1':
self.compiler.AddToListVar('CDEFINES', 'DEBUG')
self.compiler.AddToListVar('CDEFINES', '_DEBUG')
if self.vendor == 'gcc':
if self.vendor == 'gcc' or self.vendor == 'clang':
self.compiler.AddToListVar('CFLAGS', '-g3')
elif self.vendor == 'msvc':
self.compiler.AddToListVar('CFLAGS', '/Od')

View File

@ -470,7 +470,7 @@ void CSmmAPI::LoadAsVSP()
/* Chop off the "engine" file part */
len = strlen(engine_file);
for (size_t i = len - 1; i >= 0 && i < len; i--)
for (size_t i = len - 1; i < len; i--)
{
if (engine_file[i] == '/'
|| engine_file[i] == '\\')

View File

@ -230,7 +230,7 @@ public:
if (is_space(v[len-1]))
{
for (i=len-1; i>=0; i--)
for (i=len-1; i<len; i--)
{
if (!is_space(v[i])
|| (is_space(v[i]) && i==0))

View File

@ -464,7 +464,7 @@ public:
if (!GrowIfNeeded(1))
{
return false;
return iterator(0);
}
++m_CurrentUsedSize;

View File

@ -71,7 +71,7 @@ void UTIL_TrimRight(char *buffer)
size_t len = strlen(buffer);
/* Loop through buffer backwards while replacing whitespace chars with null chars */
for (size_t i = len - 1; i >= 0; i--)
for (size_t i = len - 1; i < len; i--)
{
if (isspace((unsigned char) buffer[i]))
{

View File

@ -326,7 +326,7 @@ void InitializeVSP()
/* Chop off the "engine" file part */
len = strlen(engine_file);
for (size_t i = len - 1; i >= 0 && i < len; i--)
for (size_t i = len - 1; i < len; i--)
{
if (engine_file[i] == '/' || engine_file[i] == '\\')
{

View File

@ -445,7 +445,7 @@ CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source
char file_path[256];
size_t len = g_Metamod.PathFormat(file_path, sizeof(file_path), "%s", file);
for (size_t i = len - 1; i >= 0 && i < len; i--)
for (size_t i = len - 1; i < len; i--)
{
if (_IsPathSepChar(file_path[i]))
{

View File

@ -87,7 +87,7 @@ void UTIL_TrimRight(char *buffer)
size_t len = strlen(buffer);
/* Loop through buffer backwards while replacing whitespace chars with null chars */
for (size_t i = len - 1; i >= 0; i--)
for (size_t i = len - 1; i < len; i--)
{
if (isspace((unsigned char) buffer[i]))
{
@ -138,7 +138,7 @@ bool UTIL_PathCmp(const char *path1, const char *path2)
/* If we're at a different non-alphanumeric, the next character MUST match */
if ((((unsigned)path1[pos1] & 0x80) && path1[pos1] != path2[pos2])
||
!isalpha(path1[pos1]) && (path1[pos1] != path2[pos2])
(!isalpha(path1[pos1]) && (path1[pos1] != path2[pos2]))
)
{
return false;

View File

@ -230,7 +230,7 @@ public:
if (is_space(v[len-1]))
{
for (i=len-1; i>=0; i--)
for (i=len-1; i<len; i--)
{
if (!is_space(v[i])
|| (is_space(v[i]) && i==0))

View File

@ -464,7 +464,7 @@ public:
if (!GrowIfNeeded(1))
{
return false;
return iterator(0);
}
++m_CurrentUsedSize;

View File

@ -125,7 +125,7 @@ mm_TrimRight(char *buffer)
size_t len = strlen(buffer);
/* Loop through buffer backwards while replacing whitespace chars with null chars */
for (size_t i = len - 1; i >= 0; i--)
for (size_t i = len - 1; i < len; i--)
{
if (isspace((unsigned char) buffer[i]))
buffer[i] = '\0';
@ -245,7 +245,7 @@ mm_PathCmp(const char *path1, const char *path2)
/* If we're at a different non-alphanumeric, the next character MUST match */
if ((((unsigned)path1[pos1] & 0x80) && path1[pos1] != path2[pos2])
||
!isalpha(path1[pos1]) && (path1[pos1] != path2[pos2])
(!isalpha(path1[pos1]) && (path1[pos1] != path2[pos2]))
)
{
return false;