diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-09-03 11:06:10 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-09-03 11:06:10 +0000 |
commit | a39beb9dd6b986db6dce6b0ec97eac1bee32cc60 (patch) | |
tree | ca69df921614f159456b156fc4945a8878dc1a70 /clang/lib/Parse/ParseDecl.cpp | |
parent | 12ad3b19110b8784d7aa3771cf49e7543222110f (diff) | |
download | bcm5719-llvm-a39beb9dd6b986db6dce6b0ec97eac1bee32cc60.tar.gz bcm5719-llvm-a39beb9dd6b986db6dce6b0ec97eac1bee32cc60.zip |
Parse: Replace polymorphic functor objects with lambdas and llvm::function_ref.
No change in functionality.
llvm-svn: 217025
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index b51b742f9da..53e3dbea81f 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -3235,14 +3235,15 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, /// declarator[opt] ':' constant-expression /// [GNU] declarator[opt] ':' constant-expression attributes[opt] /// -void Parser:: -ParseStructDeclaration(ParsingDeclSpec &DS, FieldCallback &Fields) { +void Parser::ParseStructDeclaration( + ParsingDeclSpec &DS, + llvm::function_ref<void(ParsingFieldDeclarator &)> FieldsCallback) { if (Tok.is(tok::kw___extension__)) { // __extension__ silences extension warnings in the subexpression. ExtensionRAIIObject O(Diags); // Use RAII to do this. ConsumeToken(); - return ParseStructDeclaration(DS, Fields); + return ParseStructDeclaration(DS, FieldsCallback); } // Parse the common specifier-qualifiers-list piece. @@ -3289,7 +3290,7 @@ ParseStructDeclaration(ParsingDeclSpec &DS, FieldCallback &Fields) { MaybeParseGNUAttributes(DeclaratorInfo.D); // We're done with this declarator; invoke the callback. - Fields.invoke(DeclaratorInfo); + FieldsCallback(DeclaratorInfo); // If we don't have a comma, it is either the end of the list (a ';') // or an error, bail out. @@ -3353,28 +3354,19 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc, } if (!Tok.is(tok::at)) { - struct CFieldCallback : FieldCallback { - Parser &P; - Decl *TagDecl; - SmallVectorImpl<Decl *> &FieldDecls; - - CFieldCallback(Parser &P, Decl *TagDecl, - SmallVectorImpl<Decl *> &FieldDecls) : - P(P), TagDecl(TagDecl), FieldDecls(FieldDecls) {} - - void invoke(ParsingFieldDeclarator &FD) override { - // Install the declarator into the current TagDecl. - Decl *Field = P.Actions.ActOnField(P.getCurScope(), TagDecl, - FD.D.getDeclSpec().getSourceRange().getBegin(), - FD.D, FD.BitfieldSize); - FieldDecls.push_back(Field); - FD.complete(Field); - } - } Callback(*this, TagDecl, FieldDecls); + auto CFieldCallback = [&](ParsingFieldDeclarator &FD) { + // Install the declarator into the current TagDecl. + Decl *Field = + Actions.ActOnField(getCurScope(), TagDecl, + FD.D.getDeclSpec().getSourceRange().getBegin(), + FD.D, FD.BitfieldSize); + FieldDecls.push_back(Field); + FD.complete(Field); + }; // Parse all the comma separated declarators. ParsingDeclSpec DS(*this); - ParseStructDeclaration(DS, Callback); + ParseStructDeclaration(DS, CFieldCallback); } else { // Handle @defs ConsumeToken(); if (!Tok.isObjCAtKeyword(tok::objc_defs)) { |