-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Finally formalise our defacto line-ending policy #86318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
input-mirror.test text eol=crlf | ||
too_large.test text eol=crlf | ||
protocol.test text eol=crlf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
# RUN: clangd -pretty -sync -input-mirror-file %t < %s | ||
# Note that we have to use '-b' as -input-mirror-file does not have a newline at the end of file. | ||
# RUN: diff -b %t %s | ||
# It is absolutely vital that this file has CRLF line endings. | ||
# | ||
Content-Length: 125 | ||
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} | ||
Content-Length: 172 | ||
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"int main() {\nint a;\na;\n}\n"}}} | ||
Content-Length: 44 | ||
{"jsonrpc":"2.0","id":3,"method":"shutdown"} | ||
Content-Length: 33 | ||
{"jsonrpc":"2.0","method":"exit"} | ||
# RUN: clangd -pretty -sync -input-mirror-file %t < %s | ||
# Note that we have to use '-b' as -input-mirror-file does not have a newline at the end of file. | ||
# RUN: diff -b %t %s | ||
# It is absolutely vital that this file has CRLF line endings. | ||
# | ||
Content-Length: 125 | ||
|
||
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} | ||
Content-Length: 172 | ||
|
||
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"int main() {\nint a;\na;\n}\n"}}} | ||
Content-Length: 44 | ||
|
||
{"jsonrpc":"2.0","id":3,"method":"shutdown"} | ||
Content-Length: 33 | ||
|
||
{"jsonrpc":"2.0","method":"exit"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,113 +1,113 @@ | ||
# RUN: not clangd -pretty -sync -enable-test-uri-scheme < %s | FileCheck -strict-whitespace %s | ||
# RUN: not clangd -pretty -sync -enable-test-uri-scheme < %s 2>&1 | FileCheck -check-prefix=STDERR %s | ||
# vim: fileformat=dos | ||
# It is absolutely vital that this file has CRLF line endings. | ||
# | ||
# Note that we invert the test because we intent to let clangd exit prematurely. | ||
# | ||
# Test protocol parsing | ||
Content-Length: 125 | ||
Content-Type: application/vscode-jsonrpc; charset-utf-8 | ||
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} | ||
# Test message with Content-Type after Content-Length | ||
# | ||
# CHECK: "jsonrpc": "2.0", | ||
# CHECK-NEXT: "result": { | ||
# CHECK: } | ||
Content-Length: 246 | ||
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"struct fake { int a, bb, ccc; int f(int i, const float f) const; };\nint main() {\n fake f;\n f.\n}\n"}}} | ||
Content-Length: 104 | ||
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///main.cpp"}}} | ||
Content-Type: application/vscode-jsonrpc; charset-utf-8 | ||
Content-Length: 146 | ||
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}} | ||
# Test message with Content-Type before Content-Length | ||
# | ||
# CHECK: "id": 1, | ||
# CHECK-NEXT: "jsonrpc": "2.0", | ||
# CHECK-NEXT: "result": { | ||
# CHECK-NEXT: "isIncomplete": false, | ||
# CHECK-NEXT: "items": [ | ||
# CHECK: "filterText": "a", | ||
# CHECK-NEXT: "insertText": "a", | ||
# CHECK-NEXT: "insertTextFormat": 1, | ||
# CHECK-NEXT: "kind": 5, | ||
# CHECK-NEXT: "label": " a", | ||
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}}, | ||
# CHECK-NEXT: "sortText": "{{.*}}" | ||
# CHECK: ] | ||
# CHECK-NEXT: } | ||
X-Test: Testing | ||
Content-Type: application/vscode-jsonrpc; charset-utf-8 | ||
Content-Length: 146 | ||
Content-Type: application/vscode-jsonrpc; charset-utf-8 | ||
X-Testing: Test | ||
{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}} | ||
Content-Type: application/vscode-jsonrpc; charset-utf-8 | ||
Content-Length: 10 | ||
Content-Length: 146 | ||
{"jsonrpc":"2.0","id":3,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}} | ||
# Test message with duplicate Content-Length headers | ||
# | ||
# CHECK: "id": 3, | ||
# CHECK-NEXT: "jsonrpc": "2.0", | ||
# CHECK-NEXT: "result": { | ||
# CHECK-NEXT: "isIncomplete": false, | ||
# CHECK-NEXT: "items": [ | ||
# CHECK: "filterText": "a", | ||
# CHECK-NEXT: "insertText": "a", | ||
# CHECK-NEXT: "insertTextFormat": 1, | ||
# CHECK-NEXT: "kind": 5, | ||
# CHECK-NEXT: "label": " a", | ||
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}}, | ||
# CHECK-NEXT: "sortText": "{{.*}}" | ||
# CHECK: ] | ||
# CHECK-NEXT: } | ||
# STDERR: Warning: Duplicate Content-Length header received. The previous value for this message (10) was ignored. | ||
Content-Type: application/vscode-jsonrpc; charset-utf-8 | ||
Content-Length: 10 | ||
{"jsonrpc":"2.0","id":4,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}} | ||
# Test message with malformed Content-Length | ||
# | ||
# STDERR: JSON parse error | ||
# Ensure we recover by sending another (valid) message | ||
Content-Length: 146 | ||
{"jsonrpc":"2.0","id":5,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}} | ||
# Test message with Content-Type before Content-Length | ||
# | ||
# CHECK: "id": 5, | ||
# CHECK-NEXT: "jsonrpc": "2.0", | ||
# CHECK-NEXT: "result": { | ||
# CHECK-NEXT: "isIncomplete": false, | ||
# CHECK-NEXT: "items": [ | ||
# CHECK: "filterText": "a", | ||
# CHECK-NEXT: "insertText": "a", | ||
# CHECK-NEXT: "insertTextFormat": 1, | ||
# CHECK-NEXT: "kind": 5, | ||
# CHECK-NEXT: "label": " a", | ||
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}}, | ||
# CHECK-NEXT: "sortText": "{{.*}}" | ||
# CHECK: ] | ||
# CHECK-NEXT: } | ||
Content-Length: 1024 | ||
{"jsonrpc":"2.0","id":5,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}} | ||
# Test message which reads beyond the end of the stream. | ||
# | ||
# Ensure this is the last test in the file! | ||
# STDERR: Input was aborted. Read only {{[0-9]+}} bytes of expected {{[0-9]+}}. | ||
# RUN: not clangd -pretty -sync -enable-test-uri-scheme < %s | FileCheck -strict-whitespace %s | ||
# RUN: not clangd -pretty -sync -enable-test-uri-scheme < %s 2>&1 | FileCheck -check-prefix=STDERR %s | ||
# vim: fileformat=dos | ||
# It is absolutely vital that this file has CRLF line endings. | ||
# | ||
# Note that we invert the test because we intent to let clangd exit prematurely. | ||
# | ||
# Test protocol parsing | ||
Content-Length: 125 | ||
Content-Type: application/vscode-jsonrpc; charset-utf-8 | ||
|
||
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} | ||
# Test message with Content-Type after Content-Length | ||
# | ||
# CHECK: "jsonrpc": "2.0", | ||
# CHECK-NEXT: "result": { | ||
# CHECK: } | ||
Content-Length: 246 | ||
|
||
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"struct fake { int a, bb, ccc; int f(int i, const float f) const; };\nint main() {\n fake f;\n f.\n}\n"}}} | ||
|
||
Content-Length: 104 | ||
|
||
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///main.cpp"}}} | ||
|
||
Content-Type: application/vscode-jsonrpc; charset-utf-8 | ||
Content-Length: 146 | ||
|
||
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}} | ||
# Test message with Content-Type before Content-Length | ||
# | ||
# CHECK: "id": 1, | ||
# CHECK-NEXT: "jsonrpc": "2.0", | ||
# CHECK-NEXT: "result": { | ||
# CHECK-NEXT: "isIncomplete": false, | ||
# CHECK-NEXT: "items": [ | ||
# CHECK: "filterText": "a", | ||
# CHECK-NEXT: "insertText": "a", | ||
# CHECK-NEXT: "insertTextFormat": 1, | ||
# CHECK-NEXT: "kind": 5, | ||
# CHECK-NEXT: "label": " a", | ||
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}}, | ||
# CHECK-NEXT: "sortText": "{{.*}}" | ||
# CHECK: ] | ||
# CHECK-NEXT: } | ||
|
||
X-Test: Testing | ||
Content-Type: application/vscode-jsonrpc; charset-utf-8 | ||
Content-Length: 146 | ||
Content-Type: application/vscode-jsonrpc; charset-utf-8 | ||
X-Testing: Test | ||
|
||
{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}} | ||
|
||
Content-Type: application/vscode-jsonrpc; charset-utf-8 | ||
Content-Length: 10 | ||
Content-Length: 146 | ||
|
||
{"jsonrpc":"2.0","id":3,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}} | ||
# Test message with duplicate Content-Length headers | ||
# | ||
# CHECK: "id": 3, | ||
# CHECK-NEXT: "jsonrpc": "2.0", | ||
# CHECK-NEXT: "result": { | ||
# CHECK-NEXT: "isIncomplete": false, | ||
# CHECK-NEXT: "items": [ | ||
# CHECK: "filterText": "a", | ||
# CHECK-NEXT: "insertText": "a", | ||
# CHECK-NEXT: "insertTextFormat": 1, | ||
# CHECK-NEXT: "kind": 5, | ||
# CHECK-NEXT: "label": " a", | ||
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}}, | ||
# CHECK-NEXT: "sortText": "{{.*}}" | ||
# CHECK: ] | ||
# CHECK-NEXT: } | ||
# STDERR: Warning: Duplicate Content-Length header received. The previous value for this message (10) was ignored. | ||
|
||
Content-Type: application/vscode-jsonrpc; charset-utf-8 | ||
Content-Length: 10 | ||
|
||
{"jsonrpc":"2.0","id":4,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}} | ||
# Test message with malformed Content-Length | ||
# | ||
# STDERR: JSON parse error | ||
# Ensure we recover by sending another (valid) message | ||
|
||
Content-Length: 146 | ||
|
||
{"jsonrpc":"2.0","id":5,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}} | ||
# Test message with Content-Type before Content-Length | ||
# | ||
# CHECK: "id": 5, | ||
# CHECK-NEXT: "jsonrpc": "2.0", | ||
# CHECK-NEXT: "result": { | ||
# CHECK-NEXT: "isIncomplete": false, | ||
# CHECK-NEXT: "items": [ | ||
# CHECK: "filterText": "a", | ||
# CHECK-NEXT: "insertText": "a", | ||
# CHECK-NEXT: "insertTextFormat": 1, | ||
# CHECK-NEXT: "kind": 5, | ||
# CHECK-NEXT: "label": " a", | ||
# CHECK-NEXT: "score": {{[0-9]+.[0-9]+}}, | ||
# CHECK-NEXT: "sortText": "{{.*}}" | ||
# CHECK: ] | ||
# CHECK-NEXT: } | ||
Content-Length: 1024 | ||
|
||
{"jsonrpc":"2.0","id":5,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}} | ||
# Test message which reads beyond the end of the stream. | ||
# | ||
# Ensure this is the last test in the file! | ||
# STDERR: Input was aborted. Read only {{[0-9]+}} bytes of expected {{[0-9]+}}. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# RUN: not clangd -sync < %s 2>&1 | FileCheck -check-prefix=STDERR %s | ||
# vim: fileformat=dos | ||
# It is absolutely vital that this file has CRLF line endings. | ||
# | ||
Content-Length: 2147483648 | ||
# STDERR: Refusing to read message | ||
# RUN: not clangd -sync < %s 2>&1 | FileCheck -check-prefix=STDERR %s | ||
# vim: fileformat=dos | ||
# It is absolutely vital that this file has CRLF line endings. | ||
# | ||
Content-Length: 2147483648 | ||
|
||
# STDERR: Refusing to read message |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FixIt/fixit-newline-style.c text eol=crlf | ||
Frontend/system-header-line-directive-ms-lineendings.c text eol=crlf | ||
Frontend/rewrite-includes-mixed-eol-crlf.* text eol=crlf | ||
clang/test/Frontend/rewrite-includes-mixed-eol-lf.h text eolf=lf |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need
.sln
? There is only one file inclang/tools/clang-format-vs
. There are a few other text files in this directory, so perhaps a gitattributes in that directory is better?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to put the well-known-extension attributes in the root. I don't envision a
.sln
file ever not having crlf endings, so I considered it a global convenience