Fix the end location of init-capture annotations in ObjC++

And thereby stop asserting.

In ObjC++ modes, we tentatively parse the lambda introducer twice: once
to disambiguate designators, which we also do in C++, and a second time
to disambiguate objc message expressions. During the second tentative
parse, the last cached token will be the annotation token we built in
the first parse. So use getLastLoc() to get the correct end location
for the rebuilt annotation.

llvm-svn: 236246
This commit is contained in:
Ben Langmuir 2015-04-30 18:40:23 +00:00
parent 03b99f66d7
commit c861f4174d
2 changed files with 14 additions and 1 deletions

View File

@ -1179,7 +1179,7 @@ public:
/// location of an annotation token.
SourceLocation getLastCachedTokenLocation() const {
assert(CachedLexPos != 0);
return CachedTokens[CachedLexPos-1].getLocation();
return CachedTokens[CachedLexPos-1].getLastLoc();
}
/// \brief Replace the last token with an annotation token.

View File

@ -41,3 +41,16 @@ class C {
};
struct Func {
template <typename F>
Func(F&&);
};
int getInt();
void test() {
[val = getInt()]() { };
Func{
[val = getInt()]() { }
};
}