Closed Bug 1621789 Opened 4 years ago Closed 11 months ago

Navigation to MatrixType::Simple from reference does not work

Categories

(Webtools :: Searchfox, defect)

defect

Tracking

(firefox115 fixed)

RESOLVED FIXED
Tracking Status
firefox115 --- fixed

People

(Reporter: botond, Assigned: botond)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

STR

  1. Go to https://searchfox.org/mozilla-central/source/gfx/2d/Matrix.h#1955
  2. Click on the token Simple token in MatrixType::Simple

Expected results

There is a navigation target that takes you here.

Actual results

There is no such navigation target.

The issue almost certainly has to do with the fact that MatrixType is a nested type defined inside Matrix4x4TypedFlagged which is a template, making it a dependent name. However, the references occur inside the primary template definition, which means they cannot possibly resolve to anything other than the nested type defined inside that same primary template definition.

(In reply to Botond Ballo [:botond] from comment #1)

However, the references occur inside the primary template definition, which means they cannot possibly resolve to anything other than the nested type defined inside that same primary template definition.

I stand corrected: it turns out you can specialize a nested type of a template without specializing the entire template:

template <typename T>
struct Outer {
  enum class MatrixType {
    Simple,   // declaration #1
    NotSimple
  };

  void foo() {
    // MatrixType::Simple resolves to declaration #1
    // unless T = int in which case it resolves to declaration #2
    MatrixType m = MatrixType::Simple;
  }
};

template <>
enum class Outer<int>::MatrixType {
  CPlusPlusFooledYou,
  Simple  // declaration #2
};

int main() {
  Outer<int>().foo();
  Outer<float>().foo();
}

All the same: it would be an eminently reasonable heuristic for Searchfox to resolve the reference to the declaration inside the primary template.

Somewhat off-topic here: I think my recent work on the fancy branch with the "structured" record type may let us avoid the general scale-explosion issue with templates that causes us to be so conservative about what we emit.

On trunk, searchfox doesn't really have a concept of a type hierarchy; instead it emits symbols for a method and all of its overrides. This results in scale problems because de-duplication is based on exact match of the JSON record object. With "structured" records, we can instead just say "this is an instantiation of template Foo with T=Bar" and emit the template records as Foo<T>::Method instead of worrying about emitting every method record for every T. I'll try and take a look at whether that's viable this weekend and perhaps file a canonical bug for that with my results.

Duplicate of this bug: 1835433

Reduced testcase:

Steps to reproduce

Have Searchfox index the following code:

template <typename>
struct Foo {
   enum class E {
     Waldo,
   };
   
  void Bar() {
    E::Waldo;
  }
};

Expected results

Navigation from the use of Waldo goes to the definition.

Actual results

No navigation is offered at the use.

Assignee: nobody → botond
Blocks: 1781178

The expression type of E::Waldo in the clang AST is DependentScopeDeclRefExpr. That doesn't currently have a Visit method in IndexConsumer; we'll need to add one.

Pushed by bballo@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/24fb0275178b
Handle DependentScopeDeclRefExpr in MozsearchIndexer. r=andi
Blocks: 1835692
Blocks: 1835694
Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: