Skip to content

Commit d13cda6

Browse files
committed
Remove commented out code & extra ';'
Update ResolveTypeByName to return immediately when full match is found. Remove 'DIL' prefix from GetTypeSystemFromCU.
1 parent 77e940c commit d13cda6

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

lldb/include/lldb/ValueObject/DILParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ enum class ErrorCode : unsigned char {
3333
};
3434

3535
llvm::Expected<lldb::TypeSystemSP>
36-
DILGetTypeSystemFromCU(std::shared_ptr<StackFrame> ctx);
36+
GetTypeSystemFromCU(std::shared_ptr<StackFrame> ctx);
3737

3838
// The following is modeled on class OptionParseError.
3939
class DILDiagnosticError

lldb/source/ValueObject/DILEval.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ Interpreter::PickIntegerType(lldb::TypeSystemSP type_system,
586586
llvm::Expected<lldb::ValueObjectSP>
587587
Interpreter::Visit(const IntegerLiteralNode *node) {
588588
llvm::Expected<lldb::TypeSystemSP> type_system =
589-
DILGetTypeSystemFromCU(m_exe_ctx_scope);
589+
GetTypeSystemFromCU(m_exe_ctx_scope);
590590
if (!type_system)
591591
return type_system.takeError();
592592

@@ -610,7 +610,7 @@ Interpreter::Visit(const IntegerLiteralNode *node) {
610610
llvm::Expected<lldb::ValueObjectSP>
611611
Interpreter::Visit(const FloatLiteralNode *node) {
612612
llvm::Expected<lldb::TypeSystemSP> type_system =
613-
DILGetTypeSystemFromCU(m_exe_ctx_scope);
613+
GetTypeSystemFromCU(m_exe_ctx_scope);
614614
if (!type_system)
615615
return type_system.takeError();
616616

lldb/source/ValueObject/DILParser.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ DILDiagnosticError::DILDiagnosticError(llvm::StringRef expr,
4545
}
4646

4747
llvm::Expected<lldb::TypeSystemSP>
48-
DILGetTypeSystemFromCU(std::shared_ptr<StackFrame> ctx) {
48+
GetTypeSystemFromCU(std::shared_ptr<StackFrame> ctx) {
4949
SymbolContext symbol_context =
5050
ctx->GetSymbolContext(lldb::eSymbolContextCompUnit);
5151
lldb::LanguageType language = symbol_context.comp_unit->GetLanguage();
@@ -102,18 +102,14 @@ ResolveTypeByName(const std::string &name,
102102
for (uint32_t i = 0; i < result_type_list.size(); ++i) {
103103
CompilerType type = result_type_list[i];
104104
llvm::StringRef type_name_ref = type.GetTypeName().GetStringRef();
105-
;
106105

107-
if (type_name_ref == name_ref)
108-
full_match = type;
109-
else if (type_name_ref.ends_with(name_ref))
106+
if (type_name_ref == name_ref && type.IsValid())
107+
return type;
108+
109+
if (type_name_ref.ends_with(name_ref))
110110
partial_matches.push_back(type);
111111
}
112112

113-
// Full match is always correct.
114-
if (full_match.IsValid())
115-
return full_match;
116-
117113
// If we have partial matches, pick a "random" one.
118114
if (partial_matches.size() > 0)
119115
return partial_matches.back();
@@ -198,8 +194,6 @@ ASTNodeUP DILParser::ParseCastExpression() {
198194
m_dil_lexer.Advance();
199195
auto rhs = ParseCastExpression();
200196

201-
// return BuildCStyleCast(type_id.value(), std::move(rhs),
202-
// token.GetLocation());
203197
return std::make_unique<CStyleCastNode>(
204198
loc, type_id.value(), std::move(rhs), CStyleCastKind::eNone);
205199
}
@@ -436,7 +430,7 @@ std::optional<CompilerType> DILParser::ParseTypeId(bool must_be_type_id) {
436430
CompilerType type;
437431
if (type_decl.m_is_builtin) {
438432
llvm::Expected<lldb::TypeSystemSP> type_system =
439-
DILGetTypeSystemFromCU(m_ctx_scope);
433+
GetTypeSystemFromCU(m_ctx_scope);
440434
if (!type_system)
441435
return {};
442436
// type = GetBasicType(m_ctx_scope, type_decl.GetBasicType());
@@ -751,11 +745,7 @@ bool DILParser::HandleSimpleTypeSpecifier(TypeDeclaration *type_decl) {
751745
uint32_t loc = CurToken().GetLocation();
752746
std::string kind = CurToken().GetSpelling();
753747

754-
// switch (kind) {
755748
if (kind == "int") {
756-
// case Token::kw_int: {
757-
// "int" can have signedness and be combined with "short", "long" and
758-
// "long long" (but not with another "int").
759749
if (type_decl->m_has_int_specifier) {
760750
BailOut("cannot combine with previous 'int' declaration specifier", loc,
761751
CurToken().GetSpelling().length());

0 commit comments

Comments
 (0)