#pragma once #include #include namespace clice { /// Convert a clang::SourceLocation to a proto::Position according to the /// specified encoding kind. Note that `SourceLocation` in clang is one-based and /// is always encoded in UTF-8. proto::Position toPosition(llvm::StringRef content, clang::SourceLocation location, proto::PositionEncodingKind kind, const clang::SourceManager& srcMgr); /// 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 toPosition(llvm::StringRef content, llvm::ArrayRef locations, proto::PositionEncodingKind kind, const clang::SourceManager& srcMgr); /// 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); } // namespace clice