Skip to content

Commit 1fc4e1f

Browse files
[MERGE #5476 @Penguinwizzard] Fix a set of permissive- issues
Merge pull request #5476 from Penguinwizzard:permissiveminus This is a set of fixes for some of the issues that permissive- hits in our codebase. There's a few more (~15 or so right now) that I didn't get around to yet, and won't address in this PR (they tend to look like they need more extensive changes to address). Fixes #4596 Fixes #5189
2 parents 2d76ace + dd8b53c commit 1fc4e1f

File tree

13 files changed

+107
-77
lines changed

13 files changed

+107
-77
lines changed

lib/Backend/GlobHashTable.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,13 @@ class ValueHashTable
329329
{
330330
_TYPENAME SListBase<HashBucket>::Iterator iter2(&this2->table[i]);
331331
iter2.Next();
332-
FOREACH_SLISTBASE_ENTRY_EDITING((HashBucket), bucket, &this->table[i], iter)
332+
FOREACH_SLISTBASE_ENTRY_EDITING(HashBucket, bucket, &this->table[i], iter)
333333
{
334334
while (iter2.IsValid() && bucket.value < iter2.Data().value)
335335
{
336336
HashBucket * newBucket = iter.InsertNodeBefore(this->alloc);
337337
newBucket->value = iter2.Data().value;
338-
newBucket->element = fn(null, iter2.Data().element);
338+
newBucket->element = fn(nullptr, iter2.Data().element);
339339
iter2.Next();
340340
}
341341

@@ -354,7 +354,7 @@ class ValueHashTable
354354
{
355355
HashBucket * newBucket = iter.InsertNodeBefore(this->alloc);
356356
newBucket->value = iter2.Data().value;
357-
newBucket->element = fn(null, iter2.Data().element);
357+
newBucket->element = fn(nullptr, iter2.Data().element);
358358
iter2.Next();
359359
}
360360
}

lib/Common/CommonMin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ using namespace Memory;
5353
#include "DataStructures/SList.h"
5454
#include "DataStructures/DList.h"
5555
#include "DataStructures/KeyValuePair.h"
56-
#include "DataStructures/BaseDictionary.h"
5756
#include "DataStructures/DictionaryEntry.h"
57+
#include "DataStructures/BaseDictionary.h"
5858
#include "DataStructures/ClusterList.h"
5959

6060
// === Configurations Header ===

lib/Common/DataStructures/ClusterList.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class ClusterList
4444
, consolidated(true)
4545
#endif
4646
{
47-
list = AllocatorNewArrayLeaf(TAllocator, this->alloc, indexType, maxCount);
48-
for (indextype i = 0; i < maxIndex; i++)
47+
list = AllocatorNewArrayLeaf(TAllocator, this->alloc, indexType, maxIndex);
48+
for (indexType i = 0; i < maxIndex; i++)
4949
{
5050
list[i] = i;
5151
}
@@ -68,7 +68,7 @@ class ClusterList
6868
{
6969
if (this->list != nullptr)
7070
{
71-
AllocatorDeleteArrayLeaf(TAllocator, this->alloc, maxCount, this->list);
71+
AllocatorDeleteArrayLeaf(TAllocator, this->alloc, maxIndex, this->list);
7272
this->list = nullptr;
7373
}
7474
}
@@ -86,7 +86,7 @@ class ClusterList
8686
// Reset the list; useful if we're re-using the data structure
8787
void Reset()
8888
{
89-
for (indextype i = 0; i < maxIndex; i++)
89+
for (indexType i = 0; i < maxIndex; i++)
9090
{
9191
list[i] = i;
9292
}
@@ -313,7 +313,7 @@ class SegmentClusterList
313313
{
314314
if (backingStore[i] != nullptr)
315315
{
316-
AllocatorDeleteArrayLeaf(TAllocator, alloc, numPerSegment, backingstore[i]);
316+
AllocatorDeleteArrayLeaf(TAllocator, alloc, numPerSegment, backingStore[i]);
317317
backingStore[i] = nullptr;
318318
}
319319
}

lib/Common/DataStructures/EvalMapString.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace Js
3434
EvalMapStringInternal& operator=(void * str)
3535
{
3636
Assert(str == null);
37-
memset(this, 0, sizeof(EvalMapString));
37+
memset(this, 0, sizeof(*this));
3838
return (*this);
3939
}
4040

lib/Common/DataStructures/List.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ namespace JsUtil
341341
template <typename TConditionalFunction>
342342
bool Last(TConditionalFunction function, T& outElement)
343343
{
344-
for (int i = count - 1; i >= 0; --i)
344+
for (int i = this->count - 1; i >= 0; --i)
345345
{
346346
if (function(this->buffer[i]))
347347
{
@@ -420,7 +420,7 @@ namespace JsUtil
420420
JsUtil::ExternalApi::RaiseOnIntOverflow();
421421
}
422422

423-
js_memcpy_s(buffer + this->count, availableByteSpace, items, givenBufferSize);
423+
js_memcpy_s(this->buffer + this->count, availableByteSpace, items, givenBufferSize);
424424
this->count = requiredSize;
425425

426426
return requiredSize; //Returns count

lib/Common/Memory/AutoAllocatorObjectPtr.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ class AutoAllocatorArrayPtr : public BasePtr<T>
6161
private:
6262
void Clear()
6363
{
64-
if (ptr != nullptr)
64+
if (this->ptr != nullptr)
6565
{
66-
DeleteArray<TAllocator>(m_allocator, m_elementCount, ptr);
67-
ptr = nullptr;
66+
DeleteArray<TAllocator>(m_allocator, this->m_elementCount, this->ptr);
67+
this->ptr = nullptr;
6868
}
6969
}
7070
};
@@ -98,14 +98,14 @@ class AutoAllocatorObjectArrayPtr : public AutoAllocatorArrayPtr<T*, ArrayAlloca
9898
private:
9999
void Clear()
100100
{
101-
if (ptr != nullptr)
101+
if (this->ptr != nullptr)
102102
{
103-
for (size_t i = 0; i < m_elementCount; i++)
103+
for (size_t i = 0; i < this->m_elementCount; i++)
104104
{
105-
if (ptr[i] != nullptr)
105+
if (this->ptr[i] != nullptr)
106106
{
107-
DeleteObject<TAllocator>(m_allocator, ptr[i]);
108-
ptr[i] = nullptr;
107+
DeleteObject<TAllocator>(this->m_allocator, this->ptr[i]);
108+
this->ptr[i] = nullptr;
109109
}
110110
}
111111
}

lib/Common/Memory/AutoPtr.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,18 @@ class AutoArrayAndItemsPtr : public AutoArrayPtr<T>
7676
private:
7777
void Clear()
7878
{
79-
if (ptr != nullptr){
79+
if (this->ptr != nullptr){
8080
for (size_t i = 0; i < this->m_elementCount; i++)
8181
{
82-
if (ptr[i] != nullptr)
82+
if (this->ptr[i] != nullptr)
8383
{
84-
ptr[i]->CleanUp();
85-
ptr[i] = nullptr;
84+
this->ptr[i]->CleanUp();
85+
this->ptr[i] = nullptr;
8686
}
8787
}
8888

89-
HeapDeleteArray(m_elementCount, ptr);
90-
ptr = nullptr;
89+
HeapDeleteArray(this->m_elementCount, this->ptr);
90+
this->ptr = nullptr;
9191
}
9292
}
9393
};

lib/Common/PlatformAgnostic/Arrays.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace Arrays
3131
bool GetLocaleSeparator(char16* szSeparator, uint32* sepOutLength, uint32 sepBufferSize);
3232

3333
template <uint32 sepBufferSize>
34-
inline bool GetLocaleSeparator(char16(&szSepatator)[sepBufferSize], uint32 *sepOutLength)
34+
inline bool GetLocaleSeparator(char16(&szSeparator)[sepBufferSize], uint32 *sepOutLength)
3535
{
3636
return GetLocaleSeparator(szSeparator, sepOutLength, sepBufferSize);
3737
}

lib/Parser/Parse.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,6 @@ bool Parser::IsES6DestructuringEnabled() const
3131
return m_scriptContext->GetConfig()->IsES6DestructuringEnabled();
3232
}
3333

34-
struct StmtNest
35-
{
36-
union
37-
{
38-
struct
39-
{
40-
ParseNodeStmt * pnodeStmt; // This statement node.
41-
};
42-
struct
43-
{
44-
bool isDeferred : 1;
45-
OpCode op; // This statement operation.
46-
};
47-
};
48-
LabelId* pLabelId; // Labels for this statement.
49-
StmtNest *pstmtOuter; // Enclosing statement.
50-
51-
OpCode GetNop() const
52-
{
53-
AnalysisAssert(isDeferred || pnodeStmt != nullptr);
54-
return isDeferred ? op : pnodeStmt->nop;
55-
}
56-
};
57-
5834
struct BlockInfoStack
5935
{
6036
StmtNest pstmt;

lib/Parser/Parse.h

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,32 @@ struct PidRefStack;
7676

7777
struct DeferredFunctionStub;
7878

79-
struct StmtNest;
8079
struct BlockInfoStack;
80+
81+
struct StmtNest
82+
{
83+
union
84+
{
85+
struct
86+
{
87+
ParseNodeStmt * pnodeStmt; // This statement node.
88+
};
89+
struct
90+
{
91+
bool isDeferred : 1;
92+
OpCode op; // This statement operation.
93+
};
94+
};
95+
LabelId* pLabelId; // Labels for this statement.
96+
StmtNest *pstmtOuter; // Enclosing statement.
97+
98+
inline OpCode GetNop() const
99+
{
100+
AnalysisAssert(isDeferred || pnodeStmt != nullptr);
101+
return isDeferred ? op : pnodeStmt->nop;
102+
}
103+
};
104+
81105
struct ParseContext
82106
{
83107
LPCUTF8 pszSrc;

0 commit comments

Comments
 (0)