[lldb] Capture error messages from parseASTSection to log from the caller.

This helps fix a lldb console output mixup between the lldb logging
and the llvm::dbgs() messages from parseASTSection.
This commit is contained in:
Hiroshi Yamauchi
2023-08-09 10:26:53 -07:00
parent f02ca3b3ca
commit 24dfc905f5
6 changed files with 127 additions and 20 deletions

View File

@@ -364,14 +364,20 @@ int main(int argc, char **argv) {
ClangImporter->setDWARFImporterDelegate(dummyDWARFImporter);
}
llvm::SmallString<0> error;
llvm::raw_svector_ostream errs(error);
llvm::Triple filter(Filter);
for (auto &Module : Modules)
if (!parseASTSection(*CI.getMemoryBufferSerializedModuleLoader(),
StringRef(Module.first, Module.second), filter,
modules)) {
llvm::errs() << "error: Failed to parse AST section!\n";
for (auto &Module : Modules) {
auto Result = parseASTSection(
*CI.getMemoryBufferSerializedModuleLoader(),
StringRef(Module.first, Module.second), filter);
if (auto E = Result.takeError()) {
std::string error = toString(std::move(E));
llvm::errs() << "error: Failed to parse AST section! " << error << "\n";
return 1;
}
modules.insert(modules.end(), Result->begin(), Result->end());
}
// Attempt to import all modules we found.
for (auto path : modules) {