[Patch] Add SourceLocations for TagStart/Finish, FinalizeDeclaratorGroup

Hello Clangers,

I started playing with Clang today, with intention of hooking in
to the parser to report back the textual locations of typedef and
struct definitions for a given translation unit.

After playing a bit, I eventually found that I needed programmatic
access to the SourceLocations of some tokens when hooking into the
FinalizeDeclaratorGroup and ActOnTagStart/FinishDefinition callbacks.

Attached is a patch which augments those APIs to add SourceLocations
that action consumers can use to infer the exact textual area occupied
by a given struct definition. With this patch, one can compute the
location of the second semicolon below:

   typedef struct foo { int x; } foo_t ;
                                       ^ This guy

I tested the C parsing (ParseDecl changes) by instrumenting the
PrintParserCallbacks class. I added stubs there for the Tag start
and finish callbacks. I looked over output for structs, typedef'd
structs, simple typedefs, and enums.

For testing the C++ change (ParseDeclCXX), I instrumented SemaDecl's
FinalizeDeclaratorGroup and ActOnTagStart/FinishDefinition stubs.
The -parse-print-callbacks stubs don't do enough to get the parsing
to invoke those callbacks (ParseDeclCXX:434's TagOrTempDecl will
remain NULL when using the PrintParserCallbacks implementation).

I didn't actually test the ObjC 'in' part for for-each loops.

I tried 'make test' from $LLVM/tools/clang, and 'make' from
$LLVM/tools/clang/test, but both invocations ended up failing tests.
Looking into the errors seemed to suggest some kind of path issue
(thought I had seen that mentioned on this list from a while back).

I'm using GNU Make 3.81 on a straight-forward Ubuntu system if that
matters. Is 'make test' expected to work?

Lastly, this project is awesome! Kudos to everyone and all of the
hard work that has obviously gone into this. I'm looking forward to
the codebase progressing; the world has been in need of a programmable
C compiler front end for a long, long time now.

-Jon Simons

PatchJS (9.7 KB)