Fix <rdar://problem/6512717> by correctly reading the right offset in the token data in PTHLexer::getSourceLocation().

llvm-svn: 62725
This commit is contained in:
Ted Kremenek 2009-01-21 22:41:38 +00:00
parent 3041abd608
commit ae54f2f590
2 changed files with 3 additions and 2 deletions

View File

@ -324,7 +324,7 @@ SourceLocation PTHLexer::getSourceLocation() {
// handling a #included file. Just read the necessary data from the token // handling a #included file. Just read the necessary data from the token
// data buffer to construct the SourceLocation object. // data buffer to construct the SourceLocation object.
// NOTE: This is a virtual function; hence it is defined out-of-line. // 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); uint32_t Offset = Read32(OffsetPtr);
return FileStartLoc.getFileLocWithOffset(Offset); return FileStartLoc.getFileLocWithOffset(Offset);
} }

View File

@ -1,5 +1,6 @@
// RUN: clang %s -print-stats && // 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__ #ifdef __APPLE__
#include <Cocoa/Cocoa.h> #include <Cocoa/Cocoa.h>
#endif #endif