LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 17182 - Make clang-format play nice with other line endings
Summary: Make clang-format play nice with other line endings
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Formatter (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Alexander Kornienko
URL:
Keywords:
: 17269 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-09-10 07:26 PDT by İsmail Dönmez
Modified: 2013-11-13 08:58 PST (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
Sample file (154 bytes, text/x-c++src)
2013-09-10 07:26 PDT, İsmail Dönmez
Details

Note You need to log in before you can comment on or make changes to this bug.
Description İsmail Dönmez 2013-09-10 07:26:17 PDT
Created attachment 11178 [details]
Sample file

> cat sha1.cpp 
            #define sha1macro(func,val) \
			{ \
                const unsigned int t = rol(a, 5) + (func) + e + val + w[round]; \
				e = d; \
			}

> clang-format sha1.cpp
Can't find usable .clang-format, using LLVM style
#define sha1macro(func, val)
{
  const unsigned int t = rol(a, 5) + (func) + e + val + w[round];
  e = d;
}


sha1.cpp attached.
Comment 1 Daniel Jasper 2013-09-10 07:37:52 PDT
That works fine here, results in:

#define sha1macro(func, val)                                        \
  {                                                                 \
    const unsigned int t = rol(a, 5) + (func) + e + val + w[round]; \
    e = d;                                                          \
  }

Can you provide more details? Which version of clang-format are you running, which platform are you running on, etc.?

One thought, does that file contain windows line endings (<CR><NL>)?
Comment 2 İsmail Dönmez 2013-09-10 07:42:12 PDT
(In reply to comment #1)
> That works fine here, results in:
> 
> #define sha1macro(func, val)                                        \
>   {                                                                 \
>     const unsigned int t = rol(a, 5) + (func) + e + val + w[round]; \
>     e = d;                                                          \
>   }
> 
> Can you provide more details? Which version of clang-format are you running,
> which platform are you running on, etc.?

Linux, clang r190394

> One thought, does that file contain windows line endings (<CR><NL>)?

Yes it does and if I convert those newlines into Unix one clang-format works fine.
Comment 3 Alexander Kornienko 2013-09-11 13:16:55 PDT
Most of the issues related to CR LF line endings are fixed in r190519. Starting from this revision, clang-format should correctly handle both LF and CR LF line endings, and output replacements with the line ending style prevalent in the input file.
Comment 4 Alexander Kornienko 2013-11-13 08:58:09 PST
*** Bug 17269 has been marked as a duplicate of this bug. ***