Coverage Report

Created: 2020-09-19 12:23

/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
869k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
869k
  if (!TU)
51
0
    return nullptr;
52
869k
  return TU->TheASTUnit;
53
869k
}
CIndex.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
138k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
138k
  if (!TU)
51
0
    return nullptr;
52
138k
  return TU->TheASTUnit;
53
138k
}
CIndexCodeCompletion.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
723
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
723
  if (!TU)
51
0
    return nullptr;
52
723
  return TU->TheASTUnit;
53
723
}
CIndexDiagnostic.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
1.20k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
1.20k
  if (!TU)
51
0
    return nullptr;
52
1.20k
  return TU->TheASTUnit;
53
1.20k
}
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.67k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
2.67k
  if (!TU)
51
0
    return nullptr;
52
2.67k
  return TU->TheASTUnit;
53
2.67k
}
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
684k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
684k
  if (!TU)
51
0
    return nullptr;
52
684k
  return TU->TheASTUnit;
53
684k
}
CXIndexDataConsumer.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
168
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
168
  if (!TU)
51
0
    return nullptr;
52
168
  return TU->TheASTUnit;
53
168
}
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
29.4k
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
29.4k
  if (!TU)
51
0
    return nullptr;
52
29.4k
  return TU->TheASTUnit;
53
29.4k
}
Indexing.cpp:clang::cxtu::getASTUnit(CXTranslationUnitImpl*)
Line
Count
Source
49
8
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
50
8
  if (!TU)
51
0
    return nullptr;
52
8
  return TU->TheASTUnit;
53
8
}
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
720
static inline bool isNotUsableTU(CXTranslationUnit TU) {
60
720
  return !TU;
61
720
}
CIndexDiagnostic.cpp:clang::cxtu::isNotUsableTU(CXTranslationUnitImpl*)
Line
Count
Source
59
582
static inline bool isNotUsableTU(CXTranslationUnit TU) {
60
582
  return !TU;
61
582
}
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
8
static inline bool isNotUsableTU(CXTranslationUnit TU) {
60
8
  return !TU;
61
8
}
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
38
  CXTUOwner(CXTranslationUnitImpl *tu) : TU(tu) { }
75
  ~CXTUOwner();
76
77
38
  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