[cfe-dev] Getting DecompositionDecl from BindingDecl

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 29 13:48:59 PDT 2018


On 28 March 2018 at 17:27, George Karpenkov via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi,
>
> I am trying to support c++17 structured bindings in the static analyzer,
> and I was really surprised to learn there is no reasonable way to find a
> DecompositionDecl from a BindingDecl (that is often necessary because
> DecompositionDecl often is the only available VarDecl).
> Shouldn’t getParentContext() be usable here?
> Any clues for how this can be solved apart from preprocessing and
> populating parent pointers?


getParentContext() doesn't seem appropriate to me, because a
DecompositionDecl is not really a DeclContext in any normal sense -- it
doesn't "contain" other declarations, in the same way that in "struct X {}
x;", the declaration of "x" does not "contain" the declaration of "struct
X". Rather, we have a syntactic construct that happens to declare multiple
related things at once. Can you say more about why the static analyzer
might want to map from a BindingDecl to a DecompositionDecl? BindingDecls
should generally just be treated wrappers around some lvalue expression.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180329/759e27da/attachment.html>


More information about the cfe-dev mailing list