[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
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!
> On Jan 7, 2019, at 7:37 PM, Pardis Pashakhanloo via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 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.
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev