It is not enough to clone the attributes at import.
They can contain reference to objects that should be imported.
This work is done now for AlignedAttr.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 47189 Build 50007: arc lint + arc unit
Event Timeline
LGTM aside from the comments I made.
clang/lib/AST/ASTImporter.cpp | ||
---|---|---|
7944 | This call to Create and the one below look identical can we please refactor to avoid code duplication. | |
clang/unittests/AST/ASTImporterTest.cpp | ||
5891 | If we have a test case that triggers this failure can we add the test as a know failing test and then we the FIXME is done the test should pass. | |
5910 | What about getSemanticSpelling()? |
- Do not call AlignedAttr::Create with same parameters at 2 places. I think the code duplication was near to each other and only 2 instances that is not a big problem, anyway now it is a bit better.
- Improved the comment in the test and added some new checks.
clang/lib/AST/ASTImporter.cpp | ||
---|---|---|
7944 | How about something more like, maybe I am missing a detail but hopefully not: bool IsAlignmentExpr=From->isAlignmentExpr(); auto ToEOrErr = [IsAlignmentExpr]() { if (IsAlignmentExpr) return Import(From->getAlignmentExpr()); return Import(From->getAlignmentType()); }(); if (!ToTOrErr) return ToTOrErr.takeError(); To = AlignedAttr::Create(ToContext, IsAlignmentExpr, *ToEOrErr, ToRange, From->getSyntax(),From->getSemanticSpelling()); |
clang/lib/AST/ASTImporter.cpp | ||
---|---|---|
7944 | It is only possible by using a template. Importing of AlignmentExpr returns Expected<Expr *> and importing the AlignmentType returns Expected<TypeSourceInfo *>. The ToTOrErr and ToEOrErr are of different types. (The create function expects a void * that can be a pointer to Expr or TypeSourceInfo). |
This call to Create and the one below look identical can we please refactor to avoid code duplication.