r220493 - Add a "signature" to AST files to verify that they haven't changed

Chandler Carruth chandlerc at google.com
Mon Mar 23 17:38:37 PDT 2015


Digging this thread back up, I'm starting to work on deterministic output
of modules. This is *really* important. Unfortunately, it's almost
impossible to make progress as long as this code is actually firing because
it kind of makes things definitively non-deterministic. ;]

Ben, do you have any concerns about only emitting the signature record for
implicit modules? This would omit it for explicit modules (where I'm
working), PCH files, etc. Based on your commit message and explanation, it
doesn't really make sense outside of implicit modules AFAICT, and we're
hoping it will go away completely.


Also, I have one question here which may just be my ignorance:

On Thu, Oct 23, 2014 at 11:05 AM, Ben Langmuir <blangmuir at apple.com> wrote:

> +                            ASTFileSignature ExpectedSignature,
> +
> std::function<ASTFileSignature(llvm::BitstreamReader &)>
> +                                ReadSignature,
>

Wow, a std::function? Is this really necessary? Seems super heavy weight.


>
> +static ASTFileSignature readASTFileSignature(llvm::BitstreamReader
> &StreamFile){
> +  BitstreamCursor Stream(StreamFile);
> +  if (Stream.Read(8) != 'C' ||
> +      Stream.Read(8) != 'P' ||
> +      Stream.Read(8) != 'C' ||
> +      Stream.Read(8) != 'H') {
> +    return 0;
> +  }
>

This is truly magical. I assume this is checking for some magic string?
Comments or something would be really nice here. Sharing the code would be
even more nice.


> +
> +  // Scan for the CONTROL_BLOCK_ID block.
> +  if (SkipCursorToBlock(Stream, CONTROL_BLOCK_ID))
> +    return 0;
>

Why would it ever be reasonable to call this for a module file without such
a block?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150323/7304da23/attachment.html>


More information about the cfe-commits mailing list