[cfe-commits] r63004 - /cfe/trunk/include/clang/Basic/SourceManager.h

steve naroff snaroff at apple.com
Mon Feb 2 15:56:40 PST 2009


Hey Chris,

The commit below causes clang to be very unhappy on Windows.

Preprocessing the simplest program (with no #includes/#imports)  
results in the following assertion:

Assertion failed: (X.Data & 7) == 0 &&"ContentCache pointer  
insufficiently a
ed", file c:\cygwin\home\Administrator\llvm\tools\clang\include\clang/ 
Basic/
ceManager.h, line 146

Any clues?

Thanks,

snaroff

On Jan 26, 2009, at 1:49 AM, Chris Lattner wrote:

> Author: lattner
> Date: Mon Jan 26 00:49:09 2009
> New Revision: 63004
>
> URL: http://llvm.org/viewvc/llvm-project?rev=63004&view=rev
> Log:
> Bitmangle file characteristic bits into the low bits of
> the content cache pointer.  This saves 105876 bytes on
> cocoa.h because it shrinks the SLocEntry union, which
> we have a big array of.  It would be nice to use
> PointerIntPair here, but we can't because it is in a
> union.
>
> Modified:
>    cfe/trunk/include/clang/Basic/SourceManager.h
>
> Modified: cfe/trunk/include/clang/Basic/SourceManager.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=63004&r1=63003&r2=63004&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/include/clang/Basic/SourceManager.h (original)
> +++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Jan 26  
> 00:49:09 2009
> @@ -130,31 +130,33 @@
>     /// This is an invalid SLOC for the main file (top of the  
> #include chain).
>     unsigned IncludeLoc;  // Really a SourceLocation
>
> -    /// Content - Information about the source buffer itself.
> -    const ContentCache *Content;
> -
> -    /// FileCharacteristic - This is an instance of  
> CharacteristicKind,
> -    /// indicating whether this is a system header dir or not.
> -    unsigned FileCharacteristic : 2;
> +    /// Data - This contains the ContentCache* and the bits  
> indicating the
> +    /// characteristic of the file and whether it has #line info,  
> all bitmangled
> +    /// together.
> +    uintptr_t Data;
>   public:
>     /// get - Return a FileInfo object.
>     static FileInfo get(SourceLocation IL, const ContentCache *Con,
>                         CharacteristicKind FileCharacter) {
>       FileInfo X;
>       X.IncludeLoc = IL.getRawEncoding();
> -      X.Content = Con;
> -      X.FileCharacteristic = FileCharacter;
> +      X.Data = (uintptr_t)Con;
> +      assert((X.Data & 7) == 0 &&"ContentCache pointer  
> insufficiently aligned");
> +      assert((unsigned)FileCharacter < 4 && "invalid file  
> character");
> +      X.Data |= (unsigned)FileCharacter;
>       return X;
>     }
>
>     SourceLocation getIncludeLoc() const {
>       return SourceLocation::getFromRawEncoding(IncludeLoc);
>     }
> -    const ContentCache* getContentCache() const { return Content; }
> +    const ContentCache* getContentCache() const {
> +      return reinterpret_cast<const ContentCache*>(Data & ~7UL);
> +    }
>
>     /// getCharacteristic - Return whether this is a system header  
> or not.
>     CharacteristicKind getFileCharacteristic() const {
> -      return (CharacteristicKind)FileCharacteristic;
> +      return (CharacteristicKind)(Data & 3);
>     }
>   };
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list