Bug 72219

Summary: [Scanner] Exit Inclusion occurs too soon
Product: [Tools] CDT Reporter: Sean Evoy <sevoy>
Component: cdt-coreAssignee: Andrew Niefer <aniefer>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P2 CC: john.camelon
Version: 2.0   
Target Milestone: 2.0.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Sean Evoy CLA 2004-08-18 17:19:40 EDT
This is a wierd one. If I define something in an exteranl file, F3 (Open 
Declaration) gives the proper result, but searching All Declarations > 
Workspace gives a bad result. 

Testing environment:
M200408111300
I200408120400
J9 JRE

1. Create mgd C++ project (problem in properly configure std project too but 
this is faster)
2. Add the following to a main.cpp file
#include <iostream>
#include "findme.h"
using namespace std;

int main(int argc, char **argv) {
	cout << "Find code is: " << FOUND_ME << endl;
	return (0);
}

3. Create an external file, findme.h, somewhere on your machine (not in the 
workspace) with contents:

const int FOUND_ME =1;

4. Add the path to the file to the project's build properties do something to 
trigger an index
5. Do an F3 on FOUND_ME and the header file will be opened in an editor. Cool.
6. Now try All Declarations > Workspace. You will see that the result will be 
the main file at offset 11. This is the offset of the symbol in the header 
file. It's almost as though the search has the offset right, but the file 
wrong. Anyway, this seems like a bug.
Comment 1 Andrew Niefer CLA 2004-08-19 15:39:38 EDT
Because the scanner is 1 token ahead of the parser, when we get the semi colon 
to complete the FOUND_ME declaration, the scanner immediately gets the next 
token and encounters the end of the include file and does the callback 
exitInclusion before the parser processed the semi-colon and does the callback 
for the variable declaration.  

The result is that clients think that this variable declaration is happening 
outside the inclusion instead of being the last thing in the inclusion.
Comment 2 John Camelon CLA 2004-08-20 09:56:34 EDT
What is your proposed solution, oh stealer of defects?
Comment 3 John Camelon CLA 2004-08-20 09:57:23 EDT
This should be fixed for 2.0.1, it will affect more than just Search/Index.
Comment 4 Andrew Niefer CLA 2004-08-23 15:32:28 EDT
fixed in head and 2.0.1

Fix postpones the reporting of callback if we were getting the token one ahead.
Comment 5 Tanya Wolff CLA 2004-08-26 17:51:43 EDT
Verified fixed in cdt 2.0.1 build 20040826
Comment 6 Sean Evoy CLA 2004-08-27 11:37:00 EDT
Marking verified for Tanya.