[PATCH] D29990: [clangd] Implement format on type
Benjamin Kramer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 15 10:17:35 PST 2017
bkramer added inline comments.
================
Comment at: clangd/ProtocolHandlers.cpp:117
+ // starting from there.
+ StringRef Code = Store.getDocument(DOTFP->textDocument.uri);
+ size_t CursorPos = positionToOffset(Code, DOTFP->position);
----------------
This should be a std::string in trunk, StringRef gives you a use after free.
================
Comment at: clangd/ProtocolHandlers.cpp:119
+ size_t CursorPos = positionToOffset(Code, DOTFP->position);
+ size_t PreviousLBracePos = Code.find_last_of("{", CursorPos);
+ if (PreviousLBracePos == StringRef::npos)
----------------
nit: use the character overload of this function (`Code.find_last_of('{'...`)
https://reviews.llvm.org/D29990
More information about the cfe-commits
mailing list