/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::SemaDiagnosticBuilder Sema::SYCLDiagIfDeviceCode(SourceLocation Loc, |
21 | 85 | unsigned DiagID) { |
22 | 85 | assert(getLangOpts().SYCLIsDevice && |
23 | 85 | "Should only be called during SYCL compilation"); |
24 | 85 | FunctionDecl *FD = dyn_cast<FunctionDecl>(getCurLexicalContext()); |
25 | 85 | SemaDiagnosticBuilder::Kind DiagKind = [this, FD] { |
26 | 85 | if (!FD) |
27 | 8 | return SemaDiagnosticBuilder::K_Nop; |
28 | 77 | if (getEmissionStatus(FD) == Sema::FunctionEmissionStatus::Emitted) |
29 | 0 | return SemaDiagnosticBuilder::K_ImmediateWithCallStack; |
30 | 77 | return SemaDiagnosticBuilder::K_Deferred; |
31 | 77 | }(); |
32 | 85 | return SemaDiagnosticBuilder(DiagKind, Loc, DiagID, FD, *this); |
33 | 85 | } |
34 | | |
35 | 215 | bool Sema::checkSYCLDeviceFunction(SourceLocation Loc, FunctionDecl *Callee) { |
36 | 215 | assert(getLangOpts().SYCLIsDevice && |
37 | 215 | "Should only be called during SYCL compilation"); |
38 | 215 | 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 | 215 | if (isUnevaluatedContext() || isConstantEvaluated()) |
43 | 0 | return true; |
44 | | |
45 | 215 | SemaDiagnosticBuilder::Kind DiagKind = SemaDiagnosticBuilder::K_Nop; |
46 | | |
47 | 215 | return DiagKind != SemaDiagnosticBuilder::K_Immediate && |
48 | 215 | DiagKind != SemaDiagnosticBuilder::K_ImmediateWithCallStack; |
49 | 215 | } |