[PATCH] D50967: [Preamble] Fix an undefined behavior when checking an empty preamble can be reused.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 22 00:51:52 PDT 2018
hokein updated this revision to Diff 161891.
hokein added a comment.
Use the std::equal to replace the memcmp.
Repository:
rC Clang
https://reviews.llvm.org/D50967
Files:
lib/Frontend/PrecompiledPreamble.cpp
Index: lib/Frontend/PrecompiledPreamble.cpp
===================================================================
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -426,8 +426,8 @@
// new main file.
if (PreambleBytes.size() != Bounds.Size ||
PreambleEndsAtStartOfLine != Bounds.PreambleEndsAtStartOfLine ||
- memcmp(PreambleBytes.data(), MainFileBuffer->getBufferStart(),
- Bounds.Size) != 0)
+ !std::equal(PreambleBytes.begin(), PreambleBytes.end(),
+ MainFileBuffer->getBuffer().begin()))
return false;
// The preamble has not changed. We may be able to re-use the precompiled
// preamble.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50967.161891.patch
Type: text/x-patch
Size: 688 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180822/a2551e76/attachment.bin>
More information about the cfe-commits
mailing list