summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/SourceCode.h
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/SourceCode.h')
-rw-r--r--clang-tools-extra/clangd/SourceCode.h14
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.
OpenPOWER on IntegriCloud