Author: Raphael Isemann Date: 2020-02-19T17:35:07+01:00 New Revision: bb61021a8fcc21676af65e4cbbf4d495831fad52
URL: https://github.com/llvm/llvm-project/commit/bb61021a8fcc21676af65e4cbbf4d495831fad52 DIFF: https://github.com/llvm/llvm-project/commit/bb61021a8fcc21676af65e4cbbf4d495831fad52.diff LOG: [lldb][NFC] Remove giant do{...}while(false); in ClangASTSource::FindExternalVisibleDecls Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index ad1111e1aef9..02b1f9bcd4a0 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -705,149 +705,146 @@ void ClangASTSource::FindExternalVisibleDecls( } } - do { - if (context.m_found.type) - break; + if (context.m_found.type) + return; - TypeList types; - const bool exact_match = true; - llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files; - if (module_sp && namespace_decl) - module_sp->FindTypesInNamespace(name, namespace_decl, 1, types); - else { - m_target->GetImages().FindTypes(module_sp.get(), name, exact_match, 1, - searched_symbol_files, types); - } + TypeList types; + const bool exact_match = true; + llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files; + if (module_sp && namespace_decl) + module_sp->FindTypesInNamespace(name, namespace_decl, 1, types); + else { + m_target->GetImages().FindTypes(module_sp.get(), name, exact_match, 1, + searched_symbol_files, types); + } - if (size_t num_types = types.GetSize()) { - for (size_t ti = 0; ti < num_types; ++ti) { - lldb::TypeSP type_sp = types.GetTypeAtIndex(ti); + if (size_t num_types = types.GetSize()) { + for (size_t ti = 0; ti < num_types; ++ti) { + lldb::TypeSP type_sp = types.GetTypeAtIndex(ti); - if (log) { - const char *name_string = type_sp->GetName().GetCString(); + if (log) { + const char *name_string = type_sp->GetName().GetCString(); - LLDB_LOG(log, " CAS::FEVD[{0}] Matching type found for \"{1}\": {2}", - current_id, name, - (name_string ? name_string : "<anonymous>")); - } + LLDB_LOG(log, " CAS::FEVD[{0}] Matching type found for \"{1}\": {2}", + current_id, name, + (name_string ? name_string : "<anonymous>")); + } - CompilerType full_type = type_sp->GetFullCompilerType(); + CompilerType full_type = type_sp->GetFullCompilerType(); - CompilerType copied_clang_type(GuardedCopyType(full_type)); + CompilerType copied_clang_type(GuardedCopyType(full_type)); - if (!copied_clang_type) { - LLDB_LOG(log, " CAS::FEVD[{0}] - Couldn't export a type", - current_id); + if (!copied_clang_type) { + LLDB_LOG(log, " CAS::FEVD[{0}] - Couldn't export a type", + current_id); - continue; - } + continue; + } - context.AddTypeDecl(copied_clang_type); + context.AddTypeDecl(copied_clang_type); - context.m_found.type = true; - break; - } + context.m_found.type = true; + break; } + } - if (!context.m_found.type) { - // Try the modules next. + if (!context.m_found.type) { + // Try the modules next. - do { - if (ClangModulesDeclVendor *modules_decl_vendor = - m_target->GetClangModulesDeclVendor()) { - bool append = false; - uint32_t max_matches = 1; - std::vector<clang::NamedDecl *> decls; + do { + if (ClangModulesDeclVendor *modules_decl_vendor = + m_target->GetClangModulesDeclVendor()) { + bool append = false; + uint32_t max_matches = 1; + std::vector<clang::NamedDecl *> decls; - if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls)) - break; + if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls)) + break; - if (log) { - LLDB_LOG(log, - " CAS::FEVD[{0}] Matching entity found for \"{1}\" in " - "the modules", - current_id, name); - } + if (log) { + LLDB_LOG(log, + " CAS::FEVD[{0}] Matching entity found for \"{1}\" in " + "the modules", + current_id, name); + } - clang::NamedDecl *const decl_from_modules = decls[0]; + clang::NamedDecl *const decl_from_modules = decls[0]; - if (llvm::isa<clang::TypeDecl>(decl_from_modules) || - llvm::isa<clang::ObjCContainerDecl>(decl_from_modules) || - llvm::isa<clang::EnumConstantDecl>(decl_from_modules)) { - clang::Decl *copied_decl = CopyDecl(decl_from_modules); - clang::NamedDecl *copied_named_decl = - copied_decl ? dyn_cast<clang::NamedDecl>(copied_decl) : nullptr; + if (llvm::isa<clang::TypeDecl>(decl_from_modules) || + llvm::isa<clang::ObjCContainerDecl>(decl_from_modules) || + llvm::isa<clang::EnumConstantDecl>(decl_from_modules)) { + clang::Decl *copied_decl = CopyDecl(decl_from_modules); + clang::NamedDecl *copied_named_decl = + copied_decl ? dyn_cast<clang::NamedDecl>(copied_decl) : nullptr; - if (!copied_named_decl) { - LLDB_LOG( - log, - " CAS::FEVD[{0}] - Couldn't export a type from the modules", - current_id); + if (!copied_named_decl) { + LLDB_LOG( + log, + " CAS::FEVD[{0}] - Couldn't export a type from the modules", + current_id); - break; - } + break; + } - context.AddNamedDecl(copied_named_decl); + context.AddNamedDecl(copied_named_decl); - context.m_found.type = true; - } + context.m_found.type = true; } - } while (false); - } - - if (!context.m_found.type) { - do { - // Couldn't find any types elsewhere. Try the Objective-C runtime if - // one exists. + } + } while (false); + } - lldb::ProcessSP process(m_target->GetProcessSP()); + if (!context.m_found.type) { + do { + // Couldn't find any types elsewhere. Try the Objective-C runtime if + // one exists. - if (!process) - break; + lldb::ProcessSP process(m_target->GetProcessSP()); - ObjCLanguageRuntime *language_runtime( - ObjCLanguageRuntime::Get(*process)); + if (!process) + break; - if (!language_runtime) - break; + ObjCLanguageRuntime *language_runtime( + ObjCLanguageRuntime::Get(*process)); - DeclVendor *decl_vendor = language_runtime->GetDeclVendor(); + if (!language_runtime) + break; - if (!decl_vendor) - break; + DeclVendor *decl_vendor = language_runtime->GetDeclVendor(); - bool append = false; - uint32_t max_matches = 1; - std::vector<clang::NamedDecl *> decls; + if (!decl_vendor) + break; - auto *clang_decl_vendor = llvm::cast<ClangDeclVendor>(decl_vendor); - if (!clang_decl_vendor->FindDecls(name, append, max_matches, decls)) - break; + bool append = false; + uint32_t max_matches = 1; + std::vector<clang::NamedDecl *> decls; - if (log) { - LLDB_LOG( - log, - " CAS::FEVD[{0}] Matching type found for \"{0}\" in the runtime", - current_id, name); - } + auto *clang_decl_vendor = llvm::cast<ClangDeclVendor>(decl_vendor); + if (!clang_decl_vendor->FindDecls(name, append, max_matches, decls)) + break; - clang::Decl *copied_decl = CopyDecl(decls[0]); - clang::NamedDecl *copied_named_decl = - copied_decl ? dyn_cast<clang::NamedDecl>(copied_decl) : nullptr; + if (log) { + LLDB_LOG( + log, + " CAS::FEVD[{0}] Matching type found for \"{0}\" in the runtime", + current_id, name); + } - if (!copied_named_decl) { - LLDB_LOG(log, - " CAS::FEVD[{0}] - Couldn't export a type from the runtime", - current_id); + clang::Decl *copied_decl = CopyDecl(decls[0]); + clang::NamedDecl *copied_named_decl = + copied_decl ? dyn_cast<clang::NamedDecl>(copied_decl) : nullptr; - break; - } + if (!copied_named_decl) { + LLDB_LOG(log, + " CAS::FEVD[{0}] - Couldn't export a type from the runtime", + current_id); - context.AddNamedDecl(copied_named_decl); - } while (false); - } + break; + } - } while (false); + context.AddNamedDecl(copied_named_decl); + } while (false); + } } template <class D> class TaggedASTDecl { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits