Author: hokein Date: Fri Oct 19 01:35:24 2018 New Revision: 344777 URL: http://llvm.org/viewvc/llvm-project?rev=344777&view=rev Log: [clangd] Remove the overflow log.
Summary: LLVM codebase has generated files (all are build/Target/XXX/*.inc) that exceed the MaxLine & MaxColumn. Printing these log would be noisy. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53400 Modified: clang-tools-extra/trunk/clangd/XRefs.cpp clang-tools-extra/trunk/clangd/index/Index.cpp clang-tools-extra/trunk/clangd/index/Index.h clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp Modified: clang-tools-extra/trunk/clangd/XRefs.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=344777&r1=344776&r2=344777&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/XRefs.cpp (original) +++ clang-tools-extra/trunk/clangd/XRefs.cpp Fri Oct 19 01:35:24 2018 @@ -37,6 +37,11 @@ const Decl *getDefinition(const Decl *D) return nullptr; } +void logIfOverflow(const SymbolLocation &Loc) { + if (Loc.Start.hasOverflow() || Loc.End.hasOverflow()) + log("Possible overflow in symbol location: {0}", Loc); +} + // Convert a SymbolLocation to LSP's Location. // HintPath is used to resolve the path of URI. // FIXME: figure out a good home for it, and share the implementation with @@ -61,6 +66,7 @@ llvm::Optional<Location> toLSPLocation(c LSPLoc.range.start.character = Loc.Start.column(); LSPLoc.range.end.line = Loc.End.line(); LSPLoc.range.end.character = Loc.End.column(); + logIfOverflow(Loc); return LSPLoc; } Modified: clang-tools-extra/trunk/clangd/index/Index.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=344777&r1=344776&r2=344777&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/index/Index.cpp (original) +++ clang-tools-extra/trunk/clangd/index/Index.cpp Fri Oct 19 01:35:24 2018 @@ -23,7 +23,6 @@ constexpr uint32_t SymbolLocation::Posit constexpr uint32_t SymbolLocation::Position::MaxColumn; void SymbolLocation::Position::setLine(uint32_t L) { if (L > MaxLine) { - log("Set an overflowed Line {0}", L); Line = MaxLine; return; } @@ -31,7 +30,6 @@ void SymbolLocation::Position::setLine(u } void SymbolLocation::Position::setColumn(uint32_t Col) { if (Col > MaxColumn) { - log("Set an overflowed Column {0}", Col); Column = MaxColumn; return; } Modified: clang-tools-extra/trunk/clangd/index/Index.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=344777&r1=344776&r2=344777&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/index/Index.h (original) +++ clang-tools-extra/trunk/clangd/index/Index.h Fri Oct 19 01:35:24 2018 @@ -43,6 +43,10 @@ struct SymbolLocation { void setColumn(uint32_t Column); uint32_t column() const { return Column; } + bool hasOverflow() const { + return Line >= MaxLine || Column >= MaxColumn; + } + static constexpr uint32_t MaxLine = (1 << 20) - 1; static constexpr uint32_t MaxColumn = (1 << 12) - 1; Modified: clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp?rev=344777&r1=344776&r2=344777&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp Fri Oct 19 01:35:24 2018 @@ -46,10 +46,15 @@ TEST(SymbolLocation, Position) { EXPECT_EQ(1u, Pos.line()); Pos.setColumn(2); EXPECT_EQ(2u, Pos.column()); + EXPECT_FALSE(Pos.hasOverflow()); Pos.setLine(Position::MaxLine + 1); // overflow + EXPECT_TRUE(Pos.hasOverflow()); EXPECT_EQ(Pos.line(), Position::MaxLine); + Pos.setLine(1); // reset the overflowed line. + Pos.setColumn(Position::MaxColumn + 1); // overflow + EXPECT_TRUE(Pos.hasOverflow()); EXPECT_EQ(Pos.column(), Position::MaxColumn); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits