Coverage Report

Created: 2021-01-19 06:58

/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
147k
                        SourceLocation Loc) {
31
147k
  if (Loc.isInvalid())
32
204
    clang_getNullLocation();
33
34
147k
  CXSourceLocation Result = { { &SM, &LangOpts, },
35
147k
                              Loc.getRawEncoding() };
36
147k
  return Result;
37
147k
}
CIndex.cpp:clang::cxloc::translateSourceLocation(clang::SourceManager const&, clang::LangOptions const&, clang::SourceLocation)
Line
Count
Source
30
136k
                        SourceLocation Loc) {
31
136k
  if (Loc.isInvalid())
32
204
    clang_getNullLocation();
33
34
136k
  CXSourceLocation Result = { { &SM, &LangOpts, },
35
136k
                              Loc.getRawEncoding() };
36
136k
  return Result;
37
136k
}
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
    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
    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
    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.01k
                        SourceLocation Loc) {
31
2.01k
  if (Loc.isInvalid())
32
0
    clang_getNullLocation();
33
34
2.01k
  CXSourceLocation Result = { { &SM, &LangOpts, },
35
2.01k
                              Loc.getRawEncoding() };
36
2.01k
  return Result;
37
2.01k
}
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
145k
                                                       SourceLocation Loc) {
42
145k
  return translateSourceLocation(Context.getSourceManager(),
43
145k
                                 Context.getLangOpts(),
44
145k
                                 Loc);
45
145k
}
CIndex.cpp:clang::cxloc::translateSourceLocation(clang::ASTContext&, clang::SourceLocation)
Line
Count
Source
41
136k
                                                       SourceLocation Loc) {
42
136k
  return translateSourceLocation(Context.getSourceManager(),
43
136k
                                 Context.getLangOpts(),
44
136k
                                 Loc);
45
136k
}
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
335k
                                                 SourceRange R) {
60
335k
  return translateSourceRange(Context.getSourceManager(),
61
335k
                              Context.getLangOpts(),
62
335k
                              CharSourceRange::getTokenRange(R));
63
335k
}
CIndex.cpp:clang::cxloc::translateSourceRange(clang::ASTContext&, clang::SourceRange)
Line
Count
Source
59
335k
                                                 SourceRange R) {
60
335k
  return translateSourceRange(Context.getSourceManager(),
61
335k
                              Context.getLangOpts(),
62
335k
                              CharSourceRange::getTokenRange(R));
63
335k
}
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