|
132 | 132 | #include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h"
|
133 | 133 | #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
|
134 | 134 |
|
135 |
| -#define VALID_OR_RETURN(value) \ |
136 |
| - do { \ |
137 |
| - if (HasFatalErrors()) { \ |
138 |
| - return (value); \ |
139 |
| - } \ |
140 |
| - } while (0) |
141 |
| -#define VALID_OR_RETURN_VOID() \ |
142 |
| - do { \ |
143 |
| - if (HasFatalErrors()) { \ |
144 |
| - return; \ |
145 |
| - } \ |
146 |
| - } while (0); |
147 |
| -#define VALID_OR_RETURN_CHECK_TYPE(type, value) \ |
148 |
| - do { \ |
149 |
| - if (HasFatalErrors() || !type) { \ |
150 |
| - return (value); \ |
151 |
| - } \ |
152 |
| - } while (0) |
153 |
| - |
154 | 135 | namespace {
|
155 | 136 | /// This silly constexpr allows us to filter out the useless __FUNCTION__ name
|
156 | 137 | /// of lambdas in the LOG_PRINTF macro.
|
@@ -190,6 +171,27 @@ std::recursive_mutex g_log_mutex;
|
190 | 171 | LOG_PRINTF(LIBLLDB_LOG_TYPES, FMT, ##__VA_ARGS__); \
|
191 | 172 | LOG_PRINTF_IMPL(lldb_private::GetSwiftHealthLog(), false, FMT, ##__VA_ARGS__)
|
192 | 173 |
|
| 174 | +#define VALID_OR_RETURN(value) \ |
| 175 | + do { \ |
| 176 | + if (HasFatalErrors()) { \ |
| 177 | + LOG_PRINTF(LIBLLDB_LOG_TYPES, \ |
| 178 | + "SwiftASTContext is in fatal error state, bailing out."); \ |
| 179 | + return value; \ |
| 180 | + } \ |
| 181 | + } while (0) |
| 182 | +#define VALID_OR_RETURN_CHECK_TYPE(type, value) \ |
| 183 | + do { \ |
| 184 | + if (HasFatalErrors()) { \ |
| 185 | + LOG_PRINTF(LIBLLDB_LOG_TYPES, \ |
| 186 | + "SwiftASTContext is in fatal error state, bailing out."); \ |
| 187 | + return (value); \ |
| 188 | + } \ |
| 189 | + if (!type) { \ |
| 190 | + LOG_PRINTF(LIBLLDB_LOG_TYPES, "Input type is nullptr, bailing out."); \ |
| 191 | + return (value); \ |
| 192 | + } \ |
| 193 | + } while (0) |
| 194 | + |
193 | 195 | using namespace lldb;
|
194 | 196 | using namespace lldb_private;
|
195 | 197 |
|
@@ -3608,7 +3610,7 @@ SwiftASTContext::CreateModule(const SourceModule &module, Status &error,
|
3608 | 3610 | }
|
3609 | 3611 |
|
3610 | 3612 | void SwiftASTContext::CacheModule(swift::ModuleDecl *module) {
|
3611 |
| - VALID_OR_RETURN_VOID(); |
| 3613 | + VALID_OR_RETURN(); |
3612 | 3614 |
|
3613 | 3615 | if (!module)
|
3614 | 3616 | return;
|
@@ -3825,7 +3827,7 @@ GetLibrarySearchPaths(const swift::SearchPathOptions &search_path_opts) {
|
3825 | 3827 |
|
3826 | 3828 | void SwiftASTContext::LoadModule(swift::ModuleDecl *swift_module,
|
3827 | 3829 | Process &process, Status &error) {
|
3828 |
| - VALID_OR_RETURN_VOID(); |
| 3830 | + VALID_OR_RETURN(); |
3829 | 3831 | LLDB_SCOPED_TIMER();
|
3830 | 3832 |
|
3831 | 3833 | Status current_error;
|
@@ -4127,7 +4129,7 @@ bool SwiftASTContext::LoadLibraryUsingPaths(
|
4127 | 4129 | }
|
4128 | 4130 |
|
4129 | 4131 | void SwiftASTContext::LoadExtraDylibs(Process &process, Status &error) {
|
4130 |
| - VALID_OR_RETURN_VOID(); |
| 4132 | + VALID_OR_RETURN(); |
4131 | 4133 |
|
4132 | 4134 | error.Clear();
|
4133 | 4135 | swift::IRGenOptions &irgen_options = GetIRGenOptions();
|
@@ -4161,7 +4163,7 @@ static std::string GetBriefModuleName(Module &module) {
|
4161 | 4163 |
|
4162 | 4164 | void SwiftASTContext::RegisterSectionModules(
|
4163 | 4165 | Module &module, std::vector<std::string> &module_names) {
|
4164 |
| - VALID_OR_RETURN_VOID(); |
| 4166 | + VALID_OR_RETURN(); |
4165 | 4167 | LLDB_SCOPED_TIMER();
|
4166 | 4168 |
|
4167 | 4169 | swift::MemoryBufferSerializedModuleLoader *loader =
|
@@ -4235,7 +4237,7 @@ void SwiftASTContext::RegisterSectionModules(
|
4235 | 4237 |
|
4236 | 4238 | void SwiftASTContext::ValidateSectionModules(
|
4237 | 4239 | Module &module, const std::vector<std::string> &module_names) {
|
4238 |
| - VALID_OR_RETURN_VOID(); |
| 4240 | + VALID_OR_RETURN(); |
4239 | 4241 | LLDB_SCOPED_TIMER();
|
4240 | 4242 |
|
4241 | 4243 | Status error;
|
@@ -4280,14 +4282,14 @@ ConstString SwiftASTContext::GetMangledTypeName(swift::TypeBase *type_base) {
|
4280 | 4282 |
|
4281 | 4283 | void SwiftASTContext::CacheDemangledType(ConstString name,
|
4282 | 4284 | swift::TypeBase *found_type) {
|
4283 |
| - VALID_OR_RETURN_VOID(); |
| 4285 | + VALID_OR_RETURN(); |
4284 | 4286 |
|
4285 | 4287 | m_type_to_mangled_name_map.insert({found_type, name.AsCString()});
|
4286 | 4288 | m_mangled_name_to_type_map.insert({name.AsCString(), found_type});
|
4287 | 4289 | }
|
4288 | 4290 |
|
4289 | 4291 | void SwiftASTContext::CacheDemangledTypeFailure(ConstString name) {
|
4290 |
| - VALID_OR_RETURN_VOID(); |
| 4292 | + VALID_OR_RETURN(); |
4291 | 4293 |
|
4292 | 4294 | m_negative_type_cache.Insert(name.AsCString());
|
4293 | 4295 | }
|
@@ -5024,7 +5026,7 @@ void SwiftASTContext::PrintDiagnostics(DiagnosticManager &diagnostic_manager,
|
5024 | 5026 | // fatal error field, and then put it to the stream, otherwise just
|
5025 | 5027 | // dump the diagnostics to the stream.
|
5026 | 5028 |
|
5027 |
| - // N.B. you cannot use VALID_OR_RETURN_VOID here since that exits if |
| 5029 | + // N.B. you cannot use VALID_OR_RETURN here since that exits if |
5028 | 5030 | // you have fatal errors, which are what we are trying to print
|
5029 | 5031 | // here.
|
5030 | 5032 | if (!m_ast_context_ap.get()) {
|
@@ -5096,7 +5098,10 @@ void SwiftASTContextForExpressions::ModulesDidLoad(ModuleList &module_list) {
|
5096 | 5098 | // We cannot reconfigure ClangImporter after its creation.
|
5097 | 5099 | // Instead poison the SwiftASTContext so it gets recreated.
|
5098 | 5100 | m_fatal_errors.SetErrorStringWithFormat(
|
5099 |
| - "New Swift image added: %s", |
| 5101 | + "New Swift image added: %s. ClangImporter needs to be reinitialized.", |
| 5102 | + module_sp->GetFileSpec().GetPath().c_str()); |
| 5103 | + HEALTH_LOG_PRINTF( |
| 5104 | + "New Swift image added: %s. ClangImporter needs to be reinitialized.", |
5100 | 5105 | module_sp->GetFileSpec().GetPath().c_str());
|
5101 | 5106 | }
|
5102 | 5107 |
|
|
0 commit comments