how to write a source location?

we want to write a front-end and my teacher let me to write a sourcelocation to locate some words where it to be,in which file and in which line?
I think i can get some knowledge from clang ,but i find it`s too hard to who can help me to tell me about sourcelocation and source/file manager in clang and give some advice about my programe .
thank you all the same! is all
the documentation we really have about the clang SourceLocation and
SourceManager; if you're really interested in using it, I think you'll
have to read the code to get an understanding of what it's doing.

What language does your front-end process? Unless your language uses
something like the preprocessor in C, it's probably overkill to borrow
anything from clang; a SourceLocation-like class that doesn't have to
deal with macro instantiations is extremely simple to write from


just like i have argued,i get a mission to write the programe,if they want
to know a code come from where,they can get a
32bits integer,16bits for file name,16bits for in which line..
and i dont know how to get a file now,i am thinking about how to get
file name from tokens...if you know it,please help me!

SourceManager::getFileID and SourceManager::getFileEntryForID should
work, I think? I'm having trouble following what you're asking,