Coverage Report

Created: 2019-02-20 00:17

/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
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
///
9
/// \file
10
/// This file provides some common utility functions for processing
11
/// Lambda related AST Constructs.
12
///
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_CLANG_AST_ASTLAMBDA_H
16
#define LLVM_CLANG_AST_ASTLAMBDA_H
17
18
#include "clang/AST/DeclCXX.h"
19
#include "clang/AST/DeclTemplate.h"
20
21
namespace clang {
22
5.96k
inline StringRef getLambdaStaticInvokerName() {
23
5.96k
  return "__invoke";
24
5.96k
}
25
// This function returns true if M is a specialization, a template,
26
// or a non-generic lambda call operator.
27
14.2M
inline bool isLambdaCallOperator(const CXXMethodDecl *MD) {
28
14.2M
  const CXXRecordDecl *LambdaClass = MD->getParent();
29
14.2M
  if (!LambdaClass || !LambdaClass->isLambda()) 
return false14.1M
;
30
96.4k
  return MD->getOverloadedOperator() == OO_Call;
31
96.4k
}
32
33
34.6M
inline bool isLambdaCallOperator(const DeclContext *DC) {
34
34.6M
  if (!DC || 
!isa<CXXMethodDecl>(DC)27.0M
)
return false20.7M
;
35
13.9M
  return isLambdaCallOperator(cast<CXXMethodDecl>(DC));
36
13.9M
}
37
38
13.5M
inline bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD) {
39
13.5M
  if (!MD) 
return false3.00M
;
40
10.5M
  const CXXRecordDecl *LambdaClass = MD->getParent();
41
10.5M
  if (
LambdaClass10.5M
&& LambdaClass->isGenericLambda())
42
7.55k
    return isLambdaCallOperator(MD) &&
43
7.55k
                    
MD->isFunctionTemplateSpecialization()5.21k
;
44
10.5M
  return false;
45
10.5M
}
46
47
265
inline bool isLambdaConversionOperator(CXXConversionDecl *C) {
48
265
  return C ? C->getParent()->isLambda() : 
false0
;
49
265
}
50
51
3.98k
inline bool isLambdaConversionOperator(Decl *D) {
52
3.98k
  if (!D) 
return false0
;
53
3.98k
  if (CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(D))
54
265
    return isLambdaConversionOperator(Conv);
55
3.71k
  if (FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(D))
56
0
    if (CXXConversionDecl *Conv =
57
0
        dyn_cast_or_null<CXXConversionDecl>(F->getTemplatedDecl()))
58
0
      return isLambdaConversionOperator(Conv);
59
3.71k
  return false;
60
3.71k
}
61
62
4.18M
inline bool isGenericLambdaCallOperatorSpecialization(DeclContext *DC) {
63
4.18M
  return isGenericLambdaCallOperatorSpecialization(
64
4.18M
                                          dyn_cast<CXXMethodDecl>(DC));
65
4.18M
}
66
67
68
// This returns the parent DeclContext ensuring that the correct
69
// parent DeclContext is returned for Lambdas
70
1.04M
inline DeclContext *getLambdaAwareParentOfDeclContext(DeclContext *DC) {
71
1.04M
  if (isLambdaCallOperator(DC))
72
22.5k
    return DC->getParent()->getParent();
73
1.02M
  else
74
1.02M
    return DC->getParent();
75
1.04M
}
76
77
} // clang
78
79
#endif