diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2019-08-06 20:25:59 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2019-08-06 20:25:59 +0000 |
| commit | 957380714da38ca4871602933388bce32c32d7aa (patch) | |
| tree | 8411b8a1bbc75ea44431263adcb9e728d10d91af /clang-tools-extra/clangd/SourceCode.h | |
| parent | 4c7b28d6bbbd5a057307d9d3ac39705671412781 (diff) | |
| download | bcm5719-llvm-957380714da38ca4871602933388bce32c32d7aa.tar.gz bcm5719-llvm-957380714da38ca4871602933388bce32c32d7aa.zip | |
[clangd] Unfold SourceLocation flattening from findNameLoc in preparation for adding more overloads. NFC
llvm-svn: 368083
Diffstat (limited to 'clang-tools-extra/clangd/SourceCode.h')
| -rw-r--r-- | clang-tools-extra/clangd/SourceCode.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/SourceCode.h b/clang-tools-extra/clangd/SourceCode.h index 4bbf3cf49fc..6517043759f 100644 --- a/clang-tools-extra/clangd/SourceCode.h +++ b/clang-tools-extra/clangd/SourceCode.h @@ -83,6 +83,20 @@ llvm::Expected<SourceLocation> sourceLocationInMainFile(const SourceManager &SM, /// the main file. bool isInsideMainFile(SourceLocation Loc, const SourceManager &SM); +/// Returns true if the token at Loc is spelled in the source code. +/// This is not the case for: +/// * symbols formed via macro concatenation, the spelling location will +/// be "<scratch space>" +/// * symbols controlled and defined by a compile command-line option +/// `-DName=foo`, the spelling location will be "<command line>". +bool isSpelledInSource(SourceLocation Loc, const SourceManager &SM); + +/// Returns the spelling location of the token at Loc if isSpelledInSource, +/// otherwise its expansion location. +/// FIXME: Most callers likely want some variant of "file location" instead. +SourceLocation spellingLocIfSpelled(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. |

