Some small changes. (#20)

This commit is contained in:
ykiko
2024-12-27 11:20:11 +08:00
committed by GitHub
parent 440303b81f
commit 97d29bb96b
14 changed files with 610 additions and 150 deletions

View File

@@ -5,26 +5,26 @@
namespace clice {
/// Measure the length of the content with the specified encoding kind.
std::size_t remeasure(llvm::StringRef content, proto::PositionEncodingKind kind);
/// Convert a clang::SourceLocation to a proto::Position according to the
/// specified encoding kind. Note that `SourceLocation` in clang is one-based and
/// specified encoding kind. Note that `SourceLocation` in clang is 1-based and
/// is always encoded in UTF-8.
proto::Position toPosition(llvm::StringRef content,
clang::SourceLocation location,
proto::PositionEncodingKind kind,
const clang::SourceManager& srcMgr);
const clang::SourceManager& SM);
/// Same as above, but for a group of locations. It is more efficient than calling
/// `toLocation` multiple times. Note that the locations must be sorted.
std::vector<proto::Position> toPosition(llvm::StringRef content,
llvm::ArrayRef<clang::SourceLocation> locations,
proto::PositionEncodingKind kind,
const clang::SourceManager& srcMgr);
/// Same as above, but content is retrieved from the `SourceManager`.
proto::Position toPosition(clang::SourceLocation location,
proto::PositionEncodingKind kind,
const clang::SourceManager& SM);
/// Convert a proto::Position to a clang::SourceLocation according to the
/// specified encoding kind. If any error occurs, return an invalid location.
clang::SourceLocation toSourceLocation(llvm::StringRef content,
proto::Position position,
proto::PositionEncodingKind kind,
const clang::SourceManager& srcMgr);
/// Convert a proto::Position to a file offset in the content with the specified
/// encoding kind.
std::size_t toOffset(llvm::StringRef content,
proto::Position position,
proto::PositionEncodingKind kind);
} // namespace clice