Coverage Report

Created: 2020-02-15 09:57

/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
144k
                        SourceLocation Loc) {
31
144k
  if (Loc.isInvalid())
32
202
    clang_getNullLocation();
33
144k
34
144k
  CXSourceLocation Result = { { &SM, &LangOpts, },
35
144k
                              Loc.getRawEncoding() };
36
144k
  return Result;
37
144k
}
CIndex.cpp:clang::cxloc::translateSourceLocation(clang::SourceManager const&, clang::LangOptions const&, clang::SourceLocation)
Line
Count
Source
30
133k
                        SourceLocation Loc) {
31
133k
  if (Loc.isInvalid())
32
202
    clang_getNullLocation();
33
133k
34
133k
  CXSourceLocation Result = { { &SM, &LangOpts, },
35
133k
                              Loc.getRawEncoding() };
36
133k
  return Result;
37
133k
}
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
240
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
8
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.56k
                        SourceLocation Loc) {
31
9.56k
  if (Loc.isInvalid())
32
0
    clang_getNullLocation();
33
9.56k
34
9.56k
  CXSourceLocation Result = { { &SM, &LangOpts, },
35
9.56k
                              Loc.getRawEncoding() };
36
9.56k
  return Result;
37
9.56k
}
CXStoredDiagnostic.cpp:clang::cxloc::translateSourceLocation(clang::SourceManager const&, clang::LangOptions const&, clang::SourceLocation)
Line
Count
Source
30
1.87k
                        SourceLocation Loc) {
31
1.87k
  if (Loc.isInvalid())
32
0
    clang_getNullLocation();
33
1.87k
34
1.87k
  CXSourceLocation Result = { { &SM, &LangOpts, },
35
1.87k
                              Loc.getRawEncoding() };
36
1.87k
  return Result;
37
1.87k
}
Unexecuted instantiation: Indexing.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
142k
                                                       SourceLocation Loc) {
42
142k
  return translateSourceLocation(Context.getSourceManager(),
43
142k
                                 Context.getLangOpts(),
44
142k
                                 Loc);
45
142k
}
CIndex.cpp:clang::cxloc::translateSourceLocation(clang::ASTContext&, clang::SourceLocation)
Line
Count
Source
41
133k
                                                       SourceLocation Loc) {
42
133k
  return translateSourceLocation(Context.getSourceManager(),
43
133k
                                 Context.getLangOpts(),
44
133k
                                 Loc);
45
133k
}
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.56k
                                                       SourceLocation Loc) {
42
9.56k
  return translateSourceLocation(Context.getSourceManager(),
43
9.56k
                                 Context.getLangOpts(),
44
9.56k
                                 Loc);
45
9.56k
}
Unexecuted instantiation: CXStoredDiagnostic.cpp:clang::cxloc::translateSourceLocation(clang::ASTContext&, clang::SourceLocation)
Unexecuted instantiation: Indexing.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
329k
                                                 SourceRange R) {
60
329k
  return translateSourceRange(Context.getSourceManager(),
61
329k
                              Context.getLangOpts(),
62
329k
                              CharSourceRange::getTokenRange(R));
63
329k
}
CIndex.cpp:clang::cxloc::translateSourceRange(clang::ASTContext&, clang::SourceRange)
Line
Count
Source
59
329k
                                                 SourceRange R) {
60
329k
  return translateSourceRange(Context.getSourceManager(),
61
329k
                              Context.getLangOpts(),
62
329k
                              CharSourceRange::getTokenRange(R));
63
329k
}
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)
64
65
9.84k
static inline SourceLocation translateSourceLocation(CXSourceLocation L) {
66
9.84k
  return SourceLocation::getFromRawEncoding(L.int_data);
67
9.84k
}
CIndex.cpp:clang::cxloc::translateSourceLocation(CXSourceLocation)
Line
Count
Source
65
9.72k
static inline SourceLocation translateSourceLocation(CXSourceLocation L) {
66
9.72k
  return SourceLocation::getFromRawEncoding(L.int_data);
67
9.72k
}
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)
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)
73
74
75
}} // end namespace: clang::cxloc
76
77
#endif