diff options
| author | Haojian Wu <hokein@google.com> | 2019-07-19 08:33:39 +0000 |
|---|---|---|
| committer | Haojian Wu <hokein@google.com> | 2019-07-19 08:33:39 +0000 |
| commit | 6ae86ea2752126d386206cd92ef6a905f6f58598 (patch) | |
| tree | 191106b54c7ba063a74f2bb2fbbc00bd34299a3b /clang-tools-extra/clangd/SourceCode.h | |
| parent | f2eb403144959e9da93ed28ee7b9736c993b5a3c (diff) | |
| download | bcm5719-llvm-6ae86ea2752126d386206cd92ef6a905f6f58598.tar.gz bcm5719-llvm-6ae86ea2752126d386206cd92ef6a905f6f58598.zip | |
[clangd] cleanup: unify the implemenation of checking a location is inside main file.
Summary: We have variant implementations in the codebase, this patch unifies them.
Reviewers: ilya-biryukov, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64915
llvm-svn: 366541
Diffstat (limited to 'clang-tools-extra/clangd/SourceCode.h')
| -rw-r--r-- | clang-tools-extra/clangd/SourceCode.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/SourceCode.h b/clang-tools-extra/clangd/SourceCode.h index 8e58e66f4db..4bbf3cf49fc 100644 --- a/clang-tools-extra/clangd/SourceCode.h +++ b/clang-tools-extra/clangd/SourceCode.h @@ -75,6 +75,14 @@ llvm::Optional<Range> getTokenRange(const SourceManager &SM, llvm::Expected<SourceLocation> sourceLocationInMainFile(const SourceManager &SM, Position P); +/// Returns true iff \p Loc is inside the main file. This function handles +/// file & macro locations. For macro locations, returns iff the macro is being +/// expanded inside the main file. +/// +/// The function is usually used to check whether a declaration is inside the +/// the main file. +bool isInsideMainFile(SourceLocation Loc, const SourceManager &SM); + /// Turns a token range into a half-open range and checks its correctness. /// The resulting range will have only valid source location on both sides, both /// of which are file locations. |

