Open llvmbot opened 4 years ago
I did, whoops. I haven't even committed the correct fix, will sort that out now.
@njames93 did you link the wrong diff here? Or the correct diff to the wrong bug? To be sure I retested this bug with current master (5f5fb56c68e). No change.
This bug will be fixed via D76037 and D76054 once they are merged.
This https://reviews.llvm.org/rG7693a9b9314083eafd9b5b1e19b02aac06962eb2 should fix the issue. If it works please close this. The extra new lines shouldn't cause concern as they are currently removed when parsing the yaml file. Though a patch is in works to escape them
Bug llvm/llvm-project#31360 has been marked as a duplicate of this bug.
Surely there is an issue that its not escaping the text as well. https://godbolt.org/z/F9qP6x I'm not sure how clang-apply-replacements works but I feel they should both consistently escape and un-escape the yaml text
Part 1 is mostly fixable by reverting 080014ee6 from https://reviews.llvm.org/D63482. It's not quite clear to me why that change was introduced.
Maybe this is even unrelated to issue 2.
Extended Description
Summary: It seems that the --export-fixes option is adding unexpected extra newlines to the generated output. Even worse those added characters are not counted when calculating following FileOffsets, so files with >= 2 fixes get completely broken. As far as I can tell this is not verified anywhere in the test suit, as all lit tests are always using -fix directly.
export-fixes is used e.g. by run-clang-tidy which is the one way to run clang-tidy with auto-fix option according to all sources on the internet.
Reproduction: These two produce different results:
bin/clang-tidy -checks="-*,readability-braces-around-statements" --fix ../clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements.cpp
mkdir temp && bin/clang-tidy -checks="-*,readability-braces-around-statements" --export-fixes=temp/fixes.yaml ../clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements.cpp && bin/clang-apply-replacements temp
Breaking code: Given
void f(){if(1) if(2) return;}
runmkdir temp && in/clang-tidy -checks="-*,readability-braces-around-statements" --export-fixes=temp/fixes.yaml ../clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements.cpp && bin/clang-apply-replacements temp
And you will end up with: `void f(){if(1) { if(2) { return;}}
(there is one
}` missing).This does not happen when running clang-tidy with -fix option.