[PATCH] D144708: [clangd] Fix UB in scanPreamble
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 24 01:38:18 PST 2023
kadircet marked an inline comment as done.
kadircet added inline comments.
================
Comment at: clang-tools-extra/clangd/Preamble.cpp:351
auto PreambleContents =
- llvm::MemoryBuffer::getMemBufferCopy(Contents.substr(0, Bounds.Size));
+ llvm::MemoryBuffer::getMemBufferCopy(PI.Contents.substr(0, Bounds.Size));
auto Clang = prepareCompilerInstance(
----------------
hokein wrote:
> Looks like we have an extra cost here -- the std::string.substr will construct a new string everytime, we could save it by using `llvm::StringRef(PI.Contents).substr(0, Bounds.Size)`.
thanks!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144708/new/
https://reviews.llvm.org/D144708
More information about the cfe-commits
mailing list