From ae54f2f590f9c7d6b80e026eb89577cb77440c61 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 21 Jan 2009 22:41:38 +0000 Subject: [PATCH] Fix by correctly reading the right offset in the token data in PTHLexer::getSourceLocation(). llvm-svn: 62725 --- clang/lib/Lex/PTHLexer.cpp | 2 +- clang/test/SemaObjC/cocoa.m | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp index aa59db5ae2a0..9fa2bb2b0fbf 100644 --- a/clang/lib/Lex/PTHLexer.cpp +++ b/clang/lib/Lex/PTHLexer.cpp @@ -324,7 +324,7 @@ SourceLocation PTHLexer::getSourceLocation() { // handling a #included file. Just read the necessary data from the token // data buffer to construct the SourceLocation object. // NOTE: This is a virtual function; hence it is defined out-of-line. - const unsigned char *OffsetPtr = CurPtr + (1 + 1 + 3); + const unsigned char *OffsetPtr = CurPtr + (DISK_TOKEN_SIZE - 4); uint32_t Offset = Read32(OffsetPtr); return FileStartLoc.getFileLocWithOffset(Offset); } diff --git a/clang/test/SemaObjC/cocoa.m b/clang/test/SemaObjC/cocoa.m index ac7d1dc66688..795e0c8cb28d 100644 --- a/clang/test/SemaObjC/cocoa.m +++ b/clang/test/SemaObjC/cocoa.m @@ -1,5 +1,6 @@ // RUN: clang %s -print-stats && -// RUN: clang -x objective-c-header -o %t %s && clang -token-cache %t %s +// RUN: clang -x objective-c-header -o %t %s && clang -token-cache %t %s && +// RUN: clang -x objective-c-header -o %t %s && clang -token-cache %t %s -E %s -o /dev/null #ifdef __APPLE__ #include #endif