mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 12:56:07 +00:00
PCH support for CompoundLiteralExpr. This is the last C expression
that does not require PCH support for statements. Only AddrLabelExpr, StmtExpr, and BlockExpr remain (for C). llvm-svn: 69255
This commit is contained in:
parent
653dee0884
commit
4c5cd33527
@ -1137,13 +1137,20 @@ public:
|
||||
: Expr(CompoundLiteralExprClass, ty), LParenLoc(lparenloc), Init(init),
|
||||
FileScope(fileScope) {}
|
||||
|
||||
/// \brief Construct an empty compound literal.
|
||||
explicit CompoundLiteralExpr(EmptyShell Empty)
|
||||
: Expr(CompoundLiteralExprClass, Empty) { }
|
||||
|
||||
const Expr *getInitializer() const { return cast<Expr>(Init); }
|
||||
Expr *getInitializer() { return cast<Expr>(Init); }
|
||||
void setInitializer(Expr *E) { Init = E; }
|
||||
|
||||
bool isFileScope() const { return FileScope; }
|
||||
|
||||
void setFileScope(bool FS) { FileScope = FS; }
|
||||
|
||||
SourceLocation getLParenLoc() const { return LParenLoc; }
|
||||
|
||||
void setLParenLoc(SourceLocation L) { LParenLoc = L; }
|
||||
|
||||
virtual SourceRange getSourceRange() const {
|
||||
// FIXME: Init should never be null.
|
||||
if (!Init)
|
||||
|
@ -419,7 +419,8 @@ namespace clang {
|
||||
EXPR_IMPLICIT_CAST,
|
||||
/// \brief A CStyleCastExpr record.
|
||||
EXPR_CSTYLE_CAST,
|
||||
/// FIXME: CompoundLiteralExpr
|
||||
/// \brief A CompoundLiteralExpr record.
|
||||
EXPR_COMPOUND_LITERAL,
|
||||
/// \brief An ExtVectorElementExpr record.
|
||||
EXPR_EXT_VECTOR_ELEMENT,
|
||||
/// \brief An InitListExpr record.
|
||||
|
@ -257,6 +257,7 @@ namespace {
|
||||
unsigned VisitImplicitCastExpr(ImplicitCastExpr *E);
|
||||
unsigned VisitExplicitCastExpr(ExplicitCastExpr *E);
|
||||
unsigned VisitCStyleCastExpr(CStyleCastExpr *E);
|
||||
unsigned VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
|
||||
unsigned VisitExtVectorElementExpr(ExtVectorElementExpr *E);
|
||||
unsigned VisitInitListExpr(InitListExpr *E);
|
||||
unsigned VisitDesignatedInitExpr(DesignatedInitExpr *E);
|
||||
@ -447,6 +448,14 @@ unsigned PCHStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned PCHStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
|
||||
VisitExpr(E);
|
||||
E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
||||
E->setInitializer(ExprStack.back());
|
||||
E->setFileScope(Record[Idx++]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned PCHStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
|
||||
VisitExpr(E);
|
||||
E->setBase(ExprStack.back());
|
||||
@ -2103,6 +2112,10 @@ Expr *PCHReader::ReadExpr() {
|
||||
E = new (Context) CStyleCastExpr(Empty);
|
||||
break;
|
||||
|
||||
case pch::EXPR_COMPOUND_LITERAL:
|
||||
E = new (Context) CompoundLiteralExpr(Empty);
|
||||
break;
|
||||
|
||||
case pch::EXPR_EXT_VECTOR_ELEMENT:
|
||||
E = new (Context) ExtVectorElementExpr(Empty);
|
||||
break;
|
||||
|
@ -464,6 +464,7 @@ namespace {
|
||||
void VisitImplicitCastExpr(ImplicitCastExpr *E);
|
||||
void VisitExplicitCastExpr(ExplicitCastExpr *E);
|
||||
void VisitCStyleCastExpr(CStyleCastExpr *E);
|
||||
void VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
|
||||
void VisitExtVectorElementExpr(ExtVectorElementExpr *E);
|
||||
void VisitInitListExpr(InitListExpr *E);
|
||||
void VisitDesignatedInitExpr(DesignatedInitExpr *E);
|
||||
@ -647,6 +648,14 @@ void PCHStmtWriter::VisitCStyleCastExpr(CStyleCastExpr *E) {
|
||||
Code = pch::EXPR_CSTYLE_CAST;
|
||||
}
|
||||
|
||||
void PCHStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
|
||||
VisitExpr(E);
|
||||
Writer.AddSourceLocation(E->getLParenLoc(), Record);
|
||||
Writer.WriteSubExpr(E->getInitializer());
|
||||
Record.push_back(E->isFileScope());
|
||||
Code = pch::EXPR_COMPOUND_LITERAL;
|
||||
}
|
||||
|
||||
void PCHStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
|
||||
VisitExpr(E);
|
||||
Writer.WriteSubExpr(E->getBase());
|
||||
|
@ -61,6 +61,10 @@ conditional_operator *double_ptr4 = &floating;
|
||||
// CStyleCastExpr
|
||||
void_ptr vp1 = &integer;
|
||||
|
||||
// CompoundLiteral
|
||||
struct S s;
|
||||
compound_literal *sptr = &s;
|
||||
|
||||
// ExtVectorElementExpr
|
||||
ext_vector_element *double_ptr5 = &floating;
|
||||
|
||||
|
@ -56,6 +56,9 @@ typedef typeof(i? : d0) conditional_operator;
|
||||
// CStyleCastExpr
|
||||
typedef typeof((void *)0) void_ptr;
|
||||
|
||||
// CompoundLiteral
|
||||
typedef typeof((struct S){.x = 3.5}) compound_literal;
|
||||
|
||||
// ExtVectorElementExpr
|
||||
typedef __attribute__(( ext_vector_type(2) )) double double2;
|
||||
extern double2 vec2, vec2b;
|
||||
|
Loading…
x
Reference in New Issue
Block a user