[PATCH] D50967: [Preamble] Fix an undefined behavior when checking an empty preamble can be reused.

Haojian Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 22 05:34:57 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL340403: [Preamble] Fix an undefined behavior when checking an empty preamble can be… (authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50967

Files:
  cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp


Index: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
===================================================================
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
+++ cfe/trunk/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.161928.patch
Type: text/x-patch
Size: 718 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180822/2ed52d47/attachment.bin>


More information about the llvm-commits mailing list