Skip to content

Update type.cpp#4

Open
acheron2302 wants to merge 7 commits into
19h:masterfrom
acheron2302:master
Open

Update type.cpp#4
acheron2302 wants to merge 7 commits into
19h:masterfrom
acheron2302:master

Conversation

@acheron2302
Copy link
Copy Markdown

Adding apply_callee_tinfo for apply to automatically recognise and change type if it is function call instruction

acheron2302 and others added 3 commits April 16, 2026 23:59
Adding apply_callee_tinfo for apply to automatically recognise and change type if it is function call instruction
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b38e6b730c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/type.cpp Outdated
@acheron2302
Copy link
Copy Markdown
Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d4bc33ec72

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/type.cpp Outdated
Comment on lines +521 to +524
if (ida::instruction::is_call(ea)) {
if (!apply_callee_tinfo(ea, impl_->ti))
return std::unexpected(
Error::sdk("apply_callee_tinfo failed", std::to_string(ea)));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add fallback when callee typing preconditions are unmet

TypeInfo::apply now sends every is_call(ea) address to apply_callee_tinfo, but Hex-Rays documents that apply_callee_tinfo requires the caller address to belong to a function; call instructions outside a defined function (or addresses misclassified as call-like) will therefore fail this branch and return an SDK error, whereas the previous implementation still attempted apply_tinfo at that address. This is a behavior regression for valid apply() use cases on not-yet-functionized code and should fall back to apply_tinfo when callee application is not applicable or fails (https://python.docs.hex-rays.com/ida_typeinf/index.html#ida_typeinf.apply_callee_tinfo).

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b6a96ff66d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/type.cpp Outdated

NamedTypeIterator NamedTypeRange::begin() const {
NamedTypeIterator it;
NamedTypeAccess::get(it) = new NamedTypeIterator::Impl(impl_->root_til, impl_->flags);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard default-constructed ranges before dereferencing

NamedTypeRange is publicly default-constructible, leaving impl_ == nullptr, and the new unit tests exercise empty_range.begin()/end() for an empty/default range. This dereference turns that valid empty-range scenario into a crash instead of begin() == end(); return a default/end iterator when impl_ is null before reading impl_->root_til.

Useful? React with 👍 / 👎.

Comment thread src/type.cpp Outdated
return std::unexpected(Error::not_found("No type library available"));

NamedTypeRange range;
NamedTypeAccess::get(range) = new NamedTypeRange::Impl(til, flags);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve base TIL count for iteration

NamedTypeRange::Impl initializes base_count to 0, and named_types() stores that unchanged here. After the root TIL is exhausted, operator++ only enters base libraries while base_index < base_count, so named_types()/named_types({}) never visits any loaded base TILs despite the API documenting iteration across all TILs. Initialize the range with til->nbases + 1 (or equivalent) when constructing it.

Useful? React with 👍 / 👎.

Comment thread src/type.cpp Outdated
Comment on lines +981 to +983
til_t* current_til = (impl_->base_index == 0)
? impl_->root_til
: impl_->root_til->base[impl_->base_index];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Index base TILs from zero

When iteration advances past the root, base_index == 1 represents the first base TIL, but this indexes root_til->base[1], skipping base[0]; at the last valid base_index it reads one past base[nbases - 1]. This affects any named_types() iteration once base traversal is enabled, so the base case should use base_index - 1 as TilBaseIterator does.

Useful? React with 👍 / 👎.

All three fixes applied:

type.cpp:986,1004 — base[impl_->base_index] → base[impl_->base_index - 1]. Matches TilBaseIterator convention: base_index == 1 means base[0].
type_impl.hpp:38,47 + type.cpp:1103,1064,1079 — Impl constructors now accept base_count parameter (default 0). named_types() passes til->nbases + 1, begin()/end() propagate it to the iterator, following TilBaseRange::Impl's existing pattern.
type.cpp:1063,1078 — begin() returns end() when impl_ is null. end() returns a default-constructed iterator (null impl_) when impl_ is null. Both produce begin() == end() for default-constructed NamedTypeRange.
@acheron2302
Copy link
Copy Markdown
Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78847f113d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/type.cpp
}

TILTypeIterator::TILTypeIterator(const TILTypeIterator& other) {
auto* copy = new TILTypeIterator::Impl(*TILTypeAccess::get(other));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle null impls in iterator copies

When a TILTypeIterator is default-constructed, its public default constructor leaves impl_ null, so copying it dereferences a null pointer here. This makes ordinary operations such as TILTypeIterator b = a or post-increment on a default/empty iterator crash; the newly added TilBase* copy constructors use the same unchecked pattern, while NamedType* already guard null impls.

Useful? React with 👍 / 👎.

Comment thread src/type.cpp
Comment on lines +1068 to +1075
const char* first = first_named_type(NamedTypeAccess::get(it)->root_til, NamedTypeAccess::get(it)->flags);
if (first) {
NamedTypeAccess::get(it)->current_name = first;
NamedTypeAccess::get(it)->current_library = get_library_name(NamedTypeAccess::get(it)->root_til);
return it;
}
}
return end();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Continue into base TILs when the root is empty

If the local/root TIL has no matching named types but loaded base TILs do, begin() returns end() immediately and the iterator never reaches the base-skipping logic in operator++. In that scenario named_types() reports an empty range despite the new API being documented as iterating across all TILs.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant