From 250eae24528d1f10299a8cb35591e5b3899cefec Mon Sep 17 00:00:00 2001 From: Kadir Cetinkaya Date: Mon, 29 Apr 2019 17:25:58 +0000 Subject: [PATCH] [clangd] Fix serialization logic for Origin and Flags. llvm-svn: 359470 --- clang-tools-extra/clangd/index/Serialization.cpp | 4 ++-- clang-tools-extra/clangd/unittests/SerializationTests.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/clang-tools-extra/clangd/index/Serialization.cpp b/clang-tools-extra/clangd/index/Serialization.cpp index 410cba04c09c..62eb3fcdf375 100644 --- a/clang-tools-extra/clangd/index/Serialization.cpp +++ b/clang-tools-extra/clangd/index/Serialization.cpp @@ -314,8 +314,8 @@ Symbol readSymbol(Reader &Data, llvm::ArrayRef Strings) { Sym.Definition = readLocation(Data, Strings); Sym.CanonicalDeclaration = readLocation(Data, Strings); Sym.References = Data.consumeVar(); - Sym.Flags = static_cast(Data.consumeVar()); - Sym.Origin = static_cast(Data.consumeVar()); + Sym.Flags = static_cast(Data.consume8()); + Sym.Origin = static_cast(Data.consume8()); Sym.Signature = Data.consumeString(Strings); Sym.CompletionSnippetSuffix = Data.consumeString(Strings); Sym.Documentation = Data.consumeString(Strings); diff --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp b/clang-tools-extra/clangd/unittests/SerializationTests.cpp index 3260ac68019b..c85920821a8e 100644 --- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp +++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp @@ -40,8 +40,8 @@ CanonicalDeclaration: End: Line: 1 Column: 1 -Origin: 4 -Flags: 1 +Origin: 128 +Flags: 129 Documentation: 'Foo doc' ReturnType: 'int' IncludeHeaders: @@ -115,7 +115,8 @@ TEST(SerializationTest, YAMLConversions) { EXPECT_EQ(Sym1.Documentation, "Foo doc"); EXPECT_EQ(Sym1.ReturnType, "int"); EXPECT_EQ(StringRef(Sym1.CanonicalDeclaration.FileURI), "file:///path/foo.h"); - EXPECT_EQ(Sym1.Origin, SymbolOrigin::Static); + EXPECT_EQ(Sym1.Origin, static_cast(1 << 7)); + EXPECT_EQ(static_cast(Sym1.Flags), 129); EXPECT_TRUE(Sym1.Flags & Symbol::IndexedForCodeCompletion); EXPECT_FALSE(Sym1.Flags & Symbol::Deprecated); EXPECT_THAT(Sym1.IncludeHeaders,