]> granicus.if.org Git - clang/blob - include/clang/AST/ASTLambda.h
Implement a rudimentary form of generic lambdas.
[clang] / include / clang / AST / ASTLambda.h
1 //===--- ASTLambda.h - Lambda Helper Functions --------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief This file provides some common utility functions for processing
12 /// Lambda related AST Constructs.
13 ///
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_CLANG_AST_LAMBDA_H
17 #define LLVM_CLANG_AST_LAMBDA_H
18
19 #include "clang/AST/DeclCXX.h"
20 #include "clang/AST/DeclTemplate.h"
21
22 namespace clang {
23 inline StringRef getLambdaStaticInvokerName() {
24   return "__invoke";
25 }
26 // This function returns true if M is a specialization, a template,
27 // or a non-generic lambda call operator.
28 inline bool isLambdaCallOperator(const CXXMethodDecl *MD) {
29   const CXXRecordDecl *LambdaClass = MD->getParent();
30   if (!LambdaClass || !LambdaClass->isLambda()) return false;
31   return MD->getOverloadedOperator() == OO_Call;
32 }
33
34 inline bool isGenericLambdaCallOperatorSpecialization(CXXMethodDecl *MD) {
35   CXXRecordDecl *LambdaClass = MD->getParent();
36   if (LambdaClass && LambdaClass->isGenericLambda())
37     return isLambdaCallOperator(MD) && 
38                     MD->isFunctionTemplateSpecialization();
39   return false;
40 }
41
42 inline bool isGenericLambdaCallOperatorSpecialization(Decl *D) {
43   if (!D || !isa<CXXMethodDecl>(D)) return false;
44   return isGenericLambdaCallOperatorSpecialization(
45                                 cast<CXXMethodDecl>(D));
46 }
47 } // clang
48
49 #endif // LLVM_CLANG_AST_LAMBDA_H