|
7 | 7 | //===----------------------------------------------------------------------===//
|
8 | 8 |
|
9 | 9 | #include "lldb/Core/Module.h"
|
| 10 | +#include "lldb/Core/Progress.h" |
10 | 11 | #include "lldb/Utility/LLDBAssert.h"
|
11 | 12 | #include "lldb/Utility/LLDBLog.h"
|
12 | 13 | #include "lldb/Utility/Log.h"
|
|
17 | 18 | #include "clang/AST/RecordLayout.h"
|
18 | 19 | #include "clang/Sema/Lookup.h"
|
19 | 20 | #include "clang/Sema/Sema.h"
|
| 21 | +#include "llvm/ADT/ScopeExit.h" |
20 | 22 | #include "llvm/Support/raw_ostream.h"
|
21 | 23 |
|
22 | 24 | #include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
|
@@ -1131,6 +1133,7 @@ ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) {
|
1131 | 1133 | LLDB_LOG(log, "[ClangASTImporter] Complete definition not found");
|
1132 | 1134 | }
|
1133 | 1135 |
|
| 1136 | + UpdateImportProgress(From); |
1134 | 1137 | return ASTImporter::ImportImpl(From);
|
1135 | 1138 | }
|
1136 | 1139 |
|
@@ -1411,3 +1414,35 @@ clang::Decl *
|
1411 | 1414 | ClangASTImporter::ASTImporterDelegate::GetOriginalDecl(clang::Decl *To) {
|
1412 | 1415 | return m_main.GetDeclOrigin(To).decl;
|
1413 | 1416 | }
|
| 1417 | + |
| 1418 | +void ClangASTImporter::ASTImporterDelegate::UpdateImportProgress( |
| 1419 | + clang::Decl const *From) { |
| 1420 | + assert(From && |
| 1421 | + "Trying to report import progress using an invalid clang::Decl."); |
| 1422 | + |
| 1423 | + // If we can't determine the decl's name, we don't know what to |
| 1424 | + // update the progress bar with. So bail out. |
| 1425 | + auto const *ND = dyn_cast<NamedDecl>(From); |
| 1426 | + if (!ND) |
| 1427 | + return; |
| 1428 | + |
| 1429 | + if (!m_import_progress_up) { |
| 1430 | + auto const *from_ast = |
| 1431 | + TypeSystemClang::GetASTContext(&From->getASTContext()); |
| 1432 | + auto const *to_ast = TypeSystemClang::GetASTContext(&getToContext()); |
| 1433 | + |
| 1434 | + assert(from_ast && to_ast); |
| 1435 | + |
| 1436 | + llvm::SmallVector<llvm::StringRef> from_name_parts; |
| 1437 | + llvm::SplitString(from_ast->getDisplayName(), from_name_parts, "/"); |
| 1438 | + auto from_name = from_name_parts.back(); |
| 1439 | + |
| 1440 | + llvm::SmallVector<llvm::StringRef> to_name_parts; |
| 1441 | + llvm::SplitString(to_ast->getDisplayName(), to_name_parts, "/"); |
| 1442 | + auto to_name = to_name_parts.back(); |
| 1443 | + m_import_progress_up = std::make_unique<Progress>( |
| 1444 | + llvm::formatv("Importing '{0}' to '{1}'", from_name, to_name)); |
| 1445 | + } |
| 1446 | + |
| 1447 | + m_import_progress_up->Increment(1, ND->getNameAsString()); |
| 1448 | +} |
0 commit comments