forked from OSchip/llvm-project
[AST] RecursiveASTVisitor should not crash on lambdas with type attributes
rdar://31960860 llvm-svn: 302689
This commit is contained in:
parent
e60a976fce
commit
3b21d372c2
|
@ -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.
|
||||
|
|
|
@ -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> {
|
||||
|
|
Loading…
Reference in New Issue