[cfe-dev] Using clang-query on the whole project

Nikola Smiljanic popizdeh at gmail.com
Thu Jun 11 19:24:14 PDT 2015


What about unity build, you'd have one cpp file and include guards would
take care of the rest.

On Fri, Jun 12, 2015 at 7:31 AM, Sean Silva <chisophugis at gmail.com> wrote:

>
>
> On Thu, Jun 11, 2015 at 2:39 AM, Manuel Klimek <klimek at google.com> wrote:
>
>> On Thu, Jun 11, 2015 at 11:33 AM Kevin Funk <kfunk at kde.org> wrote:
>>
>>> Heya,
>>>
>>> I've found clang-query to be useful to query single files. Matching the
>>> Clang
>>> AST is easy enough and fast to learn. I don't see how to use clang-query
>>> on a
>>> whole project, though, which would be super useful.
>>>
>>> A simple example where it's effectively useless: Assume some header
>>> "global.h"
>>> containing "struct Global {};", every file in the project includes this
>>> header.
>>>
>>> Now the idiomatic way to run clang-query over all the files in the
>>> project:
>>>   clang-query -p $BUILD $(find . -name "*.cpp")
>>>
>>> Let's try to find record decls named "Global":
>>>   match recordDecl(hasName("Global"), isDefinition())
>>>
>>> => You get one match per file / translation unit. But in fact, this is
>>> not
>>> really what you want. You want one match here.
>>>
>>> So of course this is difficult: clang-query is TU-centric, while for a
>>> whole
>>> project you'd "somehow" want a global view over the source code and not
>>> have
>>> duplicate results for a query like above.
>>>
>>> Questions:
>>> - Is it possible to get clang-query to behave like that?
>>>   - Any research/pointers in that regard?
>>> - Is it possible to filter duplicates in the results without external
>>> tools?
>>>
>>> Thanks a lot for a great tool so far!
>>>
>>
>> Well, usually at that point you'll want to start writing a go/clangmr.
>>
>
> What is "go/clangmr"? Some sort of golang library? Can't seem to find a
> reference other than http://research.google.com/pubs/pub41342.html
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__research.google.com_pubs_pub41342.html&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=VQcoH58OOqt8UguEXN6SNUsxImNsEIVOpsLBoZoV9jw&s=D85eDFfVLAj750vWT3AwGJfmTyx4N69I20nfZu9OTOo&e=>
> but no mention of "go".
>
> -- Sean Silva
>
>
>>
>> It might also be cool to make clang-query work as clangmr; sounds like
>> that would be a nice 20% project ;)
>>
>>
>>> Greets
>>>
>>> --
>>> Kevin Funk | kfunk at kde.org | http://kfunk.org
>>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__kfunk.org&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=0CyHQX4kFht-O-Dq4O9unNWXJr-EdeaxjoOo2AN8vhE&s=ujWrYOxcQV8goq5L7MFeVqPdHVHUoKvb_5p5Z8v8Oq0&e=>
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150612/aa2667b2/attachment.html>


More information about the cfe-dev mailing list