[PATCH] D147580: [Clang] Refactor "Designators" to be more similar [NFC]
void updated this revision to Diff 511215. void added a comment. Rebase. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147580/new/ https://reviews.llvm.org/D147580 Files: clang/include/clang/AST/Expr.h clang/include/clang/Sema/Designator.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/Expr.cpp clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtProfile.cpp clang/lib/Parse/ParseInit.cpp clang/lib/Sema/SemaCodeComplete.cpp clang/lib/Sema/SemaInit.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp Index: clang/lib/Serialization/ASTWriterStmt.cpp === --- clang/lib/Serialization/ASTWriterStmt.cpp +++ clang/lib/Serialization/ASTWriterStmt.cpp @@ -1098,13 +1098,13 @@ Record.AddSourceLocation(D.getFieldLoc()); } else if (D.isArrayDesignator()) { Record.push_back(serialization::DESIG_ARRAY); - Record.push_back(D.getFirstExprIndex()); + Record.push_back(D.getArrayIndex()); Record.AddSourceLocation(D.getLBracketLoc()); Record.AddSourceLocation(D.getRBracketLoc()); } else { assert(D.isArrayRangeDesignator() && "Unknown designator"); Record.push_back(serialization::DESIG_ARRAY_RANGE); - Record.push_back(D.getFirstExprIndex()); + Record.push_back(D.getArrayIndex()); Record.AddSourceLocation(D.getLBracketLoc()); Record.AddSourceLocation(D.getEllipsisLoc()); Record.AddSourceLocation(D.getRBracketLoc()); Index: clang/lib/Serialization/ASTReaderStmt.cpp === --- clang/lib/Serialization/ASTReaderStmt.cpp +++ clang/lib/Serialization/ASTReaderStmt.cpp @@ -1216,8 +1216,8 @@ auto *Field = readDeclAs(); SourceLocation DotLoc = readSourceLocation(); SourceLocation FieldLoc = readSourceLocation(); - Designators.push_back(Designator(Field->getIdentifier(), DotLoc, - FieldLoc)); + Designators.push_back(Designator::CreateFieldDesignator( + Field->getIdentifier(), DotLoc, FieldLoc)); Designators.back().setField(Field); break; } @@ -1226,7 +1226,8 @@ const IdentifierInfo *Name = Record.readIdentifier(); SourceLocation DotLoc = readSourceLocation(); SourceLocation FieldLoc = readSourceLocation(); - Designators.push_back(Designator(Name, DotLoc, FieldLoc)); + Designators.push_back(Designator::CreateFieldDesignator(Name, DotLoc, + FieldLoc)); break; } @@ -1234,7 +1235,9 @@ unsigned Index = Record.readInt(); SourceLocation LBracketLoc = readSourceLocation(); SourceLocation RBracketLoc = readSourceLocation(); - Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc)); + Designators.push_back(Designator::CreateArrayDesignator(Index, + LBracketLoc, + RBracketLoc)); break; } @@ -1243,8 +1246,8 @@ SourceLocation LBracketLoc = readSourceLocation(); SourceLocation EllipsisLoc = readSourceLocation(); SourceLocation RBracketLoc = readSourceLocation(); - Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc, - RBracketLoc)); + Designators.push_back(Designator::CreateArrayRangeDesignator( + Index, LBracketLoc, EllipsisLoc, RBracketLoc)); break; } } Index: clang/lib/Sema/TreeTransform.h === --- clang/lib/Sema/TreeTransform.h +++ clang/lib/Sema/TreeTransform.h @@ -11661,9 +11661,8 @@ bool ExprChanged = false; for (const DesignatedInitExpr::Designator : E->designators()) { if (D.isFieldDesignator()) { - Desig.AddDesignator(Designator::getField(D.getFieldName(), - D.getDotLoc(), - D.getFieldLoc())); + Desig.AddDesignator(Designator::CreateFieldDesignator( + D.getFieldName(), D.getDotLoc(), D.getFieldLoc())); if (D.getField()) { FieldDecl *Field = cast_or_null( getDerived().TransformDecl(D.getFieldLoc(), D.getField())); @@ -11686,7 +11685,7 @@ return ExprError(); Desig.AddDesignator( - Designator::getArray(Index.get(), D.getLBracketLoc())); + Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc())); ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(D); ArrayExprs.push_back(Index.get()); @@ -11703,10 +11702,8 @@ if (End.isInvalid()) return ExprError(); -Desig.AddDesignator(Designator::getArrayRange(Start.get(), -
[PATCH] D147580: [Clang] Refactor "Designators" to be more similar [NFC]
void created this revision. void added reviewers: aaron.ballman, rjmccall, rsmith, dblaikie, shafik. Herald added a subscriber: martong. Herald added a project: All. void requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. This makes the two interfaces for designators more similar so that it's easier to merge them together in a future refactoring. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D147580 Files: clang/include/clang/AST/Expr.h clang/include/clang/Sema/Designator.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/Expr.cpp clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtProfile.cpp clang/lib/Parse/ParseInit.cpp clang/lib/Sema/SemaCodeComplete.cpp clang/lib/Sema/SemaInit.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp Index: clang/lib/Serialization/ASTWriterStmt.cpp === --- clang/lib/Serialization/ASTWriterStmt.cpp +++ clang/lib/Serialization/ASTWriterStmt.cpp @@ -1098,13 +1098,13 @@ Record.AddSourceLocation(D.getFieldLoc()); } else if (D.isArrayDesignator()) { Record.push_back(serialization::DESIG_ARRAY); - Record.push_back(D.getFirstExprIndex()); + Record.push_back(D.getArrayIndex()); Record.AddSourceLocation(D.getLBracketLoc()); Record.AddSourceLocation(D.getRBracketLoc()); } else { assert(D.isArrayRangeDesignator() && "Unknown designator"); Record.push_back(serialization::DESIG_ARRAY_RANGE); - Record.push_back(D.getFirstExprIndex()); + Record.push_back(D.getArrayIndex()); Record.AddSourceLocation(D.getLBracketLoc()); Record.AddSourceLocation(D.getEllipsisLoc()); Record.AddSourceLocation(D.getRBracketLoc()); Index: clang/lib/Serialization/ASTReaderStmt.cpp === --- clang/lib/Serialization/ASTReaderStmt.cpp +++ clang/lib/Serialization/ASTReaderStmt.cpp @@ -1216,8 +1216,8 @@ auto *Field = readDeclAs(); SourceLocation DotLoc = readSourceLocation(); SourceLocation FieldLoc = readSourceLocation(); - Designators.push_back(Designator(Field->getIdentifier(), DotLoc, - FieldLoc)); + Designators.push_back(Designator::CreateFieldDesignator( + Field->getIdentifier(), DotLoc, FieldLoc)); Designators.back().setField(Field); break; } @@ -1226,7 +1226,8 @@ const IdentifierInfo *Name = Record.readIdentifier(); SourceLocation DotLoc = readSourceLocation(); SourceLocation FieldLoc = readSourceLocation(); - Designators.push_back(Designator(Name, DotLoc, FieldLoc)); + Designators.push_back(Designator::CreateFieldDesignator(Name, DotLoc, + FieldLoc)); break; } @@ -1234,7 +1235,9 @@ unsigned Index = Record.readInt(); SourceLocation LBracketLoc = readSourceLocation(); SourceLocation RBracketLoc = readSourceLocation(); - Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc)); + Designators.push_back(Designator::CreateArrayDesignator(Index, + LBracketLoc, + RBracketLoc)); break; } @@ -1243,8 +1246,8 @@ SourceLocation LBracketLoc = readSourceLocation(); SourceLocation EllipsisLoc = readSourceLocation(); SourceLocation RBracketLoc = readSourceLocation(); - Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc, - RBracketLoc)); + Designators.push_back(Designator::CreateArrayRangeDesignator( + Index, LBracketLoc, EllipsisLoc, RBracketLoc)); break; } } Index: clang/lib/Sema/TreeTransform.h === --- clang/lib/Sema/TreeTransform.h +++ clang/lib/Sema/TreeTransform.h @@ -11661,9 +11661,8 @@ bool ExprChanged = false; for (const DesignatedInitExpr::Designator : E->designators()) { if (D.isFieldDesignator()) { - Desig.AddDesignator(Designator::getField(D.getFieldName(), - D.getDotLoc(), - D.getFieldLoc())); + Desig.AddDesignator(Designator::CreateFieldDesignator( + D.getFieldName(), D.getDotLoc(), D.getFieldLoc())); if (D.getField()) { FieldDecl *Field = cast_or_null( getDerived().TransformDecl(D.getFieldLoc(), D.getField())); @@ -11686,7 +11685,7 @@ return ExprError(); Desig.AddDesignator( - Designator::getArray(Index.get(), D.getLBracketLoc())); + Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));