[cfe-dev] Help with clang AST matchers: find semicolon after a decl statement

Manuel Klimek klimek at google.com
Mon Aug 4 05:48:04 PDT 2014

On Thu, Jul 31, 2014 at 12:37 AM, Frederico Araujo <araujof at gmail.com>

> I found the problem!
> I forgot to update my make file to link against the ARCMigrate library.
> I realized that after adding -I$(LLVM_SRC_PATH)/tools/clang/lib/ARCMigrate
> to my CLANG_INCLUDES, I also had to add -lclangARCMigrate to my CLANG_LIBS,
> which solved the problem.
> I wonder why Transforms.h isn't included in clang's tools build directory?

I didn't even know the transforms stuff has such nice reusable functions.
Generally, I'd say "arcmigrate" is the wrong layer of abstraction for those
functions. We might want to put them next to clang's Lexer.

Generally, so far everybody has just rolled their own version of the
findSemiAfterLocation function, which is admittedly very unfortunate.

> So, in conclusion, answering my first question, the following code can be
> used to find the location just after the semicolon:
> *SourceLocation SemiLoc =
> clang::arcmt::trans::findSemiAfterLocation(D->getLocEnd(),
> D->getASTContext());*

> Regards,
> Fred
> On Wed, Jul 30, 2014 at 5:18 PM, Frederico Araujo <araujof at gmail.com>
> wrote:
>> Dear list,
>> I'm implementing a small source-to-source rewriter using clang tooling
>> and AST matchers.
>> I'd like to ask if there is a way to use clang's API to find the source
>> location after a semicolon of a matched declaration statement?
>> Looking in the documentation, I found the "*findLocationAfterSemi*"
>> function which seems to be exactly what I want. However, I'm not being able
>> to use it. Searching my llvm sources, I see its corresponding header file
>> Transforms.h in <llvm_src_dir>/tools/clang/lib/ARCMigrate/ but not inside
>> any sub-directory inside the directory I compiled clang (using cmake).
>> The function I mentioned can be found here:
>> http://clang.llvm.org/doxygen/Transforms_8h.html
>> Any help will be much appreciated!
>> Thanks,
>> Fred
> _______________________________________________
> 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/20140804/8c008daf/attachment.html>

More information about the cfe-dev mailing list