[PATCH] D96542: [clang-tidy] Fix `TransformerClangTidyCheck`'s handling of include insertions.
Yitzhak Mandelbaum via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 11 13:33:33 PST 2021
ymandel created this revision.
ymandel added a reviewer: alexfh.
Herald added a subscriber: xazax.hun.
ymandel requested review of this revision.
Herald added a project: clang.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D96542
Files:
clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -104,7 +104,8 @@
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;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96542.323132.patch
Type: text/x-patch
Size: 649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210211/b7885f70/attachment-0001.bin>
More information about the cfe-commits
mailing list