Skip to content

No way using libclang to get a string literal that contains zero bytes #69749

Open
@xTachyon

Description

@xTachyon

Code:

const char BUFFER[] = "a\0b";

Using clang_Cursor_Evaluate + clang_EvalResult_getAsStr at least, there's no way to get the full literal.

Doing some debugging I found this strncpy which doesn't copy anything after the first \0, stripping the actual literal.

Even more, the clang_EvalResult_getAsStr only returns a const char* and no size, relying on the \0 to get the size of the string.

Is there any other way to get the actual literal? Is adding a new function that can do this something acceptable?

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:as-a-librarylibclang and C++ APIenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions