upsj updated this revision to Diff 424838. upsj added a comment. Review updates
- Fix inverted check-lines condition - Output InlayHintKind via ostream operators Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124344/new/ https://reviews.llvm.org/D124344 Files: clang-tools-extra/clangd/Protocol.cpp clang-tools-extra/clangd/Protocol.h clang-tools-extra/clangd/tool/Check.cpp Index: clang-tools-extra/clangd/tool/Check.cpp =================================================================== --- clang-tools-extra/clangd/tool/Check.cpp +++ clang-tools-extra/clangd/tool/Check.cpp @@ -193,14 +193,13 @@ } // Build Inlay Hints for the entire AST or the specified range - bool buildInlayHints(llvm::Optional<Range> LineRange) { + void buildInlayHints(llvm::Optional<Range> LineRange) { log("Building inlay hints"); auto Hints = inlayHints(*AST, LineRange); for (const auto &Hint : Hints) { - vlog(" {0} {1} {2}", toString(Hint.kind), Hint.position, Hint.label); + vlog(" {0} {1} {2}", Hint.kind, Hint.position, Hint.label); } - return true; } // Run AST-based features at each token in the file. @@ -219,7 +218,7 @@ unsigned End = Start + Tok.length(); Position Pos = offsetToPosition(Inputs.Contents, Start); - if (LineRange && LineRange->contains(Pos)) + if (LineRange && !LineRange->contains(Pos)) continue; trace::Span Trace("Token"); @@ -293,8 +292,9 @@ : /*Don't turn on local configs for an arbitrary temp path.*/ "")); Checker C(File, Opts); if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) || - !C.buildAST() || !C.buildInlayHints(LineRange)) + !C.buildAST()) return false; + C.buildInlayHints(LineRange); C.testLocationFeatures(LineRange, EnableCodeCompletion); log("All checks completed, {0} errors", C.ErrCount); Index: clang-tools-extra/clangd/Protocol.h =================================================================== --- clang-tools-extra/clangd/Protocol.h +++ clang-tools-extra/clangd/Protocol.h @@ -1576,10 +1576,10 @@ /// naturally when placed inline with the code. std::string label; }; -const char *toString(InlayHintKind); llvm::json::Value toJSON(const InlayHint &); bool operator==(const InlayHint &, const InlayHint &); bool operator<(const InlayHint &, const InlayHint &); +llvm::raw_ostream &operator<<(llvm::raw_ostream &, InlayHintKind); struct ReferenceContext { /// Include the declaration of the current symbol. Index: clang-tools-extra/clangd/Protocol.cpp =================================================================== --- clang-tools-extra/clangd/Protocol.cpp +++ clang-tools-extra/clangd/Protocol.cpp @@ -1345,6 +1345,10 @@ std::tie(B.position, B.range, B.kind, B.label); } +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, InlayHintKind Kind) { + return OS << toString(Kind); +} + static const char *toString(OffsetEncoding OE) { switch (OE) { case OffsetEncoding::UTF8:
Index: clang-tools-extra/clangd/tool/Check.cpp =================================================================== --- clang-tools-extra/clangd/tool/Check.cpp +++ clang-tools-extra/clangd/tool/Check.cpp @@ -193,14 +193,13 @@ } // Build Inlay Hints for the entire AST or the specified range - bool buildInlayHints(llvm::Optional<Range> LineRange) { + void buildInlayHints(llvm::Optional<Range> LineRange) { log("Building inlay hints"); auto Hints = inlayHints(*AST, LineRange); for (const auto &Hint : Hints) { - vlog(" {0} {1} {2}", toString(Hint.kind), Hint.position, Hint.label); + vlog(" {0} {1} {2}", Hint.kind, Hint.position, Hint.label); } - return true; } // Run AST-based features at each token in the file. @@ -219,7 +218,7 @@ unsigned End = Start + Tok.length(); Position Pos = offsetToPosition(Inputs.Contents, Start); - if (LineRange && LineRange->contains(Pos)) + if (LineRange && !LineRange->contains(Pos)) continue; trace::Span Trace("Token"); @@ -293,8 +292,9 @@ : /*Don't turn on local configs for an arbitrary temp path.*/ "")); Checker C(File, Opts); if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) || - !C.buildAST() || !C.buildInlayHints(LineRange)) + !C.buildAST()) return false; + C.buildInlayHints(LineRange); C.testLocationFeatures(LineRange, EnableCodeCompletion); log("All checks completed, {0} errors", C.ErrCount); Index: clang-tools-extra/clangd/Protocol.h =================================================================== --- clang-tools-extra/clangd/Protocol.h +++ clang-tools-extra/clangd/Protocol.h @@ -1576,10 +1576,10 @@ /// naturally when placed inline with the code. std::string label; }; -const char *toString(InlayHintKind); llvm::json::Value toJSON(const InlayHint &); bool operator==(const InlayHint &, const InlayHint &); bool operator<(const InlayHint &, const InlayHint &); +llvm::raw_ostream &operator<<(llvm::raw_ostream &, InlayHintKind); struct ReferenceContext { /// Include the declaration of the current symbol. Index: clang-tools-extra/clangd/Protocol.cpp =================================================================== --- clang-tools-extra/clangd/Protocol.cpp +++ clang-tools-extra/clangd/Protocol.cpp @@ -1345,6 +1345,10 @@ std::tie(B.position, B.range, B.kind, B.label); } +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, InlayHintKind Kind) { + return OS << toString(Kind); +} + static const char *toString(OffsetEncoding OE) { switch (OE) { case OffsetEncoding::UTF8:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits