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

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

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:

You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to