summaryrefslogtreecommitdiffstats
path: root/clang/Lex/Lexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-02 20:05:54 +0000
committerChris Lattner <sabre@nondot.org>2006-07-02 20:05:54 +0000
commit4cca5ba7da5cceb898128863064f983de9ed6885 (patch)
treefedf93facf3d5ed74775b92210d63dffe2b19b7c /clang/Lex/Lexer.cpp
parent847e0e45524de4d2454333b702f9e8b0ab10fb2a (diff)
downloadbcm5719-llvm-4cca5ba7da5cceb898128863064f983de9ed6885.tar.gz
bcm5719-llvm-4cca5ba7da5cceb898128863064f983de9ed6885.zip
Allow the buffer start/end positions to be optionally specified. Make sure
to use them instead of the current buffer start/end when computing diagnostics. llvm-svn: 38603
Diffstat (limited to 'clang/Lex/Lexer.cpp')
-rw-r--r--clang/Lex/Lexer.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp
index def75555345..68ff3777dfc 100644
--- a/clang/Lex/Lexer.cpp
+++ b/clang/Lex/Lexer.cpp
@@ -37,10 +37,12 @@ using namespace clang;
static void InitCharacterInfo();
-Lexer::Lexer(const SourceBuffer *File, unsigned fileid, Preprocessor &pp)
- : BufferPtr(File->getBufferStart()), BufferStart(BufferPtr),
- BufferEnd(File->getBufferEnd()), InputFile(File), CurFileID(fileid), PP(pp),
- Features(PP.getLangOptions()) {
+Lexer::Lexer(const SourceBuffer *File, unsigned fileid, Preprocessor &pp,
+ const char *BufStart, const char *BufEnd)
+ : BufferPtr(BufStart ? BufStart : File->getBufferStart()),
+ BufferStart(BufferPtr),
+ BufferEnd(BufEnd ? BufEnd : File->getBufferEnd()),
+ InputFile(File), CurFileID(fileid), PP(pp), Features(PP.getLangOptions()) {
InitCharacterInfo();
assert(BufferEnd[0] == 0 &&
@@ -127,9 +129,9 @@ static inline bool isNumberBody(unsigned char c) {
/// getSourceLocation - Return a source location identifier for the specified
/// offset in the current file.
SourceLocation Lexer::getSourceLocation(const char *Loc) const {
- assert(Loc >= InputFile->getBufferStart() && Loc <= InputFile->getBufferEnd()
- && "Location out of range for this buffer!");
- return SourceLocation(CurFileID, Loc-InputFile->getBufferStart());
+ assert(Loc >= BufferStart && Loc <= BufferEnd &&
+ "Location out of range for this buffer!");
+ return SourceLocation(CurFileID, Loc-BufferStart);
}
OpenPOWER on IntegriCloud