summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-27 17:53:17 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-27 17:53:17 +0000
commit96977da72c7cce3109cd787f795e586771980562 (patch)
tree622661cfbb2c78621f44b4f0aba0fd7fa75430ab /clang/lib/Lex/Preprocessor.cpp
parent7094c15d7e44cd53530752387399d984cf3f4a05 (diff)
downloadbcm5719-llvm-96977da72c7cce3109cd787f795e586771980562.tar.gz
bcm5719-llvm-96977da72c7cce3109cd787f795e586771980562.zip
Clean up and document code modification hints.
llvm-svn: 65641
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r--clang/lib/Lex/Preprocessor.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index ccb179d1e4c..26777d9170b 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -265,7 +265,6 @@ unsigned Preprocessor::getSpelling(const Token &Tok,
return OutBuf-Buffer;
}
-
/// CreateString - Plop the specified string into a scratch buffer and return a
/// location for it. If specified, the source location provides a source
/// location for the token.
@@ -321,6 +320,25 @@ SourceLocation Preprocessor::AdvanceToTokenCharacter(SourceLocation TokStart,
return TokStart.getFileLocWithOffset(PhysOffset);
}
+/// \brief Computes the source location just past the end of the
+/// token at this source location.
+///
+/// This routine can be used to produce a source location that
+/// points just past the end of the token referenced by \p Loc, and
+/// is generally used when a diagnostic needs to point just after a
+/// token where it expected something different that it received. If
+/// the returned source location would not be meaningful (e.g., if
+/// it points into a macro), this routine returns an invalid
+/// source location.
+SourceLocation Preprocessor::getLocForEndOfToken(SourceLocation Loc) {
+ if (Loc.isInvalid() || !Loc.isFileID())
+ return SourceLocation();
+
+ unsigned Len = Lexer::MeasureTokenLength(Loc, getSourceManager());
+ return AdvanceToTokenCharacter(Loc, Len);
+}
+
+
//===----------------------------------------------------------------------===//
// Preprocessor Initialization Methods
OpenPOWER on IntegriCloud