Coverage Report

Created: 2018-07-20 23:04

/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.54k
inline StringRef getLambdaStaticInvokerName() {
24
5.54k
  return "__invoke";
25
5.54k
}
26
// This function returns true if M is a specialization, a template,
27
// or a non-generic lambda call operator.
28
10.8M
inline bool isLambdaCallOperator(const CXXMethodDecl *MD) {
29
10.8M
  const CXXRecordDecl *LambdaClass = MD->getParent();
30
10.8M
  if (!LambdaClass || !LambdaClass->isLambda()) 
return false10.7M
;
31
84.1k
  return MD->getOverloadedOperator() == OO_Call;
32
84.1k
}
33
34
26.8M
inline bool isLambdaCallOperator(const DeclContext *DC) {
35
26.8M
  if (!DC || 
!isa<CXXMethodDecl>(DC)19.5M
)
return false16.1M
;
36
10.6M
  return isLambdaCallOperator(cast<CXXMethodDecl>(DC));
37
10.6M
}
38
39
12.2M
inline bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD) {
40
12.2M
  if (!MD) 
return false2.73M
;
41
9.51M
  const CXXRecordDecl *LambdaClass = MD->getParent();
42
9.51M
  if (LambdaClass && 
LambdaClass->isGenericLambda()9.51M
)
43
7.55k
    return isLambdaCallOperator(MD) && 
44
7.55k
                    
MD->isFunctionTemplateSpecialization()5.21k
;
45
9.50M
  return false;
46
9.50M
}
47
48
261
inline bool isLambdaConversionOperator(CXXConversionDecl *C) {
49
261
  return C ? C->getParent()->isLambda() : 
false0
;
50
261
}
51
52
3.61k
inline bool isLambdaConversionOperator(Decl *D) {
53
3.61k
  if (!D) 
return false0
;
54
3.61k
  if (CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(D)) 
55
261
    return isLambdaConversionOperator(Conv);  
56
3.35k
  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.35k
  return false;
61
3.35k
}
62
63
3.88M
inline bool isGenericLambdaCallOperatorSpecialization(DeclContext *DC) {
64
3.88M
  return isGenericLambdaCallOperatorSpecialization(
65
3.88M
                                          dyn_cast<CXXMethodDecl>(DC));
66
3.88M
}
67
68
69
// This returns the parent DeclContext ensuring that the correct
70
// parent DeclContext is returned for Lambdas
71
1.10M
inline DeclContext *getLambdaAwareParentOfDeclContext(DeclContext *DC) {
72
1.10M
  if (isLambdaCallOperator(DC))
73
21.7k
    return DC->getParent()->getParent();
74
1.08M
  else 
75
1.08M
    return DC->getParent();
76
1.10M
}
77
78
} // clang
79
80
#endif