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;


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;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to