[llvm-bugs] [Bug 36576] New: clang_Cursor_Evaluate does not support aggregate or complex initializers

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 2 10:07:31 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=36576

            Bug ID: 36576
           Summary: clang_Cursor_Evaluate does not support aggregate or
                    complex initializers
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: libclang
          Assignee: unassignedclangbugs at nondot.org
          Reporter: matti.niemenmaa+llvmbugs at iki.fi
                CC: klimek at google.com, llvm-bugs at lists.llvm.org

At the time of writing (2018-03-02, SVN r326551) clang_Cursor_Evaluate only
supports integers, doubles, and strings, as is evident from the structure it
returns:


struct ExprEvalResult {
  CXEvalResultKind EvalType;
  union {
    unsigned long long unsignedVal;
    long long intVal;
    double floatVal;
    char *stringVal;
  } EvalData;
  bool IsUnsignedInt;
  // destructor omitted
}


This means that attempting to examine the values of e.g. any of the following
constants results in a null pointer instead of any useful information:


const int array[] = {1, 2, 3};
const struct { int x, y; } structure = { .x = 1, .y = 2 };
const union { int x, y; } my_union = { .y = 3 };
#include <complex.h>
const float complex complex_float = 1 + 2*I;


As far as I can tell there is no way of discovering those values using
libclang. One user that would benefit from this information is Rust's binding
generation tool, bindgen:
https://github.com/rust-lang-nursery/rust-bindgen/issues/1266

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180302/58b4d49c/attachment.html>


More information about the llvm-bugs mailing list