mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Fix Clang static analysis warnings
This commit is contained in:
@@ -230,8 +230,14 @@ public:
|
||||
ElementType operator[] (const int index) const
|
||||
{
|
||||
const ScopedLockType lock (getLock());
|
||||
return isPositiveAndBelow (index, numUsed) ? data.elements [index]
|
||||
: ElementType();
|
||||
|
||||
if (isPositiveAndBelow (index, numUsed))
|
||||
{
|
||||
bassert (data.elements != nullptr);
|
||||
return data.elements [index];
|
||||
}
|
||||
|
||||
return ElementType();
|
||||
}
|
||||
|
||||
/** Returns one of the elements in the array, without checking the index passed in.
|
||||
@@ -246,7 +252,7 @@ public:
|
||||
inline ElementType getUnchecked (const int index) const
|
||||
{
|
||||
const ScopedLockType lock (getLock());
|
||||
bassert (isPositiveAndBelow (index, numUsed));
|
||||
bassert (isPositiveAndBelow (index, numUsed) && data.elements != nullptr);
|
||||
return data.elements [index];
|
||||
}
|
||||
|
||||
@@ -262,7 +268,7 @@ public:
|
||||
inline ElementType& getReference (const int index) const noexcept
|
||||
{
|
||||
const ScopedLockType lock (getLock());
|
||||
bassert (isPositiveAndBelow (index, numUsed));
|
||||
bassert (isPositiveAndBelow (index, numUsed) && data.elements != nullptr);
|
||||
return data.elements [index];
|
||||
}
|
||||
|
||||
@@ -383,6 +389,7 @@ public:
|
||||
{
|
||||
const ScopedLockType lock (getLock());
|
||||
data.ensureAllocatedSize (numUsed + 1);
|
||||
bassert (data.elements != nullptr);
|
||||
|
||||
if (isPositiveAndBelow (indexToInsertAt, numUsed))
|
||||
{
|
||||
@@ -1043,5 +1050,4 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // BEAST_ARRAY_BEASTHEADER
|
||||
|
||||
@@ -103,6 +103,8 @@ public:
|
||||
{
|
||||
if (minNumElements > numAllocated)
|
||||
setAllocatedSize ((minNumElements + minNumElements / 2 + 8) & ~7);
|
||||
|
||||
bassert (numAllocated <= 0 || elements != nullptr);
|
||||
}
|
||||
|
||||
/** Minimises the amount of storage allocated so that it's no more than
|
||||
@@ -129,5 +131,4 @@ private:
|
||||
BEAST_DECLARE_NON_COPYABLE (ArrayAllocationBase)
|
||||
};
|
||||
|
||||
|
||||
#endif // BEAST_ARRAYALLOCATIONBASE_BEASTHEADER
|
||||
|
||||
@@ -124,8 +124,13 @@ public:
|
||||
inline ObjectClass* operator[] (const int index) const noexcept
|
||||
{
|
||||
const ScopedLockType lock (getLock());
|
||||
return isPositiveAndBelow (index, numUsed) ? data.elements [index]
|
||||
: static_cast <ObjectClass*> (nullptr);
|
||||
if (isPositiveAndBelow (index, numUsed))
|
||||
{
|
||||
bassert (data.elements != nullptr);
|
||||
return data.elements [index];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** Returns a pointer to the object at this index in the array, without checking whether the index is in-range.
|
||||
@@ -136,7 +141,7 @@ public:
|
||||
inline ObjectClass* getUnchecked (const int index) const noexcept
|
||||
{
|
||||
const ScopedLockType lock (getLock());
|
||||
bassert (isPositiveAndBelow (index, numUsed));
|
||||
bassert (isPositiveAndBelow (index, numUsed) && data.elements != nullptr);
|
||||
return data.elements [index];
|
||||
}
|
||||
|
||||
@@ -243,6 +248,7 @@ public:
|
||||
{
|
||||
const ScopedLockType lock (getLock());
|
||||
data.ensureAllocatedSize (numUsed + 1);
|
||||
bassert (data.elements != nullptr);
|
||||
data.elements [numUsed++] = const_cast <ObjectClass*> (newObject);
|
||||
}
|
||||
|
||||
@@ -274,6 +280,7 @@ public:
|
||||
indexToInsertAt = numUsed;
|
||||
|
||||
data.ensureAllocatedSize (numUsed + 1);
|
||||
bassert (data.elements != nullptr);
|
||||
|
||||
ObjectClass** const e = data.elements + indexToInsertAt;
|
||||
const int numToMove = numUsed - indexToInsertAt;
|
||||
@@ -426,6 +433,7 @@ public:
|
||||
numElementsToAdd = arrayToAddFrom.size() - startIndex;
|
||||
|
||||
data.ensureAllocatedSize (numUsed + numElementsToAdd);
|
||||
bassert (data.elements != nullptr);
|
||||
|
||||
while (--numElementsToAdd >= 0)
|
||||
{
|
||||
@@ -466,6 +474,7 @@ public:
|
||||
numElementsToAdd = arrayToAddFrom.size() - startIndex;
|
||||
|
||||
data.ensureAllocatedSize (numUsed + numElementsToAdd);
|
||||
bassert (data.elements != nullptr);
|
||||
|
||||
while (--numElementsToAdd >= 0)
|
||||
{
|
||||
@@ -861,5 +870,4 @@ private:
|
||||
BEAST_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OwnedArray)
|
||||
};
|
||||
|
||||
|
||||
#endif // BEAST_OWNEDARRAY_BEASTHEADER
|
||||
|
||||
@@ -292,6 +292,7 @@ public:
|
||||
{
|
||||
const ScopedLockType lock (getLock());
|
||||
data.ensureAllocatedSize (numUsed + 1);
|
||||
bassert (data.elements != nullptr);
|
||||
data.elements [numUsed++] = newObject;
|
||||
|
||||
if (newObject != nullptr)
|
||||
@@ -322,6 +323,7 @@ public:
|
||||
indexToInsertAt = numUsed;
|
||||
|
||||
data.ensureAllocatedSize (numUsed + 1);
|
||||
bassert (data.elements != nullptr);
|
||||
|
||||
ObjectClass** const e = data.elements + indexToInsertAt;
|
||||
const int numToMove = numUsed - indexToInsertAt;
|
||||
@@ -388,6 +390,7 @@ public:
|
||||
else
|
||||
{
|
||||
data.ensureAllocatedSize (numUsed + 1);
|
||||
bassert (data.elements != nullptr);
|
||||
data.elements [numUsed++] = newObject;
|
||||
}
|
||||
}
|
||||
@@ -851,5 +854,4 @@ private:
|
||||
int numUsed;
|
||||
};
|
||||
|
||||
|
||||
#endif // BEAST_REFERENCECOUNTEDARRAY_BEASTHEADER
|
||||
|
||||
@@ -78,6 +78,17 @@
|
||||
#define beast_breakDebugger { __asm int 3 }
|
||||
#endif
|
||||
|
||||
#if BEAST_CLANG && defined (__has_feature) && ! defined (BEAST_ANALYZER_NORETURN)
|
||||
#if __has_feature (attribute_analyzer_noreturn)
|
||||
inline void __attribute__((analyzer_noreturn)) beast_assert_noreturn() {}
|
||||
#define BEAST_ANALYZER_NORETURN beast_assert_noreturn();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef BEAST_ANALYZER_NORETURN
|
||||
#define BEAST_ANALYZER_NORETURN
|
||||
#endif
|
||||
|
||||
|
||||
//==============================================================================
|
||||
#if BEAST_DEBUG || DOXYGEN
|
||||
@@ -92,7 +103,7 @@
|
||||
It is only compiled in a debug build, (unless BEAST_LOG_ASSERTIONS is enabled for your build).
|
||||
@see bassert
|
||||
*/
|
||||
#define bassertfalse { beast_LogCurrentAssertion; if (beast::beast_isRunningUnderDebugger()) beast_breakDebugger; }
|
||||
#define bassertfalse { beast_LogCurrentAssertion; if (beast::beast_isRunningUnderDebugger()) beast_breakDebugger; BEAST_ANALYZER_NORETURN }
|
||||
|
||||
//==============================================================================
|
||||
/** Platform-independent assertion macro.
|
||||
|
||||
Reference in New Issue
Block a user