Added detection for clang compiler and fixed various warnings triggered by it (bug 4878, r=dvander).
This commit is contained in:
parent
0b06d3412e
commit
939bc00b2b
@ -69,15 +69,18 @@ class SM:
|
||||
|
||||
#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')
|
||||
@ -85,16 +88,18 @@ class SM:
|
||||
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':
|
||||
@ -130,7 +135,7 @@ class SM:
|
||||
#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')
|
||||
@ -141,7 +146,7 @@ class SM:
|
||||
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')
|
||||
|
@ -410,7 +410,7 @@ size_t LibrarySystem::GetFileFromPath(char *buffer, size_t maxlength, const char
|
||||
size_t length = strlen(path);
|
||||
|
||||
for (size_t i = length - 1;
|
||||
i >= 0 && i <= length - 1;
|
||||
i <= length - 1;
|
||||
i--)
|
||||
{
|
||||
if (path[i] == '/'
|
||||
|
@ -872,7 +872,7 @@ bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listene
|
||||
ptr = save_ptr;
|
||||
|
||||
/* Lastly, strip ending whitespace off */
|
||||
for (size_t i=len-1; i>=0 && i<len; i--)
|
||||
for (size_t i=len-1; i<len; i--)
|
||||
{
|
||||
if (g_ws_chartable[(unsigned char)ptr[i]])
|
||||
{
|
||||
|
@ -37,7 +37,6 @@
|
||||
template <typename T>
|
||||
class FastLink
|
||||
{
|
||||
friend class iterator;
|
||||
public:
|
||||
struct FastLinkNode
|
||||
{
|
||||
|
@ -142,7 +142,7 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late
|
||||
|
||||
/* Store name of game directory by itself */
|
||||
size_t len = strlen(gamepath);
|
||||
for (size_t i = len - 1; i >= 0; i--)
|
||||
for (size_t i = len - 1; i < len; i--)
|
||||
{
|
||||
if (gamepath[i] == PLATFORM_SEP_CHAR)
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ CallConvention CallWrapper::GetCallConvention()
|
||||
|
||||
const PassEncode *CallWrapper::GetParamInfo(unsigned int num)
|
||||
{
|
||||
if (num + 1 > GetParamCount() || num < 0)
|
||||
if (num + 1 > GetParamCount())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -170,7 +170,7 @@ SourceHook::ProtoInfo::CallConvention CallWrapper::GetSHCallConvention()
|
||||
|
||||
const SourceHook::PassInfo * CallWrapper::GetSHParamInfo(unsigned int num)
|
||||
{
|
||||
if (num + 1 > GetParamCount() || num < 0)
|
||||
if (num + 1 > GetParamCount())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ IResultRow *MyBoundResults::FetchRow()
|
||||
{
|
||||
if (mysql_stmt_bind_result(m_stmt, m_bind) != 0)
|
||||
{
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
m_bUpdatedBinds = false;
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ for i in SM.sdkInfo:
|
||||
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'jit'))
|
||||
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'jit', 'x86'))
|
||||
|
||||
if compiler.cc.name == 'gcc':
|
||||
compiler['CFLAGS'].append('-Wno-parentheses')
|
||||
if compiler.cc.name == 'gcc' or compiler.cc.name == 'clang':
|
||||
compiler['CFLAGS'].append('-Wno-parentheses')
|
||||
|
||||
if i != 'ep1':
|
||||
compiler['CDEFINES'].append('HOOKING_ENABLED')
|
||||
|
@ -167,7 +167,7 @@ IDatabase *SqDriver::Connect(const DatabaseInfo *info, bool persistent, char *er
|
||||
|
||||
/* Chop any filename off */
|
||||
for (size_t i = len-1;
|
||||
i >= 0 && i <= len-1;
|
||||
i <= len-1;
|
||||
i--)
|
||||
{
|
||||
if (IsPathSepChar(path[i]))
|
||||
|
@ -3,7 +3,7 @@ import os
|
||||
|
||||
sdk = SM.sdkInfo['ep2v']
|
||||
compiler = SM.DefaultHL2Compiler('extensions/tf2', 'ep2v')
|
||||
if compiler.cc.name == 'gcc':
|
||||
if compiler.cc.name == 'gcc' or compiler.cc.name == 'clang':
|
||||
compiler['CFLAGS'].append('-Wno-parentheses')
|
||||
|
||||
name = 'game.tf2.ext.' + sdk['ext']
|
||||
|
@ -293,7 +293,7 @@ DLL_EXPORT void *CreateInterface(const char *iface, int *ret)
|
||||
}
|
||||
|
||||
size_t len = strlen(thisfile);
|
||||
for (size_t iter=len-1; iter>=0 && iter<len; iter--)
|
||||
for (size_t iter=len-1; iter<len; iter--)
|
||||
{
|
||||
if (IsPathSepChar(thisfile[iter]))
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ compiler['CINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'sourc
|
||||
compiler['CINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'sourcepawn', 'compiler'))
|
||||
compiler['CINCLUDES'].append(os.path.join(AMBuild.outputFolder, 'includes'))
|
||||
|
||||
if compiler.cc.name == 'gcc':
|
||||
if compiler.cc.name == 'gcc' or compiler.cc.name == 'clang':
|
||||
compiler['CFLAGS'].extend(['-Wno-parentheses', '-Wno-format'])
|
||||
if AMBuild.target['platform'] == 'linux':
|
||||
compiler['POSTLINKFLAGS'].extend(['-lgcc', '-lm'])
|
||||
|
@ -579,7 +579,7 @@ static void inst_binary_name(char *binfname)
|
||||
|
||||
binptr = NULL;
|
||||
len = strlen(binfname);
|
||||
for (i = len - 1; i >= 0 && i < len; i--)
|
||||
for (i = len - 1; i < len; i--)
|
||||
{
|
||||
if (binfname[i] == '/'
|
||||
#if defined WIN32 || defined _WIN32
|
||||
|
@ -98,7 +98,7 @@ IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file
|
||||
size_t len;
|
||||
|
||||
len = strlen(file);
|
||||
for (size_t i = len - 1; i >= 0 && i < len; i--)
|
||||
for (size_t i = len - 1; i < len; i--)
|
||||
{
|
||||
if (file[i] == '/'
|
||||
#if defined WIN32
|
||||
|
Loading…
Reference in New Issue
Block a user