[cfe-dev] how to write a source location?

Eli Friedman eli.friedman at gmail.com
Thu Aug 13 01:54:17 PDT 2009


2009/8/13 wangjue1985 <wangjue1985 at 126.com>:
> 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 name.by 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,
though.

-Eli

> 在2009-08-13 16:29:05,"Eli Friedman" <eli.friedman at gmail.com> 写道:
>>2009/8/13 wangjue1985 <wangjue1985 at 126.com>:
>>> 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
>>> understand.so 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!
>>
>>http://clang.llvm.org/docs/InternalsManual.html#SourceLocation 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
>>scratch.
>>
>>-Eli
>
>
> ________________________________
> 没有广告的终身免费邮箱,www.yeah.net




More information about the cfe-dev mailing list