Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367611

Summary: Range-based for loop should be treated as referencing the relevant begin/end functions
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-indexerAssignee: Markus Schorn <mschorn.eclipse>
Status: RESOLVED FIXED QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug
Version: 8.1.0   
Target Milestone: 8.1.0   
Hardware: All   
OS: All   
Whiteboard:

Description Nathan Ridge CLA 2011-12-28 23:32:22 EST
In the following code:


struct intarr
{
    int* first;
    int size;
};

int* begin(const intarr& a) { return a.first; }  // "find references" for this...
int* end(const intarr& a) { return a.first + a.size; }

int main()
{
    intarr a;
    for (int i : a)      // ... does not find this
        ;
}


If I do a "find references" on the "begin" or "end" function, the for loop is not found as a reference, even though it implicitly calls both. Range-based for loops for non-array types always call some begin() and end() functions, and they should be treated as referencing these functions.
Comment 1 Markus Schorn CLA 2012-01-05 05:27:44 EST
I have added implicit names for 'begin' and 'end' to the range based for loop. With that the references are written to the index.