From: Abramo Bagnara Date: Thu, 4 Oct 2012 21:42:10 +0000 (+0000) Subject: Fixed FunctionTypeLoc source range. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aeeb989cc4dccddf1d73e53f40dc36227efd1629;p=platform%2Fupstream%2Fllvm.git Fixed FunctionTypeLoc source range. llvm-svn: 165259 --- diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h index 4330184..ff29e44 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -1060,6 +1060,8 @@ public: struct FunctionLocInfo { SourceLocation LocalRangeBegin; + SourceLocation LParenLoc; + SourceLocation RParenLoc; SourceLocation LocalRangeEnd; }; @@ -1083,6 +1085,24 @@ public: getLocalData()->LocalRangeEnd = L; } + SourceLocation getLParenLoc() const { + return this->getLocalData()->LParenLoc; + } + void setLParenLoc(SourceLocation Loc) { + this->getLocalData()->LParenLoc = Loc; + } + + SourceLocation getRParenLoc() const { + return this->getLocalData()->RParenLoc; + } + void setRParenLoc(SourceLocation Loc) { + this->getLocalData()->RParenLoc = Loc; + } + + SourceRange getParensRange() const { + return SourceRange(getLParenLoc(), getRParenLoc()); + } + ArrayRef getParams() const { return ArrayRef(getParmArray(), getNumArgs()); } @@ -1110,6 +1130,8 @@ public: void initializeLocal(ASTContext &Context, SourceLocation Loc) { setLocalRangeBegin(Loc); + setLParenLoc(Loc); + setRParenLoc(Loc); setLocalRangeEnd(Loc); for (unsigned i = 0, e = getNumArgs(); i != e; ++i) setArg(i, NULL); diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h index b16d5f8..6a4a9ce4 100644 --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -1102,7 +1102,7 @@ struct DeclaratorChunk { /// \brief Whether the ref-qualifier (if any) is an lvalue reference. /// Otherwise, it's an rvalue reference. unsigned RefQualifierIsLValueRef : 1; - + /// The type qualifiers: const/volatile/restrict. /// The qualifier bitmask values are the same as in QualType. unsigned TypeQuals : 3; @@ -1117,9 +1117,15 @@ struct DeclaratorChunk { /// specified. unsigned HasTrailingReturnType : 1; + /// The location of the left parenthesis in the source. + unsigned LParenLoc; + /// When isVariadic is true, the location of the ellipsis in the source. unsigned EllipsisLoc; + /// The location of the right parenthesis in the source. + unsigned RParenLoc; + /// NumArgs - This is the number of formal arguments provided for the /// declarator. unsigned NumArgs; @@ -1194,10 +1200,19 @@ struct DeclaratorChunk { bool isKNRPrototype() const { return !hasPrototype && NumArgs != 0; } - + + SourceLocation getLParenLoc() const { + return SourceLocation::getFromRawEncoding(LParenLoc); + } + SourceLocation getEllipsisLoc() const { return SourceLocation::getFromRawEncoding(EllipsisLoc); } + + SourceLocation getRParenLoc() const { + return SourceLocation::getFromRawEncoding(RParenLoc); + } + SourceLocation getExceptionSpecLoc() const { return SourceLocation::getFromRawEncoding(ExceptionSpecLoc); } @@ -1350,11 +1365,13 @@ struct DeclaratorChunk { /// DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function. /// "TheDeclarator" is the declarator that this will be added to. - static DeclaratorChunk getFunction(bool hasProto, bool isVariadic, + static DeclaratorChunk getFunction(bool hasProto, bool isAmbiguous, - SourceLocation EllipsisLoc, + SourceLocation LParenLoc, ParamInfo *ArgInfo, unsigned NumArgs, - unsigned TypeQuals, + SourceLocation EllipsisLoc, + SourceLocation RParenLoc, + unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation ConstQualifierLoc, diff --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp index 4c103db..de9d22a 100644 --- a/clang/lib/AST/TypeLoc.cpp +++ b/clang/lib/AST/TypeLoc.cpp @@ -98,6 +98,7 @@ void TypeLoc::initializeImpl(ASTContext &Context, TypeLoc TL, SourceLocation TypeLoc::getBeginLoc() const { TypeLoc Cur = *this; + SourceLocation SavedParenLoc; while (true) { switch (Cur.getTypeLocClass()) { // FIXME: Currently QualifiedTypeLoc does not have a source range @@ -106,6 +107,44 @@ SourceLocation TypeLoc::getBeginLoc() const { case DependentName: case DependentTemplateSpecialization: break; + + case Paren: + // Save local source begin, if still unset. + if (SavedParenLoc.isInvalid()) + SavedParenLoc = Cur.getLocalSourceRange().getBegin(); + Cur = Cur.getNextTypeLoc(); + assert(!Cur.isNull()); + continue; + break; + + case Pointer: + case BlockPointer: + case MemberPointer: + case ObjCObjectPointer: + case LValueReference: + case RValueReference: + case ConstantArray: + case DependentSizedArray: + case IncompleteArray: + case VariableArray: + case FunctionNoProto: + // Discard previously saved paren loc, if any. + SavedParenLoc = SourceLocation(); + Cur = Cur.getNextTypeLoc(); + assert(!Cur.isNull()); + continue; + break; + + case FunctionProto: + // Discard previously saved paren loc, if any. + SavedParenLoc = SourceLocation(); + if (cast(&Cur)->getTypePtr()->hasTrailingReturn()) + return Cur.getLocalSourceRange().getBegin(); + Cur = Cur.getNextTypeLoc(); + assert(!Cur.isNull()); + continue; + break; + default: TypeLoc Next = Cur.getNextTypeLoc(); if (Next.isNull()) break; @@ -114,7 +153,9 @@ SourceLocation TypeLoc::getBeginLoc() const { } break; } - return Cur.getLocalSourceRange().getBegin(); + return SavedParenLoc.isValid() + ? SavedParenLoc + : Cur.getLocalSourceRange().getBegin(); } SourceLocation TypeLoc::getEndLoc() const { @@ -131,10 +172,15 @@ SourceLocation TypeLoc::getEndLoc() const { case DependentSizedArray: case IncompleteArray: case VariableArray: - case FunctionProto: case FunctionNoProto: Last = Cur; break; + case FunctionProto: + if (cast(&Cur)->getTypePtr()->hasTrailingReturn()) + Last = TypeLoc(); + else + Last = Cur; + break; case Pointer: case BlockPointer: case MemberPointer: diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 27cc484..52bd416 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -4581,7 +4581,11 @@ void Parser::ParseFunctionDeclarator(Declarator &D, Actions.ActOnStartFunctionDeclarator(); - SourceLocation EndLoc; + SourceLocation StartLoc, EndLoc; + SourceLocation LParenLoc, RParenLoc; + LParenLoc = Tracker.getOpenLocation(); + StartLoc = LParenLoc; + if (isFunctionDeclaratorIdentifierList()) { if (RequiresArg) Diag(Tok, diag::err_argument_required_after_attribute); @@ -4589,7 +4593,8 @@ void Parser::ParseFunctionDeclarator(Declarator &D, ParseFunctionDeclaratorIdentifierList(D, ParamInfo); Tracker.consumeClose(); - EndLoc = Tracker.getCloseLocation(); + RParenLoc = Tracker.getCloseLocation(); + EndLoc = RParenLoc; } else { if (Tok.isNot(tok::r_paren)) ParseParameterDeclarationClause(D, FirstArgAttrs, ParamInfo, EllipsisLoc); @@ -4600,7 +4605,8 @@ void Parser::ParseFunctionDeclarator(Declarator &D, // If we have the closing ')', eat it. Tracker.consumeClose(); - EndLoc = Tracker.getCloseLocation(); + RParenLoc = Tracker.getCloseLocation(); + EndLoc = RParenLoc; if (getLangOpts().CPlusPlus) { // FIXME: Accept these components in any order, and produce fixits to @@ -4658,19 +4664,21 @@ void Parser::ParseFunctionDeclarator(Declarator &D, // Parse trailing-return-type[opt]. if (getLangOpts().CPlusPlus0x && Tok.is(tok::arrow)) { Diag(Tok, diag::warn_cxx98_compat_trailing_return_type); + if (D.getDeclSpec().getTypeSpecType() == TST_auto) + StartLoc = D.getDeclSpec().getTypeSpecTypeLoc(); + EndLoc = Tok.getLocation(); SourceRange Range; TrailingReturnType = ParseTrailingReturnType(Range); - if (Range.getEnd().isValid()) - EndLoc = Range.getEnd(); } } } // Remember that we parsed a function type, and remember the attributes. D.AddTypeInfo(DeclaratorChunk::getFunction(HasProto, - /*isVariadic=*/EllipsisLoc.isValid(), - IsAmbiguous, EllipsisLoc, + IsAmbiguous, + LParenLoc, ParamInfo.data(), ParamInfo.size(), + EllipsisLoc, RParenLoc, DS.getTypeQualifiers(), RefQualifierIsLValueRef, RefQualifierLoc, ConstQualifierLoc, @@ -4682,8 +4690,7 @@ void Parser::ParseFunctionDeclarator(Declarator &D, DynamicExceptions.size(), NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0, - Tracker.getOpenLocation(), - EndLoc, D, + StartLoc, EndLoc, D, TrailingReturnType), FnAttrs, EndLoc); diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 9037392..c7be0d3 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -2486,18 +2486,28 @@ ExprResult Parser::ParseBlockLiteralExpression() { } else { // Otherwise, pretend we saw (void). ParsedAttributes attrs(AttrFactory); - ParamInfo.AddTypeInfo(DeclaratorChunk::getFunction(true, false, false, - SourceLocation(), - 0, 0, 0, - true, SourceLocation(), - SourceLocation(), - SourceLocation(), - SourceLocation(), - EST_None, - SourceLocation(), - 0, 0, 0, 0, - CaretLoc, CaretLoc, - ParamInfo), + SourceLocation NoLoc; + ParamInfo.AddTypeInfo(DeclaratorChunk::getFunction(/*HasProto=*/true, + /*IsAmbiguous=*/false, + /*RParenLoc=*/NoLoc, + /*ArgInfo=*/0, + /*NumArgs=*/0, + /*EllipsisLoc=*/NoLoc, + /*RParenLoc=*/NoLoc, + /*TypeQuals=*/0, + /*RefQualifierIsLvalueRef=*/true, + /*RefQualifierLoc=*/NoLoc, + /*ConstQualifierLoc=*/NoLoc, + /*VolatileQualifierLoc=*/NoLoc, + /*MutableLoc=*/NoLoc, + EST_None, + /*ESpecLoc=*/NoLoc, + /*Exceptions=*/0, + /*ExceptionRanges=*/0, + /*NumExceptions=*/0, + /*NoexceptExpr=*/0, + CaretLoc, CaretLoc, + ParamInfo), attrs, CaretLoc); MaybeParseGNUAttributes(ParamInfo); diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 41bf1b6..e478ef4 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -756,10 +756,10 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( Scope::FunctionPrototypeScope | Scope::DeclScope); - SourceLocation DeclLoc, DeclEndLoc; + SourceLocation DeclEndLoc; BalancedDelimiterTracker T(*this, tok::l_paren); T.consumeOpen(); - DeclLoc = T.getOpenLocation(); + SourceLocation LParenLoc = T.getOpenLocation(); // Parse parameter-declaration-clause. ParsedAttributes Attr(AttrFactory); @@ -770,7 +770,8 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( ParseParameterDeclarationClause(D, Attr, ParamInfo, EllipsisLoc); T.consumeClose(); - DeclEndLoc = T.getCloseLocation(); + SourceLocation RParenLoc = T.getCloseLocation(); + DeclEndLoc = RParenLoc; // Parse 'mutable'[opt]. SourceLocation MutableLoc; @@ -796,9 +797,12 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( // Parse attribute-specifier[opt]. MaybeParseCXX0XAttributes(Attr, &DeclEndLoc); + SourceLocation FunLocalRangeEnd = DeclEndLoc; + // Parse trailing-return-type[opt]. TypeResult TrailingReturnType; if (Tok.is(tok::arrow)) { + FunLocalRangeEnd = Tok.getLocation(); SourceRange Range; TrailingReturnType = ParseTrailingReturnType(Range); if (Range.getEnd().isValid()) @@ -807,15 +811,17 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( PrototypeScope.Exit(); + SourceLocation NoLoc; D.AddTypeInfo(DeclaratorChunk::getFunction(/*hasProto=*/true, - /*isVariadic=*/EllipsisLoc.isValid(), - /*isAmbiguous=*/false, EllipsisLoc, + /*isAmbiguous=*/false, + LParenLoc, ParamInfo.data(), ParamInfo.size(), + EllipsisLoc, RParenLoc, DS.getTypeQualifiers(), /*RefQualifierIsLValueRef=*/true, - /*RefQualifierLoc=*/SourceLocation(), - /*ConstQualifierLoc=*/SourceLocation(), - /*VolatileQualifierLoc=*/SourceLocation(), + /*RefQualifierLoc=*/NoLoc, + /*ConstQualifierLoc=*/NoLoc, + /*VolatileQualifierLoc=*/NoLoc, MutableLoc, ESpecType, ESpecRange.getBegin(), DynamicExceptions.data(), @@ -823,7 +829,7 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( DynamicExceptions.size(), NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0, - DeclLoc, DeclEndLoc, D, + LParenLoc, FunLocalRangeEnd, D, TrailingReturnType), Attr, DeclEndLoc); } else if (Tok.is(tok::kw_mutable) || Tok.is(tok::arrow)) { @@ -852,25 +858,28 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( } ParsedAttributes Attr(AttrFactory); + SourceLocation NoLoc; D.AddTypeInfo(DeclaratorChunk::getFunction(/*hasProto=*/true, - /*isVariadic=*/false, - /*isAmbiguous=*/false, - /*EllipsisLoc=*/SourceLocation(), - /*Params=*/0, /*NumParams=*/0, - /*TypeQuals=*/0, - /*RefQualifierIsLValueRef=*/true, - /*RefQualifierLoc=*/SourceLocation(), - /*ConstQualifierLoc=*/SourceLocation(), - /*VolatileQualifierLoc=*/SourceLocation(), - MutableLoc, - EST_None, - /*ESpecLoc=*/SourceLocation(), - /*Exceptions=*/0, - /*ExceptionRanges=*/0, - /*NumExceptions=*/0, - /*NoexceptExpr=*/0, - DeclLoc, DeclEndLoc, D, - TrailingReturnType), + /*isAmbiguous=*/false, + /*LParenLoc=*/NoLoc, + /*Params=*/0, + /*NumParams=*/0, + /*EllipsisLoc=*/NoLoc, + /*RParenLoc=*/NoLoc, + /*TypeQuals=*/0, + /*RefQualifierIsLValueRef=*/true, + /*RefQualifierLoc=*/NoLoc, + /*ConstQualifierLoc=*/NoLoc, + /*VolatileQualifierLoc=*/NoLoc, + MutableLoc, + EST_None, + /*ESpecLoc=*/NoLoc, + /*Exceptions=*/0, + /*ExceptionRanges=*/0, + /*NumExceptions=*/0, + /*NoexceptExpr=*/0, + DeclLoc, DeclEndLoc, D, + TrailingReturnType), Attr, DeclEndLoc); } diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index 86833c0..971fc72 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -144,11 +144,13 @@ CXXScopeSpec::getWithLocInContext(ASTContext &Context) const { /// DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function. /// "TheDeclarator" is the declarator that this will be added to. -DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, bool isVariadic, +DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, bool isAmbiguous, - SourceLocation EllipsisLoc, + SourceLocation LParenLoc, ParamInfo *ArgInfo, unsigned NumArgs, + SourceLocation EllipsisLoc, + SourceLocation RParenLoc, unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, @@ -173,9 +175,11 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, bool isVariadic, I.EndLoc = LocalRangeEnd; I.Fun.AttrList = 0; I.Fun.hasPrototype = hasProto; - I.Fun.isVariadic = isVariadic; + I.Fun.isVariadic = EllipsisLoc.isValid(); I.Fun.isAmbiguous = isAmbiguous; + I.Fun.LParenLoc = LParenLoc.getRawEncoding(); I.Fun.EllipsisLoc = EllipsisLoc.getRawEncoding(); + I.Fun.RParenLoc = RParenLoc.getRawEncoding(); I.Fun.DeleteArgInfo = false; I.Fun.TypeQuals = TypeQuals; I.Fun.NumArgs = NumArgs; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 7ca1f29..0979228 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -8043,13 +8043,28 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, bool Error = DS.SetTypeSpecType(DeclSpec::TST_int, Loc, Dummy, DiagID); (void)Error; // Silence warning. assert(!Error && "Error setting up implicit decl!"); + SourceLocation NoLoc; Declarator D(DS, Declarator::BlockContext); - D.AddTypeInfo(DeclaratorChunk::getFunction(false, false, false, - SourceLocation(), 0, 0, 0, true, - SourceLocation(), SourceLocation(), - SourceLocation(), SourceLocation(), - EST_None, SourceLocation(), - 0, 0, 0, 0, Loc, Loc, D), + D.AddTypeInfo(DeclaratorChunk::getFunction(/*HasProto=*/false, + /*IsAmbiguous=*/false, + /*RParenLoc=*/NoLoc, + /*ArgInfo=*/0, + /*NumArgs=*/0, + /*EllipsisLoc=*/NoLoc, + /*RParenLoc=*/NoLoc, + /*TypeQuals=*/0, + /*RefQualifierIsLvalueRef=*/true, + /*RefQualifierLoc=*/NoLoc, + /*ConstQualifierLoc=*/NoLoc, + /*VolatileQualifierLoc=*/NoLoc, + /*MutableLoc=*/NoLoc, + EST_None, + /*ESpecLoc=*/NoLoc, + /*Exceptions=*/0, + /*ExceptionRanges=*/0, + /*NumExceptions=*/0, + /*NoexceptExpr=*/0, + Loc, Loc, D), DS.getAttributes(), SourceLocation()); D.SetIdentifier(&II, Loc); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index a3af981..0b1dbd15 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -552,19 +552,28 @@ static void maybeSynthesizeBlockSignature(TypeProcessingState &state, SourceLocation loc = declarator.getLocStart(); // ...and *prepend* it to the declarator. + SourceLocation NoLoc; declarator.AddInnermostTypeInfo(DeclaratorChunk::getFunction( - /*proto*/ true, - /*variadic*/ false, - /*ambiguous*/ false, SourceLocation(), - /*args*/ 0, 0, - /*type quals*/ 0, - /*ref-qualifier*/true, SourceLocation(), - /*const qualifier*/SourceLocation(), - /*volatile qualifier*/SourceLocation(), - /*mutable qualifier*/SourceLocation(), - /*EH*/ EST_None, SourceLocation(), 0, 0, 0, 0, - /*parens*/ loc, loc, - declarator)); + /*HasProto=*/true, + /*IsAmbiguous=*/false, + /*LParenLoc=*/NoLoc, + /*ArgInfo=*/0, + /*NumArgs=*/0, + /*EllipsisLoc=*/NoLoc, + /*RParenLoc=*/NoLoc, + /*TypeQuals=*/0, + /*RefQualifierIsLvalueRef=*/true, + /*RefQualifierLoc=*/NoLoc, + /*ConstQualifierLoc=*/NoLoc, + /*VolatileQualifierLoc=*/NoLoc, + /*MutableLoc=*/NoLoc, + EST_None, + /*ESpecLoc=*/NoLoc, + /*Exceptions=*/0, + /*ExceptionRanges=*/0, + /*NumExceptions=*/0, + /*NoexceptExpr=*/0, + loc, loc, declarator)); // For consistency, make sure the state still has us as processing // the decl spec. @@ -3281,6 +3290,8 @@ namespace { TL.setLocalRangeEnd(Chunk.EndLoc); const DeclaratorChunk::FunctionTypeInfo &FTI = Chunk.Fun; + TL.setLParenLoc(FTI.getLParenLoc()); + TL.setRParenLoc(FTI.getRParenLoc()); for (unsigned i = 0, e = TL.getNumArgs(), tpi = 0; i != e; ++i) { ParmVarDecl *Param = cast(FTI.ArgInfo[i].Param); TL.setArg(tpi++, Param); diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index f76c947..7bf1a29 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -4196,6 +4196,8 @@ TreeTransform::TransformFunctionProtoType(TypeLocBuilder &TLB, FunctionProtoTypeLoc NewTL = TLB.push(Result); NewTL.setLocalRangeBegin(TL.getLocalRangeBegin()); + NewTL.setLParenLoc(TL.getLParenLoc()); + NewTL.setRParenLoc(TL.getRParenLoc()); NewTL.setLocalRangeEnd(TL.getLocalRangeEnd()); for (unsigned i = 0, e = NewTL.getNumArgs(); i != e; ++i) NewTL.setArg(i, ParamDecls[i]); @@ -4219,6 +4221,8 @@ QualType TreeTransform::TransformFunctionNoProtoType( FunctionNoProtoTypeLoc NewTL = TLB.push(Result); NewTL.setLocalRangeBegin(TL.getLocalRangeBegin()); + NewTL.setLParenLoc(TL.getLParenLoc()); + NewTL.setRParenLoc(TL.getRParenLoc()); NewTL.setLocalRangeEnd(TL.getLocalRangeEnd()); return Result; diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index f5de6c4..79173f5 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -4293,6 +4293,8 @@ void TypeLocReader::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) { } void TypeLocReader::VisitFunctionTypeLoc(FunctionTypeLoc TL) { TL.setLocalRangeBegin(ReadSourceLocation(Record, Idx)); + TL.setLParenLoc(ReadSourceLocation(Record, Idx)); + TL.setRParenLoc(ReadSourceLocation(Record, Idx)); TL.setLocalRangeEnd(ReadSourceLocation(Record, Idx)); for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i) { TL.setArg(i, ReadDeclAs(Record, Idx)); diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 6e19977..5906179 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -485,6 +485,8 @@ void TypeLocWriter::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) { } void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) { Writer.AddSourceLocation(TL.getLocalRangeBegin(), Record); + Writer.AddSourceLocation(TL.getLParenLoc(), Record); + Writer.AddSourceLocation(TL.getRParenLoc(), Record); Writer.AddSourceLocation(TL.getLocalRangeEnd(), Record); for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i) Writer.AddDeclRef(TL.getArg(i), Record);