Coverage Report

Created: 2020-09-22 08:39

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Sema/SemaSYCL.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- SemaSYCL.cpp - Semantic Analysis for SYCL constructs ---------------===//
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
// This implements Semantic Analysis for SYCL constructs.
9
//===----------------------------------------------------------------------===//
10
11
#include "clang/Sema/Sema.h"
12
#include "clang/Sema/SemaDiagnostic.h"
13
14
using namespace clang;
15
16
// -----------------------------------------------------------------------------
17
// SYCL device specific diagnostics implementation
18
// -----------------------------------------------------------------------------
19
20
Sema::DeviceDiagBuilder Sema::SYCLDiagIfDeviceCode(SourceLocation Loc,
21
45
                                                   unsigned DiagID) {
22
45
  assert(getLangOpts().SYCLIsDevice &&
23
45
         "Should only be called during SYCL compilation");
24
45
  FunctionDecl *FD = dyn_cast<FunctionDecl>(getCurLexicalContext());
25
45
  DeviceDiagBuilder::Kind DiagKind = [this, FD] {
26
45
    if (!FD)
27
6
      return DeviceDiagBuilder::K_Nop;
28
39
    if (getEmissionStatus(FD) == Sema::FunctionEmissionStatus::Emitted)
29
0
      return DeviceDiagBuilder::K_ImmediateWithCallStack;
30
39
    return DeviceDiagBuilder::K_Deferred;
31
39
  }();
32
45
  return DeviceDiagBuilder(DiagKind, Loc, DiagID, FD, *this);
33
45
}
34
35
225
bool Sema::checkSYCLDeviceFunction(SourceLocation Loc, FunctionDecl *Callee) {
36
225
  assert(getLangOpts().SYCLIsDevice &&
37
225
         "Should only be called during SYCL compilation");
38
225
  assert(Callee && "Callee may not be null.");
39
40
  // Errors in unevaluated context don't need to be generated,
41
  // so we can safely skip them.
42
225
  if (isUnevaluatedContext() || isConstantEvaluated())
43
0
    return true;
44
45
225
  DeviceDiagBuilder::Kind DiagKind = DeviceDiagBuilder::K_Nop;
46
47
225
  return DiagKind != DeviceDiagBuilder::K_Immediate &&
48
225
         DiagKind != DeviceDiagBuilder::K_ImmediateWithCallStack;
49
225
}