diff options
Diffstat (limited to 'clang-tools-extra/clangd/SourceCode.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/SourceCode.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/clang-tools-extra/clangd/SourceCode.cpp b/clang-tools-extra/clangd/SourceCode.cpp index 7ef3700681fc..4495b537d696 100644 --- a/clang-tools-extra/clangd/SourceCode.cpp +++ b/clang-tools-extra/clangd/SourceCode.cpp @@ -8,6 +8,8 @@ //===----------------------------------------------------------------------===// #include "SourceCode.h" +#include "clang/Basic/SourceManager.h" + namespace clang { namespace clangd { using namespace llvm; @@ -39,6 +41,12 @@ Position offsetToPosition(StringRef Code, size_t Offset) { return Pos; } +Position sourceLocToPosition(const SourceManager &SM, SourceLocation Loc) { + Position P; + P.line = static_cast<int>(SM.getSpellingLineNumber(Loc)) - 1; + P.character = static_cast<int>(SM.getSpellingColumnNumber(Loc)) - 1; + return P; +} + } // namespace clangd } // namespace clang - |
