[PATCH] D49508: [Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 21 03:05:03 PDT 2018


lebedev.ri added inline comments.


================
Comment at: include/clang/AST/Stmt.h:206
+    bool PartOfExplicitCast : 1;
+    unsigned BasePathSize : 32 - 6 - 1 - NumExprBits;
   };
----------------
rsmith wrote:
> lebedev.ri wrote:
> > rjmccall wrote:
> > > lebedev.ri wrote:
> > > > rjmccall wrote:
> > > > > This needs to be serialized.
> > > > Uhm, could you please explain what do you mean by 'serialized'?
> > > It needs to be preserved when writing an ICE into a PCH / module file.  See the ASTWriter / ASTReader.
> > Aha. I did add handling there but it raises questions:
> >   #  This will silently break with different AST serialization versions.
> >      I'm not sure how to handle it, since `VERSION_MINOR` isn't even read back.
> >   #  //Does// this need a test? How to write one?
> >      Like `./test/PCH/include-timestamp.cpp`, using `llvm-bcanalyzer`?
> Don't worry about breaking the serialization format. We do not maintain AST file format compatibility in general (neither between major releases nor between any two arbitrary SVN revisions). [We should probably maintain file format compatibility between patch releases, but I don't think that works right now because we check the full version number including the patch level when reading a file.]
> 
> Please do add a test: what you need to do is create a PCH containing an implicit cast expression and then import that AST file and do anything to check that the value is preserved (such as inspecting the output of `-ast-dump`). Maybe you could add this to the existing `test/PCH/cxx_exprs.cpp` test, which already does most of what you want, but doesn't have any `FileCheck` tests on the `-ast-dump` output yet.
Uhm, so i have tried to add a test.
With git master, the `-ast-dump` from the first runline of `test/PCH/cxx_exprs.cpp` contains:
```
|-TypedefDecl 0x55a348020b88 </build/clang/test/PCH/cxx_exprs.h:5:1, col:44> col:44 referenced static_cast_result 'typeof (static_cast<void *>(0))':'void *'
| `-TypeOfExprType 0x55a348020b50 'typeof (static_cast<void *>(0))' sugar
|   |-ParenExpr 0x55a348020b28 <col:19, col:42> 'void *'
|   | `-CXXStaticCastExpr 0x55a348020af8 <col:20, col:41> 'void *' static_cast<void *> <NoOp>
|   |   `-ImplicitCastExpr 0x55a348020ae0 <col:40> 'void *' <NullToPointer>
|   |     `-IntegerLiteral 0x55a348020aa8 <col:40> 'int' 0
|   `-PointerType 0x55a347fe6390 'void *'
|     `-BuiltinType 0x55a347fe5b90 'void'
```
But the last runline (which uses PCH) does not have that.
Unfortunately i know next to nothing about PCH / AST serialization, so i'm not sure how to workaround that yet.
It does contain ``-<undeserialized declarations>`, so maybe i have to somehow force full deserialization?
{F6733062} {F6733063}


Repository:
  rC Clang

https://reviews.llvm.org/D49508





More information about the cfe-commits mailing list