llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.02k stars 11.96k forks source link

Finally formalise our defacto line-ending policy #86318

Closed ldrumm closed 3 weeks ago

ldrumm commented 7 months ago

Historically, we've not automatically enforced how git tracks line endings, but there are many, many commits that "undo" unintended CRLFs getting into history.

git log --pretty=oneline --grep=CRLF shows nearly 100 commits involving reverts of CRLF making its way into the index and then history. As far as I can tell, there are none the other way round except for specific cases like .bat files or tests for parsers that need to accept such sequences.

Of note, one of the earliest of those listed in that output is:

commit 9795860250734e5c2a879546c534e35d9edd5944 Author: NAKAMURA Takumi geek4civic@gmail.com Date: Thu Feb 3 11:41:27 2011 +0000

  cmake/*: Add svn:eol-style=native and fix CRLF.

  llvm-svn: 124793

...which introduced such a defacto policy for subversion.

With old versions of git, it's been a bit of a crapshoot whether enforcing storing line endings in the history will upset checkouts on machines where such line endings are the norm. Indeed many users have enforced that git checks out the working copy according to a global or per-user config via core crlf, or core autocrlf.

However, for ~8 years now[1], however, git has supported the ability to "do as the Romans do" on checkout, but internally store subsets of text files with line-endings specified via a system of patterns in the gitattributes file. Since we now have this ability, and we've been specifying attributes for various binary files, I think it makes sense to rid us of all that work converting things "back", and just let git handle the local checkout. Thus the new toplevel policy here is

In simple terms this means "unless otherwise specified, convert all files considered "text" files to LF in the project history, but checkout them out as expected on the local machine. What is "expected on the local machine" is dependent on configuration and default.

For those files in the repository that do need CRLF endings, I've adopted a policy of eol=crlf which means that git will store them in history with LF, but regardless of user config, they'll be checked out in tree with CRLF.

Finally, existing files have been "corrected" in history via git add --renormalize .

[1]: git 2.10 was released with fixed support for fine-grained line-ending tracking that respects user-config and repo policy. This can be considered the point at which git will respect both the user's local working tree preference and the history as specified by the maintainers. See https://github.com/git/git/blob/master/Documentation/RelNotes/2.10.0.txt#L248 for the release note.

llvmbot commented 7 months ago

@llvm/pr-subscribers-llvm-support @llvm/pr-subscribers-backend-spir-v @llvm/pr-subscribers-backend-directx @llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-hlsl @llvm/pr-subscribers-mlir-shape @llvm/pr-subscribers-debuginfo @llvm/pr-subscribers-mlir-llvm @llvm/pr-subscribers-lld-coff @llvm/pr-subscribers-backend-amdgpu @llvm/pr-subscribers-pgo @llvm/pr-subscribers-mlir-gpu @llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang-tools-extra @llvm/pr-subscribers-testing-tools @llvm/pr-subscribers-clang-static-analyzer-1 @llvm/pr-subscribers-lld-elf @llvm/pr-subscribers-clangd

@llvm/pr-subscribers-lldb

Author: None (ldrumm)

Changes Historically, we've not automatically enforced how git tracks line endings, but there are many, many commits that "undo" unintended CRLFs getting into history. `git log --pretty=oneline --grep=CRLF` shows nearly 100 commits involving reverts of CRLF making its way into the index and then history. As far as I can tell, there are none the other way round except for specific cases like `.bat` files or tests for parsers that need to accept such sequences. Of note, one of the earliest of those listed in that output is: commit 9795860250734e5c2a879546c534e35d9edd5944 Author: NAKAMURA Takumi <geek4civic@gmail.com> Date: Thu Feb 3 11:41:27 2011 +0000 cmake/*: Add svn:eol-style=native and fix CRLF. llvm-svn: 124793 ...which introduced such a defacto policy for subversion. With old versions of git, it's been a bit of a crapshoot whether enforcing storing line endings in the history will upset checkouts on machines where such line endings are the norm. Indeed many users have enforced that git checks out the working copy according to a global or per-user config via core crlf, or core autocrlf. However, for ~8 years now[1], however, git has supported the ability to "do as the Romans do" on checkout, but internally store subsets of text files with line-endings specified via a system of patterns in the gitattributes file. Since we now have this ability, and we've been specifying attributes for various binary files, I think it makes sense to rid us of all that work converting things "back", and just let git handle the local checkout. Thus the new toplevel policy here is * text=auto In simple terms this means "unless otherwise specified, convert all files considered "text" files to LF in the project history, but checkout them out as expected on the local machine. What is "expected on the local machine" is dependent on configuration and default. For those files in the repository that *do* need CRLF endings, I've adopted a policy of `eol=crlf` which means that git will store them in history with LF, but regardless of user config, they'll be checked out in tree with CRLF. There also appears to be a single test, clang/test/Frontend/rewrite-includes-mixed-eol-crlf.[ch] which needs mixed line endings. This one uses eol=input to preserve it as-is. Finally, existing files have been "corrected" in history via `git add --renormalize .` [1]: git 2.10 was released with fixed support for fine-grained line-ending tracking that respects user-config *and* repo policy. This can be considered the point at which git will respect both the user's local working tree preference *and* the history as specified by the maintainers. See https://github.com/git/git/blob/master/Documentation/RelNotes/2.10.0.txt#L248 for the release note. --- Patch is 1.90 MiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/86318.diff 254 Files Affected: - (modified) .gitattributes (+6) - (added) clang-tools-extra/clangd/test/.gitattributes (+3) - (modified) clang-tools-extra/clangd/test/delimited-input-comment-at-the-end.test (+11-11) - (modified) clang-tools-extra/clangd/test/hover.test (+57-57) - (modified) clang-tools-extra/clangd/test/input-mirror.test (+17-17) - (modified) clang-tools-extra/clangd/test/protocol.test (+113-113) - (modified) clang-tools-extra/clangd/test/spaces-in-delimited-input.test (+13-13) - (modified) clang-tools-extra/clangd/test/too_large.test (+7-7) - (modified) clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/duplicate-include.h (+15-15) - (modified) clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/duplicate-include2.h (+1-1) - (modified) clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/system/sys/types.h (+1-1) - (modified) clang-tools-extra/test/clang-tidy/checkers/readability/else-after-return-if-constexpr.cpp (+22-22) - (modified) clang-tools-extra/test/modularize/Inputs/CompileError/module.modulemap (+10-10) - (modified) clang-tools-extra/test/modularize/Inputs/MissingHeader/module.modulemap (+10-10) - (modified) clang-tools-extra/test/pp-trace/Inputs/module.modulemap (+18-18) - (modified) clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp (+155-155) - (added) clang/test/.gitattributes (+3) - (modified) clang/test/AST/HLSL/this-reference-template.hlsl (+46-46) - (modified) clang/test/AST/HLSL/this-reference.hlsl (+62-62) - (modified) clang/test/AST/objc-default-ctor-init.mm (+21-21) - (modified) clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp (+56-56) - (modified) clang/test/CXX/expr/expr.prim/expr.prim.lambda/p15-star-this-capture.cpp (+22-22) - (modified) clang/test/CXX/lex/lex.literal/lex.string/p4.cpp (+17-17) - (modified) clang/test/CodeGen/fpconstrained.c (+25-25) - (modified) clang/test/CodeGen/fpconstrained.cpp (+49-49) - (modified) clang/test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp (+31-31) - (modified) clang/test/CodeGenCXX/debug-info-atexit-stub.cpp (+22-22) - (modified) clang/test/CodeGenHLSL/builtins/bitreverse.hlsl (+155-155) - (modified) clang/test/CodeGenHLSL/builtins/clamp.hlsl (+134-134) - (modified) clang/test/CodeGenHLSL/builtins/cos.hlsl (+41-41) - (modified) clang/test/CodeGenHLSL/builtins/floor.hlsl (+56-56) - (modified) clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl (+15-15) - (modified) clang/test/CodeGenHLSL/builtins/lerp.hlsl (+78-78) - (modified) clang/test/CodeGenHLSL/builtins/log.hlsl (+41-41) - (modified) clang/test/CodeGenHLSL/builtins/log2.hlsl (+41-41) - (modified) clang/test/CodeGenHLSL/builtins/mad.hlsl (+191-191) - (modified) clang/test/CodeGenHLSL/builtins/max.hlsl (+134-134) - (modified) clang/test/CodeGenHLSL/builtins/pow.hlsl (+54-54) - (modified) clang/test/CodeGenHLSL/builtins/reversebits.hlsl (+155-155) - (modified) clang/test/CodeGenHLSL/builtins/sin.hlsl (+41-41) - (modified) clang/test/CodeGenHLSL/builtins/trunc.hlsl (+47-47) - (modified) clang/test/CodeGenHLSL/semantics/DispatchThreadID.hlsl (+25-25) - (modified) clang/test/CodeGenHLSL/sret_output.hlsl (+22-22) - (modified) clang/test/CodeGenHLSL/this-assignment-overload.hlsl (+55-55) - (modified) clang/test/CodeGenHLSL/this-assignment.hlsl (+45-45) - (modified) clang/test/CodeGenHLSL/this-reference.hlsl (+34-34) - (modified) clang/test/CodeGenObjC/exceptions-personality.m (+53-53) - (modified) clang/test/Driver/ps4-ps5-relax-relocations.c (+29-29) - (modified) clang/test/FixIt/fixit-newline-style.c (+11-11) - (modified) clang/test/Frontend/rewrite-includes-macros.cpp (+15-15) - (modified) clang/test/Frontend/rewrite-includes-mixed-eol-crlf.c (+8-8) - (modified) clang/test/Frontend/rewrite-includes-mixed-eol-crlf.h (+11-11) - (modified) clang/test/Frontend/system-header-line-directive-ms-lineendings.c (+21-21) - (modified) clang/test/Lexer/minimize_source_to_dependency_directives_include.c (+8-8) - (modified) clang/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c (+10-10) - (modified) clang/test/Options/HV.hlsl (+20-20) - (modified) clang/test/Parser/objc-attr.m (+28-28) - (modified) clang/test/Preprocessor/macro_vaopt_check.cpp (+76-76) - (modified) clang/test/Preprocessor/macro_vaopt_expand.cpp (+150-150) - (modified) clang/test/Sema/aarch64-sve-vector-log-ops.c (+23-23) - (modified) clang/test/Sema/aarch64-sve-vector-trig-ops.c (+18-18) - (modified) clang/test/Sema/incorrect_pure.cpp (+14-14) - (modified) clang/test/Sema/riscv-rvv-vector-log-ops.c (+25-25) - (modified) clang/test/Sema/riscv-rvv-vector-trig-ops.c (+19-19) - (modified) clang/test/SemaCXX/attr-non-x86-no_caller_saved_registers.cpp (+29-29) - (modified) clang/test/SemaCXX/attr-x86-no_caller_saved_registers.cpp (+33-33) - (modified) clang/test/SemaCXX/compound-literal.cpp (+131-131) - (modified) clang/test/SemaCXX/cxx23-static-callop-lambda-expression.cpp (+33-33) - (modified) clang/test/SemaCXX/vla-ext-diag.cpp (+40-40) - (modified) clang/test/SemaCXX/warn-redundant-move.cpp (+116-116) - (modified) clang/test/SemaCXX/warn-shadow.cpp (+47-47) - (modified) clang/test/SemaHLSL/BuiltIns/clamp-errors.hlsl (+91-91) - (modified) clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl (+119-119) - (modified) clang/test/SemaHLSL/BuiltIns/lerp-errors.hlsl (+109-109) - (modified) clang/test/SemaHLSL/BuiltIns/mad-errors.hlsl (+86-86) - (modified) clang/test/SemaObjCXX/block-cleanup.mm (+16-16) - (modified) clang/test/SemaTemplate/default-expr-arguments-3.cpp (+55-55) - (modified) clang/tools/clang-format-vs/ClangFormat.sln (+22-22) - (modified) clang/tools/clang-format-vs/ClangFormat/ClangFormat.csproj (+261-261) - (modified) clang/tools/clang-format-vs/ClangFormat/ClangFormat.vsct (+127-127) - (modified) clang/tools/clang-format-vs/ClangFormat/GlobalSuppressions.cs (+11-11) - (modified) clang/tools/clang-format-vs/ClangFormat/Guids.cs (+12-12) - (modified) clang/tools/clang-format-vs/ClangFormat/PkgCmdID.cs (+8-8) - (modified) clang/tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs (+33-33) - (modified) clang/tools/clang-format-vs/ClangFormat/Resources.Designer.cs (+63-63) - (modified) clang/tools/clang-format-vs/ClangFormat/Resources.resx (+128-128) - (modified) clang/tools/clang-format-vs/ClangFormat/VSPackage.resx (+139-139) - (modified) clang/tools/clang-format-vs/README.txt (+51-51) - (modified) clang/tools/clang-format-vs/source.extension.vsixmanifest.in (+19-19) - (modified) clang/tools/scan-build/bin/scan-build.bat (+1-1) - (modified) clang/tools/scan-build/libexec/c++-analyzer.bat (+1-1) - (modified) clang/tools/scan-build/libexec/ccc-analyzer.bat (+1-1) - (modified) clang/utils/ClangVisualizers/clang.natvis (+1089-1089) - (modified) compiler-rt/test/asan/TestCases/Posix/strndup_oob_test2.cpp (+21-21) - (modified) flang/test/Driver/msvc-dependent-lib-flags.f90 (+40-40) - (modified) lld/test/COFF/Inputs/combined-resources.rc (+50-50) - (modified) lld/test/COFF/pdb-type-server-invalid-signature.yaml (+2-2) - (modified) lld/test/COFF/pdb_char8_t.ll (+46-46) - (modified) lld/test/ELF/dynamic-list-cpp.s (+18-18) - (modified) lldb/test/API/commands/expression/ir-interpreter-phi-nodes/Makefile (+4-4) - (modified) lldb/test/API/functionalities/postmortem/minidump/fizzbuzz.syms (+2-2) - (modified) lldb/test/API/functionalities/unwind/zeroth_frame/Makefile (+3-3) - (modified) lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py (+89-89) - (modified) lldb/test/API/python_api/debugger/Makefile (+3-3) - (modified) lldb/test/Shell/BuildScript/modes.test (+35-35) - (modified) lldb/test/Shell/BuildScript/script-args.test (+32-32) - (modified) lldb/test/Shell/BuildScript/toolchain-clang-cl.test (+49-49) - (modified) lldb/test/Shell/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp (+40-40) - (modified) lldb/test/Shell/SymbolFile/NativePDB/Inputs/inline_sites.s (+622-622) - (modified) lldb/test/Shell/SymbolFile/NativePDB/Inputs/inline_sites_live.lldbinit (+7-7) - (modified) lldb/test/Shell/SymbolFile/NativePDB/Inputs/local-variables-registers.lldbinit (+35-35) - (modified) lldb/test/Shell/SymbolFile/NativePDB/Inputs/lookup-by-types.lldbinit (+3-3) - (modified) lldb/test/Shell/SymbolFile/NativePDB/Inputs/subfield_register_simple_type.lldbinit (+2-2) - (modified) lldb/test/Shell/SymbolFile/NativePDB/function-types-classes.cpp (+6-6) - (modified) lldb/test/Shell/SymbolFile/NativePDB/inline_sites_live.cpp (+34-34) - (modified) lldb/test/Shell/SymbolFile/NativePDB/lookup-by-types.cpp (+46-46) - (modified) lldb/unittests/Breakpoint/CMakeLists.txt (+10-10) - (modified) llvm/docs/CommandGuide/llvm-pdbutil.rst (+38-38) - (modified) llvm/docs/GettingInvolved.rst (+494-494) - (modified) llvm/docs/GettingStartedTutorials.rst (+43-43) - (modified) llvm/docs/PDB/CodeViewSymbols.rst (+3-3) - (modified) llvm/docs/Reference.rst (+230-230) - (modified) llvm/docs/UserGuides.rst (+286-286) - (modified) llvm/test/Analysis/MustExecute/const-cond.ll (+47-47) - (modified) llvm/test/CodeGen/MIR/X86/dbg-value-list.mir (+64-64) - (modified) llvm/test/CodeGen/NVPTX/bf16x2-instructions-approx.ll (+42-42) - (modified) llvm/test/CodeGen/NVPTX/bf16x2-instructions.ll (+532-532) - (modified) llvm/test/CodeGen/NVPTX/zeroext-32bit.ll (+27-27) - (modified) llvm/test/CodeGen/SPARC/LeonSMACUMACInstructionUT.ll (+20-20) - (modified) llvm/test/CodeGen/X86/dbg-value-superreg-copy2.mir (+1-1) - (modified) llvm/test/CodeGen/X86/non-value-mem-operand.mir (+293-293) - (modified) llvm/test/CodeGen/X86/patchable-prologue-debuginfo.ll (+56-56) - (modified) llvm/test/CodeGen/X86/post-ra-sched-with-debug.mir (+2-2) - (modified) llvm/test/CodeGen/X86/windows-seh-EHa-CppCatchDotDotDot.ll (+290-290) - (modified) llvm/test/CodeGen/X86/windows-seh-EHa-CppDtors01.ll (+255-255) - (modified) llvm/test/CodeGen/X86/windows-seh-EHa-TryInFinally.ll (+224-224) - (modified) llvm/test/DebugInfo/AArch64/instr-ref-const-physreg.ll (+1-1) - (modified) llvm/test/DebugInfo/ARM/instr-ref-tcreturn.ll (+1-1) - (modified) llvm/test/DebugInfo/COFF/AArch64/lit.local.cfg (+2-2) - (modified) llvm/test/DebugInfo/COFF/jump-table-with-indirect-ptr-null.ll (+72-72) - (modified) llvm/test/DebugInfo/COFF/jump-table.ll (+262-262) - (modified) llvm/test/DebugInfo/COFF/pieces.ll (+1-1) - (modified) llvm/test/DebugInfo/Generic/debug_value_list.ll (+50-50) - (modified) llvm/test/DebugInfo/MIR/InstrRef/accept-nonlive-reg-phis.mir (+1-1) - (modified) llvm/test/DebugInfo/MIR/InstrRef/dbg-phi-subregister-location.mir (+3-3) - (modified) llvm/test/DebugInfo/MIR/InstrRef/dbg-phis-in-ldv.mir (+3-3) - (modified) llvm/test/DebugInfo/MIR/InstrRef/dbg-phis-in-ldv2.mir (+12-12) - (modified) llvm/test/DebugInfo/MIR/InstrRef/dbg-phis-merging-in-ldv.mir (+12-12) - (modified) llvm/test/DebugInfo/MIR/InstrRef/dbg-phis-with-loops.mir (+12-12) - (modified) llvm/test/DebugInfo/MIR/InstrRef/follow-spill-of-live-value.mir (+3-3) - (modified) llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_illegal_locs.mir (+24-24) - (modified) llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_instrref_tolocs.mir (+27-27) - (modified) llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_stackslot_subregs.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_subreg_substitutions.mir (+24-24) - (modified) llvm/test/DebugInfo/MIR/InstrRef/memory-operand-folding-tieddef.mir (+1-1) - (modified) llvm/test/DebugInfo/MIR/InstrRef/memory-operand-load-folding.mir (+1-1) - (modified) llvm/test/DebugInfo/MIR/InstrRef/memory-operand-tracking.mir (+14-14) - (modified) llvm/test/DebugInfo/MIR/InstrRef/out-of-scope-blocks.mir (+15-15) - (modified) llvm/test/DebugInfo/MIR/InstrRef/phi-coalesce-subreg.mir (+1-1) - (modified) llvm/test/DebugInfo/MIR/InstrRef/phi-on-stack-coalesced.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/phi-on-stack-coalesced2.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/phi-regallocd-to-stack.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/phi-through-regalloc.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/spill-slot-limits.mir (+8-8) - (modified) llvm/test/DebugInfo/MIR/InstrRef/substitusions-roundtrip.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/twoaddr-to-threeaddr-sub.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/win32-chkctk-modifies-esp.mir (+10-10) - (modified) llvm/test/DebugInfo/MIR/InstrRef/x86-drop-compare-inst.mir (+1-1) - (modified) llvm/test/DebugInfo/MIR/X86/dvl-livedebugvalues-clobber.mir (+106-106) - (modified) llvm/test/DebugInfo/MIR/X86/dvl-livedebugvalues-join.mir (+160-160) - (modified) llvm/test/DebugInfo/MIR/X86/dvl-livedebugvalues-movements.mir (+90-90) - (modified) llvm/test/DebugInfo/MIR/X86/dvl-livedebugvalues-spillrestore.mir (+77-77) - (modified) llvm/test/DebugInfo/MIR/X86/dvl-livedebugvars-movements.mir (+109-109) - (modified) llvm/test/DebugInfo/MIR/X86/dvl-livedebugvars-stackptr.mir (+113-113) - (modified) llvm/test/DebugInfo/MIR/X86/instr-ref-join-def-vphi.mir (+4-4) - (modified) llvm/test/DebugInfo/PDB/Inputs/longname-truncation.yaml (+26-26) - (modified) llvm/test/DebugInfo/PDB/Inputs/merge-types-1.yaml (+52-52) - (modified) llvm/test/DebugInfo/PDB/Inputs/merge-types-2.yaml (+52-52) - (modified) llvm/test/DebugInfo/PDB/Inputs/one-symbol.yaml (+11-11) - (modified) llvm/test/DebugInfo/PDB/pdb-longname-truncation.test (+3-3) - (modified) llvm/test/DebugInfo/PDB/pdbdump-raw-bytes.test (+25-25) - (modified) llvm/test/DebugInfo/X86/dbg-val-list-dangling.ll (+69-69) - (modified) llvm/test/DebugInfo/X86/dbg-value-arg-movement.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/dbg-value-funcarg.ll (+4-4) - (modified) llvm/test/DebugInfo/X86/dbg-value-funcarg2.ll (+2-2) - (modified) llvm/test/DebugInfo/X86/dbg-value-funcarg4.ll (+2-2) - (modified) llvm/test/DebugInfo/X86/dbg-value-list-dag-combine.ll (+61-61) - (modified) llvm/test/DebugInfo/X86/dbg_value_list_clobbers.mir (+84-84) - (modified) llvm/test/DebugInfo/X86/dbg_value_list_emission.mir (+107-107) - (modified) llvm/test/DebugInfo/X86/instr-ref-dbg-declare.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/instr-ref-dyn-alloca-win32.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/instr-ref-ir-reg-read.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/live-debug-values-expr-conflict.ll (+6-6) - (modified) llvm/test/DebugInfo/X86/pieces-4.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/pr34545.ll (+11-11) - (modified) llvm/test/DebugInfo/X86/pr40427.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/sdag-combine.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/sdag-dangling-dbgvalue.ll (+7-7) - (modified) llvm/test/DebugInfo/X86/sdag-dbgvalue-phi-use-1.ll (+4-4) - (modified) llvm/test/DebugInfo/X86/sdag-dbgvalue-phi-use-2.ll (+7-7) - (modified) llvm/test/DebugInfo/X86/sdag-dbgvalue-phi-use-3.ll (+6-6) - (modified) llvm/test/DebugInfo/X86/sdag-dbgvalue-phi-use-4.ll (+5-5) - (modified) llvm/test/DebugInfo/X86/sdag-dbgvalue-ssareg.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/sdag-ir-salvage.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/sdag-salvage-add.ll (+8-8) - (modified) llvm/test/DebugInfo/X86/sdag-transfer-dbgvalue.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/sdagsplit-1.ll (+2-2) - (modified) llvm/test/DebugInfo/X86/spill-nospill.ll (+1-1) - (modified) llvm/test/DebugInfo/precomp.test (+57-57) - (modified) llvm/test/DebugInfo/salvage-nonconst-binop.ll (+45-45) - (modified) llvm/test/Demangle/ms-options.test (+43-43) - (added) llvm/test/FileCheck/.gitattributes (+1) - (modified) llvm/test/FileCheck/dos-style-eol.txt (+10-10) - (modified) llvm/test/MC/AMDGPU/v_illegal-atomics.s (+6-6) - (modified) llvm/test/MC/AsmParser/directive_file-g.s (+24-24) - (modified) llvm/test/Transforms/InstCombine/debuginfo-sink.ll (+31-31) - (modified) llvm/test/Transforms/InstSimplify/ConstProp/gep-alias.ll (+17-17) - (modified) llvm/test/Transforms/InstSimplify/ConstProp/gep-constanfolding-error.ll (+52-52) - (modified) llvm/test/Transforms/InstSimplify/ConstProp/timeout.ll (+70-70) - (modified) llvm/test/Transforms/LoopStrengthReduce/pr51329.ll (+54-54) - (modified) llvm/test/Transforms/PhaseOrdering/pr32544.ll (+1-1) - (modified) llvm/test/Transforms/Reassociate/undef_intrinsics_when_deleting_instructions.ll (+61-61) - (modified) llvm/test/Transforms/ThinLTOBitcodeWriter/split-typed-decl.ll (+12-12) - (modified) llvm/test/tools/dxil-dis/shuffle.ll (+27-27) - (added) llvm/test/tools/llvm-ar/Inputs/.gitattributes (+1) - (modified) llvm/test/tools/llvm-ar/Inputs/mri-crlf.mri (+4-4) - (modified) llvm/test/tools/llvm-cvtres/Inputs/languages.rc (+36-36) - (modified) llvm/test/tools/llvm-cvtres/Inputs/test_resource.rc (+49-49) - (modified) llvm/test/tools/llvm-dwarfdump/X86/parent_recurse_depth.s (+67-67) - (modified) llvm/test/tools/llvm-dwarfdump/X86/quiet.s (+10-10) - (modified) llvm/test/tools/llvm-objcopy/ELF/dynrelocsec-remove-shinfo-reference.test (+30-30) - (modified) llvm/test/tools/llvm-objcopy/ELF/dynrelocsec-remove-shlink-reference.test (+34-34) - (modified) llvm/test/tools/llvm-objdump/ELF/ARM/literal-arm.s (+66-66) - (modified) llvm/test/tools/llvm-objdump/ELF/ARM/literal-thumb.s (+24-24) - (modified) llvm/test/tools/llvm-objdump/ELF/ARM/literal-thumb2.s (+116-116) - (modified) llvm/test/tools/llvm-objdump/ELF/ARM/literal-vldr-arm.s (+48-48) - (modified) llvm/test/tools/llvm-objdump/ELF/ARM/literal-vldr-thumb2.s (+66-66) - (modified) llvm/test/tools/llvm-objdump/X86/print-imm-hex.s (+29-29) - (modified) llvm/test/tools/llvm-pdbutil/Inputs/TypeServerTest.cpp (+6-6) - (modified) llvm/test/tools/llvm-pdbutil/complex-padding-graphical.test (+55-55) - (modified) llvm/test/tools/llvm-profgen/Inputs/coff-profile.perfscript (+13-13) - (modified) llvm/test/tools/llvm-readobj/COFF/Inputs/resources/test_resource.rc (+44-44) - (modified) llvm/test/tools/llvm-symbolizer/Inputs/discrim.inp (+8-8) - (modified) llvm/test/tools/obj2yaml/ELF/relr-section.yaml (+63-63) - (modified) llvm/utils/LLVMVisualizers/llvm.natvis (+408-408) - (modified) llvm/utils/emacs/llvm-mir-mode.el (+70-70) - (modified) llvm/utils/lit/tests/Inputs/shtest-shell/diff-in.dos (+3-3) - (modified) llvm/utils/release/build_llvm_release.bat (+512-512) - (modified) mlir/test/Conversion/GPUCommon/transfer_write.mlir (+13-13) - (modified) mlir/test/Dialect/Shape/arg_with_shape.mlir (+16-16) - (modified) mlir/test/Target/LLVMIR/Import/metadata-linker-options.ll (+15-15) - (modified) mlir/test/mlir-vulkan-runner/addf_if.mlir (+54-54) - (modified) openmp/runtime/doc/doxygen/config (+1822-1822) - (modified) pstl/CREDITS.txt (+21-21) ``````````diff diff --git a/.gitattributes b/.gitattributes index 6b281f33f737db9..a5a0ecb8ccb2b87 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,9 @@ +# Checkout as native, commit as LF except in specific circumstances +* text=auto +*.bat text eol=crlf +*.rc text eol=crlf +*.sln text eol=crlf + libcxx/src/**/*.cpp merge=libcxx-reformat libcxx/include/**/*.h merge=libcxx-reformat diff --git a/clang-tools-extra/clangd/test/.gitattributes b/clang-tools-extra/clangd/test/.gitattributes new file mode 100644 index 000000000000000..20971adc2b5d033 --- /dev/null +++ b/clang-tools-extra/clangd/test/.gitattributes @@ -0,0 +1,3 @@ +input-mirror.test text eol=crlf +too_large.test text eol=crlf +protocol.test text eol=crlf diff --git a/clang-tools-extra/clangd/test/delimited-input-comment-at-the-end.test b/clang-tools-extra/clangd/test/delimited-input-comment-at-the-end.test index bbbd72f8c59f6f2..85a1f2199fadf90 100644 --- a/clang-tools-extra/clangd/test/delimited-input-comment-at-the-end.test +++ b/clang-tools-extra/clangd/test/delimited-input-comment-at-the-end.test @@ -1,11 +1,11 @@ -# RUN: clangd -input-style=delimited -sync -input-mirror-file %t < %s -# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t -# -# RUN: clangd -lit-test -input-mirror-file %t < %s -# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t -# -{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} ---- -{"jsonrpc":"2.0","id":3,"method":"shutdown"} ---- -{"jsonrpc":"2.0","method":"exit"} +# RUN: clangd -input-style=delimited -sync -input-mirror-file %t < %s +# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t +# +# RUN: clangd -lit-test -input-mirror-file %t < %s +# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t +# +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} +--- +{"jsonrpc":"2.0","id":3,"method":"shutdown"} +--- +{"jsonrpc":"2.0","method":"exit"} diff --git a/clang-tools-extra/clangd/test/hover.test b/clang-tools-extra/clangd/test/hover.test index ec8d0488fa5ed11..dc76ae85fa41dd3 100644 --- a/clang-tools-extra/clangd/test/hover.test +++ b/clang-tools-extra/clangd/test/hover.test @@ -1,57 +1,57 @@ -# RUN: clangd -lit-test < %s | FileCheck %s -{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} ---- -{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void foo(); int main() { foo(); }\n"}}} ---- -{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":0,"character":27}}} -# CHECK: "id": 1, -# CHECK-NEXT: "jsonrpc": "2.0", -# CHECK-NEXT: "result": { -# CHECK-NEXT: "contents": { -# CHECK-NEXT: "kind": "plaintext", -# CHECK-NEXT: "value": "function foo\n\n→ void\n\nvoid foo()" -# CHECK-NEXT: }, -# CHECK-NEXT: "range": { -# CHECK-NEXT: "end": { -# CHECK-NEXT: "character": 28, -# CHECK-NEXT: "line": 0 -# CHECK-NEXT: }, -# CHECK-NEXT: "start": { -# CHECK-NEXT: "character": 25, -# CHECK-NEXT: "line": 0 -# CHECK-NEXT: } -# CHECK-NEXT: } -# CHECK-NEXT: } -# CHECK-NEXT:} ---- -{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":0,"character":10}}} -# CHECK: "id": 1, -# CHECK-NEXT: "jsonrpc": "2.0", -# CHECK-NEXT: "result": null ---- -{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main2.cpp","languageId":"cpp","version":1,"text":"enum foo{}; int main() { foo f; }\n"}}} ---- -{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main2.cpp"},"position":{"line":0,"character":27}}} -# CHECK: "id": 1, -# CHECK-NEXT: "jsonrpc": "2.0", -# CHECK-NEXT: "result": { -# CHECK-NEXT: "contents": { -# CHECK-NEXT: "kind": "plaintext", -# CHECK-NEXT: "value": "enum foo\n\nenum foo {}" -# CHECK-NEXT: }, -# CHECK-NEXT: "range": { -# CHECK-NEXT: "end": { -# CHECK-NEXT: "character": 28, -# CHECK-NEXT: "line": 0 -# CHECK-NEXT: }, -# CHECK-NEXT: "start": { -# CHECK-NEXT: "character": 25, -# CHECK-NEXT: "line": 0 -# CHECK-NEXT: } -# CHECK-NEXT: } -# CHECK-NEXT: } -# CHECK-NEXT:} ---- -{"jsonrpc":"2.0","id":3,"method":"shutdown"} ---- -{"jsonrpc":"2.0","method":"exit"} +# RUN: clangd -lit-test < %s | FileCheck %s +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} +--- +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void foo(); int main() { foo(); }\n"}}} +--- +{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":0,"character":27}}} +# CHECK: "id": 1, +# CHECK-NEXT: "jsonrpc": "2.0", +# CHECK-NEXT: "result": { +# CHECK-NEXT: "contents": { +# CHECK-NEXT: "kind": "plaintext", +# CHECK-NEXT: "value": "function foo\n\n→ void\n\nvoid foo()" +# CHECK-NEXT: }, +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 28, +# CHECK-NEXT: "line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 25, +# CHECK-NEXT: "line": 0 +# CHECK-NEXT: } +# CHECK-NEXT: } +# CHECK-NEXT: } +# CHECK-NEXT:} +--- +{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":0,"character":10}}} +# CHECK: "id": 1, +# CHECK-NEXT: "jsonrpc": "2.0", +# CHECK-NEXT: "result": null +--- +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main2.cpp","languageId":"cpp","version":1,"text":"enum foo{}; int main() { foo f; }\n"}}} +--- +{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main2.cpp"},"position":{"line":0,"character":27}}} +# CHECK: "id": 1, +# CHECK-NEXT: "jsonrpc": "2.0", +# CHECK-NEXT: "result": { +# CHECK-NEXT: "contents": { +# CHECK-NEXT: "kind": "plaintext", +# CHECK-NEXT: "value": "enum foo\n\nenum foo {}" +# CHECK-NEXT: }, +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 28, +# CHECK-NEXT: "line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 25, +# CHECK-NEXT: "line": 0 +# CHECK-NEXT: } +# CHECK-NEXT: } +# CHECK-NEXT: } +# CHECK-NEXT:} +--- +{"jsonrpc":"2.0","id":3,"method":"shutdown"} +--- +{"jsonrpc":"2.0","method":"exit"} diff --git a/clang-tools-extra/clangd/test/input-mirror.test b/clang-tools-extra/clangd/test/input-mirror.test index a34a4a08cf60cfa..bce3f9923a3b901 100644 --- a/clang-tools-extra/clangd/test/input-mirror.test +++ b/clang-tools-extra/clangd/test/input-mirror.test @@ -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"} diff --git a/clang-tools-extra/clangd/test/protocol.test b/clang-tools-extra/clangd/test/protocol.test index 5e852d1d9deebca..64ccfaef1891115 100644 --- a/clang-tools-extra/clangd/test/protocol.test +++ b/clang-tools-extra/clangd/test/protocol.test @@ -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]+}}. + diff --git a/clang-tools-extra/clangd/test/spaces-in-delimited-input.test b/clang-tools-extra/clangd/test/spaces-in-delimited-input.test index dc2e2f5ea0f64dd..aa191b6f2097f97 100644 --- a/clang-tools-extra/clangd/test/spaces-in-delimited-input.test +++ b/clang-tools-extra/clangd/test/spaces-in-delimited-input.test @@ -1,13 +1,13 @@ -# RUN: clangd -input-style=delimited -sync < %s 2>&1 | FileCheck %s -# RUN: clangd -lit-test -sync < %s 2>&1 | FileCheck %s -# -{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} - ---- - -{"jsonrpc":"2.0","id":3,"method":"shutdown"} - ---- - -{"jsonrpc":"2.0","method":"exit"} -# CHECK-NOT: JSON parse error +# RUN: clangd -input-style=delimited -sync < %s 2>&1 | FileCheck %s +# RUN: clangd -lit-test -sync < %s 2>&1 | FileCheck %s +# +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} + +--- + +{"jsonrpc":"2.0","id":3,"method":"shutdown"} + +--- + +{"jsonrpc":"2.0","method":"exit"} +# CHECK-NOT: JSON parse error diff --git a/clang-tools-extra/clangd/test/too_large.test b/clang-tools-extra/clangd/test/too_large.test index 7df981e7942073a..6986bd5e258e87a 100644 --- a/clang-tools-extra/clangd/test/too_large.test +++ b/clang-tools-extra/clangd/test/too_large.test @@ -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 diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/duplicate-include.h b/clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/duplicate-include.h index bf288023274b155..22d3a3acbc916ed 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-in... [truncated] ``````````
llvmbot commented 7 months ago

@llvm/pr-subscribers-backend-x86

Author: None (ldrumm)

Changes Historically, we've not automatically enforced how git tracks line endings, but there are many, many commits that "undo" unintended CRLFs getting into history. `git log --pretty=oneline --grep=CRLF` shows nearly 100 commits involving reverts of CRLF making its way into the index and then history. As far as I can tell, there are none the other way round except for specific cases like `.bat` files or tests for parsers that need to accept such sequences. Of note, one of the earliest of those listed in that output is: commit 9795860250734e5c2a879546c534e35d9edd5944 Author: NAKAMURA Takumi <geek4civic@gmail.com> Date: Thu Feb 3 11:41:27 2011 +0000 cmake/*: Add svn:eol-style=native and fix CRLF. llvm-svn: 124793 ...which introduced such a defacto policy for subversion. With old versions of git, it's been a bit of a crapshoot whether enforcing storing line endings in the history will upset checkouts on machines where such line endings are the norm. Indeed many users have enforced that git checks out the working copy according to a global or per-user config via core crlf, or core autocrlf. However, for ~8 years now[1], however, git has supported the ability to "do as the Romans do" on checkout, but internally store subsets of text files with line-endings specified via a system of patterns in the gitattributes file. Since we now have this ability, and we've been specifying attributes for various binary files, I think it makes sense to rid us of all that work converting things "back", and just let git handle the local checkout. Thus the new toplevel policy here is * text=auto In simple terms this means "unless otherwise specified, convert all files considered "text" files to LF in the project history, but checkout them out as expected on the local machine. What is "expected on the local machine" is dependent on configuration and default. For those files in the repository that *do* need CRLF endings, I've adopted a policy of `eol=crlf` which means that git will store them in history with LF, but regardless of user config, they'll be checked out in tree with CRLF. There also appears to be a single test, clang/test/Frontend/rewrite-includes-mixed-eol-crlf.[ch] which needs mixed line endings. This one uses eol=input to preserve it as-is. Finally, existing files have been "corrected" in history via `git add --renormalize .` [1]: git 2.10 was released with fixed support for fine-grained line-ending tracking that respects user-config *and* repo policy. This can be considered the point at which git will respect both the user's local working tree preference *and* the history as specified by the maintainers. See https://github.com/git/git/blob/master/Documentation/RelNotes/2.10.0.txt#L248 for the release note. --- Patch is 1.90 MiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/86318.diff 254 Files Affected: - (modified) .gitattributes (+6) - (added) clang-tools-extra/clangd/test/.gitattributes (+3) - (modified) clang-tools-extra/clangd/test/delimited-input-comment-at-the-end.test (+11-11) - (modified) clang-tools-extra/clangd/test/hover.test (+57-57) - (modified) clang-tools-extra/clangd/test/input-mirror.test (+17-17) - (modified) clang-tools-extra/clangd/test/protocol.test (+113-113) - (modified) clang-tools-extra/clangd/test/spaces-in-delimited-input.test (+13-13) - (modified) clang-tools-extra/clangd/test/too_large.test (+7-7) - (modified) clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/duplicate-include.h (+15-15) - (modified) clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/duplicate-include2.h (+1-1) - (modified) clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/system/sys/types.h (+1-1) - (modified) clang-tools-extra/test/clang-tidy/checkers/readability/else-after-return-if-constexpr.cpp (+22-22) - (modified) clang-tools-extra/test/modularize/Inputs/CompileError/module.modulemap (+10-10) - (modified) clang-tools-extra/test/modularize/Inputs/MissingHeader/module.modulemap (+10-10) - (modified) clang-tools-extra/test/pp-trace/Inputs/module.modulemap (+18-18) - (modified) clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp (+155-155) - (added) clang/test/.gitattributes (+3) - (modified) clang/test/AST/HLSL/this-reference-template.hlsl (+46-46) - (modified) clang/test/AST/HLSL/this-reference.hlsl (+62-62) - (modified) clang/test/AST/objc-default-ctor-init.mm (+21-21) - (modified) clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp (+56-56) - (modified) clang/test/CXX/expr/expr.prim/expr.prim.lambda/p15-star-this-capture.cpp (+22-22) - (modified) clang/test/CXX/lex/lex.literal/lex.string/p4.cpp (+17-17) - (modified) clang/test/CodeGen/fpconstrained.c (+25-25) - (modified) clang/test/CodeGen/fpconstrained.cpp (+49-49) - (modified) clang/test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp (+31-31) - (modified) clang/test/CodeGenCXX/debug-info-atexit-stub.cpp (+22-22) - (modified) clang/test/CodeGenHLSL/builtins/bitreverse.hlsl (+155-155) - (modified) clang/test/CodeGenHLSL/builtins/clamp.hlsl (+134-134) - (modified) clang/test/CodeGenHLSL/builtins/cos.hlsl (+41-41) - (modified) clang/test/CodeGenHLSL/builtins/floor.hlsl (+56-56) - (modified) clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl (+15-15) - (modified) clang/test/CodeGenHLSL/builtins/lerp.hlsl (+78-78) - (modified) clang/test/CodeGenHLSL/builtins/log.hlsl (+41-41) - (modified) clang/test/CodeGenHLSL/builtins/log2.hlsl (+41-41) - (modified) clang/test/CodeGenHLSL/builtins/mad.hlsl (+191-191) - (modified) clang/test/CodeGenHLSL/builtins/max.hlsl (+134-134) - (modified) clang/test/CodeGenHLSL/builtins/pow.hlsl (+54-54) - (modified) clang/test/CodeGenHLSL/builtins/reversebits.hlsl (+155-155) - (modified) clang/test/CodeGenHLSL/builtins/sin.hlsl (+41-41) - (modified) clang/test/CodeGenHLSL/builtins/trunc.hlsl (+47-47) - (modified) clang/test/CodeGenHLSL/semantics/DispatchThreadID.hlsl (+25-25) - (modified) clang/test/CodeGenHLSL/sret_output.hlsl (+22-22) - (modified) clang/test/CodeGenHLSL/this-assignment-overload.hlsl (+55-55) - (modified) clang/test/CodeGenHLSL/this-assignment.hlsl (+45-45) - (modified) clang/test/CodeGenHLSL/this-reference.hlsl (+34-34) - (modified) clang/test/CodeGenObjC/exceptions-personality.m (+53-53) - (modified) clang/test/Driver/ps4-ps5-relax-relocations.c (+29-29) - (modified) clang/test/FixIt/fixit-newline-style.c (+11-11) - (modified) clang/test/Frontend/rewrite-includes-macros.cpp (+15-15) - (modified) clang/test/Frontend/rewrite-includes-mixed-eol-crlf.c (+8-8) - (modified) clang/test/Frontend/rewrite-includes-mixed-eol-crlf.h (+11-11) - (modified) clang/test/Frontend/system-header-line-directive-ms-lineendings.c (+21-21) - (modified) clang/test/Lexer/minimize_source_to_dependency_directives_include.c (+8-8) - (modified) clang/test/Lexer/minimize_source_to_dependency_directives_utf8bom.c (+10-10) - (modified) clang/test/Options/HV.hlsl (+20-20) - (modified) clang/test/Parser/objc-attr.m (+28-28) - (modified) clang/test/Preprocessor/macro_vaopt_check.cpp (+76-76) - (modified) clang/test/Preprocessor/macro_vaopt_expand.cpp (+150-150) - (modified) clang/test/Sema/aarch64-sve-vector-log-ops.c (+23-23) - (modified) clang/test/Sema/aarch64-sve-vector-trig-ops.c (+18-18) - (modified) clang/test/Sema/incorrect_pure.cpp (+14-14) - (modified) clang/test/Sema/riscv-rvv-vector-log-ops.c (+25-25) - (modified) clang/test/Sema/riscv-rvv-vector-trig-ops.c (+19-19) - (modified) clang/test/SemaCXX/attr-non-x86-no_caller_saved_registers.cpp (+29-29) - (modified) clang/test/SemaCXX/attr-x86-no_caller_saved_registers.cpp (+33-33) - (modified) clang/test/SemaCXX/compound-literal.cpp (+131-131) - (modified) clang/test/SemaCXX/cxx23-static-callop-lambda-expression.cpp (+33-33) - (modified) clang/test/SemaCXX/vla-ext-diag.cpp (+40-40) - (modified) clang/test/SemaCXX/warn-redundant-move.cpp (+116-116) - (modified) clang/test/SemaCXX/warn-shadow.cpp (+47-47) - (modified) clang/test/SemaHLSL/BuiltIns/clamp-errors.hlsl (+91-91) - (modified) clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl (+119-119) - (modified) clang/test/SemaHLSL/BuiltIns/lerp-errors.hlsl (+109-109) - (modified) clang/test/SemaHLSL/BuiltIns/mad-errors.hlsl (+86-86) - (modified) clang/test/SemaObjCXX/block-cleanup.mm (+16-16) - (modified) clang/test/SemaTemplate/default-expr-arguments-3.cpp (+55-55) - (modified) clang/tools/clang-format-vs/ClangFormat.sln (+22-22) - (modified) clang/tools/clang-format-vs/ClangFormat/ClangFormat.csproj (+261-261) - (modified) clang/tools/clang-format-vs/ClangFormat/ClangFormat.vsct (+127-127) - (modified) clang/tools/clang-format-vs/ClangFormat/GlobalSuppressions.cs (+11-11) - (modified) clang/tools/clang-format-vs/ClangFormat/Guids.cs (+12-12) - (modified) clang/tools/clang-format-vs/ClangFormat/PkgCmdID.cs (+8-8) - (modified) clang/tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs (+33-33) - (modified) clang/tools/clang-format-vs/ClangFormat/Resources.Designer.cs (+63-63) - (modified) clang/tools/clang-format-vs/ClangFormat/Resources.resx (+128-128) - (modified) clang/tools/clang-format-vs/ClangFormat/VSPackage.resx (+139-139) - (modified) clang/tools/clang-format-vs/README.txt (+51-51) - (modified) clang/tools/clang-format-vs/source.extension.vsixmanifest.in (+19-19) - (modified) clang/tools/scan-build/bin/scan-build.bat (+1-1) - (modified) clang/tools/scan-build/libexec/c++-analyzer.bat (+1-1) - (modified) clang/tools/scan-build/libexec/ccc-analyzer.bat (+1-1) - (modified) clang/utils/ClangVisualizers/clang.natvis (+1089-1089) - (modified) compiler-rt/test/asan/TestCases/Posix/strndup_oob_test2.cpp (+21-21) - (modified) flang/test/Driver/msvc-dependent-lib-flags.f90 (+40-40) - (modified) lld/test/COFF/Inputs/combined-resources.rc (+50-50) - (modified) lld/test/COFF/pdb-type-server-invalid-signature.yaml (+2-2) - (modified) lld/test/COFF/pdb_char8_t.ll (+46-46) - (modified) lld/test/ELF/dynamic-list-cpp.s (+18-18) - (modified) lldb/test/API/commands/expression/ir-interpreter-phi-nodes/Makefile (+4-4) - (modified) lldb/test/API/functionalities/postmortem/minidump/fizzbuzz.syms (+2-2) - (modified) lldb/test/API/functionalities/unwind/zeroth_frame/Makefile (+3-3) - (modified) lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py (+89-89) - (modified) lldb/test/API/python_api/debugger/Makefile (+3-3) - (modified) lldb/test/Shell/BuildScript/modes.test (+35-35) - (modified) lldb/test/Shell/BuildScript/script-args.test (+32-32) - (modified) lldb/test/Shell/BuildScript/toolchain-clang-cl.test (+49-49) - (modified) lldb/test/Shell/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp (+40-40) - (modified) lldb/test/Shell/SymbolFile/NativePDB/Inputs/inline_sites.s (+622-622) - (modified) lldb/test/Shell/SymbolFile/NativePDB/Inputs/inline_sites_live.lldbinit (+7-7) - (modified) lldb/test/Shell/SymbolFile/NativePDB/Inputs/local-variables-registers.lldbinit (+35-35) - (modified) lldb/test/Shell/SymbolFile/NativePDB/Inputs/lookup-by-types.lldbinit (+3-3) - (modified) lldb/test/Shell/SymbolFile/NativePDB/Inputs/subfield_register_simple_type.lldbinit (+2-2) - (modified) lldb/test/Shell/SymbolFile/NativePDB/function-types-classes.cpp (+6-6) - (modified) lldb/test/Shell/SymbolFile/NativePDB/inline_sites_live.cpp (+34-34) - (modified) lldb/test/Shell/SymbolFile/NativePDB/lookup-by-types.cpp (+46-46) - (modified) lldb/unittests/Breakpoint/CMakeLists.txt (+10-10) - (modified) llvm/docs/CommandGuide/llvm-pdbutil.rst (+38-38) - (modified) llvm/docs/GettingInvolved.rst (+494-494) - (modified) llvm/docs/GettingStartedTutorials.rst (+43-43) - (modified) llvm/docs/PDB/CodeViewSymbols.rst (+3-3) - (modified) llvm/docs/Reference.rst (+230-230) - (modified) llvm/docs/UserGuides.rst (+286-286) - (modified) llvm/test/Analysis/MustExecute/const-cond.ll (+47-47) - (modified) llvm/test/CodeGen/MIR/X86/dbg-value-list.mir (+64-64) - (modified) llvm/test/CodeGen/NVPTX/bf16x2-instructions-approx.ll (+42-42) - (modified) llvm/test/CodeGen/NVPTX/bf16x2-instructions.ll (+532-532) - (modified) llvm/test/CodeGen/NVPTX/zeroext-32bit.ll (+27-27) - (modified) llvm/test/CodeGen/SPARC/LeonSMACUMACInstructionUT.ll (+20-20) - (modified) llvm/test/CodeGen/X86/dbg-value-superreg-copy2.mir (+1-1) - (modified) llvm/test/CodeGen/X86/non-value-mem-operand.mir (+293-293) - (modified) llvm/test/CodeGen/X86/patchable-prologue-debuginfo.ll (+56-56) - (modified) llvm/test/CodeGen/X86/post-ra-sched-with-debug.mir (+2-2) - (modified) llvm/test/CodeGen/X86/windows-seh-EHa-CppCatchDotDotDot.ll (+290-290) - (modified) llvm/test/CodeGen/X86/windows-seh-EHa-CppDtors01.ll (+255-255) - (modified) llvm/test/CodeGen/X86/windows-seh-EHa-TryInFinally.ll (+224-224) - (modified) llvm/test/DebugInfo/AArch64/instr-ref-const-physreg.ll (+1-1) - (modified) llvm/test/DebugInfo/ARM/instr-ref-tcreturn.ll (+1-1) - (modified) llvm/test/DebugInfo/COFF/AArch64/lit.local.cfg (+2-2) - (modified) llvm/test/DebugInfo/COFF/jump-table-with-indirect-ptr-null.ll (+72-72) - (modified) llvm/test/DebugInfo/COFF/jump-table.ll (+262-262) - (modified) llvm/test/DebugInfo/COFF/pieces.ll (+1-1) - (modified) llvm/test/DebugInfo/Generic/debug_value_list.ll (+50-50) - (modified) llvm/test/DebugInfo/MIR/InstrRef/accept-nonlive-reg-phis.mir (+1-1) - (modified) llvm/test/DebugInfo/MIR/InstrRef/dbg-phi-subregister-location.mir (+3-3) - (modified) llvm/test/DebugInfo/MIR/InstrRef/dbg-phis-in-ldv.mir (+3-3) - (modified) llvm/test/DebugInfo/MIR/InstrRef/dbg-phis-in-ldv2.mir (+12-12) - (modified) llvm/test/DebugInfo/MIR/InstrRef/dbg-phis-merging-in-ldv.mir (+12-12) - (modified) llvm/test/DebugInfo/MIR/InstrRef/dbg-phis-with-loops.mir (+12-12) - (modified) llvm/test/DebugInfo/MIR/InstrRef/follow-spill-of-live-value.mir (+3-3) - (modified) llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_illegal_locs.mir (+24-24) - (modified) llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_instrref_tolocs.mir (+27-27) - (modified) llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_stackslot_subregs.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_subreg_substitutions.mir (+24-24) - (modified) llvm/test/DebugInfo/MIR/InstrRef/memory-operand-folding-tieddef.mir (+1-1) - (modified) llvm/test/DebugInfo/MIR/InstrRef/memory-operand-load-folding.mir (+1-1) - (modified) llvm/test/DebugInfo/MIR/InstrRef/memory-operand-tracking.mir (+14-14) - (modified) llvm/test/DebugInfo/MIR/InstrRef/out-of-scope-blocks.mir (+15-15) - (modified) llvm/test/DebugInfo/MIR/InstrRef/phi-coalesce-subreg.mir (+1-1) - (modified) llvm/test/DebugInfo/MIR/InstrRef/phi-on-stack-coalesced.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/phi-on-stack-coalesced2.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/phi-regallocd-to-stack.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/phi-through-regalloc.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/spill-slot-limits.mir (+8-8) - (modified) llvm/test/DebugInfo/MIR/InstrRef/substitusions-roundtrip.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/twoaddr-to-threeaddr-sub.mir (+2-2) - (modified) llvm/test/DebugInfo/MIR/InstrRef/win32-chkctk-modifies-esp.mir (+10-10) - (modified) llvm/test/DebugInfo/MIR/InstrRef/x86-drop-compare-inst.mir (+1-1) - (modified) llvm/test/DebugInfo/MIR/X86/dvl-livedebugvalues-clobber.mir (+106-106) - (modified) llvm/test/DebugInfo/MIR/X86/dvl-livedebugvalues-join.mir (+160-160) - (modified) llvm/test/DebugInfo/MIR/X86/dvl-livedebugvalues-movements.mir (+90-90) - (modified) llvm/test/DebugInfo/MIR/X86/dvl-livedebugvalues-spillrestore.mir (+77-77) - (modified) llvm/test/DebugInfo/MIR/X86/dvl-livedebugvars-movements.mir (+109-109) - (modified) llvm/test/DebugInfo/MIR/X86/dvl-livedebugvars-stackptr.mir (+113-113) - (modified) llvm/test/DebugInfo/MIR/X86/instr-ref-join-def-vphi.mir (+4-4) - (modified) llvm/test/DebugInfo/PDB/Inputs/longname-truncation.yaml (+26-26) - (modified) llvm/test/DebugInfo/PDB/Inputs/merge-types-1.yaml (+52-52) - (modified) llvm/test/DebugInfo/PDB/Inputs/merge-types-2.yaml (+52-52) - (modified) llvm/test/DebugInfo/PDB/Inputs/one-symbol.yaml (+11-11) - (modified) llvm/test/DebugInfo/PDB/pdb-longname-truncation.test (+3-3) - (modified) llvm/test/DebugInfo/PDB/pdbdump-raw-bytes.test (+25-25) - (modified) llvm/test/DebugInfo/X86/dbg-val-list-dangling.ll (+69-69) - (modified) llvm/test/DebugInfo/X86/dbg-value-arg-movement.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/dbg-value-funcarg.ll (+4-4) - (modified) llvm/test/DebugInfo/X86/dbg-value-funcarg2.ll (+2-2) - (modified) llvm/test/DebugInfo/X86/dbg-value-funcarg4.ll (+2-2) - (modified) llvm/test/DebugInfo/X86/dbg-value-list-dag-combine.ll (+61-61) - (modified) llvm/test/DebugInfo/X86/dbg_value_list_clobbers.mir (+84-84) - (modified) llvm/test/DebugInfo/X86/dbg_value_list_emission.mir (+107-107) - (modified) llvm/test/DebugInfo/X86/instr-ref-dbg-declare.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/instr-ref-dyn-alloca-win32.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/instr-ref-ir-reg-read.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/live-debug-values-expr-conflict.ll (+6-6) - (modified) llvm/test/DebugInfo/X86/pieces-4.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/pr34545.ll (+11-11) - (modified) llvm/test/DebugInfo/X86/pr40427.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/sdag-combine.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/sdag-dangling-dbgvalue.ll (+7-7) - (modified) llvm/test/DebugInfo/X86/sdag-dbgvalue-phi-use-1.ll (+4-4) - (modified) llvm/test/DebugInfo/X86/sdag-dbgvalue-phi-use-2.ll (+7-7) - (modified) llvm/test/DebugInfo/X86/sdag-dbgvalue-phi-use-3.ll (+6-6) - (modified) llvm/test/DebugInfo/X86/sdag-dbgvalue-phi-use-4.ll (+5-5) - (modified) llvm/test/DebugInfo/X86/sdag-dbgvalue-ssareg.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/sdag-ir-salvage.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/sdag-salvage-add.ll (+8-8) - (modified) llvm/test/DebugInfo/X86/sdag-transfer-dbgvalue.ll (+1-1) - (modified) llvm/test/DebugInfo/X86/sdagsplit-1.ll (+2-2) - (modified) llvm/test/DebugInfo/X86/spill-nospill.ll (+1-1) - (modified) llvm/test/DebugInfo/precomp.test (+57-57) - (modified) llvm/test/DebugInfo/salvage-nonconst-binop.ll (+45-45) - (modified) llvm/test/Demangle/ms-options.test (+43-43) - (added) llvm/test/FileCheck/.gitattributes (+1) - (modified) llvm/test/FileCheck/dos-style-eol.txt (+10-10) - (modified) llvm/test/MC/AMDGPU/v_illegal-atomics.s (+6-6) - (modified) llvm/test/MC/AsmParser/directive_file-g.s (+24-24) - (modified) llvm/test/Transforms/InstCombine/debuginfo-sink.ll (+31-31) - (modified) llvm/test/Transforms/InstSimplify/ConstProp/gep-alias.ll (+17-17) - (modified) llvm/test/Transforms/InstSimplify/ConstProp/gep-constanfolding-error.ll (+52-52) - (modified) llvm/test/Transforms/InstSimplify/ConstProp/timeout.ll (+70-70) - (modified) llvm/test/Transforms/LoopStrengthReduce/pr51329.ll (+54-54) - (modified) llvm/test/Transforms/PhaseOrdering/pr32544.ll (+1-1) - (modified) llvm/test/Transforms/Reassociate/undef_intrinsics_when_deleting_instructions.ll (+61-61) - (modified) llvm/test/Transforms/ThinLTOBitcodeWriter/split-typed-decl.ll (+12-12) - (modified) llvm/test/tools/dxil-dis/shuffle.ll (+27-27) - (added) llvm/test/tools/llvm-ar/Inputs/.gitattributes (+1) - (modified) llvm/test/tools/llvm-ar/Inputs/mri-crlf.mri (+4-4) - (modified) llvm/test/tools/llvm-cvtres/Inputs/languages.rc (+36-36) - (modified) llvm/test/tools/llvm-cvtres/Inputs/test_resource.rc (+49-49) - (modified) llvm/test/tools/llvm-dwarfdump/X86/parent_recurse_depth.s (+67-67) - (modified) llvm/test/tools/llvm-dwarfdump/X86/quiet.s (+10-10) - (modified) llvm/test/tools/llvm-objcopy/ELF/dynrelocsec-remove-shinfo-reference.test (+30-30) - (modified) llvm/test/tools/llvm-objcopy/ELF/dynrelocsec-remove-shlink-reference.test (+34-34) - (modified) llvm/test/tools/llvm-objdump/ELF/ARM/literal-arm.s (+66-66) - (modified) llvm/test/tools/llvm-objdump/ELF/ARM/literal-thumb.s (+24-24) - (modified) llvm/test/tools/llvm-objdump/ELF/ARM/literal-thumb2.s (+116-116) - (modified) llvm/test/tools/llvm-objdump/ELF/ARM/literal-vldr-arm.s (+48-48) - (modified) llvm/test/tools/llvm-objdump/ELF/ARM/literal-vldr-thumb2.s (+66-66) - (modified) llvm/test/tools/llvm-objdump/X86/print-imm-hex.s (+29-29) - (modified) llvm/test/tools/llvm-pdbutil/Inputs/TypeServerTest.cpp (+6-6) - (modified) llvm/test/tools/llvm-pdbutil/complex-padding-graphical.test (+55-55) - (modified) llvm/test/tools/llvm-profgen/Inputs/coff-profile.perfscript (+13-13) - (modified) llvm/test/tools/llvm-readobj/COFF/Inputs/resources/test_resource.rc (+44-44) - (modified) llvm/test/tools/llvm-symbolizer/Inputs/discrim.inp (+8-8) - (modified) llvm/test/tools/obj2yaml/ELF/relr-section.yaml (+63-63) - (modified) llvm/utils/LLVMVisualizers/llvm.natvis (+408-408) - (modified) llvm/utils/emacs/llvm-mir-mode.el (+70-70) - (modified) llvm/utils/lit/tests/Inputs/shtest-shell/diff-in.dos (+3-3) - (modified) llvm/utils/release/build_llvm_release.bat (+512-512) - (modified) mlir/test/Conversion/GPUCommon/transfer_write.mlir (+13-13) - (modified) mlir/test/Dialect/Shape/arg_with_shape.mlir (+16-16) - (modified) mlir/test/Target/LLVMIR/Import/metadata-linker-options.ll (+15-15) - (modified) mlir/test/mlir-vulkan-runner/addf_if.mlir (+54-54) - (modified) openmp/runtime/doc/doxygen/config (+1822-1822) - (modified) pstl/CREDITS.txt (+21-21) ``````````diff diff --git a/.gitattributes b/.gitattributes index 6b281f33f737db9..a5a0ecb8ccb2b87 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,9 @@ +# Checkout as native, commit as LF except in specific circumstances +* text=auto +*.bat text eol=crlf +*.rc text eol=crlf +*.sln text eol=crlf + libcxx/src/**/*.cpp merge=libcxx-reformat libcxx/include/**/*.h merge=libcxx-reformat diff --git a/clang-tools-extra/clangd/test/.gitattributes b/clang-tools-extra/clangd/test/.gitattributes new file mode 100644 index 000000000000000..20971adc2b5d033 --- /dev/null +++ b/clang-tools-extra/clangd/test/.gitattributes @@ -0,0 +1,3 @@ +input-mirror.test text eol=crlf +too_large.test text eol=crlf +protocol.test text eol=crlf diff --git a/clang-tools-extra/clangd/test/delimited-input-comment-at-the-end.test b/clang-tools-extra/clangd/test/delimited-input-comment-at-the-end.test index bbbd72f8c59f6f2..85a1f2199fadf90 100644 --- a/clang-tools-extra/clangd/test/delimited-input-comment-at-the-end.test +++ b/clang-tools-extra/clangd/test/delimited-input-comment-at-the-end.test @@ -1,11 +1,11 @@ -# RUN: clangd -input-style=delimited -sync -input-mirror-file %t < %s -# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t -# -# RUN: clangd -lit-test -input-mirror-file %t < %s -# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t -# -{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} ---- -{"jsonrpc":"2.0","id":3,"method":"shutdown"} ---- -{"jsonrpc":"2.0","method":"exit"} +# RUN: clangd -input-style=delimited -sync -input-mirror-file %t < %s +# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t +# +# RUN: clangd -lit-test -input-mirror-file %t < %s +# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t +# +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} +--- +{"jsonrpc":"2.0","id":3,"method":"shutdown"} +--- +{"jsonrpc":"2.0","method":"exit"} diff --git a/clang-tools-extra/clangd/test/hover.test b/clang-tools-extra/clangd/test/hover.test index ec8d0488fa5ed11..dc76ae85fa41dd3 100644 --- a/clang-tools-extra/clangd/test/hover.test +++ b/clang-tools-extra/clangd/test/hover.test @@ -1,57 +1,57 @@ -# RUN: clangd -lit-test < %s | FileCheck %s -{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} ---- -{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void foo(); int main() { foo(); }\n"}}} ---- -{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":0,"character":27}}} -# CHECK: "id": 1, -# CHECK-NEXT: "jsonrpc": "2.0", -# CHECK-NEXT: "result": { -# CHECK-NEXT: "contents": { -# CHECK-NEXT: "kind": "plaintext", -# CHECK-NEXT: "value": "function foo\n\n→ void\n\nvoid foo()" -# CHECK-NEXT: }, -# CHECK-NEXT: "range": { -# CHECK-NEXT: "end": { -# CHECK-NEXT: "character": 28, -# CHECK-NEXT: "line": 0 -# CHECK-NEXT: }, -# CHECK-NEXT: "start": { -# CHECK-NEXT: "character": 25, -# CHECK-NEXT: "line": 0 -# CHECK-NEXT: } -# CHECK-NEXT: } -# CHECK-NEXT: } -# CHECK-NEXT:} ---- -{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":0,"character":10}}} -# CHECK: "id": 1, -# CHECK-NEXT: "jsonrpc": "2.0", -# CHECK-NEXT: "result": null ---- -{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main2.cpp","languageId":"cpp","version":1,"text":"enum foo{}; int main() { foo f; }\n"}}} ---- -{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main2.cpp"},"position":{"line":0,"character":27}}} -# CHECK: "id": 1, -# CHECK-NEXT: "jsonrpc": "2.0", -# CHECK-NEXT: "result": { -# CHECK-NEXT: "contents": { -# CHECK-NEXT: "kind": "plaintext", -# CHECK-NEXT: "value": "enum foo\n\nenum foo {}" -# CHECK-NEXT: }, -# CHECK-NEXT: "range": { -# CHECK-NEXT: "end": { -# CHECK-NEXT: "character": 28, -# CHECK-NEXT: "line": 0 -# CHECK-NEXT: }, -# CHECK-NEXT: "start": { -# CHECK-NEXT: "character": 25, -# CHECK-NEXT: "line": 0 -# CHECK-NEXT: } -# CHECK-NEXT: } -# CHECK-NEXT: } -# CHECK-NEXT:} ---- -{"jsonrpc":"2.0","id":3,"method":"shutdown"} ---- -{"jsonrpc":"2.0","method":"exit"} +# RUN: clangd -lit-test < %s | FileCheck %s +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} +--- +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void foo(); int main() { foo(); }\n"}}} +--- +{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":0,"character":27}}} +# CHECK: "id": 1, +# CHECK-NEXT: "jsonrpc": "2.0", +# CHECK-NEXT: "result": { +# CHECK-NEXT: "contents": { +# CHECK-NEXT: "kind": "plaintext", +# CHECK-NEXT: "value": "function foo\n\n→ void\n\nvoid foo()" +# CHECK-NEXT: }, +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 28, +# CHECK-NEXT: "line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 25, +# CHECK-NEXT: "line": 0 +# CHECK-NEXT: } +# CHECK-NEXT: } +# CHECK-NEXT: } +# CHECK-NEXT:} +--- +{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":0,"character":10}}} +# CHECK: "id": 1, +# CHECK-NEXT: "jsonrpc": "2.0", +# CHECK-NEXT: "result": null +--- +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main2.cpp","languageId":"cpp","version":1,"text":"enum foo{}; int main() { foo f; }\n"}}} +--- +{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main2.cpp"},"position":{"line":0,"character":27}}} +# CHECK: "id": 1, +# CHECK-NEXT: "jsonrpc": "2.0", +# CHECK-NEXT: "result": { +# CHECK-NEXT: "contents": { +# CHECK-NEXT: "kind": "plaintext", +# CHECK-NEXT: "value": "enum foo\n\nenum foo {}" +# CHECK-NEXT: }, +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 28, +# CHECK-NEXT: "line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 25, +# CHECK-NEXT: "line": 0 +# CHECK-NEXT: } +# CHECK-NEXT: } +# CHECK-NEXT: } +# CHECK-NEXT:} +--- +{"jsonrpc":"2.0","id":3,"method":"shutdown"} +--- +{"jsonrpc":"2.0","method":"exit"} diff --git a/clang-tools-extra/clangd/test/input-mirror.test b/clang-tools-extra/clangd/test/input-mirror.test index a34a4a08cf60cfa..bce3f9923a3b901 100644 --- a/clang-tools-extra/clangd/test/input-mirror.test +++ b/clang-tools-extra/clangd/test/input-mirror.test @@ -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"} diff --git a/clang-tools-extra/clangd/test/protocol.test b/clang-tools-extra/clangd/test/protocol.test index 5e852d1d9deebca..64ccfaef1891115 100644 --- a/clang-tools-extra/clangd/test/protocol.test +++ b/clang-tools-extra/clangd/test/protocol.test @@ -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]+}}. + diff --git a/clang-tools-extra/clangd/test/spaces-in-delimited-input.test b/clang-tools-extra/clangd/test/spaces-in-delimited-input.test index dc2e2f5ea0f64dd..aa191b6f2097f97 100644 --- a/clang-tools-extra/clangd/test/spaces-in-delimited-input.test +++ b/clang-tools-extra/clangd/test/spaces-in-delimited-input.test @@ -1,13 +1,13 @@ -# RUN: clangd -input-style=delimited -sync < %s 2>&1 | FileCheck %s -# RUN: clangd -lit-test -sync < %s 2>&1 | FileCheck %s -# -{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} - ---- - -{"jsonrpc":"2.0","id":3,"method":"shutdown"} - ---- - -{"jsonrpc":"2.0","method":"exit"} -# CHECK-NOT: JSON parse error +# RUN: clangd -input-style=delimited -sync < %s 2>&1 | FileCheck %s +# RUN: clangd -lit-test -sync < %s 2>&1 | FileCheck %s +# +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} + +--- + +{"jsonrpc":"2.0","id":3,"method":"shutdown"} + +--- + +{"jsonrpc":"2.0","method":"exit"} +# CHECK-NOT: JSON parse error diff --git a/clang-tools-extra/clangd/test/too_large.test b/clang-tools-extra/clangd/test/too_large.test index 7df981e7942073a..6986bd5e258e87a 100644 --- a/clang-tools-extra/clangd/test/too_large.test +++ b/clang-tools-extra/clangd/test/too_large.test @@ -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 diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/duplicate-include.h b/clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-include/duplicate-include.h index bf288023274b155..22d3a3acbc916ed 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/duplicate-in... [truncated] ``````````
ldrumm commented 7 months ago

I'm sure there are lots of people that will want to look at this, so please bring in reviewers at will

github-actions[bot] commented 7 months ago

:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

You can test this locally with the following command: ``````````bash git-clang-format --diff ae778ae7ce72219270c30d5c8b3d88c9a4803f81 ed0c7d0da0ff2bcbb56ce477ee4be0ab4bae0b63 --extensions c,h,cpp -- clang/test/C/C2y/n3262.c clang/test/C/C2y/n3274.c clang/test/FixIt/fixit-newline-style.c clang/test/Frontend/rewrite-includes-mixed-eol-crlf.c clang/test/Frontend/rewrite-includes-mixed-eol-crlf.h clang/test/Frontend/system-header-line-directive-ms-lineendings.c clang/test/Sema/aarch64-sve-vector-trig-ops.c clang/test/Sema/riscv-rvv-vector-trig-ops.c lldb/test/API/functionalities/target-new-solib-notifications/a.cpp lldb/test/API/functionalities/target-new-solib-notifications/b.cpp lldb/test/API/functionalities/target-new-solib-notifications/c.cpp lldb/test/API/functionalities/target-new-solib-notifications/d.cpp lldb/test/API/functionalities/target-new-solib-notifications/main.cpp lldb/test/Shell/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp lldb/test/Shell/SymbolFile/NativePDB/function-types-classes.cpp lldb/test/Shell/SymbolFile/NativePDB/inline_sites_live.cpp lldb/test/Shell/SymbolFile/NativePDB/lookup-by-types.cpp llvm/benchmarks/FormatVariadicBM.cpp llvm/benchmarks/GetIntrinsicForClangBuiltin.cpp llvm/benchmarks/GetIntrinsicInfoTableEntriesBM.cpp llvm/lib/Support/rpmalloc/malloc.c llvm/lib/Support/rpmalloc/rpmalloc.c llvm/lib/Support/rpmalloc/rpmalloc.h llvm/lib/Support/rpmalloc/rpnew.h llvm/lib/Target/DirectX/DXILFinalizeLinkage.cpp llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp llvm/unittests/Support/ModRefTest.cpp ``````````
View the diff from clang-format here. ``````````diff diff --git a/lldb/test/Shell/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp b/lldb/test/Shell/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp index d5b96472eb..1519b625fa 100644 --- a/lldb/test/Shell/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp +++ b/lldb/test/Shell/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp @@ -5,36 +5,28 @@ #include #else int main(); -extern "C" -{ - int _fltused; - void mainCRTStartup() { main(); } - void printf(const char*, ...) {} +extern "C" { +int _fltused; +void mainCRTStartup() { main(); } +void printf(const char *, ...) {} } #endif -void crash(bool crash_self) -{ - printf("Before...\n"); - if(crash_self) - { - printf("Crashing in 3, 2, 1 ...\n"); - *(volatile int*)nullptr = 0; - } - printf("After...\n"); +void crash(bool crash_self) { + printf("Before...\n"); + if (crash_self) { + printf("Crashing in 3, 2, 1 ...\n"); + *(volatile int *)nullptr = 0; + } + printf("After...\n"); } -int foo(int x, float y, const char* msg) -{ - bool flag = x > y; - if(flag) - printf("x = %d, y = %f, msg = %s\n", x, y, msg); - crash(flag); - return x << 1; -} - -int main() -{ - foo(10, 3.14, "testing"); +int foo(int x, float y, const char *msg) { + bool flag = x > y; + if (flag) + printf("x = %d, y = %f, msg = %s\n", x, y, msg); + crash(flag); + return x << 1; } +int main() { foo(10, 3.14, "testing"); } ``````````
adrian-prantl commented 7 months ago

While I'm sure this commit will manage to break something unexpectedly, I think this is reasonable to do! Thanks for taking this on.

rnk commented 7 months ago

I think it makes sense to remove carriage returns on checkin, but I'm not sure it makes sense to add them back on checkout on Windows. Historically, it's been really easy to write LLVM tests that fail when the source is checked out with CRLF. Many Windows developers have noted that LLVM tests fail when using the git config options to accomplish this. So, is there a way to do CRLF -> LF on checkin, but do nothing on checkout?

I think all modern editors on Windows can read LF files, it's just that they tend to prefer to write files out in CRLF, and that's the main source of friction.

pogo59 commented 7 months ago

As a data point, I've been setting core.autocrlf=true on Windows for years. I've been trained to make sure new files have LF endings (usually I copy an existing file instead of creating a new file) but both Notepad and the Visual Studio editor are willing to preserve the line-ending mode of the file as they found it. (This was not always true, but is these days.)

ldrumm commented 7 months ago

So, is there a way to do CRLF -> LF on checkin, but do nothing on checkout?

To be clear, this may do nothing on checkout if a user has set a config option. The point of the present policy is not to control local preferences as far as the filetype isn't required to have a specific format; we only control what ends up in history.

rnk commented 7 months ago

As a data point, I've been setting core.autocrlf=true on Windows for years.

If that's the case, my information is stale, which I accept.

To be clear, this may do nothing on checkout if a user has set a config option.

That addresses my concerns.

joker-eph commented 7 months ago

LGTM overall, but the CI failure looks real.

ldrumm commented 7 months ago

LGTM overall, but the CI failure looks real.

Failed Tests (3):
  Clang :: CXX/drs/dr23xx.cpp
  Clang :: CXX/drs/dr6xx.cpp
  Clang :: Lexer/raw-string-dlim-invalid.cpp

None of these files are in the diffstat, and none of them include any headers. I'm a bit stumped. Is it possible this is spurious?

tru commented 7 months ago

I think .natvis files should be CRLF (those are used with Visual Studio for debug visualizers).

Agreed, Visual Studio should handle this correctly, but who knows 🤷🏼

ldrumm commented 7 months ago

On Mon Mar 25, 2024 at 1:48 PM GMT, Tobias Hieta wrote:

I think .natvis files should be CRLF (those are used with Visual Studio for debug visualizers).

Agreed, Visual Studio should handle this correctly, but who knows 🤷🏼

Thanks. I'll add a rule and update

llvm-beanz commented 7 months ago

Philosophically I agree with this change, but I think some subprojects may need to adopt specific policies about how they handle files that are expected to be specific line endings. Specifically, Clang needs testing that verifies correct behavior on both CRLF and LF files in some cases, as does LLVM's split-file.

I did a pass a few years ago fixing a bunch of tests that had hard-specified file offsets in them that broke if you had CRLF line endings, and fixing how the correct line ending type was detected (some of the changes are 13fa17db3a720d149bcd0783856347a4f09cf634, 9d3437fbf3419502351d41ff9e28f06b0c3f06e8, ea836c880abcc74d3983fc35de407d647f0a002d, 1c1b0027e86fab2b0877488abc1625a457ca70b3).

Should we come up with an expected filename format that we can use with gitattributes and rename the existing files rather than just listing each file that has special needs by itself?

ldrumm commented 7 months ago

Should we come up with an expected filename format that we can use with gitattributes and rename the existing files rather than just listing each file that has special needs by itself?

Either way, the author has to do or know something. I'm not a fan of "magic" like this (notwithstanding the use of file extensions for common win32 formats here), so I'd personally just prefer that the tests that require knowledge of line endings are manually tracked and documented in the gitattributes file.

dwblaikie commented 7 months ago

For those files in the repository that do need CRLF endings, I've adopted a policy of eol=crlf which means that git will store them in history with LF, but regardless of user config, they'll be checked out in tree with CRLF.

This ^ seems a bit problematic to me, though (where the contents of the repo isn't representative of the bits we want - but perhaps it's schrodinger's line endings & it doesn't matter if it's always checked out as crlf - though if we one day converted to another source control system, would that be a problem? are there some things that examine the underlying/"real" repo contents?) - what would be the cost to using eol=input as you've done for the mixed line ending case? below \=

There also appears to be a single test, clang/test/Frontend/rewrite-includes-mixed-eol-crlf.[ch] which needs mixed line endings. This one uses eol=input to preserve it as-is.

fmayer commented 7 months ago

I don't have a strong opinion, but fundamentally I would prefer if the source control system stored exactly the files I have in my checkout, not mess with them in any way. I understand there are practical concerns, but a linter for unexpected CRLF would maybe be an option?

ldrumm commented 7 months ago

I don't have a strong opinion, but fundamentally I would prefer if the source control system stored exactly the files I have in my checkout, not mess with them in any way. I understand there are practical concerns, but a linter for unexpected CRLF would maybe be an option?

That wish is fine until you start working with others. Then you get 50000 line diffs that are somebody changing a single line on their system, because they happen to use the opposite system to the last person to check code in. I think the best middle ground here is to say -text or eol=input for files that must be encoded a certain way.

As for linters: linters require people to run it, and we still have to encode those rules somewhere - just not gitattributes. As far as I can see this is the lowest overhead and most reliable pragmatic option that has the nice property of being fully integrated into the tooling, transparent to end users, and in a known (semi) central location.

fmayer commented 7 months ago

That wish is fine until you start working with others.

Do we actually have that little faith in developers that we think they will check in a 50k line diff?

ldrumm commented 7 months ago

That wish is fine until you start working with others.

Do we actually have that little faith in developers that we think they will check in a 50k line diff?

depending on their diff settings, or the web interface they use, it may not show until they actually look at a hex editor. The point of this patch is not to lambast developers or interfere with their local setups; it's to get the line-ending issues out of the way for good so they can focus on what they do best.

And, given what I quoted above, it's not about faith - it's about historical evidence that this is a problem.

fmayer commented 7 months ago

. The point of this patch is not to lambast developers or interfere with their local setups; it's to get the line-ending issues out of the way for good so they can focus on what they do best.

Fair enough. I don't think it will fully make them go away for good, as you mentioned "[...] except for specific cases like .bat files or tests for parsers that need to accept such sequences." Something somewhere is bound to work before the transformation, and no longer after. It's possible that that will be more rare, though I would say 100 reverts in all of LLVM history isn't really that much either, all things considered.

And, given what I quoted above, it's not about faith - it's about historical evidence that this is a problem.

I am not saying this isn't a problem at all, but how often has anyone done a one line change and caused a 50k diff, and submitted it without noticing?

llvm-beanz commented 7 months ago

I am not saying this isn't a problem at all, but how often has anyone done a one line change and caused a 50k diff, and submitted it without noticing?

Way more often than you would hope. I don't have numbers but if you search through the git history for crlf or dos2unix those phrases hit on a lot of commits (more than just my abolishcrlf.org email address).

llvm-beanz commented 7 months ago

This ^ seems a bit problematic to me, though (where the contents of the repo isn't representative of the bits we want - but perhaps it's schrodinger's line endings & it doesn't matter if it's always checked out as crlf - though if we one day converted to another source control system, would that be a problem? are there some things that examine the underlying/"real" repo contents?) - what would be the cost to using eol=input as you've done for the mixed line ending case? below \=

The argument I would have in favor of an explicit value rather than eol=input is that it at least gives us a source of truth in the .gitattributes as to what type of line ending the file is supposed to have.

I don't have a strong feeling one way or another. I just want autocrlf=true to work reliably on all platforms.

ldrumm commented 7 months ago

This ^ seems a bit problematic to me, though (where the contents of the repo isn't representative of the bits we want - but perhaps it's schrodinger's line endings & it doesn't matter if it's always checked out as crlf - though if we one day converted to another source control system, would that be a problem? are there some things that examine the underlying/"real" repo contents?) - what would be the cost to using eol=input as you've done for the mixed line ending case? below =

The argument I would have in favor of an explicit value rather than eol=input is that it at least gives us a source of truth in the .gitattributes as to what type of line ending the file is supposed to have.

Missed this first time round. Apologies.

To address the first part: I'm not sure I'm equipped to deal with the philosphy matters here, though it might make more practical sense to use -text for the mixed line endings - actually eol=input might be wrong where we're testing mixed file endings; I'll have to check.

As for the second point: I don't think it's productive to worry about other future source control systems at this point - or indeed interoperability. Tools which do translation and don't respect gitattributes are buggy, and authors that use them and somehow manage to get bad bytes in llvm.org's git history will really have to try hard to do so, and we'll be back to another fixup commit. I don't really see this a problem worth worrying about.

I don't have a strong feeling one way or another. I just want autocrlf=true to work reliably on all platforms.

I'm a bit confused. Are you saying that as I've expressed it, autocrlf=true won't work correctly? I think you're saying you're in favour of this patch in principal, but I need to fix the mixed line endings case?

llvm-beanz commented 7 months ago

I'm a bit confused. Are you saying that as I've expressed it, autocrlf=true won't work correctly? I think you're saying you're in favour of this patch in principal, but I need to fix the mixed line endings case?

Sorry for being unclear. I meant to express that I'm so strongly in favor of what you're accomplishing here that I don't want any of my feedback to stand in the way.

compnerd commented 7 months ago

Philosophically, I agree with this change. Enshrining the information about the line endings into the SCM tool makes sense.

I think that the concern that I have is that do we have sufficient testing for supporting line-ending dependent behaviour in the compiler? Additionally, do we have sufficient documentation for others to figure out how to ensure that git does not munge the line endings if they are introducing a test which is dependent on it? In such a case, how do we ensure that they are aware that the SCM will do so without actually checking the post-commit state with a hex editor?

ldrumm commented 6 months ago

I've added the natvis changes and added a couple of clangd test exceptions.

For the sanity of pending reviewers, and to make rebasing this trivial I've split this into two commits: the gitattributes changes, followed by the --renormalize fixup.

For downstreams, I'm considering keeping this as two separate commits (rather than a fixup) so that merge conflicts can be resolved the same way. Anyone have opinions on this?

ldrumm commented 6 months ago

@compnerd I just realised I didn't respond to your concern. Apologies.

I think that the concern that I have is that do we have sufficient testing for supporting line-ending dependent behaviour in the compiler?

For the first part: I don't know that it matters, since this patch changes how the LLVM source code is stored, but not how its parsers operate. In any case, we run parser testing on LF and CRLF systems since the precommit testing runs on Linux, and Win32 at least. In addition, and there are several tests dedicated to line ending, so I think we should be good there. Happy to tend to this and fix anything I've missed if someone lets me know something is broken after we merge.

As for the second part

Additionally, do we have sufficient documentation for others to figure out how to ensure that git does not munge the line endings if they are introducing a test which is dependent on it? In such a case, how do we ensure that they are aware that the SCM will do so without actually checking the post-commit state with a hex editor?

I don't think we do, but also this patch doesn't really change the problem since right now basically anything can happen due to local configuration overrides (~/.gitconfig). I'll add a comment to the testing infrastructure page to be mindful of how line endings are storedand link to the .gitattributes documentation. Does that sound enough?

ldrumm commented 6 months ago

I'll add a comment to the testing infrastructure page to be mindful of how line endings are storedand link to the .gitattributes documentation. Does that sound enough?

Added here

cor3ntin commented 6 months ago

changes to clang/test/CXX/lex/lex.literal/lex.string/p4.cpp should be reverted (it's a CRLF related test)

compnerd commented 6 months ago

@compnerd I just realised I didn't respond to your concern. Apologies.

I think that the concern that I have is that do we have sufficient testing for supporting line-ending dependent behaviour in the compiler?

For the first part: I don't know that it matters, since this patch changes how the LLVM source code is stored, but not how its parsers operate. In any case, we run parser testing on LF and CRLF systems since the precommit testing runs on Linux, and Win32 at least. In addition, and there are several tests dedicated to line ending, so I think we should be good there. Happy to tend to this and fix anything I've missed if someone lets me know something is broken after we merge.

I don't know if the pre-commit testing guarantees that. Configuration settings will permit the files to be checked out in either Unix (\n) or Windows (\r\n) line-endings. If the builders are all configured to run in Unix line endings we lose that coverage. While I understand that this change only changes how the LLVM sources are stored, the issue is that the LLVM sources include the tests directory. These need to be tested in various manners to ensure that we test how we handle the different inputs (in clang). One option might be to exclude the tests directory from the line ending conversion if we cannot verify that we have tests in both formats.

As for the second part

Additionally, do we have sufficient documentation for others to figure out how to ensure that git does not munge the line endings if they are introducing a test which is dependent on it? In such a case, how do we ensure that they are aware that the SCM will do so without actually checking the post-commit state with a hex editor?

I don't think we do, but also this patch doesn't really change the problem since right now basically anything can happen due to local configuration overrides (~/.gitconfig). I'll add a comment to the testing infrastructure page to be mindful of how line endings are storedand link to the .gitattributes documentation. Does that sound enough?

I think that the documentation should be good. While, yes, it is possible to get the wrong behaviour currently, if the user configures git explicitly for a line-ending, I would expect them to be aware of that. The use of .gitattributes means that their defaults are not necessarily honoured and thus this can catch them by surprise.

compnerd commented 6 months ago

changes to clang/test/CXX/lex/lex.literal/lex.string/p4.cpp should be reverted (it's a CRLF related test)

This is the class of problems that I am concerned about. We certainly have some tests which are line-ending sensitive, and each test should be audited before we make such a change.

compnerd commented 6 months ago

Also, it's a bit funny to have .bat files without CRLF endings given that they run on Windows.

I'm not sure about the funny bit - but certainly dangerous. I've had cmd misinterpret batch files with LF vs CRLF.

ldrumm commented 6 months ago

Also, it's a bit funny to have .bat files without CRLF endings given that they run on Windows

They do have CRLF line endings: https://github.com/llvm/llvm-project/pull/86318/commits/1994c29731fde75f075c0605b79a14667bcfb9ac#diff-618cd5b83d62060ba3d027e314a21ceaf75d36067ff820db126642944145393eR3

ldrumm commented 6 months ago

Note, the changes to clang-format-vs should likely all be reverted. .sln is a Microsoft Visual Studio solution file, as are many of the others

Right. .sln is a text file: https://learn.microsoft.com/en-us/visualstudio/extensibility/internals/solution-dot-sln-file?view=vs-2022

I have no idea whether Visual Studio will be happy with .natvis files having non-Windows line endings.

They have CRLF line endings: https://github.com/llvm/llvm-project/pull/86318/commits/1994c29731fde75f075c0605b79a14667bcfb9ac#diff-618cd5b83d62060ba3d027e314a21ceaf75d36067ff820db126642944145393eR6

ldrumm commented 6 months ago

Perhaps things have got lost during the discussion, but this part of my original commit message is perhaps worth re-reading:

In simple terms this means "unless otherwise specified, convert all files considered "text" files to LF in the project history, but checkout them out as expected on the local machine. What is "expected on the local machine" is dependent on configuration and default.

For those files in the repository that do need CRLF endings, I've adopted a policy of eol=crlf which means that git will store them in history with LF, but regardless of user config, they'll be checked out in tree with CRLF.

llvm-beanz commented 6 months ago

I don't know if the pre-commit testing guarantees that. Configuration settings will permit the files to be checked out in either Unix (\n) or Windows (\r\n) line-endings.

Today on Windows you basically have to check out LLVM as unix line endings. There are a bunch of tests that fail if you don't. Hopefully this is a step toward fixing that (which is why I'm in favor of this).

If the builders are all configured to run in Unix line endings we lose that coverage.

I suspect the Windows bots are basically all configured that way today. Our instructions tell people they need to disable autocrlf (see: https://llvm.org/docs/GettingStarted.html#getting-the-source-code-and-building-llvm), and not disabling it causes problems for users still (see this message from today: https://discord.com/channels/636084430946959380/745925509971705877/1235913415902629958).

While I understand that this change only changes how the LLVM sources are stored, the issue is that the LLVM sources include the tests directory. These need to be tested in various manners to ensure that we test how we handle the different inputs (in clang). One option might be to exclude the tests directory from the line ending conversion if we cannot verify that we have tests in both formats.

I see two issues with this:

1) because the repo doesn't work with autocrlf today, we actually can't rely on testing on different platforms to provide this coverage. 2) We shouldn't be relying on git settings to get this coverage anyways. We should have tests that require specific line endings, and we should use gitattributes to ensure that we run those tests regardless of the user's git settings.

While, yes, it is possible to get the wrong behaviour currently, if the user configures git explicitly for a line-ending, I would expect them to be aware of that. The use of .gitattributes means that their defaults are not necessarily honoured and thus this can catch them by surprise.

I think today not only is it possible to get the wrong behavior, if you're developing on Windows Git's default behavior causes the wrong behavior for LLVM. Which often means that contributors (especially new contributors) have no idea that they're doing something wrong.

I don't know that this PR is perfect, but IMO it is a huge step in the right direction to allow Windows contributors to build, test and contribute to LLVM using the default configurations of the OS and tools.

ldrumm commented 6 months ago

There are a bunch of tests that fail if you don't.

Yes. Even better than that: this patch just uncovered a legitimate bug in the C++ AST parser tests for clang

Our instructions tell people they need to disable autocrlf

I didn't see that. Shall I remove that instruction now, or after we've merged?

I don't know that this PR is perfect, but IMO it is a huge step in the right direction to allow Windows contributors to build, test and contribute to LLVM using the default configurations of the OS and tools.

Absolutely. This patch is not a panacea but it enables us to correctly formalize the case where we actually do care about line-endings. Before this patch, it was basically incredibly brittle, but now we actually have control for those tests that matter. For things that don't really matter a whole class of irritating paper-cuts go away forever.

I understand folks' hesitance around downstream rebases, but since this will go in as two commits, resolving a merge conflict becomes an easy step (I've given instructions in the commit that will cause conflicts). I've bumped downstream llvm projects through many major releases in my life (llvm v3 through 13), and change-of-method-name has been a much greater source of merge conflicts than whitespace. LLVM's codebase is healthy and clean largely because we give people the ability to making sweeping improvements. In any case, this will be the last time that a downstream will need to resolve major CRLF changes during a bump, so I consider that a long-term win too.

ldrumm commented 3 weeks ago

I've let this patch stew for long enough, and I think it's now time. The spurious test failures in files unchanged by this patch have gone away. After re-reading the discussion above I'm ready to merge these changes.

There's been a good discussion, which helped me polish this a fair bit, and a few contentions which needed clarifying or ironing out. The main contention seems to have been that what's stored in git's database is always LF - even for for windows users or files that need CRLF endings (e.g. .bat). As I pointed out in a few comments (e.g.1,2,3) it may be unintuitive to store everything in git's internal database with normalized LF, but it's how git checks them out that's important, and I believe I've ironed out any issues here by tracking down files and testcases that depend on a particular line-ending style and adding rules for them.

For those who had such concerns, I believe I've clarified the principal and pointed out the practicalities that will make life easier for windows and unix contributors.

To summarize:

No user should need adjust their local config as a result of this change

I'll keep an eye on this, and will be happy to react to any issues that arise over the next week or so.

Thanks for all the input.

mstorsjo commented 3 weeks ago

This breaks a number of tests on Windows.

Previously, to have tests working on Windows, one would do git config --global core.autocrlf false or similar, before checking out llvm-project - a number of test input files need to be in LF form to work. This was brought up earlier already by @llvm-beanz in https://github.com/llvm/llvm-project/pull/86318#issuecomment-2093160376.

Now after this change, due to the added .gitattributes which overrides the core.autocrlf setting, these files get checked out with CRLF newlines (as the native form for the platform).

Based on the comment in the .gitattributes file, it seems like this is both known and intentional behaviour:

# Checkout as native, commit as LF except in specific circumstances
* text=auto

While it was already stated that blanket checkouts with CRLF will fail.

Additionally, the old mechanism of getting working newlines in the files is suddenly broken.


To make things worse, you won't notice this thing if you're updating an existing workdir - files that aren't touched aren't rewritten. (To trigger re-checkout of files to get .gitattributes applied, one can do something like git rm -r subdir && git reset && git checkout subdir.) So I guess most buildbots will keep chugging along fine, until someone pushes changes that touch those files. If running with a fresh checkout of llvm-project, this has a much bigger impact.


For compiler-rt tests, a handful of the profile tests depend on the right line endings - I can push a local .gitattributes file to fix that (see https://github.com/mstorsjo/llvm-project/commit/99bec81c87dcd2b7a7970954882bc0e42239d381).

But the Clang, clang-tools-extra and LLVM testsuites have many tests that are broken - there are around 80 tests failing due to this; sorting that out is a much bigger task that I'm not volunteering to take on right now.

CC @AaronBallman as the majority of those failing tests are in Clang.

Can we revert this until we figure out these bits? Do we really want checkouts to default to having the majority of files with CRLF on Windows? I would expect that most people working on Windows don't really want this (this wasn't the case so far anyway)? And other than that, we do need to tag the files that rely on being in LF form so that things work on Windows with either setting.

ldrumm commented 3 weeks ago

There are a couple of things to unpack here

a number of test input files need to be in LF form to work

Which ones? Either there's a bug in a parser somewhere, or I missed some test files. In either case I'd like to fix the issue. I watched the buildbots quite closely last night and only noticed failures in ARM frame lowering - which isn't this, I think.

Now after this change, due to the added .gitattributes which overrides the core.autocrlf setting, these files get checked out with CRLF newlines (as the native form for the platform).

It's my understanding that text=auto does not override core.autocrlf. As far as I can tell from the documentation it honours the user's configuration for core.eol in combination with core.autocrlf - from git config --help:

core.eol Sets the line ending type to use in the working directory for files that are marked as text (either by having the text attribute set, or by having text=auto and Git auto-detecting the contents as text). Alternatives are lf, crlf and native, which uses the platform’s native line ending. The default value is native. See gitattributes(5) for more information on end-of-line conversion. Note that this value is ignored if core.autocrlf is set to true or input.

and

core.autocrlf Setting this variable to "true" is the same as setting the text attribute to "auto" on all files and core.eol to "crlf". Set to true if you want to have CRLF line endings in your working directory and the repository has LF line endings. This variable can be set to input, in which case no output conversion is performed.

Can we revert this until we figure out these bits

Sure, but like I said, I'm happy to fix these broken cases. The old configuration was broken, but not in a controllable way, so I think it's reasonable to fix up the broken tests and move forward. Perhaps we also need clearer documentation?

AaronBallman commented 3 weeks ago

This seems to have broken precommit CI on Windows: https://buildkite.com/llvm-project/github-pull-requests/builds/111165#0192a01b-d3ac-44ad-abff-e53ac4a206ab all of the failures look related to line endings, and I noticed that I got a ton of command line messages of the form:

warning: in the working copy of 'clang/include/clang/Basic/Attr.td', LF will be replaced by CRLF the next time Git touches it

Can we revert this until we figure out these bits?

Yes, please.

Do we really want checkouts to default to having the majority of files with CRLF on Windows? I would expect that most people working on Windows don't really want this (this wasn't the case so far anyway)?

It certainly came as a surprise to me; my editors handle LF line endings just fine on Windows; it was very jarring to get hundreds of warnings from git that all seemed unactionable.

mstorsjo commented 3 weeks ago

a number of test input files need to be in LF form to work

Which ones?

A whole bunch of them. @AaronBallman's link to https://buildkite.com/llvm-project/github-pull-requests/builds/111165#0192a01b-d3ac-44ad-abff-e53ac4a206ab shows mostly what I saw. If including clang-tools-extra and llvm in the set of tests to run, I have failures in the following tests as well:

   Clang Tools :: clang-move/move-used-helper-decls.cpp
   LLVM :: MC/ELF/warn-newline-in-escaped-string.s
   LLVM :: TableGen/x86-fold-tables.td
   LLVM :: tools/llvm-rc/tag-html.test
   lit :: shtest-shell.py

Either there's a bug in a parser somewhere,

In the vast majority of cases, it's not a bug in a parser, but a test that relies on the exact contents of the source files. E.g. for tools/llvm-rc/tag-html.test I would guess that the issue is that the test takes a text file (which now has variable line endings) and includes it in a binary resource file, and checks the output to match bitwise the expected output.

In my nightly run of compiler-rt tests https://github.com/mstorsjo/llvm-mingw/actions/runs/11395494568/job/31717433112, I had the following failures:

Failed Tests (5):
  Profile-x86_64 :: instrprof-gcov-exceptions.test
  Profile-x86_64 :: instrprof-gcov-multiple-bbs-single-line.test
  Profile-x86_64 :: instrprof-gcov-one-line-function.test
  Profile-x86_64 :: instrprof-gcov-switch.test
  Profile-x86_64 :: instrprof-gcov-two-objects.test

I think the issue here may be something around testing the exact amount of whitespace somewhere or so.

Mostly "brittle" tests that don't expect the source files to vary.

or I missed some test files. In either case I'd like to fix the issue. I watched the buildbots quite closely last night and only noticed failures in ARM frame lowering - which isn't this, I think.

Did you do a test run on Windows? Even on Linux, I guess it should be possible to check out the code, forcing Git to prefer checking out text files as CRLF, so you could experience the same amount of fallout.

Now after this change, due to the added .gitattributes which overrides the core.autocrlf setting, these files get checked out with CRLF newlines (as the native form for the platform).

It's my understanding that text=auto does not override core.autocrlf. As far as I can tell from the documentation it honours the user's configuration for core.eol in combination with core.autocrlf - from git config --help:

This doesn't match my experience.

See https://github.com/mstorsjo/llvm-project/commit/inspect-newlines for a test github actions job that shows checking out the repo on Windows. First we check out an old branch, with default settings - we get CRLF. Then we set core.autocrlf=false and retry the above, we get a file with LF newlines. Then we check out the new version with gitattributes, and we notice how we now suddenly are getting CRLF again, despite our setting. See https://github.com/mstorsjo/llvm-project/actions/runs/11407224268 for the actual run log.

Feel free to play around with such an action, to come up with a better way of checking it out while still getting LF newlines - but this is the way I have been doing it (which is scripted in a number of places), and I would expect that many others have the same setup.

mstorsjo commented 3 weeks ago

This seems to have broken precommit CI on Windows: https://buildkite.com/llvm-project/github-pull-requests/builds/111165#0192a01b-d3ac-44ad-abff-e53ac4a206ab all of the failures look related to line endings, and I noticed that I got a ton of command line messages of the form:

warning: in the working copy of 'clang/include/clang/Basic/Attr.td', LF will be replaced by CRLF the next time Git touches it

Right, that probably relates to the odd situation where files are checked out in one form, but the git attributes indicate that they should be treated differently. Getting git to rewrite the files on disk to match it is kinda messy actually - the best way I've found today is git rm -r . && git reset && git checkout ..

Do we really want checkouts to default to having the majority of files with CRLF on Windows? I would expect that most people working on Windows don't really want this (this wasn't the case so far anyway)?

It certainly came as a surprise to me; my editors handle LF line endings just fine on Windows;

Exactly - people haven't had a problem with having LF newlines so far. The main problem probably has been to set up Git to get it in that form.

I obviously don't mind fixing as many tests as possible to pass with any form of newlines, but having all checkouts of the repo actually have files in identical form, rather than in any fuzzy form, feels like a feature to me.

So keeping the gitattributes, but in a form where it dictates checking out files in LF form (which has required setting core.autocrlf=false so far) would IMO be preferrable.

Would we get there by setting the wildcard rule in .gitattrubtes to * text eof=lf, or something along those lines?

aeubanks commented 3 weeks ago

I believe Chrome is also seeing many test failures due to this (https://crbug.com/374115887), although I haven't yet confirmed it's due to this specific commit.

AaronBallman commented 3 weeks ago

I just had someone in my office hours also running into problems from this commit. I went to revert the changes myself and I cannot because of merge conflicts... due to line endings.

@ldrumm -- can you revert these changes ASAP? They're causing significant problems in practice, so best to get us back to green rather than fix forward. Thanks!

ldrumm commented 3 weeks ago

On Fri Oct 18, 2024 at 7:39 PM BST, Aaron Ballman wrote:

@ldrumm -- can you revert these changes ASAP? They're causing significant problems in practice, so best to get us back to green rather than fix forward. Thanks!

Reverted.

zmodem commented 2 weeks ago

Thanks for reverting!

I must have missed this PR originally. I oppose letting Git change any line endings. It always ends like this.

ldrumm commented 2 weeks ago

It's my understanding that text=auto does not override core.autocrlf. As far as I can tell from the documentation it honours the user's configuration for core.eol in combination with core.autocrlf - from git config --help:

This doesn't match my experience.

I think this is due to a subtly of config. Setting core.autocrlf to false doesn't actually do anything since it's the default. In that case git is still in "no opinion" mode - which means it stores the input line endings and does no conversion.

However, once eol=auto is set in a .gitattributes, it forces git to use the configured eol config:

static int text_eol_is_crlf(void)
{
    if (auto_crlf == AUTO_CRLF_TRUE)
        return 1;
    else if (auto_crlf == AUTO_CRLF_INPUT)
        return 0;
    if (core_eol == EOL_CRLF)
        return 1;
    if (core_eol == EOL_UNSET && EOL_NATIVE == EOL_CRLF)
        return 1;
    return 0;
}

static enum eol output_eol(enum convert_crlf_action crlf_action)
{
    switch (crlf_action) {
    case CRLF_BINARY:
        return EOL_UNSET;
    case CRLF_TEXT_CRLF:
        return EOL_CRLF;
    case CRLF_TEXT_INPUT:
        return EOL_LF;
    case CRLF_UNDEFINED:
    case CRLF_AUTO_CRLF:
        return EOL_CRLF;
    case CRLF_AUTO_INPUT:
        return EOL_LF;
    case CRLF_TEXT:
    case CRLF_AUTO:
        /* fall through */
        return text_eol_is_crlf() ? EOL_CRLF : EOL_LF;
    }
    warning(_("illegal crlf_action %d"), (int)crlf_action);
    return core_eol;
}

output_eol is the git function that decides to write out a file with CRLF or LF endings

Notice that now we hit the CRLF_AUTO case so it's text_eol_is_crlf() ? EOL_CRLF : EOL_LF;

text_eol_is_crlf() checks against core.autocrlf. Since you've stated that it's false, then it then it checks core.eol.

So if I've read that correctly, core.autocrlf=false is a red herring and you should really set core.eol=lf if you want git to use lf on windows.

Would we get there by setting the wildcard rule in .gitattrubtes to * text eof=lf, or something along those lines?

This patch is about respecting local config, which is the exact opposite of that suggestion. It would be a way to solve the line-ending issue by fiat, not by co-operation, so I'm against it on principle. To be clear I very much don't like CRLF, but I also very much don't like it when someone forces me to use wrong-handed tools. Windows users would be forced to use wrong handed tools if we force line-endings one way or another

ldrumm commented 2 weeks ago

It always ends like this.

Ends Like what? As far as I can see all this has done has exposed latent bugs in our testing and in clang's parser