Coverage Report

Created: 2018-11-13 17:19

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/AST/ASTLambda.h
Line
Count
Source (jump to first uncovered line)
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
/// This file provides some common utility functions for processing
12
/// Lambda related AST Constructs.
13
///
14
//===----------------------------------------------------------------------===//
15
16
#ifndef LLVM_CLANG_AST_ASTLAMBDA_H
17
#define LLVM_CLANG_AST_ASTLAMBDA_H
18
19
#include "clang/AST/DeclCXX.h"
20
#include "clang/AST/DeclTemplate.h"
21
22
namespace clang {
23
5.71k
inline StringRef getLambdaStaticInvokerName() {
24
5.71k
  return "__invoke";
25
5.71k
}
26
// This function returns true if M is a specialization, a template,
27
// or a non-generic lambda call operator.
28
11.5M
inline bool isLambdaCallOperator(const CXXMethodDecl *MD) {
29
11.5M
  const CXXRecordDecl *LambdaClass = MD->getParent();
30
11.5M
  if (!LambdaClass || !LambdaClass->isLambda()) 
return false11.4M
;
31
87.0k
  return MD->getOverloadedOperator() == OO_Call;
32
87.0k
}
33
34
28.3M
inline bool isLambdaCallOperator(const DeclContext *DC) {
35
28.3M
  if (!DC || 
!isa<CXXMethodDecl>(DC)20.6M
)
return false17.0M
;
36
11.3M
  return isLambdaCallOperator(cast<CXXMethodDecl>(DC));
37
11.3M
}
38
39
13.4M
inline bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD) {
40
13.4M
  if (!MD) 
return false2.89M
;
41
10.5M
  const CXXRecordDecl *LambdaClass = MD->getParent();
42
10.5M
  if (LambdaClass && LambdaClass->isGenericLambda())
43
7.55k
    return isLambdaCallOperator(MD) &&
44
7.55k
                    
MD->isFunctionTemplateSpecialization()5.21k
;
45
10.5M
  return false;
46
10.5M
}
47
48
264
inline bool isLambdaConversionOperator(CXXConversionDecl *C) {
49
264
  return C ? C->getParent()->isLambda() : 
false0
;
50
264
}
51
52
3.79k
inline bool isLambdaConversionOperator(Decl *D) {
53
3.79k
  if (!D) 
return false0
;
54
3.79k
  if (CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(D))
55
264
    return isLambdaConversionOperator(Conv);
56
3.53k
  if (FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(D))
57
0
    if (CXXConversionDecl *Conv =
58
0
        dyn_cast_or_null<CXXConversionDecl>(F->getTemplatedDecl()))
59
0
      return isLambdaConversionOperator(Conv);
60
3.53k
  return false;
61
3.53k
}
62
63
4.09M
inline bool isGenericLambdaCallOperatorSpecialization(DeclContext *DC) {
64
4.09M
  return isGenericLambdaCallOperatorSpecialization(
65
4.09M
                                          dyn_cast<CXXMethodDecl>(DC));
66
4.09M
}
67
68
69
// This returns the parent DeclContext ensuring that the correct
70
// parent DeclContext is returned for Lambdas
71
1.05M
inline DeclContext *getLambdaAwareParentOfDeclContext(DeclContext *DC) {
72
1.05M
  if (isLambdaCallOperator(DC))
73
22.3k
    return DC->getParent()->getParent();
74
1.03M
  else
75
1.03M
    return DC->getParent();
76
1.05M
}
77
78
} // clang
79
80
#endif