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: unassignedclangb...@nondot.org
          Reporter: matti.niemenmaa+llvmb...@iki.fi
                CC: kli...@google.com, llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to