summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/SourceCode.h
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2019-08-06 20:25:59 +0000
committerSam McCall <sam.mccall@gmail.com>2019-08-06 20:25:59 +0000
commit957380714da38ca4871602933388bce32c32d7aa (patch)
tree8411b8a1bbc75ea44431263adcb9e728d10d91af /clang-tools-extra/clangd/SourceCode.h
parent4c7b28d6bbbd5a057307d9d3ac39705671412781 (diff)
downloadbcm5719-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.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