14 #ifndef LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H 15 #define LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H 19 #include "llvm/ADT/DenseMap.h" 20 #include "llvm/ADT/SmallPtrSet.h" 21 #include "llvm/ADT/StringMap.h" 22 #include "llvm/Support/Error.h" 25 class CompilerInstance;
33 class TranslationUnitDecl;
57 : Code(C), FileName(
std::move(FileName)), LineNo(LineNo) {}
59 std::string TripleFromName)
60 : Code(C), FileName(
std::move(FileName)),
61 TripleToName(
std::move(TripleToName)),
62 TripleFromName(
std::move(TripleFromName)) {}
63 void log(raw_ostream &OS)
const override;
64 std::error_code convertToErrorCode()
const override;
75 std::string TripleToName;
76 std::string TripleFromName;
127 getCrossTUDefinition(
const FunctionDecl *FD, StringRef CrossTUDir,
128 StringRef IndexName,
bool DisplayCTUProgress =
false);
130 getCrossTUDefinition(
const VarDecl *VD, StringRef CrossTUDir,
131 StringRef IndexName,
bool DisplayCTUProgress =
false);
147 StringRef CrossTUDir,
149 bool DisplayCTUProgress =
false);
160 static std::string getLookupName(
const NamedDecl *ND);
163 void emitCrossTUDiagnostics(
const IndexError &IE);
168 template <
typename T>
170 StringRef CrossTUDir,
172 bool DisplayCTUProgress);
173 template <
typename T>
174 const T *findDefInDeclContext(
const DeclContext *DC,
175 StringRef LookupName);
176 template <
typename T>
179 llvm::StringMap<std::unique_ptr<clang::ASTUnit>> FileASTUnitMap;
180 llvm::StringMap<clang::ASTUnit *> NameASTUnitMap;
181 llvm::StringMap<std::string> NameFileMap;
182 llvm::DenseMap<TranslationUnitDecl *, std::unique_ptr<ASTImporter>>
186 std::shared_ptr<ASTImporterSharedState> ImporterSharedSt;
189 const unsigned CTULoadThreshold;
190 unsigned NumASTLoaded{0u};
196 #endif // LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H Represents a function declaration or definition.
Represents a variable declaration or definition.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
bool containsConst(const VarDecl *VD, const ASTContext &ACtx)
std::string createCrossTUIndexString(const llvm::StringMap< std::string > &Index)
std::string getFileName() const
llvm::Expected< llvm::StringMap< std::string > > parseCrossTUIndex(StringRef IndexPath, StringRef CrossTUDir)
This function parses an index file that determines which translation unit contains which definition...
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
IndexError(index_error_code C, std::string FileName, std::string TripleToName, std::string TripleFromName)
Dataflow Directional Tag Classes.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
This class is used for tools that requires cross translation unit capability.
index_error_code getCode() const
Imports selected nodes from one AST context into another context, merging AST nodes where appropriate...
IndexError(index_error_code C, std::string FileName, int LineNo=0)
The top declaration context.
This represents a decl that may have a name.
std::string getTripleToName() const
IndexError(index_error_code C)
std::string getTripleFromName() const