Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
source/API/SBModule.cpp
Show First 20 Lines • Show All 462 Lines • ▼ Show 20 Lines | lldb::SBType SBModule::FindFirstType(const char *name_cstr) { | ||||
if (name_cstr && module_sp) { | if (name_cstr && module_sp) { | ||||
SymbolContext sc; | SymbolContext sc; | ||||
const bool exact_match = false; | const bool exact_match = false; | ||||
ConstString name(name_cstr); | ConstString name(name_cstr); | ||||
sb_type = SBType(module_sp->FindFirstType(sc, name, exact_match)); | sb_type = SBType(module_sp->FindFirstType(sc, name, exact_match)); | ||||
if (!sb_type.IsValid()) { | if (!sb_type.IsValid()) { | ||||
TypeSystem *type_system = | auto type_system_or_err = | ||||
module_sp->GetTypeSystemForLanguage(eLanguageTypeC); | module_sp->GetTypeSystemForLanguage(eLanguageTypeC); | ||||
if (type_system) | if (auto err = type_system_or_err.takeError()) { | ||||
sb_type = SBType(type_system->GetBuiltinTypeByName(name)); | llvm::consumeError(std::move(err)); | ||||
} else { | |||||
sb_type = SBType(type_system_or_err->GetBuiltinTypeByName(name)); | |||||
} | |||||
} | } | ||||
} | } | ||||
return LLDB_RECORD_RESULT(sb_type); | return LLDB_RECORD_RESULT(sb_type); | ||||
} | } | ||||
lldb::SBType SBModule::GetBasicType(lldb::BasicType type) { | lldb::SBType SBModule::GetBasicType(lldb::BasicType type) { | ||||
LLDB_RECORD_METHOD(lldb::SBType, SBModule, GetBasicType, (lldb::BasicType), | LLDB_RECORD_METHOD(lldb::SBType, SBModule, GetBasicType, (lldb::BasicType), | ||||
type); | type); | ||||
ModuleSP module_sp(GetSP()); | ModuleSP module_sp(GetSP()); | ||||
if (module_sp) { | if (module_sp) { | ||||
TypeSystem *type_system = | auto type_system_or_err = | ||||
module_sp->GetTypeSystemForLanguage(eLanguageTypeC); | module_sp->GetTypeSystemForLanguage(eLanguageTypeC); | ||||
if (type_system) | if (auto err = type_system_or_err.takeError()) { | ||||
return LLDB_RECORD_RESULT(SBType(type_system->GetBasicTypeFromAST(type))); | llvm::consumeError(std::move(err)); | ||||
} else { | |||||
JDevlieghere: No else before return? | |||||
return LLDB_RECORD_RESULT( | |||||
SBType(type_system_or_err->GetBasicTypeFromAST(type))); | |||||
} | |||||
} | } | ||||
return LLDB_RECORD_RESULT(SBType()); | return LLDB_RECORD_RESULT(SBType()); | ||||
} | } | ||||
lldb::SBTypeList SBModule::FindTypes(const char *type) { | lldb::SBTypeList SBModule::FindTypes(const char *type) { | ||||
LLDB_RECORD_METHOD(lldb::SBTypeList, SBModule, FindTypes, (const char *), | LLDB_RECORD_METHOD(lldb::SBTypeList, SBModule, FindTypes, (const char *), | ||||
type); | type); | ||||
Show All 10 Lines | if (type && module_sp) { | ||||
if (num_matches > 0) { | if (num_matches > 0) { | ||||
for (size_t idx = 0; idx < num_matches; idx++) { | for (size_t idx = 0; idx < num_matches; idx++) { | ||||
TypeSP type_sp(type_list.GetTypeAtIndex(idx)); | TypeSP type_sp(type_list.GetTypeAtIndex(idx)); | ||||
if (type_sp) | if (type_sp) | ||||
retval.Append(SBType(type_sp)); | retval.Append(SBType(type_sp)); | ||||
} | } | ||||
} else { | } else { | ||||
TypeSystem *type_system = | auto type_system_or_err = | ||||
module_sp->GetTypeSystemForLanguage(eLanguageTypeC); | module_sp->GetTypeSystemForLanguage(eLanguageTypeC); | ||||
if (type_system) { | if (auto err = type_system_or_err.takeError()) { | ||||
CompilerType compiler_type = type_system->GetBuiltinTypeByName(name); | llvm::consumeError(std::move(err)); | ||||
} else { | |||||
CompilerType compiler_type = | |||||
type_system_or_err->GetBuiltinTypeByName(name); | |||||
Not Done ReplyInline ActionsAny reason you do this instead of if (!type_system_or_err) { llvm::consumeError(type_system_or_err.takeError()); ... JDevlieghere: Any reason you do this instead of
```if (!type_system_or_err) {
llvm::consumeError… | |||||
Not Done ReplyInline ActionsNo reason in particular. Is there a benefit in doing so or something I'm misunderstanding? xiaobai: No reason in particular. Is there a benefit in doing so or something I'm misunderstanding? | |||||
Not Done ReplyInline ActionsI like it because it's shorter and a bit easier to read. Probably it doesn't matter. If this works I don't want to hold up your change because of it. JDevlieghere: I like it because it's shorter and a bit easier to read. Probably it doesn't matter. If this… | |||||
if (compiler_type) | if (compiler_type) | ||||
retval.Append(SBType(compiler_type)); | retval.Append(SBType(compiler_type)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return LLDB_RECORD_RESULT(retval); | return LLDB_RECORD_RESULT(retval); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 241 Lines • Show Last 20 Lines |
No else before return?