Skip to content

Commit

Permalink
[AST] RecursiveASTVisitor should not crash on lambdas with type attri…
Browse files Browse the repository at this point in the history
…butes

rdar://31960860


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302689 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
hyp committed May 10, 2017
1 parent 1584f48 commit 91d84ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions unittests/Tooling/RecursiveASTVisitorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit 91d84ed

Please sign in to comment.