fixed #12108 - Crash in `CTU::FileInfo::getErrorPath()` with Clang-built binary (#5746)

This is actually just a workaround as it seems the issue is an upstream
Clang one.
This commit is contained in:
Oliver Stöneberg 2023-12-14 17:44:09 +01:00 committed by GitHub
parent fcb41e2533
commit 61bbcbeeee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 5 deletions

View File

@ -884,7 +884,14 @@ void CheckBufferOverrun::argumentSizeError(const Token *tok, const std::string &
// CTU..
//---------------------------------------------------------------------------
namespace {
// a Clang-built executable will crash when using the anonymous MyFileInfo later on - so put it in a unique namespace for now
// see https://trac.cppcheck.net/ticket/12108 for more details
#ifdef __clang__
inline namespace CheckBufferOverrun_internal
#else
namespace
#endif
{
/** data for multifile checking */
class MyFileInfo : public Check::FileInfo {
public:

View File

@ -3402,7 +3402,14 @@ void CheckClass::unsafeClassRefMemberError(const Token *tok, const std::string &
CWE(0), Certainty::normal);
}
namespace {
// a Clang-built executable will crash when using the anonymous MyFileInfo later on - so put it in a unique namespace for now
// see https://trac.cppcheck.net/ticket/12108 for more details
#ifdef __clang__
inline namespace CheckClass_internal
#else
namespace
#endif
{
/* multifile checking; one definition rule violations */
class MyFileInfo : public Check::FileInfo {
public:

View File

@ -558,7 +558,14 @@ static bool isUnsafeUsage(const Settings *settings, const Token *vartok, MathLib
return CheckNullPointer::isPointerDeRef(vartok, unknown, settings);
}
namespace {
// a Clang-built executable will crash when using the anonymous MyFileInfo later on - so put it in a unique namespace for now
// see https://trac.cppcheck.net/ticket/12108 for more details
#ifdef __clang__
inline namespace CheckNullPointer_internal
#else
namespace
#endif
{
/* data for multifile checking */
class MyFileInfo : public Check::FileInfo {
public:
@ -573,7 +580,6 @@ namespace {
};
}
Check::FileInfo *CheckNullPointer::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const
{
const std::list<CTU::FileInfo::UnsafeUsage> &unsafeUsage = CTU::getUnsafeUsage(tokenizer, settings, isUnsafeUsage);

View File

@ -1682,7 +1682,14 @@ static bool isVariableUsage(const Settings *settings, const Token *vartok, MathL
return CheckUninitVar::isVariableUsage(vartok, settings->library, true, CheckUninitVar::Alloc::ARRAY);
}
namespace {
// a Clang-built executable will crash when using the anonymous MyFileInfo later on - so put it in a unique namespace for now
// see https://trac.cppcheck.net/ticket/12108 for more details
#ifdef __clang__
inline namespace CheckUninitVar_internal
#else
namespace
#endif
{
/* data for multifile checking */
class MyFileInfo : public Check::FileInfo {
public: