[cfe-dev] Fwd: I am trying to using clang to do autocomplete, How to go to declaration of a macro?

罗勇刚(Yonggang Luo) via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 23 04:11:47 PST 2016


Thanks a lot, Alex.
I am trying to do that in command line:) how to do that?
I meas clang.exe driver:)


On Wed, Nov 23, 2016 at 7:39 PM, Alex L <arphaman at gmail.com> wrote:

> I'm not sure that I understood your question correctly, but if you are
> working on auto completion then you can use Preprocessor::getMacroDefinition
> to lookup the definition of a some macro. Specifically, as long as you're
> working with Sema, you can use code similar to the one below:
>
>   for (const auto &M : PP.macros()) {
>     auto MD = PP.getMacroDefinition(M->first);
>     if (MD) {
>       // you have access to macro definition here and can lookup it's
> source location
>       // by using MD.getMacroInfo()->getDefinitionLoc()
>     }
>   }
>
> Alex
>
> On 23 November 2016 at 11:00, 罗勇刚(Yonggang Luo) via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
>>
>> ---------- Forwarded message ----------
>> From: 罗勇刚(Yonggang Luo) <luoyonggang at gmail.com>
>> Date: Wed, Nov 23, 2016 at 6:58 PM
>> Subject: I am trying to using clang to do autocomplete, How to go to
>> declaration of a macro?
>> To: Clang Dev <cfe-dev at cs.uiuc.edu>
>>
>>
>> For exmaple
>>
>> #define FOO 0
>>
>> int foo() {
>>   int x = FOO; /* How to go to decleration of FOO here? *./
>> }
>>
>> --
>>          此致
>>>> 罗勇刚
>> Yours
>>     sincerely,
>> Yonggang Luo
>>
>>
>>
>> --
>>          此致
>>>> 罗勇刚
>> Yours
>>     sincerely,
>> Yonggang Luo
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>>
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161123/ec89a114/attachment.html>


More information about the cfe-dev mailing list