Help with clang AST matchers: find semicolon after a decl statement

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

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?

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

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.