Skip to content

Newlines not working correctly on Windows when calling .Dump() or .PrintToXX() #203

@dylanrafael05

Description

@dylanrafael05

Hey dev team! I've been using LLVMSharp to create my own programming language for a few days now, and am still learning the ropes so it is definitely possible that I have made a mistake or have otherwise messed up but I don't think that my code could result in an error like the one I am seeing.

The gist of what's happening is that calling LLVMModuleRef.Dump() appears to only place '\n' characters when attempting to create a new line, thus creating issues when trying to view the resulting dump on a windows computer.

For instance, calling .Dump() on a program which I have generated results in this formatting (cut off for brevity):

; ModuleID = '_test'
                    source_filename = "_test"

                                             define double @double(double %0) {
                                                                               _entry:
                                                                                        %x = alloca double, align 8
                                                                                                                     store ptr %x, double %0, align 8
              %1 = load double, ptr %x, align 8
                                                 %2 = fmul double %1, 2.000000e+00
                                                                                    ret double %2
                                                                                                 }

                                                                                                  define double @square(double %0) {     
                                                                                                                                    _entr
. . . 

To fix this, I am simply using .PrintToString() instead and appending a .ReplaceLineEndings(), but a fix in the library itself would be much better to work with.

Thank you for reading this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions