aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-09-13 16:05:53 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-09-13 16:05:53 +0000
commitffcc3105d223899740e79f3f8199f3881df4d1de (patch)
tree2595e260442f53814cca58ed8db80c1658abc9a7 /lib/Parse/ParseDecl.cpp
parentfe522c20516878927e4f90a2aeafeeba2ea31c71 (diff)
Record the full source range of an attribute.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139599 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r--lib/Parse/ParseDecl.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 197e446fd3..16c25a4790 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -195,8 +195,8 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName,
if (Tok.is(tok::r_paren)) {
// __attribute__(( mode(byte) ))
- ConsumeParen(); // ignore the right paren loc for now
- Attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc,
+ SourceLocation RParen = ConsumeParen();
+ Attrs.addNew(AttrName, SourceRange(AttrNameLoc, RParen), 0, AttrNameLoc,
ParmName, ParmLoc, 0, 0);
} else if (Tok.is(tok::comma)) {
ConsumeToken();
@@ -219,20 +219,21 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName,
ConsumeToken(); // Eat the comma, move to the next argument
}
if (ArgExprsOk && Tok.is(tok::r_paren)) {
- ConsumeParen(); // ignore the right paren loc for now
- Attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc,
+ SourceLocation RParen = ConsumeParen();
+ Attrs.addNew(AttrName, SourceRange(AttrNameLoc, RParen), 0, AttrNameLoc,
ParmName, ParmLoc, ArgExprs.take(), ArgExprs.size());
}
}
} else { // not an identifier
switch (Tok.getKind()) {
- case tok::r_paren:
+ case tok::r_paren: {
// parse a possibly empty comma separated list of expressions
// __attribute__(( nonnull() ))
- ConsumeParen(); // ignore the right paren loc for now
- Attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc,
+ SourceLocation RParen = ConsumeParen();
+ Attrs.addNew(AttrName, SourceRange(AttrNameLoc, RParen), 0, AttrNameLoc,
0, SourceLocation(), 0, 0);
break;
+ }
case tok::kw_char:
case tok::kw_wchar_t:
case tok::kw_char16_t:
@@ -248,16 +249,16 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName,
case tok::kw_double:
case tok::kw_void:
case tok::kw_typeof: {
- AttributeList *attr
- = Attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc,
- 0, SourceLocation(), 0, 0);
- if (attr->getKind() == AttributeList::AT_IBOutletCollection)
- Diag(Tok, diag::err_iboutletcollection_builtintype);
// If it's a builtin type name, eat it and expect a rparen
// __attribute__(( vec_type_hint(char) ))
- ConsumeToken();
+ SourceLocation EndLoc = ConsumeToken();
if (Tok.is(tok::r_paren))
- ConsumeParen();
+ EndLoc = ConsumeParen();
+ AttributeList *attr
+ = Attrs.addNew(AttrName, SourceRange(AttrNameLoc, EndLoc), 0,
+ AttrNameLoc, 0, SourceLocation(), 0, 0);
+ if (attr->getKind() == AttributeList::AT_IBOutletCollection)
+ Diag(Tok, diag::err_iboutletcollection_builtintype);
break;
}
default:
@@ -281,8 +282,8 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName,
}
// Match the ')'.
if (ArgExprsOk && Tok.is(tok::r_paren)) {
- ConsumeParen(); // ignore the right paren loc for now
- Attrs.addNew(AttrName, AttrNameLoc, 0,
+ SourceLocation RParen = ConsumeParen();
+ Attrs.addNew(AttrName, SourceRange(AttrNameLoc, RParen), 0,
AttrNameLoc, 0, SourceLocation(),
ArgExprs.take(), ArgExprs.size());
}
@@ -695,7 +696,7 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability,
}
// Record this attribute
- attrs.addNew(&Availability, AvailabilityLoc,
+ attrs.addNew(&Availability, SourceRange(AvailabilityLoc, RParenLoc),
0, SourceLocation(),
Platform, PlatformLoc,
Changes[Introduced],