[Lldb-commits] [PATCH] D85719: Initialize static const fields in the AST for expression evaluation
Jaroslav Sevcik via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 11 03:26:01 PDT 2020
jarin created this revision.
jarin added a reviewer: teemperor.
jarin added a project: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a reviewer: shafik.
jarin requested review of this revision.
This patch is for discussion.
Currently, the evaluator does not know about static const fields if
the code does not contain a definition (but only a declaration).
For example:
struct C { static const int f = 42; };
int main() {
return C::f; // Evaluating C::f does not work here!
}
This patch tries to fix that by initializing the varDecl of the static
field with the constant value. This works reasonably well when the
static member is only used as rvalue, but any lvalue usage still does
not work because the static member does not have a memory location.
To fix this properly, do we have to teach the materializer about the
static fields, too? What would be the best way to go about that?
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D85719
Files:
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/test/API/lang/cpp/static_const_members/Makefile
lldb/test/API/lang/cpp/static_const_members/TestStaticConstMembers.py
lldb/test/API/lang/cpp/static_const_members/main.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85719.284631.patch
Type: text/x-patch
Size: 5949 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200811/933a4979/attachment.bin>
More information about the lldb-commits
mailing list