This is an archive of the discontinued LLVM Phabricator instance.

[NFC][OCaml] Resolve const and unsigned compilation warnings

Authored by jberdine on Mar 25 2021, 5:04 PM.



There are a number of compilation warnings regarding disregarding
const qualifiers, and casting between pointers to integer types with
different sign.

The incompatible sign warnings are due to treating the result of
LLVMGetModuleIdentifier as const unsigned char *, but it is
declared as const char *.

The dropped const qualifiers are due to the code pattern
memcpy(String_val(_),_,_) which ought to be (following the
implementation of the OCaml runtime)
memcpy((char *)String_val(_),_,_). The issue is that String_val is
usually used to get the value of an immutable string. But in the
context of the memcpy calls, the string is in the process of being
initialized, so is not yet constant.

Diff Detail

Event Timeline

jberdine created this revision.Mar 25 2021, 5:04 PM
jberdine requested review of this revision.Mar 25 2021, 5:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2021, 5:04 PM
vaivaswatha accepted this revision.Mar 25 2021, 7:29 PM
This revision is now accepted and ready to land.Mar 25 2021, 7:29 PM
This revision was landed with ongoing or failed builds.Mar 26 2021, 5:01 AM
This revision was automatically updated to reflect the committed changes.