parent
5e152ce3fe
commit
f2a79d94e4
|
@ -1033,7 +1033,8 @@ public:
|
||||||
|
|
||||||
|
|
||||||
struct FunctionLocInfo {
|
struct FunctionLocInfo {
|
||||||
SourceLocation LParenLoc, RParenLoc;
|
SourceLocation LocalRangeBegin;
|
||||||
|
SourceLocation LocalRangeEnd;
|
||||||
bool TrailingReturn;
|
bool TrailingReturn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1043,18 +1044,18 @@ class FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
|
||||||
FunctionType,
|
FunctionType,
|
||||||
FunctionLocInfo> {
|
FunctionLocInfo> {
|
||||||
public:
|
public:
|
||||||
SourceLocation getLParenLoc() const {
|
SourceLocation getLocalRangeBegin() const {
|
||||||
return getLocalData()->LParenLoc;
|
return getLocalData()->LocalRangeBegin;
|
||||||
}
|
}
|
||||||
void setLParenLoc(SourceLocation Loc) {
|
void setLocalRangeBegin(SourceLocation L) {
|
||||||
getLocalData()->LParenLoc = Loc;
|
getLocalData()->LocalRangeBegin = L;
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceLocation getRParenLoc() const {
|
SourceLocation getLocalRangeEnd() const {
|
||||||
return getLocalData()->RParenLoc;
|
return getLocalData()->LocalRangeEnd;
|
||||||
}
|
}
|
||||||
void setRParenLoc(SourceLocation Loc) {
|
void setLocalRangeEnd(SourceLocation L) {
|
||||||
getLocalData()->RParenLoc = Loc;
|
getLocalData()->LocalRangeEnd = L;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getTrailingReturn() const {
|
bool getTrailingReturn() const {
|
||||||
|
@ -1082,12 +1083,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceRange getLocalSourceRange() const {
|
SourceRange getLocalSourceRange() const {
|
||||||
return SourceRange(getLParenLoc(), getRParenLoc());
|
return SourceRange(getLocalRangeBegin(), getLocalRangeEnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
void initializeLocal(ASTContext &Context, SourceLocation Loc) {
|
void initializeLocal(ASTContext &Context, SourceLocation Loc) {
|
||||||
setLParenLoc(Loc);
|
setLocalRangeBegin(Loc);
|
||||||
setRParenLoc(Loc);
|
setLocalRangeEnd(Loc);
|
||||||
setTrailingReturn(false);
|
setTrailingReturn(false);
|
||||||
for (unsigned i = 0, e = getNumArgs(); i != e; ++i)
|
for (unsigned i = 0, e = getNumArgs(); i != e; ++i)
|
||||||
setArg(i, NULL);
|
setArg(i, NULL);
|
||||||
|
|
|
@ -1240,7 +1240,8 @@ struct DeclaratorChunk {
|
||||||
SourceRange *ExceptionRanges,
|
SourceRange *ExceptionRanges,
|
||||||
unsigned NumExceptions,
|
unsigned NumExceptions,
|
||||||
Expr *NoexceptExpr,
|
Expr *NoexceptExpr,
|
||||||
SourceLocation LPLoc, SourceLocation RPLoc,
|
SourceLocation LocalRangeBegin,
|
||||||
|
SourceLocation LocalRangeEnd,
|
||||||
Declarator &TheDeclarator,
|
Declarator &TheDeclarator,
|
||||||
ParsedType TrailingReturnType =
|
ParsedType TrailingReturnType =
|
||||||
ParsedType());
|
ParsedType());
|
||||||
|
|
|
@ -2601,7 +2601,9 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS,
|
||||||
else
|
else
|
||||||
Diag(Loc, diag::err_attributes_not_allowed);
|
Diag(Loc, diag::err_attributes_not_allowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SourceLocation EndLoc;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
bool isInvalid = false;
|
bool isInvalid = false;
|
||||||
const char *PrevSpec = 0;
|
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
|
// If this is not a type-qualifier token, we're done reading type
|
||||||
// qualifiers. First verify that DeclSpec's are consistent.
|
// qualifiers. First verify that DeclSpec's are consistent.
|
||||||
DS.Finish(Diags, PP);
|
DS.Finish(Diags, PP);
|
||||||
|
if (EndLoc.isValid())
|
||||||
|
DS.SetRangeEnd(EndLoc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2662,7 +2666,7 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS,
|
||||||
assert(PrevSpec && "Method did not return previous specifier!");
|
assert(PrevSpec && "Method did not return previous specifier!");
|
||||||
Diag(Tok, DiagID) << PrevSpec;
|
Diag(Tok, DiagID) << PrevSpec;
|
||||||
}
|
}
|
||||||
ConsumeToken();
|
EndLoc = ConsumeToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3144,8 +3148,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
|
||||||
if (RequiresArg)
|
if (RequiresArg)
|
||||||
Diag(Tok, diag::err_argument_required_after_attribute);
|
Diag(Tok, diag::err_argument_required_after_attribute);
|
||||||
|
|
||||||
SourceLocation RParenLoc = ConsumeParen(); // Eat the closing ')'.
|
SourceLocation EndLoc = ConsumeParen(); // Eat the closing ')'.
|
||||||
SourceLocation EndLoc = RParenLoc;
|
|
||||||
|
|
||||||
// cv-qualifier-seq[opt].
|
// cv-qualifier-seq[opt].
|
||||||
DeclSpec DS;
|
DeclSpec DS;
|
||||||
|
@ -3167,7 +3170,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
|
||||||
if (Tok.is(tok::amp) || Tok.is(tok::ampamp)) {
|
if (Tok.is(tok::amp) || Tok.is(tok::ampamp)) {
|
||||||
if (!getLang().CPlusPlus0x)
|
if (!getLang().CPlusPlus0x)
|
||||||
Diag(Tok, diag::ext_ref_qualifier);
|
Diag(Tok, diag::ext_ref_qualifier);
|
||||||
|
|
||||||
RefQualifierIsLValueRef = Tok.is(tok::amp);
|
RefQualifierIsLValueRef = Tok.is(tok::amp);
|
||||||
RefQualifierLoc = ConsumeToken();
|
RefQualifierLoc = ConsumeToken();
|
||||||
EndLoc = RefQualifierLoc;
|
EndLoc = RefQualifierLoc;
|
||||||
|
@ -3203,7 +3206,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
|
||||||
DynamicExceptions.size(),
|
DynamicExceptions.size(),
|
||||||
NoexceptExpr.isUsable() ?
|
NoexceptExpr.isUsable() ?
|
||||||
NoexceptExpr.get() : 0,
|
NoexceptExpr.get() : 0,
|
||||||
LParenLoc, RParenLoc, D,
|
LParenLoc, EndLoc, D,
|
||||||
TrailingReturnType),
|
TrailingReturnType),
|
||||||
EndLoc);
|
EndLoc);
|
||||||
return;
|
return;
|
||||||
|
@ -3393,8 +3396,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have the closing ')', eat it.
|
// If we have the closing ')', eat it.
|
||||||
SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
|
SourceLocation EndLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
|
||||||
SourceLocation EndLoc = RParenLoc;
|
|
||||||
|
|
||||||
DeclSpec DS;
|
DeclSpec DS;
|
||||||
SourceLocation RefQualifierLoc;
|
SourceLocation RefQualifierLoc;
|
||||||
|
@ -3458,7 +3460,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
|
||||||
DynamicExceptions.size(),
|
DynamicExceptions.size(),
|
||||||
NoexceptExpr.isUsable() ?
|
NoexceptExpr.isUsable() ?
|
||||||
NoexceptExpr.get() : 0,
|
NoexceptExpr.get() : 0,
|
||||||
LParenLoc, RParenLoc, D,
|
LParenLoc, EndLoc, D,
|
||||||
TrailingReturnType),
|
TrailingReturnType),
|
||||||
EndLoc);
|
EndLoc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,14 +149,14 @@ DeclaratorChunk DeclaratorChunk::getFunction(const ParsedAttributes &attrs,
|
||||||
SourceRange *ExceptionRanges,
|
SourceRange *ExceptionRanges,
|
||||||
unsigned NumExceptions,
|
unsigned NumExceptions,
|
||||||
Expr *NoexceptExpr,
|
Expr *NoexceptExpr,
|
||||||
SourceLocation LPLoc,
|
SourceLocation LocalRangeBegin,
|
||||||
SourceLocation RPLoc,
|
SourceLocation LocalRangeEnd,
|
||||||
Declarator &TheDeclarator,
|
Declarator &TheDeclarator,
|
||||||
ParsedType TrailingReturnType) {
|
ParsedType TrailingReturnType) {
|
||||||
DeclaratorChunk I;
|
DeclaratorChunk I;
|
||||||
I.Kind = Function;
|
I.Kind = Function;
|
||||||
I.Loc = LPLoc;
|
I.Loc = LocalRangeBegin;
|
||||||
I.EndLoc = RPLoc;
|
I.EndLoc = LocalRangeEnd;
|
||||||
I.Fun.AttrList = attrs.getList();
|
I.Fun.AttrList = attrs.getList();
|
||||||
I.Fun.hasPrototype = hasProto;
|
I.Fun.hasPrototype = hasProto;
|
||||||
I.Fun.isVariadic = isVariadic;
|
I.Fun.isVariadic = isVariadic;
|
||||||
|
|
|
@ -7440,10 +7440,14 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
|
||||||
///
|
///
|
||||||
/// \param InitRange the source range that covers the "0" initializer.
|
/// \param InitRange the source range that covers the "0" initializer.
|
||||||
bool Sema::CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange) {
|
bool Sema::CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange) {
|
||||||
|
SourceLocation EndLoc = InitRange.getEnd();
|
||||||
|
if (EndLoc.isValid())
|
||||||
|
Method->setRangeEnd(EndLoc);
|
||||||
|
|
||||||
if (Method->isVirtual() || Method->getParent()->isDependentContext()) {
|
if (Method->isVirtual() || Method->getParent()->isDependentContext()) {
|
||||||
Method->setPure();
|
Method->setPure();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Method->isInvalidDecl())
|
if (!Method->isInvalidDecl())
|
||||||
Diag(Method->getLocation(), diag::err_non_virtual_pure)
|
Diag(Method->getLocation(), diag::err_non_virtual_pure)
|
||||||
|
|
|
@ -194,14 +194,14 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
|
||||||
OS << ")";
|
OS << ")";
|
||||||
OS.flush();
|
OS.flush();
|
||||||
|
|
||||||
SourceLocation AfterParenLoc;
|
SourceLocation FixItLoc;
|
||||||
if (TypeSourceInfo *TSInfo = New->getTypeSourceInfo()) {
|
if (TypeSourceInfo *TSInfo = New->getTypeSourceInfo()) {
|
||||||
TypeLoc TL = TSInfo->getTypeLoc().IgnoreParens();
|
TypeLoc TL = TSInfo->getTypeLoc().IgnoreParens();
|
||||||
if (const FunctionTypeLoc *FTLoc = dyn_cast<FunctionTypeLoc>(&TL))
|
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)
|
Diag(New->getLocation(), diag::warn_missing_exception_specification)
|
||||||
<< New << OS.str();
|
<< New << OS.str();
|
||||||
else {
|
else {
|
||||||
|
@ -209,7 +209,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
|
||||||
// late-specified return types.
|
// late-specified return types.
|
||||||
Diag(New->getLocation(), diag::warn_missing_exception_specification)
|
Diag(New->getLocation(), diag::warn_missing_exception_specification)
|
||||||
<< New << OS.str()
|
<< New << OS.str()
|
||||||
<< FixItHint::CreateInsertion(AfterParenLoc, " " + OS.str().str());
|
<< FixItHint::CreateInsertion(FixItLoc, " " + OS.str().str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Old->getLocation().isInvalid())
|
if (!Old->getLocation().isInvalid())
|
||||||
|
|
|
@ -8866,8 +8866,8 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) {
|
||||||
// Check whether that explicit signature was synthesized by
|
// Check whether that explicit signature was synthesized by
|
||||||
// GetTypeForDeclarator. If so, don't save that as part of the
|
// GetTypeForDeclarator. If so, don't save that as part of the
|
||||||
// written signature.
|
// written signature.
|
||||||
if (ExplicitSignature.getLParenLoc() ==
|
if (ExplicitSignature.getLocalRangeBegin() ==
|
||||||
ExplicitSignature.getRParenLoc()) {
|
ExplicitSignature.getLocalRangeEnd()) {
|
||||||
// This would be much cheaper if we stored TypeLocs instead of
|
// This would be much cheaper if we stored TypeLocs instead of
|
||||||
// TypeSourceInfos.
|
// TypeSourceInfos.
|
||||||
TypeLoc Result = ExplicitSignature.getResultLoc();
|
TypeLoc Result = ExplicitSignature.getResultLoc();
|
||||||
|
|
|
@ -2466,8 +2466,8 @@ namespace {
|
||||||
}
|
}
|
||||||
void VisitFunctionTypeLoc(FunctionTypeLoc TL) {
|
void VisitFunctionTypeLoc(FunctionTypeLoc TL) {
|
||||||
assert(Chunk.Kind == DeclaratorChunk::Function);
|
assert(Chunk.Kind == DeclaratorChunk::Function);
|
||||||
TL.setLParenLoc(Chunk.Loc);
|
TL.setLocalRangeBegin(Chunk.Loc);
|
||||||
TL.setRParenLoc(Chunk.EndLoc);
|
TL.setLocalRangeEnd(Chunk.EndLoc);
|
||||||
TL.setTrailingReturn(!!Chunk.Fun.TrailingReturnType);
|
TL.setTrailingReturn(!!Chunk.Fun.TrailingReturnType);
|
||||||
|
|
||||||
const DeclaratorChunk::FunctionTypeInfo &FTI = Chunk.Fun;
|
const DeclaratorChunk::FunctionTypeInfo &FTI = Chunk.Fun;
|
||||||
|
|
|
@ -3880,8 +3880,8 @@ TreeTransform<Derived>::TransformFunctionProtoType(TypeLocBuilder &TLB,
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionProtoTypeLoc NewTL = TLB.push<FunctionProtoTypeLoc>(Result);
|
FunctionProtoTypeLoc NewTL = TLB.push<FunctionProtoTypeLoc>(Result);
|
||||||
NewTL.setLParenLoc(TL.getLParenLoc());
|
NewTL.setLocalRangeBegin(TL.getLocalRangeBegin());
|
||||||
NewTL.setRParenLoc(TL.getRParenLoc());
|
NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
|
||||||
NewTL.setTrailingReturn(TL.getTrailingReturn());
|
NewTL.setTrailingReturn(TL.getTrailingReturn());
|
||||||
for (unsigned i = 0, e = NewTL.getNumArgs(); i != e; ++i)
|
for (unsigned i = 0, e = NewTL.getNumArgs(); i != e; ++i)
|
||||||
NewTL.setArg(i, ParamDecls[i]);
|
NewTL.setArg(i, ParamDecls[i]);
|
||||||
|
@ -3904,8 +3904,8 @@ QualType TreeTransform<Derived>::TransformFunctionNoProtoType(
|
||||||
Result = getDerived().RebuildFunctionNoProtoType(ResultType);
|
Result = getDerived().RebuildFunctionNoProtoType(ResultType);
|
||||||
|
|
||||||
FunctionNoProtoTypeLoc NewTL = TLB.push<FunctionNoProtoTypeLoc>(Result);
|
FunctionNoProtoTypeLoc NewTL = TLB.push<FunctionNoProtoTypeLoc>(Result);
|
||||||
NewTL.setLParenLoc(TL.getLParenLoc());
|
NewTL.setLocalRangeBegin(TL.getLocalRangeBegin());
|
||||||
NewTL.setRParenLoc(TL.getRParenLoc());
|
NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
|
||||||
NewTL.setTrailingReturn(false);
|
NewTL.setTrailingReturn(false);
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
|
|
|
@ -3443,8 +3443,8 @@ void TypeLocReader::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
|
||||||
TL.setNameLoc(ReadSourceLocation(Record, Idx));
|
TL.setNameLoc(ReadSourceLocation(Record, Idx));
|
||||||
}
|
}
|
||||||
void TypeLocReader::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
|
void TypeLocReader::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
|
||||||
TL.setLParenLoc(ReadSourceLocation(Record, Idx));
|
TL.setLocalRangeBegin(ReadSourceLocation(Record, Idx));
|
||||||
TL.setRParenLoc(ReadSourceLocation(Record, Idx));
|
TL.setLocalRangeEnd(ReadSourceLocation(Record, Idx));
|
||||||
TL.setTrailingReturn(Record[Idx++]);
|
TL.setTrailingReturn(Record[Idx++]);
|
||||||
for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i) {
|
for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i) {
|
||||||
TL.setArg(i, cast_or_null<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
|
TL.setArg(i, cast_or_null<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
|
||||||
|
|
|
@ -451,8 +451,8 @@ void TypeLocWriter::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
|
||||||
Writer.AddSourceLocation(TL.getNameLoc(), Record);
|
Writer.AddSourceLocation(TL.getNameLoc(), Record);
|
||||||
}
|
}
|
||||||
void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
|
void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
|
||||||
Writer.AddSourceLocation(TL.getLParenLoc(), Record);
|
Writer.AddSourceLocation(TL.getLocalRangeBegin(), Record);
|
||||||
Writer.AddSourceLocation(TL.getRParenLoc(), Record);
|
Writer.AddSourceLocation(TL.getLocalRangeEnd(), Record);
|
||||||
Record.push_back(TL.getTrailingReturn());
|
Record.push_back(TL.getTrailingReturn());
|
||||||
for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i)
|
for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i)
|
||||||
Writer.AddDeclRef(TL.getArg(i), Record);
|
Writer.AddDeclRef(TL.getArg(i), Record);
|
||||||
|
|
Loading…
Reference in New Issue