That makes a lot of sense. It would better document the PTH file format and help obviate such breakage in the future.
On Jan 21, 2009, at 3:03 PM, Daniel Dunbar <[email protected]> wrote: > Couldn't code like this be wrapped in a simple class which would > centralize the format (even if the actual reading is still distributed > throughout the code)? > > That is, > -- > const unsigned char *OffsetPtr = CurPtr + (1 + 1 + 3); > const unsigned char *OffsetPtr = CurPtr + (DISK_TOKEN_SIZE - 4); > uint32_t Offset = Read32(OffsetPtr); > -- > could be > -- > uint32_t Offset = DiskTokenPtr(CurPtr).Read32(); > -- > > and somewhere else there would be > > -- > class DiskTokenPtr { > const unsigned char *Ptr; > public: > DiskTokenPtr(const unsigned char *_Ptr) : Ptr(_Ptr) {} > > uint32_t ReadIdentifier() { return Read32(Ptr + ...); } > uint32_t ReadOffset() { return Read32(Ptr + ...); } > } > -- > > Etc. > > - Daniel > > On Wed, Jan 21, 2009 at 2:41 PM, Ted Kremenek <[email protected]> > wrote: >> Author: kremenek >> Date: Wed Jan 21 16:41:38 2009 >> New Revision: 62725 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=62725&view=rev >> Log: >> Fix <rdar://problem/6512717> by correctly reading the right offset >> in the token data in PTHLexer::getSourceLocation(). >> >> Modified: >> cfe/trunk/lib/Lex/PTHLexer.cpp >> cfe/trunk/test/SemaObjC/cocoa.m >> >> Modified: cfe/trunk/lib/Lex/PTHLexer.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=62725&r1=62724&r2=62725&view=diff >> >> === >> === >> === >> ===================================================================== >> --- cfe/trunk/lib/Lex/PTHLexer.cpp (original) >> +++ cfe/trunk/lib/Lex/PTHLexer.cpp Wed Jan 21 16:41:38 2009 >> @@ -324,7 +324,7 @@ >> // 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); >> } >> >> Modified: cfe/trunk/test/SemaObjC/cocoa.m >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/cocoa.m?rev=62725&r1=62724&r2=62725&view=diff >> >> === >> === >> === >> ===================================================================== >> --- cfe/trunk/test/SemaObjC/cocoa.m (original) >> +++ cfe/trunk/test/SemaObjC/cocoa.m Wed Jan 21 16:41:38 2009 >> @@ -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 <Cocoa/Cocoa.h> >> #endif >> >> >> _______________________________________________ >> cfe-commits mailing list >> [email protected] >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >> _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
