Author: kadircet Date: Wed Sep 25 07:12:05 2019 New Revision: 372875 URL: http://llvm.org/viewvc/llvm-project?rev=372875&view=rev Log: [clangd] Fix parseNamespaceEvents to parse the last token
Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68020 Modified: clang-tools-extra/trunk/clangd/SourceCode.cpp clang-tools-extra/trunk/clangd/unittests/SourceCodeTests.cpp Modified: clang-tools-extra/trunk/clangd/SourceCode.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/SourceCode.cpp?rev=372875&r1=372874&r2=372875&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/SourceCode.cpp (original) +++ clang-tools-extra/trunk/clangd/SourceCode.cpp Wed Sep 25 07:12:05 2019 @@ -659,6 +659,9 @@ static void lex(llvm::StringRef Code, co while (!Lex.LexFromRawLexer(Tok)) A(Tok); + // LexFromRawLexer returns true after it lexes last token, so we still have + // one more token to report. + A(Tok); } llvm::StringMap<unsigned> collectIdentifiers(llvm::StringRef Content, Modified: clang-tools-extra/trunk/clangd/unittests/SourceCodeTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/SourceCodeTests.cpp?rev=372875&r1=372874&r2=372875&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/unittests/SourceCodeTests.cpp (original) +++ clang-tools-extra/trunk/clangd/unittests/SourceCodeTests.cpp Wed Sep 25 07:12:05 2019 @@ -441,6 +441,16 @@ TEST(SourceCodeTests, VisibleNamespaces) "c::d", }, }, + { + "", + {""}, + }, + { + R"cpp( + // Parse until EOF + namespace bar{})cpp", + {""}, + }, }; for (const auto& Case : Cases) { EXPECT_EQ(Case.second, _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits