diff --git a/clang/lib/Format/SortJavaScriptImports.cpp b/clang/lib/Format/SortJavaScriptImports.cpp --- a/clang/lib/Format/SortJavaScriptImports.cpp +++ b/clang/lib/Format/SortJavaScriptImports.cpp @@ -133,7 +133,10 @@ public: JavaScriptImportSorter(const Environment &Env, const FormatStyle &Style) : TokenAnalyzer(Env, Style), - FileContents(Env.getSourceManager().getBufferData(Env.getFileID())) {} + FileContents(Env.getSourceManager().getBufferData(Env.getFileID())) { + // FormatToken.Tok starts out in an uninitialized state. + invalidToken.Tok.startToken(); + } std::pair analyze(TokenAnnotator &Annotator, @@ -232,7 +235,6 @@ if (!Current || Current == LineEnd->Next) { // Set the current token to an invalid token, so that further parsing on // this line fails. - invalidToken.Tok.setKind(tok::unknown); Current = &invalidToken; } }