/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/AST/Interp/Source.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===--- Source.cpp - Source expression tracking ----------------*- 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 | | #include "Source.h" |
10 | | #include "clang/AST/Expr.h" |
11 | | |
12 | | using namespace clang; |
13 | | using namespace clang::interp; |
14 | | |
15 | 0 | SourceLocation SourceInfo::getLoc() const { |
16 | 0 | if (const Expr *E = asExpr()) |
17 | 0 | return E->getExprLoc(); |
18 | 0 | if (const Stmt *S = asStmt()) |
19 | 0 | return S->getBeginLoc(); |
20 | 0 | if (const Decl *D = asDecl()) |
21 | 0 | return D->getBeginLoc(); |
22 | 0 | return SourceLocation(); |
23 | 0 | } |
24 | | |
25 | 0 | const Expr *SourceInfo::asExpr() const { |
26 | 0 | if (auto *S = Source.dyn_cast<const Stmt *>()) |
27 | 0 | return dyn_cast<Expr>(S); |
28 | 0 | return nullptr; |
29 | 0 | } |
30 | | |
31 | 0 | const Expr *SourceMapper::getExpr(Function *F, CodePtr PC) const { |
32 | 0 | if (const Expr *E = getSource(F, PC).asExpr()) |
33 | 0 | return E; |
34 | 0 | llvm::report_fatal_error("missing source expression"); |
35 | 0 | } |
36 | | |
37 | 0 | SourceLocation SourceMapper::getLocation(Function *F, CodePtr PC) const { |
38 | 0 | return getSource(F, PC).getLoc(); |
39 | 0 | } |