/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/tools/libclang/CXSourceLocation.h
Line | Count | Source |
1 | | //===- CXSourceLocation.h - CXSourceLocations Utilities ---------*- 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 | | // This file defines routines for manipulating CXSourceLocations. |
10 | | // |
11 | | //===----------------------------------------------------------------------===// |
12 | | |
13 | | #ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXSOURCELOCATION_H |
14 | | #define LLVM_CLANG_TOOLS_LIBCLANG_CXSOURCELOCATION_H |
15 | | |
16 | | #include "clang-c/Index.h" |
17 | | #include "clang/AST/ASTContext.h" |
18 | | #include "clang/Basic/LangOptions.h" |
19 | | #include "clang/Basic/SourceLocation.h" |
20 | | |
21 | | namespace clang { |
22 | | |
23 | | class SourceManager; |
24 | | |
25 | | namespace cxloc { |
26 | | |
27 | | /// Translate a Clang source location into a CIndex source location. |
28 | | static inline CXSourceLocation |
29 | | translateSourceLocation(const SourceManager &SM, const LangOptions &LangOpts, |
30 | 164k | SourceLocation Loc) { |
31 | 164k | if (Loc.isInvalid()) |
32 | 203 | return clang_getNullLocation(); |
33 | | |
34 | 164k | CXSourceLocation Result = { { &SM, &LangOpts, }, |
35 | 164k | Loc.getRawEncoding() }; |
36 | 164k | return Result; |
37 | 164k | } CIndex.cpp:clang::cxloc::translateSourceLocation(clang::SourceManager const&, clang::LangOptions const&, clang::SourceLocation) Line | Count | Source | 30 | 152k | SourceLocation Loc) { | 31 | 152k | if (Loc.isInvalid()) | 32 | 203 | return clang_getNullLocation(); | 33 | | | 34 | 152k | CXSourceLocation Result = { { &SM, &LangOpts, }, | 35 | 152k | Loc.getRawEncoding() }; | 36 | 152k | return Result; | 37 | 152k | } |
Unexecuted instantiation: CIndexCodeCompletion.cpp:clang::cxloc::translateSourceLocation(clang::SourceManager const&, clang::LangOptions const&, clang::SourceLocation) CIndexDiagnostic.cpp:clang::cxloc::translateSourceLocation(clang::SourceManager const&, clang::LangOptions const&, clang::SourceLocation) Line | Count | Source | 30 | 240 | SourceLocation Loc) { | 31 | 240 | if (Loc.isInvalid()) | 32 | 0 | return clang_getNullLocation(); | 33 | | | 34 | 240 | CXSourceLocation Result = { { &SM, &LangOpts, }, | 35 | 240 | Loc.getRawEncoding() }; | 36 | 240 | return Result; | 37 | 240 | } |
Unexecuted instantiation: CIndexHigh.cpp:clang::cxloc::translateSourceLocation(clang::SourceManager const&, clang::LangOptions const&, clang::SourceLocation) CIndexInclusionStack.cpp:clang::cxloc::translateSourceLocation(clang::SourceManager const&, clang::LangOptions const&, clang::SourceLocation) Line | Count | Source | 30 | 8 | SourceLocation Loc) { | 31 | 8 | if (Loc.isInvalid()) | 32 | 0 | return clang_getNullLocation(); | 33 | | | 34 | 8 | CXSourceLocation Result = { { &SM, &LangOpts, }, | 35 | 8 | Loc.getRawEncoding() }; | 36 | 8 | return Result; | 37 | 8 | } |
CXSourceLocation.cpp:clang::cxloc::translateSourceLocation(clang::SourceManager const&, clang::LangOptions const&, clang::SourceLocation) Line | Count | Source | 30 | 9.58k | SourceLocation Loc) { | 31 | 9.58k | if (Loc.isInvalid()) | 32 | 0 | return clang_getNullLocation(); | 33 | | | 34 | 9.58k | CXSourceLocation Result = { { &SM, &LangOpts, }, | 35 | 9.58k | Loc.getRawEncoding() }; | 36 | 9.58k | return Result; | 37 | 9.58k | } |
CXStoredDiagnostic.cpp:clang::cxloc::translateSourceLocation(clang::SourceManager const&, clang::LangOptions const&, clang::SourceLocation) Line | Count | Source | 30 | 2.02k | SourceLocation Loc) { | 31 | 2.02k | if (Loc.isInvalid()) | 32 | 0 | return clang_getNullLocation(); | 33 | | | 34 | 2.02k | CXSourceLocation Result = { { &SM, &LangOpts, }, | 35 | 2.02k | Loc.getRawEncoding() }; | 36 | 2.02k | return Result; | 37 | 2.02k | } |
Unexecuted instantiation: Indexing.cpp:clang::cxloc::translateSourceLocation(clang::SourceManager const&, clang::LangOptions const&, clang::SourceLocation) Unexecuted instantiation: Rewrite.cpp:clang::cxloc::translateSourceLocation(clang::SourceManager const&, clang::LangOptions const&, clang::SourceLocation) |
38 | | |
39 | | /// Translate a Clang source location into a CIndex source location. |
40 | | static inline CXSourceLocation translateSourceLocation(ASTContext &Context, |
41 | 162k | SourceLocation Loc) { |
42 | 162k | return translateSourceLocation(Context.getSourceManager(), |
43 | 162k | Context.getLangOpts(), |
44 | 162k | Loc); |
45 | 162k | } CIndex.cpp:clang::cxloc::translateSourceLocation(clang::ASTContext&, clang::SourceLocation) Line | Count | Source | 41 | 152k | SourceLocation Loc) { | 42 | 152k | return translateSourceLocation(Context.getSourceManager(), | 43 | 152k | Context.getLangOpts(), | 44 | 152k | Loc); | 45 | 152k | } |
Unexecuted instantiation: CIndexCodeCompletion.cpp:clang::cxloc::translateSourceLocation(clang::ASTContext&, clang::SourceLocation) Unexecuted instantiation: CIndexDiagnostic.cpp:clang::cxloc::translateSourceLocation(clang::ASTContext&, clang::SourceLocation) Unexecuted instantiation: CIndexHigh.cpp:clang::cxloc::translateSourceLocation(clang::ASTContext&, clang::SourceLocation) CIndexInclusionStack.cpp:clang::cxloc::translateSourceLocation(clang::ASTContext&, clang::SourceLocation) Line | Count | Source | 41 | 8 | SourceLocation Loc) { | 42 | 8 | return translateSourceLocation(Context.getSourceManager(), | 43 | 8 | Context.getLangOpts(), | 44 | 8 | Loc); | 45 | 8 | } |
CXSourceLocation.cpp:clang::cxloc::translateSourceLocation(clang::ASTContext&, clang::SourceLocation) Line | Count | Source | 41 | 9.58k | SourceLocation Loc) { | 42 | 9.58k | return translateSourceLocation(Context.getSourceManager(), | 43 | 9.58k | Context.getLangOpts(), | 44 | 9.58k | Loc); | 45 | 9.58k | } |
Unexecuted instantiation: CXStoredDiagnostic.cpp:clang::cxloc::translateSourceLocation(clang::ASTContext&, clang::SourceLocation) Unexecuted instantiation: Indexing.cpp:clang::cxloc::translateSourceLocation(clang::ASTContext&, clang::SourceLocation) Unexecuted instantiation: Rewrite.cpp:clang::cxloc::translateSourceLocation(clang::ASTContext&, clang::SourceLocation) |
46 | | |
47 | | /// Translate a Clang source range into a CIndex source range. |
48 | | /// |
49 | | /// Clang internally represents ranges where the end location points to the |
50 | | /// start of the token at the end. However, for external clients it is more |
51 | | /// useful to have a CXSourceRange be a proper half-open interval. This routine |
52 | | /// does the appropriate translation. |
53 | | CXSourceRange translateSourceRange(const SourceManager &SM, |
54 | | const LangOptions &LangOpts, |
55 | | const CharSourceRange &R); |
56 | | |
57 | | /// Translate a Clang source range into a CIndex source range. |
58 | | static inline CXSourceRange translateSourceRange(ASTContext &Context, |
59 | 371k | SourceRange R) { |
60 | 371k | return translateSourceRange(Context.getSourceManager(), |
61 | 371k | Context.getLangOpts(), |
62 | 371k | CharSourceRange::getTokenRange(R)); |
63 | 371k | } CIndex.cpp:clang::cxloc::translateSourceRange(clang::ASTContext&, clang::SourceRange) Line | Count | Source | 59 | 371k | SourceRange R) { | 60 | 371k | return translateSourceRange(Context.getSourceManager(), | 61 | 371k | Context.getLangOpts(), | 62 | 371k | CharSourceRange::getTokenRange(R)); | 63 | 371k | } |
Unexecuted instantiation: CIndexCodeCompletion.cpp:clang::cxloc::translateSourceRange(clang::ASTContext&, clang::SourceRange) Unexecuted instantiation: CIndexDiagnostic.cpp:clang::cxloc::translateSourceRange(clang::ASTContext&, clang::SourceRange) CIndexHigh.cpp:clang::cxloc::translateSourceRange(clang::ASTContext&, clang::SourceRange) Line | Count | Source | 59 | 118 | SourceRange R) { | 60 | 118 | return translateSourceRange(Context.getSourceManager(), | 61 | 118 | Context.getLangOpts(), | 62 | 118 | CharSourceRange::getTokenRange(R)); | 63 | 118 | } |
Unexecuted instantiation: CIndexInclusionStack.cpp:clang::cxloc::translateSourceRange(clang::ASTContext&, clang::SourceRange) Unexecuted instantiation: CXSourceLocation.cpp:clang::cxloc::translateSourceRange(clang::ASTContext&, clang::SourceRange) Unexecuted instantiation: CXStoredDiagnostic.cpp:clang::cxloc::translateSourceRange(clang::ASTContext&, clang::SourceRange) Unexecuted instantiation: Indexing.cpp:clang::cxloc::translateSourceRange(clang::ASTContext&, clang::SourceRange) Unexecuted instantiation: Rewrite.cpp:clang::cxloc::translateSourceRange(clang::ASTContext&, clang::SourceRange) |
64 | | |
65 | 9.86k | static inline SourceLocation translateSourceLocation(CXSourceLocation L) { |
66 | 9.86k | return SourceLocation::getFromRawEncoding(L.int_data); |
67 | 9.86k | } CIndex.cpp:clang::cxloc::translateSourceLocation(CXSourceLocation) Line | Count | Source | 65 | 9.74k | static inline SourceLocation translateSourceLocation(CXSourceLocation L) { | 66 | 9.74k | return SourceLocation::getFromRawEncoding(L.int_data); | 67 | 9.74k | } |
Unexecuted instantiation: CIndexCodeCompletion.cpp:clang::cxloc::translateSourceLocation(CXSourceLocation) Unexecuted instantiation: CIndexDiagnostic.cpp:clang::cxloc::translateSourceLocation(CXSourceLocation) CIndexHigh.cpp:clang::cxloc::translateSourceLocation(CXSourceLocation) Line | Count | Source | 65 | 118 | static inline SourceLocation translateSourceLocation(CXSourceLocation L) { | 66 | 118 | return SourceLocation::getFromRawEncoding(L.int_data); | 67 | 118 | } |
Unexecuted instantiation: CIndexInclusionStack.cpp:clang::cxloc::translateSourceLocation(CXSourceLocation) Unexecuted instantiation: CXSourceLocation.cpp:clang::cxloc::translateSourceLocation(CXSourceLocation) Unexecuted instantiation: CXStoredDiagnostic.cpp:clang::cxloc::translateSourceLocation(CXSourceLocation) Unexecuted instantiation: Indexing.cpp:clang::cxloc::translateSourceLocation(CXSourceLocation) Rewrite.cpp:clang::cxloc::translateSourceLocation(CXSourceLocation) Line | Count | Source | 65 | 1 | static inline SourceLocation translateSourceLocation(CXSourceLocation L) { | 66 | 1 | return SourceLocation::getFromRawEncoding(L.int_data); | 67 | 1 | } |
|
68 | | |
69 | 9.81k | static inline SourceRange translateCXSourceRange(CXSourceRange R) { |
70 | 9.81k | return SourceRange(SourceLocation::getFromRawEncoding(R.begin_int_data), |
71 | 9.81k | SourceLocation::getFromRawEncoding(R.end_int_data)); |
72 | 9.81k | } CIndex.cpp:clang::cxloc::translateCXSourceRange(CXSourceRange) Line | Count | Source | 69 | 9.81k | static inline SourceRange translateCXSourceRange(CXSourceRange R) { | 70 | 9.81k | return SourceRange(SourceLocation::getFromRawEncoding(R.begin_int_data), | 71 | 9.81k | SourceLocation::getFromRawEncoding(R.end_int_data)); | 72 | 9.81k | } |
Unexecuted instantiation: CIndexCodeCompletion.cpp:clang::cxloc::translateCXSourceRange(CXSourceRange) Unexecuted instantiation: CIndexDiagnostic.cpp:clang::cxloc::translateCXSourceRange(CXSourceRange) Unexecuted instantiation: CIndexHigh.cpp:clang::cxloc::translateCXSourceRange(CXSourceRange) Unexecuted instantiation: CIndexInclusionStack.cpp:clang::cxloc::translateCXSourceRange(CXSourceRange) Unexecuted instantiation: CXSourceLocation.cpp:clang::cxloc::translateCXSourceRange(CXSourceRange) Unexecuted instantiation: CXStoredDiagnostic.cpp:clang::cxloc::translateCXSourceRange(CXSourceRange) Unexecuted instantiation: Indexing.cpp:clang::cxloc::translateCXSourceRange(CXSourceRange) Unexecuted instantiation: Rewrite.cpp:clang::cxloc::translateCXSourceRange(CXSourceRange) |
73 | | |
74 | | /// Translates CXSourceRange to CharSourceRange. |
75 | | /// The semantics of \p R are: |
76 | | /// R.begin_int_data is first character of the range. |
77 | | /// R.end_int_data is one character past the end of the range. |
78 | | CharSourceRange translateCXRangeToCharRange(CXSourceRange R); |
79 | | }} // end namespace: clang::cxloc |
80 | | |
81 | | #endif |