Author: Yitzhak Mandelbaum Date: 2021-02-12T16:23:53Z New Revision: 33f35a4b793bb53b830f8893110af57672e1dc79
URL: https://github.com/llvm/llvm-project/commit/33f35a4b793bb53b830f8893110af57672e1dc79 DIFF: https://github.com/llvm/llvm-project/commit/33f35a4b793bb53b830f8893110af57672e1dc79.diff LOG: [clang-tidy] Fix `TransformerClangTidyCheck`'s handling of include insertions. Currently, all include insertions are directed to the main file. However, Transformer rules can specify alternative destinations for include insertions. This patch fixes the code to associate the include with the correct file. This patch was tested manually. The clang tidy unit test framework does not support testing changes to header files. Given that this is a bug fix for a live bug, the patch relies on manual testing rather than blocking on upgrading the unit test framework. Differential Revision: https://reviews.llvm.org/D96542 Added: Modified: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp index e93f3fbf21d7..9f64c562600b 100644 --- a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp @@ -104,7 +104,8 @@ void TransformerClangTidyCheck::check( Diag << FixItHint::CreateReplacement(T.Range, T.Replacement); break; case transformer::EditKind::AddInclude: - Diag << Inserter.createMainFileIncludeInsertion(T.Replacement); + Diag << Inserter.createIncludeInsertion( + Result.SourceManager->getFileID(T.Range.getBegin()), T.Replacement); break; } } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits