[AST] RecursiveASTVisitor should not crash on lambdas with type attributes

rdar://31960860

llvm-svn: 302689
This commit is contained in:
Alex Lorenz 2017-05-10 16:21:00 +00:00
parent e60a976fce
commit 3b21d372c2
2 changed files with 9 additions and 1 deletions

View File

@ -2326,7 +2326,7 @@ DEF_TRAVERSE_STMT(LambdaExpr, {
}
TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
FunctionProtoTypeLoc Proto = TL.castAs<FunctionProtoTypeLoc>();
FunctionProtoTypeLoc Proto = TL.getAsAdjusted<FunctionProtoTypeLoc>();
if (S->hasExplicitParameters() && S->hasExplicitResultType()) {
// Visit the whole type.

View File

@ -52,6 +52,14 @@ TEST(RecursiveASTVisitor, TraverseLambdaBodyCanBeOverridden) {
EXPECT_TRUE(Visitor.allBodiesHaveBeenTraversed());
}
TEST(RecursiveASTVisitor, VisitsAttributedLambdaExpr) {
LambdaExprVisitor Visitor;
Visitor.ExpectMatch("", 1, 12);
EXPECT_TRUE(Visitor.runOver(
"void f() { [] () __attribute__ (( fastcall )) { return; }(); }",
LambdaExprVisitor::Lang_CXX14));
}
// Matches the (optional) capture-default of a lambda-introducer.
class LambdaDefaultCaptureVisitor
: public ExpectedLocationVisitor<LambdaDefaultCaptureVisitor> {