aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Lex/Preprocessor.cpp')
-rw-r--r--lib/Lex/Preprocessor.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index 6fe414b664..40227dc5e6 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -278,6 +278,16 @@ void Preprocessor::CodeCompleteNaturalLanguage() {
CodeComplete->CodeCompleteNaturalLanguage();
}
+llvm::StringRef Preprocessor::getSpelling(SourceLocation loc,
+ bool *invalid) const {
+ bool invalidTemp = false;
+ if (!invalid) invalid = &invalidTemp;
+ const char *begin = SourceMgr.getCharacterData(loc, invalid);
+ if (*invalid) return llvm::StringRef();
+
+ unsigned length = Lexer::MeasureTokenLength(loc, SourceMgr, Features);
+ return llvm::StringRef(begin, length);
+}
/// getSpelling - This method is used to get the spelling of a token into a
/// SmallVector. Note that the returned StringRef may not point to the