Coverage Report

Created: 2021-08-24 07:12

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/tools/libclang/CXTranslationUnit.h
Line
Count
Source (jump to first uncovered line)
1
//===- CXTranslationUnit.h - Routines for manipulating CXTranslationUnits -===//
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 CXTranslationUnits.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXTRANSLATIONUNIT_H
14
#define LLVM_CLANG_TOOLS_LIBCLANG_CXTRANSLATIONUNIT_H
15
16
#include "CLog.h"
17
#include "CXString.h"
18
#include "clang-c/Index.h"
19
20
namespace clang {
21
  class ASTUnit;
22
  class CIndexer;
23
namespace index {
24
class CommentToXMLConverter;
25
} // namespace index
26
} // namespace clang
27
28
struct CXTranslationUnitImpl {
29
  clang::CIndexer *CIdx;
30
  clang::ASTUnit *TheASTUnit;
31
  clang::cxstring::CXStringPool *StringPool;
32
  void *Diagnostics;
33
  void *OverridenCursorsPool;
34
  clang::index::CommentToXMLConverter *CommentToXML;
35
  unsigned ParsingOptions;
36
  std::vector<std::string> Arguments;
37
};
38
39
struct CXTargetInfoImpl {
40
  CXTranslationUnit TranslationUnit;
41
};
42
43
namespace clang {
44
namespace cxtu {
45
46
CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx,
47
                                             std::unique_ptr<ASTUnit> AU);
48
49
920k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
920k
  if (!TU)
51
0
    return nullptr;
52
920k
  return TU->TheASTUnit;
53
920k
}
CIndex.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
142k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
142k
  if (!TU)
51
0
    return nullptr;
52
142k
  return TU->TheASTUnit;
53
142k
}
CIndexCodeCompletion.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
724
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
724
  if (!TU)
51
0
    return nullptr;
52
724
  return TU->TheASTUnit;
53
724
}
CIndexDiagnostic.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
1.21k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
1.21k
  if (!TU)
51
0
    return nullptr;
52
1.21k
  return TU->TheASTUnit;
53
1.21k
}
CIndexHigh.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
182
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
182
  if (!TU)
51
0
    return nullptr;
52
182
  return TU->TheASTUnit;
53
182
}
CIndexInclusionStack.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
5
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
5
  if (!TU)
51
0
    return nullptr;
52
5
  return TU->TheASTUnit;
53
5
}
CIndexUSRs.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
2.70k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
2.70k
  if (!TU)
51
0
    return nullptr;
52
2.70k
  return TU->TheASTUnit;
53
2.70k
}
CXComment.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
2.61k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
2.61k
  if (!TU)
51
0
    return nullptr;
52
2.61k
  return TU->TheASTUnit;
53
2.61k
}
CXCursor.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
728k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
728k
  if (!TU)
51
0
    return nullptr;
52
728k
  return TU->TheASTUnit;
53
728k
}
CXIndexDataConsumer.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
174
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
174
  if (!TU)
51
0
    return nullptr;
52
174
  return TU->TheASTUnit;
53
174
}
CXSourceLocation.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
9.58k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
9.58k
  if (!TU)
51
0
    return nullptr;
52
9.58k
  return TU->TheASTUnit;
53
9.58k
}
Unexecuted instantiation: CXStoredDiagnostic.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Unexecuted instantiation: CXString.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
CXType.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
31.9k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
31.9k
  if (!TU)
51
0
    return nullptr;
52
31.9k
  return TU->TheASTUnit;
53
31.9k
}
Indexing.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
9
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
9
  if (!TU)
51
0
    return nullptr;
52
9
  return TU->TheASTUnit;
53
9
}
Rewrite.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
5
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
5
  if (!TU)
51
0
    return nullptr;
52
5
  return TU->TheASTUnit;
53
5
}
54
55
/// \returns true if the ASTUnit has a diagnostic about the AST file being
56
/// corrupted.
57
bool isASTReadError(ASTUnit *AU);
58
59
50.0k
static inline bool isNotUsableTU(CXTranslationUnit TU) {
60
50.0k
  return !TU;
61
50.0k
}
CIndex.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Line
Count
Source
59
39.1k
static inline bool isNotUsableTU(CXTranslationUnit TU) {
60
39.1k
  return !TU;
61
39.1k
}
CIndexCodeCompletion.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Line
Count
Source
59
721
static inline bool isNotUsableTU(CXTranslationUnit TU) {
60
721
  return !TU;
61
721
}
CIndexDiagnostic.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Line
Count
Source
59
585
static inline bool isNotUsableTU(CXTranslationUnit TU) {
60
585
  return !TU;
61
585
}
CIndexHigh.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Line
Count
Source
59
9
static inline bool isNotUsableTU(CXTranslationUnit TU) {
60
9
  return !TU;
61
9
}
CIndexInclusionStack.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Line
Count
Source
59
2
static inline bool isNotUsableTU(CXTranslationUnit TU) {
60
2
  return !TU;
61
2
}
Unexecuted instantiation: CIndexUSRs.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Unexecuted instantiation: CXComment.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Unexecuted instantiation: CXCursor.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Unexecuted instantiation: CXIndexDataConsumer.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
CXSourceLocation.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Line
Count
Source
59
9.58k
static inline bool isNotUsableTU(CXTranslationUnit TU) {
60
9.58k
  return !TU;
61
9.58k
}
Unexecuted instantiation: CXStoredDiagnostic.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Unexecuted instantiation: CXString.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Unexecuted instantiation: CXType.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Indexing.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Line
Count
Source
59
9
static inline bool isNotUsableTU(CXTranslationUnit TU) {
60
9
  return !TU;
61
9
}
Rewrite.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Line
Count
Source
59
5
static inline bool isNotUsableTU(CXTranslationUnit TU) {
60
5
  return !TU;
61
5
}
62
63
#define LOG_BAD_TU(TU)                                  \
64
19
    do {                                                \
65
19
      LOG_FUNC_SECTION {                                \
66
0
        *Log << "called with a bad TU: " << TU;         \
67
0
      }                                                 \
68
19
    } while(false)
69
70
class CXTUOwner {
71
  CXTranslationUnitImpl *TU;
72
  
73
public:
74
39
  CXTUOwner(CXTranslationUnitImpl *tu) : TU(tu) { }
75
  ~CXTUOwner();
76
77
39
  CXTranslationUnitImpl *getTU() const { return TU; }
78
79
0
  CXTranslationUnitImpl *takeTU() {
80
0
    CXTranslationUnitImpl *retTU = TU;
81
0
    TU = nullptr;
82
0
    return retTU;
83
0
  }
84
};
85
86
87
}} // end namespace clang::cxtu
88
89
#endif