Skip to content

Commit 084e57b

Browse files
committed
[libSyntax] Don't set hot use memory region if source is empty
If the source is empty, the start of the copied buffer is a nullptr which doesn't live inside the SyntaxArena's bump allocator. Thus the assert inside `setHotUseMemoryArea` fails.
1 parent 95cf4f3 commit 084e57b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/SyntaxParse/SyntaxTreeCreator.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ SyntaxTreeCreator::SyntaxTreeCreator(SourceManager &SM, unsigned bufferID,
3636
const char *Data = BufferContent.data();
3737
Arena->copyStringToArenaIfNecessary(Data, BufferContent.size());
3838
ArenaSourceBuffer = StringRef(Data, BufferContent.size());
39-
Arena->setHotUseMemoryRegion(ArenaSourceBuffer.begin(),
40-
ArenaSourceBuffer.end());
39+
if (!ArenaSourceBuffer.empty()) {
40+
Arena->setHotUseMemoryRegion(ArenaSourceBuffer.begin(),
41+
ArenaSourceBuffer.end());
42+
}
4143
}
4244

4345
SyntaxTreeCreator::~SyntaxTreeCreator() = default;

0 commit comments

Comments
 (0)