[cfe-dev] Serialization bug

Zhongxing Xu mymlreader at gmail.com
Sun Apr 20 19:22:06 PDT 2008


$ cat test.c
void foo() {
  int i;
}

$ clang -serialize test.c

$ clang -emit-llvm test.c.ast
clang: CGDecl.cpp:41: void clang::CodeGen::CodeGenFunction::EmitDecl(const
clang::Decl&): Assertion `0 && "Should not see file-scope variables inside a
function!"' failed.
clang[0x84f5f2a]
clang[0x84f605c]
[0x110420]
/lib/libc.so.6(abort+0x101)[0x578f91]
/lib/libc.so.6(__assert_fail+0xee)[0x57093e]
clang(_ZN5clang7CodeGen15CodeGenFunction8EmitDeclERKNS_4DeclE+0xc8)[0x82ca9d2]
clang(_ZN5clang7CodeGen15CodeGenFunction12EmitDeclStmtERKNS_8DeclStmtE+0x28)[0x82df094]
clang(_ZN5clang7CodeGen15CodeGenFunction8EmitStmtEPKNS_4StmtE+0x274)[0x82df86e]
clang(_ZN5clang7CodeGen15CodeGenFunction16EmitCompoundStmtERKNS_12CompoundStmtEbPN4llvm5ValueEb+0x98)[0x82e0c86]
clang(_ZN5clang7CodeGen15CodeGenFunction8EmitStmtEPKNS_4StmtE+0x179)[0x82df773]
clang(_ZN5clang7CodeGen15CodeGenFunction12GenerateCodeEPKNS_12FunctionDeclE+0x56b)[0x82c7963]
clang(_ZN5clang7CodeGen13CodeGenModule12EmitFunctionEPKNS_12FunctionDeclE+0x120)[0x82aff9e]
clang[0x82ad772]
clang[0x829efc8]
clang(main+0x3c8)[0x82a2206]
/lib/libc.so.6(__libc_start_main+0xe0)[0x564390]
clang[0x82783a1]
Aborted

The assertion fails because the DeclContext * field of i becomes 0x0 after
deserialization.

I am investigating the problem. What is the difference between InRec and
OutRec methods in serialization?

Thanks.
--Zhongxing Xu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080421/460b1b72/attachment.html>


More information about the cfe-dev mailing list