Author: Zeyi Xu
Date: 2026-06-10T23:01:27+08:00
New Revision: 2fa0d3197e8d5401abd8252ca7971b6dc7f9a545

URL: 
https://github.com/llvm/llvm-project/commit/2fa0d3197e8d5401abd8252ca7971b6dc7f9a545
DIFF: 
https://github.com/llvm/llvm-project/commit/2fa0d3197e8d5401abd8252ca7971b6dc7f9a545.diff

LOG: [clang-tidy] Add newline style note to contributing guide. NFC. (#202999)

Recently I found around 10 checks that hardcode `\n` in their fix-its.
This is not ideal, the generated fix-it should probably preserve the
newline style of the file, rather than always inserting LF. Otherwise,
applying a fix-it may unexpectedly change part of a CRLF file to LF.

This commit documents this expectation in contributing guide.

Added: 
    

Modified: 
    clang-tools-extra/docs/clang-tidy/Contributing.rst

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/docs/clang-tidy/Contributing.rst 
b/clang-tools-extra/docs/clang-tidy/Contributing.rst
index 79551f60e9b1c..65933061b49f1 100644
--- a/clang-tools-extra/docs/clang-tidy/Contributing.rst
+++ b/clang-tools-extra/docs/clang-tidy/Contributing.rst
@@ -415,7 +415,11 @@ Some suggestions to ensure your check is robust:
 - Define macros that contain code matched by your check.
 - Define template classes that contain code matched by your check.
 - Define template specializations that contain code matched by your check.
-- Test your check under both Windows and Linux environments.
+- Test your check under both Windows and Linux environments. For example, when
+  a fix-it inserts new lines, use the source file's existing newline style
+  instead of hard-coding ``\n``. You can use
+  ``SourceManager::getBufferData(FileID).detectEOL()`` to get the newline style
+  for a file.
 - Watch out for high false-positive rates. Ideally, a check would have no
   false positives, but given that matching against an AST is not control-
   or data flow- sensitive, a number of false positives are expected. The


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to