[PATCH] D128607: [clang-format] NFC Fix uninitialized memory problem
sstwcw via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 26 15:25:29 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG141ad3ba0571: [clang-format] Fix uninitialized memory problem (authored by sstwcw).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128607/new/
https://reviews.llvm.org/D128607
Files:
clang/lib/Format/FormatTokenLexer.cpp
Index: clang/lib/Format/FormatTokenLexer.cpp
===================================================================
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -1128,11 +1128,12 @@
return false;
size_t Len = Matches[0].size();
- Tok.setLength(Len);
- Tok.setLocation(Lex->getSourceLocation(Start, Len));
// The kind has to be an identifier so we can match it against those defined
- // in Keywords.
+ // in Keywords. The kind has to be set before the length because the setLength
+ // function checks that the kind is not an annotation.
Tok.setKind(tok::raw_identifier);
+ Tok.setLength(Len);
+ Tok.setLocation(Lex->getSourceLocation(Start, Len));
Tok.setRawIdentifierData(Start);
Lex->seek(Lex->getCurrentBufferOffset() + Len, /*IsAtStartofline=*/false);
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128607.440095.patch
Type: text/x-patch
Size: 841 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220626/b2f587c7/attachment.bin>
More information about the cfe-commits
mailing list