14 #ifndef LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H 15 #define LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H 19 #include "llvm/ADT/DenseMap.h" 20 #include "llvm/ADT/Optional.h" 21 #include "llvm/ADT/SmallPtrSet.h" 22 #include "llvm/ADT/StringMap.h" 23 #include "llvm/Support/Error.h" 26 class CompilerInstance;
34 class TranslationUnitDecl;
58 : Code(C), FileName(
std::move(FileName)), LineNo(LineNo) {}
60 std::string TripleFromName)
61 : Code(C), FileName(
std::move(FileName)),
62 TripleToName(
std::move(TripleToName)),
63 TripleFromName(
std::move(TripleFromName)) {}
64 void log(raw_ostream &OS)
const override;
65 std::error_code convertToErrorCode()
const override;
76 std::string TripleToName;
77 std::string TripleFromName;
128 getCrossTUDefinition(
const FunctionDecl *FD, StringRef CrossTUDir,
129 StringRef IndexName,
bool DisplayCTUProgress =
false);
131 getCrossTUDefinition(
const VarDecl *VD, StringRef CrossTUDir,
132 StringRef IndexName,
bool DisplayCTUProgress =
false);
148 StringRef CrossTUDir,
150 bool DisplayCTUProgress =
false);
166 void emitCrossTUDiagnostics(
const IndexError &IE);
180 using ImportedFileIDMap =
181 llvm::DenseMap<FileID, std::pair<FileID, ASTUnit *>>;
185 template <
typename T>
187 StringRef CrossTUDir,
189 bool DisplayCTUProgress);
190 template <
typename T>
191 const T *findDefInDeclContext(
const DeclContext *DC,
192 StringRef LookupName);
193 template <
typename T>
196 using ImporterMapTy =
197 llvm::DenseMap<TranslationUnitDecl *, std::unique_ptr<ASTImporter>>;
199 ImporterMapTy ASTUnitImporterMap;
202 std::shared_ptr<ASTImporterSharedState> ImporterSharedSt;
210 ImportedFileIDMap ImportedFileIDs;
213 class ASTFileLoader {
216 std::unique_ptr<ASTUnit> operator()(StringRef ASTFilePath);
225 ASTLoadGuard(
unsigned Limit) : Limit(Limit) {}
229 operator bool()
const {
return Count < Limit; }
232 void indicateLoadSuccess() { ++Count; }
238 const unsigned Limit;
243 class ASTUnitStorage {
258 StringRef CrossTUDir,
260 bool DisplayCTUProgress);
272 StringRef CrossTUDir,
273 StringRef IndexName);
276 llvm::Error ensureCTUIndexLoaded(StringRef CrossTUDir, StringRef IndexName);
278 bool DisplayCTUProgress);
280 template <
typename... T>
using BaseMapTy = llvm::StringMap<T...>;
281 using OwningMapTy = BaseMapTy<std::unique_ptr<clang::ASTUnit>>;
282 using NonOwningMapTy = BaseMapTy<clang::ASTUnit *>;
284 OwningMapTy FileASTUnitMap;
285 NonOwningMapTy NameASTUnitMap;
287 using IndexMapTy = BaseMapTy<std::string>;
288 IndexMapTy NameFileMap;
290 ASTFileLoader FileAccessor;
297 ASTLoadGuard LoadGuard;
300 ASTUnitStorage ASTStorage;
307 #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 ...
Utility class for loading a ASTContext from an AST file.
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.
Encodes a location in the source.
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