[cfe-dev] Get a VarDecl Associated with a SourceLocation
Jan Korous via cfe-dev
cfe-dev at lists.llvm.org
Tue Jan 8 01:27:46 PST 2019
Hi Pardis,
You can use some of these as a basis for your feature.
1. Use libTooling - clang::tooling::getNamedDeclAt().
2. Use libclang (C interface) - clang_getCursor().
3. Use clangd via LSP - textDocument/SymbolInfo method.
4. Use clangd - clang::clangd::getSymbolInfo().
5. Take a look at implementation of these and write your own AST visitor.
Not knowing anything about your specific use-case I’d recommend to use libTooling.
Hope this helps!
Jan
> On Jan 7, 2019, at 7:37 PM, Pardis Pashakhanloo via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>
> Hi,
>
> Is it possible to get the VarDecl associated with a specific SourceLocation?
> For example, VarDecl is "int a;". However, I have the SourceLocation for a. I want to get the SourceLocation that indicates the beginning (and end) of this VarDecl.
>
> Best,
> Pardis
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190108/487e72b9/attachment.html>
More information about the cfe-dev
mailing list