diff options
-rw-r--r-- | include/clang/AST/TypeLoc.h | 25 | ||||
-rw-r--r-- | include/clang/Sema/DeclSpec.h | 3 | ||||
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 20 | ||||
-rw-r--r-- | lib/Sema/DeclSpec.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaExceptionSpec.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/TreeTransform.h | 8 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 4 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 4 |
11 files changed, 51 insertions, 43 deletions
diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index 8a0b650947..8c97a4225b 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -1033,7 +1033,8 @@ public: struct FunctionLocInfo { - SourceLocation LParenLoc, RParenLoc; + SourceLocation LocalRangeBegin; + SourceLocation LocalRangeEnd; bool TrailingReturn; }; @@ -1043,18 +1044,18 @@ class FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, FunctionType, FunctionLocInfo> { public: - SourceLocation getLParenLoc() const { - return getLocalData()->LParenLoc; + SourceLocation getLocalRangeBegin() const { + return getLocalData()->LocalRangeBegin; } - void setLParenLoc(SourceLocation Loc) { - getLocalData()->LParenLoc = Loc; + void setLocalRangeBegin(SourceLocation L) { + getLocalData()->LocalRangeBegin = L; } - SourceLocation getRParenLoc() const { - return getLocalData()->RParenLoc; + SourceLocation getLocalRangeEnd() const { + return getLocalData()->LocalRangeEnd; } - void setRParenLoc(SourceLocation Loc) { - getLocalData()->RParenLoc = Loc; + void setLocalRangeEnd(SourceLocation L) { + getLocalData()->LocalRangeEnd = L; } bool getTrailingReturn() const { @@ -1082,12 +1083,12 @@ public: } SourceRange getLocalSourceRange() const { - return SourceRange(getLParenLoc(), getRParenLoc()); + return SourceRange(getLocalRangeBegin(), getLocalRangeEnd()); } void initializeLocal(ASTContext &Context, SourceLocation Loc) { - setLParenLoc(Loc); - setRParenLoc(Loc); + setLocalRangeBegin(Loc); + setLocalRangeEnd(Loc); setTrailingReturn(false); for (unsigned i = 0, e = getNumArgs(); i != e; ++i) setArg(i, NULL); diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 30a188e4a6..2757daa673 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -1240,7 +1240,8 @@ struct DeclaratorChunk { SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, - SourceLocation LPLoc, SourceLocation RPLoc, + SourceLocation LocalRangeBegin, + SourceLocation LocalRangeEnd, Declarator &TheDeclarator, ParsedType TrailingReturnType = ParsedType()); diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index fc5fb33e84..450329a655 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -2601,7 +2601,9 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS, else Diag(Loc, diag::err_attributes_not_allowed); } - + + SourceLocation EndLoc; + while (1) { bool isInvalid = false; const char *PrevSpec = 0; @@ -2654,6 +2656,8 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS, // If this is not a type-qualifier token, we're done reading type // qualifiers. First verify that DeclSpec's are consistent. DS.Finish(Diags, PP); + if (EndLoc.isValid()) + DS.SetRangeEnd(EndLoc); return; } @@ -2662,7 +2666,7 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS, assert(PrevSpec && "Method did not return previous specifier!"); Diag(Tok, DiagID) << PrevSpec; } - ConsumeToken(); + EndLoc = ConsumeToken(); } } @@ -3144,8 +3148,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, if (RequiresArg) Diag(Tok, diag::err_argument_required_after_attribute); - SourceLocation RParenLoc = ConsumeParen(); // Eat the closing ')'. - SourceLocation EndLoc = RParenLoc; + SourceLocation EndLoc = ConsumeParen(); // Eat the closing ')'. // cv-qualifier-seq[opt]. DeclSpec DS; @@ -3167,7 +3170,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, if (Tok.is(tok::amp) || Tok.is(tok::ampamp)) { if (!getLang().CPlusPlus0x) Diag(Tok, diag::ext_ref_qualifier); - + RefQualifierIsLValueRef = Tok.is(tok::amp); RefQualifierLoc = ConsumeToken(); EndLoc = RefQualifierLoc; @@ -3203,7 +3206,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, DynamicExceptions.size(), NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0, - LParenLoc, RParenLoc, D, + LParenLoc, EndLoc, D, TrailingReturnType), EndLoc); return; @@ -3393,8 +3396,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, } // If we have the closing ')', eat it. - SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc); - SourceLocation EndLoc = RParenLoc; + SourceLocation EndLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc); DeclSpec DS; SourceLocation RefQualifierLoc; @@ -3458,7 +3460,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, DynamicExceptions.size(), NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0, - LParenLoc, RParenLoc, D, + LParenLoc, EndLoc, D, TrailingReturnType), EndLoc); } diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp index 388552d1f9..825d1afa0b 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/lib/Sema/DeclSpec.cpp @@ -149,14 +149,14 @@ DeclaratorChunk DeclaratorChunk::getFunction(const ParsedAttributes &attrs, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, - SourceLocation LPLoc, - SourceLocation RPLoc, + SourceLocation LocalRangeBegin, + SourceLocation LocalRangeEnd, Declarator &TheDeclarator, ParsedType TrailingReturnType) { DeclaratorChunk I; I.Kind = Function; - I.Loc = LPLoc; - I.EndLoc = RPLoc; + I.Loc = LocalRangeBegin; + I.EndLoc = LocalRangeEnd; I.Fun.AttrList = attrs.getList(); I.Fun.hasPrototype = hasProto; I.Fun.isVariadic = isVariadic; diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index a72c75b337..2bce585dd2 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -7440,10 +7440,14 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New, /// /// \param InitRange the source range that covers the "0" initializer. bool Sema::CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange) { + SourceLocation EndLoc = InitRange.getEnd(); + if (EndLoc.isValid()) + Method->setRangeEnd(EndLoc); + if (Method->isVirtual() || Method->getParent()->isDependentContext()) { Method->setPure(); return false; - } + } if (!Method->isInvalidDecl()) Diag(Method->getLocation(), diag::err_non_virtual_pure) diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index 75ae8c215a..dce4c6e220 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -194,14 +194,14 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { OS << ")"; OS.flush(); - SourceLocation AfterParenLoc; + SourceLocation FixItLoc; if (TypeSourceInfo *TSInfo = New->getTypeSourceInfo()) { TypeLoc TL = TSInfo->getTypeLoc().IgnoreParens(); if (const FunctionTypeLoc *FTLoc = dyn_cast<FunctionTypeLoc>(&TL)) - AfterParenLoc = PP.getLocForEndOfToken(FTLoc->getRParenLoc()); + FixItLoc = PP.getLocForEndOfToken(FTLoc->getLocalRangeEnd()); } - if (AfterParenLoc.isInvalid()) + if (FixItLoc.isInvalid()) Diag(New->getLocation(), diag::warn_missing_exception_specification) << New << OS.str(); else { @@ -209,7 +209,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { // late-specified return types. Diag(New->getLocation(), diag::warn_missing_exception_specification) << New << OS.str() - << FixItHint::CreateInsertion(AfterParenLoc, " " + OS.str().str()); + << FixItHint::CreateInsertion(FixItLoc, " " + OS.str().str()); } if (!Old->getLocation().isInvalid()) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 546d2e7e38..d0528b1bc3 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -8866,8 +8866,8 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) { // Check whether that explicit signature was synthesized by // GetTypeForDeclarator. If so, don't save that as part of the // written signature. - if (ExplicitSignature.getLParenLoc() == - ExplicitSignature.getRParenLoc()) { + if (ExplicitSignature.getLocalRangeBegin() == + ExplicitSignature.getLocalRangeEnd()) { // This would be much cheaper if we stored TypeLocs instead of // TypeSourceInfos. TypeLoc Result = ExplicitSignature.getResultLoc(); diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 2292735b50..62bf8e63ae 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -2466,8 +2466,8 @@ namespace { } void VisitFunctionTypeLoc(FunctionTypeLoc TL) { assert(Chunk.Kind == DeclaratorChunk::Function); - TL.setLParenLoc(Chunk.Loc); - TL.setRParenLoc(Chunk.EndLoc); + TL.setLocalRangeBegin(Chunk.Loc); + TL.setLocalRangeEnd(Chunk.EndLoc); TL.setTrailingReturn(!!Chunk.Fun.TrailingReturnType); const DeclaratorChunk::FunctionTypeInfo &FTI = Chunk.Fun; diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index f6c83d8c6f..bd28991e4b 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -3880,8 +3880,8 @@ TreeTransform<Derived>::TransformFunctionProtoType(TypeLocBuilder &TLB, } FunctionProtoTypeLoc NewTL = TLB.push<FunctionProtoTypeLoc>(Result); - NewTL.setLParenLoc(TL.getLParenLoc()); - NewTL.setRParenLoc(TL.getRParenLoc()); + NewTL.setLocalRangeBegin(TL.getLocalRangeBegin()); + NewTL.setLocalRangeEnd(TL.getLocalRangeEnd()); NewTL.setTrailingReturn(TL.getTrailingReturn()); for (unsigned i = 0, e = NewTL.getNumArgs(); i != e; ++i) NewTL.setArg(i, ParamDecls[i]); @@ -3904,8 +3904,8 @@ QualType TreeTransform<Derived>::TransformFunctionNoProtoType( Result = getDerived().RebuildFunctionNoProtoType(ResultType); FunctionNoProtoTypeLoc NewTL = TLB.push<FunctionNoProtoTypeLoc>(Result); - NewTL.setLParenLoc(TL.getLParenLoc()); - NewTL.setRParenLoc(TL.getRParenLoc()); + NewTL.setLocalRangeBegin(TL.getLocalRangeBegin()); + NewTL.setLocalRangeEnd(TL.getLocalRangeEnd()); NewTL.setTrailingReturn(false); return Result; diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 030e652169..1283525654 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -3443,8 +3443,8 @@ void TypeLocReader::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) { TL.setNameLoc(ReadSourceLocation(Record, Idx)); } void TypeLocReader::VisitFunctionTypeLoc(FunctionTypeLoc TL) { - TL.setLParenLoc(ReadSourceLocation(Record, Idx)); - TL.setRParenLoc(ReadSourceLocation(Record, Idx)); + TL.setLocalRangeBegin(ReadSourceLocation(Record, Idx)); + TL.setLocalRangeEnd(ReadSourceLocation(Record, Idx)); TL.setTrailingReturn(Record[Idx++]); for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i) { TL.setArg(i, cast_or_null<ParmVarDecl>(Reader.GetDecl(Record[Idx++]))); diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 1cb195dd31..5f830976a8 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -451,8 +451,8 @@ void TypeLocWriter::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) { Writer.AddSourceLocation(TL.getNameLoc(), Record); } void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) { - Writer.AddSourceLocation(TL.getLParenLoc(), Record); - Writer.AddSourceLocation(TL.getRParenLoc(), Record); + Writer.AddSourceLocation(TL.getLocalRangeBegin(), Record); + Writer.AddSourceLocation(TL.getLocalRangeEnd(), Record); Record.push_back(TL.getTrailingReturn()); for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i) Writer.AddDeclRef(TL.getArg(i), Record); |