diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-07-02 20:05:54 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-07-02 20:05:54 +0000 |
| commit | 4cca5ba7da5cceb898128863064f983de9ed6885 (patch) | |
| tree | fedf93facf3d5ed74775b92210d63dffe2b19b7c /clang | |
| parent | 847e0e45524de4d2454333b702f9e8b0ab10fb2a (diff) | |
| download | bcm5719-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')
| -rw-r--r-- | clang/Lex/Lexer.cpp | 16 | ||||
| -rw-r--r-- | clang/include/clang/Lex/Lexer.h | 3 |
2 files changed, 11 insertions, 8 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); } diff --git a/clang/include/clang/Lex/Lexer.h b/clang/include/clang/Lex/Lexer.h index 499b5a8e8ce..e8ca8e479cf 100644 --- a/clang/include/clang/Lex/Lexer.h +++ b/clang/include/clang/Lex/Lexer.h @@ -78,7 +78,8 @@ public: /// with the specified preprocessor managing the lexing process. This lexer /// assumes that the specified SourceBuffer and Preprocessor objects will /// outlive it, but doesn't take ownership of either pointer. - Lexer(const SourceBuffer *InBuffer, unsigned CurFileID, Preprocessor &PP); + Lexer(const SourceBuffer *InBuffer, unsigned CurFileID, Preprocessor &PP, + const char *BufStart = 0, const char *BufEnd = 0); /// getFeatures - Return the language features currently enabled. NOTE: this /// lexer modifies features as a file is parsed! |

