diff options
Diffstat (limited to 'clang/lib/Serialization')
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 27 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 22 |
2 files changed, 49 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 3bf51e6a0e9..7c8415a295c 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -2924,6 +2924,17 @@ QualType ASTReader::ReadTypeRecord(unsigned Index) { return T; } + case TYPE_ATTRIBUTED: { + if (Record.size() != 3) { + Error("incorrect encoding of attributed type"); + return QualType(); + } + QualType modifiedType = GetType(Record[0]); + QualType equivalentType = GetType(Record[1]); + AttributedType::Kind kind = static_cast<AttributedType::Kind>(Record[2]); + return Context->getAttributedType(kind, modifiedType, equivalentType); + } + case TYPE_PAREN: { if (Record.size() != 1) { Error("incorrect encoding of paren type"); @@ -3197,6 +3208,22 @@ void TypeLocReader::VisitRecordTypeLoc(RecordTypeLoc TL) { void TypeLocReader::VisitEnumTypeLoc(EnumTypeLoc TL) { TL.setNameLoc(ReadSourceLocation(Record, Idx)); } +void TypeLocReader::VisitAttributedTypeLoc(AttributedTypeLoc TL) { + TL.setAttrNameLoc(ReadSourceLocation(Record, Idx)); + if (TL.hasAttrOperand()) { + SourceRange range; + range.setBegin(ReadSourceLocation(Record, Idx)); + range.setEnd(ReadSourceLocation(Record, Idx)); + TL.setAttrOperandParensRange(range); + } + if (TL.hasAttrExprOperand()) { + if (Record[Idx++]) + TL.setAttrExprOperand(Reader.ReadExpr(F)); + else + TL.setAttrExprOperand(0); + } else if (TL.hasAttrEnumOperand()) + TL.setAttrEnumOperandLoc(ReadSourceLocation(Record, Idx)); +} void TypeLocReader::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) { TL.setNameLoc(ReadSourceLocation(Record, Idx)); } diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 2c0239de17e..eb312522c7a 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -228,6 +228,13 @@ void ASTTypeWriter::VisitEnumType(const EnumType *T) { Code = TYPE_ENUM; } +void ASTTypeWriter::VisitAttributedType(const AttributedType *T) { + Writer.AddTypeRef(T->getModifiedType(), Record); + Writer.AddTypeRef(T->getEquivalentType(), Record); + Record.push_back(T->getAttrKind()); + Code = TYPE_ATTRIBUTED; +} + void ASTTypeWriter::VisitSubstTemplateTypeParmType( const SubstTemplateTypeParmType *T) { @@ -462,6 +469,21 @@ void TypeLocWriter::VisitRecordTypeLoc(RecordTypeLoc TL) { void TypeLocWriter::VisitEnumTypeLoc(EnumTypeLoc TL) { Writer.AddSourceLocation(TL.getNameLoc(), Record); } +void TypeLocWriter::VisitAttributedTypeLoc(AttributedTypeLoc TL) { + Writer.AddSourceLocation(TL.getAttrNameLoc(), Record); + if (TL.hasAttrOperand()) { + SourceRange range = TL.getAttrOperandParensRange(); + Writer.AddSourceLocation(range.getBegin(), Record); + Writer.AddSourceLocation(range.getEnd(), Record); + } + if (TL.hasAttrExprOperand()) { + Expr *operand = TL.getAttrExprOperand(); + Record.push_back(operand ? 1 : 0); + if (operand) Writer.AddStmt(operand); + } else if (TL.hasAttrEnumOperand()) { + Writer.AddSourceLocation(TL.getAttrEnumOperandLoc(), Record); + } +} void TypeLocWriter::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) { Writer.AddSourceLocation(TL.getNameLoc(), Record); } |

